Merge pull request #32111 from BendingBender/npm-keyword

[npm-keyword] Add types
This commit is contained in:
Daniel Rosenwasser
2019-01-14 14:04:43 -08:00
committed by GitHub
4 changed files with 75 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
// Type definitions for npm-keyword 5.0
// Project: https://github.com/sindresorhus/npm-keyword#readme
// Definitions by: BendingBender <https://github.com/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<npmKeyword.PackageDescriptor[]>;
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<string[]>;
/**
* @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<number>;
interface Options {
/**
* Limits the amount of results.
* @default 250
*/
size?: number;
}
interface PackageDescriptor {
name: string;
description: string;
}
}
+7
View File
@@ -0,0 +1,7 @@
import npmKeyword = require('npm-keyword');
npmKeyword('gulpplugin'); // $ExpectType Promise<PackageDescriptor[]>
npmKeyword('gulpplugin', { size: 10 }); // $ExpectType Promise<PackageDescriptor[]>
npmKeyword.names('gulpplugin'); // $ExpectType Promise<string[]>
npmKeyword.names('gulpplugin', { size: 10 }); // $ExpectType Promise<string[]>
npmKeyword.count('gulpplugin'); // $ExpectType Promise<number>
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }