mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Merge pull request #32111 from BendingBender/npm-keyword
[npm-keyword] Add types
This commit is contained in:
Vendored
+44
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user