diff --git a/types/npm-keyword/index.d.ts b/types/npm-keyword/index.d.ts new file mode 100644 index 0000000000..94c8af9f13 --- /dev/null +++ b/types/npm-keyword/index.d.ts @@ -0,0 +1,44 @@ +// Type definitions for npm-keyword 5.0 +// Project: https://github.com/sindresorhus/npm-keyword#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = npmKeyword; + +/** + * Get a list of npm packages with a certain keyword. + * + * @param keyword One or more keywords. Only matches packages that have *all* the given keywords. Example: `['string', 'camelcase']` + * @returns A promise for a list of packages having the specified keyword in their package.json `keyword` property. + */ +declare function npmKeyword( + keyword: string | string[], + options?: npmKeyword.Options +): Promise; + +declare namespace npmKeyword { + /** + * @param keyword One or more keywords. Only matches packages that have *all* the given keywords. Example: `['string', 'camelcase']` + * @returns A promise for a list of package names. Use this if you don't need the description as it's faster. + */ + function names(keyword: string | string[], options?: Options): Promise; + + /** + * @param keyword One or more keywords. Only matches packages that have *all* the given keywords. Example: `['string', 'camelcase']` + * @returns A promise for the count of packages. + */ + function count(keyword: string | string[]): Promise; + + interface Options { + /** + * Limits the amount of results. + * @default 250 + */ + size?: number; + } + + interface PackageDescriptor { + name: string; + description: string; + } +} diff --git a/types/npm-keyword/npm-keyword-tests.ts b/types/npm-keyword/npm-keyword-tests.ts new file mode 100644 index 0000000000..17418bdb04 --- /dev/null +++ b/types/npm-keyword/npm-keyword-tests.ts @@ -0,0 +1,7 @@ +import npmKeyword = require('npm-keyword'); + +npmKeyword('gulpplugin'); // $ExpectType Promise +npmKeyword('gulpplugin', { size: 10 }); // $ExpectType Promise +npmKeyword.names('gulpplugin'); // $ExpectType Promise +npmKeyword.names('gulpplugin', { size: 10 }); // $ExpectType Promise +npmKeyword.count('gulpplugin'); // $ExpectType Promise diff --git a/types/npm-keyword/tsconfig.json b/types/npm-keyword/tsconfig.json new file mode 100644 index 0000000000..b0c0fed33d --- /dev/null +++ b/types/npm-keyword/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "npm-keyword-tests.ts" + ] +} diff --git a/types/npm-keyword/tslint.json b/types/npm-keyword/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/npm-keyword/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }