Git Product home page Git Product logo

npm-name's Introduction

npm-name Build Status

Check whether a package or organization name is available on npm

Install

$ npm install npm-name

Usage

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

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


	// Check an organization name
	console.log(await npmName('@ava'));
	//=> false

	console.log(await npmName('@abc123'));
	//=> true


	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, options?)

Check whether a package/organization name is available (not registered) on npm.

An organization name should start with @ and should not be a scoped package.

Returns a Promise<boolean> of whether the given name is available.

name

Type: string

Name to check.

options

Type: object

registryUrl

Default: User's configured npm registry URL.

Registry URL to check name availability against.

Note: You're unlikely to need this option. Most use-cases are best solved by using the default. You should only use this option if you need to check a package name against a specific registry.

npmName.many(names, options?)

Check whether multiple package/organization names are available (not registered) on npm.

Returns a Promise<Map> of name and status.

names

Type: string[]

Multiple names to check.

options

Type: object

Same as npmName().

Related

npm-name's People

Contributors

sindresorhus avatar kevva avatar bendingbender avatar mikehardy avatar sidoshi avatar astur avatar one19 avatar itaisteinherz avatar ntwb avatar baile320 avatar yaodingyd avatar silverwind avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.