mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #33159 from ffflorian/npm-registry-package-info
Add types for npm-registry-package-info
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
// Type definitions for npm-registry-package-info 1.0
|
||||
// Project: https://github.com/kgryte/npm-registry-package-info#readme
|
||||
// Definitions by: Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace pkginfo {
|
||||
interface Options {
|
||||
/** Boolean indicating whether to return only the latest package information from a registry. */
|
||||
latest?: boolean;
|
||||
/** Array of package names (required). */
|
||||
packages: string[];
|
||||
/** Registry port. Default: 443 (HTTPS) or 80 (HTTP). */
|
||||
port?: number;
|
||||
/** Registry protocol. Default: 'https'. */
|
||||
protocol?: 'http' | 'https';
|
||||
/** Registry. Default: 'registry.npmjs.org'. */
|
||||
registry?: string;
|
||||
}
|
||||
|
||||
interface Data {
|
||||
data: any;
|
||||
meta: {
|
||||
failure: number;
|
||||
success: number;
|
||||
total: number;
|
||||
};
|
||||
}
|
||||
|
||||
type Callback = (error: Error | null, data: Data) => void;
|
||||
|
||||
function factory(opts: Options, callback: Callback): () => void;
|
||||
}
|
||||
|
||||
declare function pkginfo(opts: pkginfo.Options, callback: pkginfo.Callback): void;
|
||||
|
||||
export = pkginfo;
|
||||
@@ -0,0 +1,21 @@
|
||||
import pkginfo = require('npm-registry-package-info');
|
||||
|
||||
const opts: pkginfo.Options = {
|
||||
latest: true,
|
||||
packages: ['dstructs-array', 'flow-map', 'utils-merge2'],
|
||||
port: 80,
|
||||
protocol: 'http',
|
||||
registry: 'my.favorite.npm/registry',
|
||||
};
|
||||
|
||||
pkginfo(opts, (error, data) => {
|
||||
data; // $ExpectType Data
|
||||
});
|
||||
|
||||
const pkgs = ['dstructs-matrix', 'compute-stdev', 'compute-variance'];
|
||||
|
||||
const get = pkginfo.factory({ packages: pkgs }, (error, data) => {
|
||||
data; // $ExpectType Data
|
||||
});
|
||||
|
||||
get();
|
||||
@@ -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-registry-package-info-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user