UNPKG

1.32 kBJavaScriptView Raw
1import { normalizeRawPackument } from '../utils/normalize-raw-packument.esm.js';
2import { getRawPackument } from './get-raw-packument.esm.js';
3
4/**
5 * `getPackument` returns the packument (package document) containing
6 * all the metadata about a package present on the registry.
7 *
8 * @param name - package name
9 * @param registry - URL of the registry (default: npm registry)
10 * @param mirrors - URLs of the registry mirrors (default: npm registry mirrors)
11 * @param cached - accept cached responses (default: `true`)
12 *
13 * @example
14 * Get the packument for package `query-registry` from the npm registry:
15 *
16 * ```typescript
17 * import { getPackument } from 'query-registry';
18 *
19 * (async () => {
20 * const packument = await getPackument({ name: 'query-registry' });
21 *
22 * // Output: 'query-registry'
23 * console.log(packument.name);
24 * })();
25 * ```
26 *
27 * @see {@link Packument}
28 * @see {@link RawPackument}
29 * @see {@link npmRegistry}
30 * @see {@link npmRegistryMirrors}
31 */
32
33async function getPackument({
34 name,
35 registry,
36 mirrors,
37 cached
38}) {
39 const rawPackument = await getRawPackument({
40 name,
41 registry,
42 mirrors,
43 cached
44 });
45 return normalizeRawPackument({
46 rawPackument
47 });
48}
49
50export { getPackument };
51//# sourceMappingURL=get-packument.esm.js.map