JSPM

  • Created
  • Published
  • Downloads 221716
  • Score
    100M100P100Q152154F
  • License MIT

Check whether a package name is available on npm

Package Exports

  • npm-name

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 (npm-name) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm-name Build Status

Check whether a package name is available on npm

Install

$ npm install npm-name

Usage

const npmName = require('npm-name');

(async () => {
    console.log(await npmName('chalk'));
    // false

    const result = await npmName.many(['chalk', '@sindresorhus/is', 'abc123'])
    console.log(result.get('chalk'));
    //=> false
    console.log(result.get('@sindresorhus/is'));
    //=> false
    console.log(result.get('abc123'));
    //=> true

    try {
        await npmName('_ABC');
    } catch (error) {
        console.log(error.message);
        // Invalid package name: _ABC
        // - name cannot start with an underscore
        // - name can no longer contain capital letters
    }
})();

API

npmName(name)

Returns a promise for a boolean.

name

Type: String

Name to check.

npmName.many(names)

Returns a promise for a Map of name/status.

names

Type: Array

Multiple names to check.

License

MIT © Sindre Sorhus