DefinitelyTyped/types/libnpmsearch/libnpmsearch-tests.ts
Joel Spadin 25fe77861d Add types npm-registry-fetch, libnpmsearch, and pacote (#38376)
* Add types for npm-registry-fetch

* Add types for libnpmsearch

* Add types for pacote

* Use ReadonlyArray in libnpmsearch

* pacote: Reorganize imports/exports
2019-09-25 09:37:07 -07:00

18 lines
519 B
TypeScript

import search = require('libnpmsearch');
const opts: search.Options = {
limit: 20,
from: 0,
detailed: false,
sortBy: 'optimal',
registry: 'https://registry.npmjs.org',
token: 'token',
};
search('libnpm'); // $ExpectType Promise<Result[]>
search('libnpm', opts); // $ExpectType Promise<Result[]>
search('libnpm', { detailed: true }); // $ExpectType Promise<DetailedResult[]>
search.stream('libnpm'); // $ExpectType ReadWriteStream
search.stream('libnpm', opts); // $ExpectType ReadWriteStream