JSPM

  • Created
  • Published
  • Downloads 55821
  • Score
    100M100P100Q149292F
  • License MIT

Query the npm registry

Package Exports

  • query-registry

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (query-registry) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

query-registry

Build status Coverage Language Dependencies npm bundle size npm License

This package exports a class, Registry, which provides methods to query the npm registry or a custom npm-like registry.

Features

  • Provides methods for common use cases:
    • Registry metadata
    • Packuments (package documents)
    • Package manifests
    • Download counts
    • Searching packages
  • Typed response data
  • Supports mirrors and custom npm-like registries
  • Supports caching network requests
  • Well documented and tested

Package Contents

View package contents on unpkg.

View repository on GitHub.

Install

Using npm:

npm i query-registry

Using yarn:

yarn add query-registry

Usage

Create the default registry backed by npm:

import { Registry } from 'query-registry';

const registry = new Registry();

// Output: `https://registry.npmjs.org`
console.log(registry.registry);

Create a custom registry:

import { Registry } from 'query-registry';

const registry = new Registry({
    registry: 'https://registry.example.com',
    mirrors: ['https://mirror.example.com'],
    api: 'https://api.example.com',
    suggestionsAPI: 'https://suggestions.example.com',
    cache: new Map(),
});

// Output: `https://registry.example.com`
console.log(registry.registry);

Get the package manifest for query-registry's latest version:

import { Registry } from 'query-registry';

(async () => {
    const registry = new Registry();
    const manifest = await registry.getPackageManifest('query-registry');

    // Output: `query-registry`
    console.log(manifest.name);
})();

Debug

Debug messages are available when the DEBUG environment variable is set to query-registry:

DEBUG="query-registry"

Test debug messages are available when the DEBUG environment variable is set to query-registry-test.

For more information, see the debug package.

License

MIT License

Copyright (c) 2020 Edoardo Scibona

See LICENSE file.