UNPKG

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