TypeScript icon, indicating that this package has built-in type declarations

1.3.2 • Public • Published

logo image


Check if it can be registered as a package name or domain name

test GitHub release deno land nest badge deno doc deno version node support version bundle size npm download

dependencies Status codecov Codacy Badge npm type definitions Commitizen friendly Gitmoji semantic-release License: MIT

🔖 Table of Contents


  • Multi runtime support (Deno, Node.js)
  • 📚 Pure TypeScript and provides type definition
  • 🌎 Universal module, providing ES modules and UMD
  • 📦 Optimized, super slim size
  • 📄 TSDoc-style comments

Module registry



The Cli interface is common to Deno and Node.js.

@runtime <name> [Options]

@runtime: How to call it depends on the runtime. See Deno or Node.js sections.

name: Check module is registerable or not. required

All options are optional

flag desc type default choice
-r, --registry Query to registry array [,, npm],, npm
-j, --json Display to JSON format boolean false
--verbose Verbose mode boolean true
-h, --help Show help boolean
-v, --version Show version number


@runtime: deno run --allow-net


Required permissions:

  • --allow-net

You can use it directly from the CLI by using deno run:

deno run --allow-net <name> [Options]

You can also install it globally using the following:

deno install --allow-net -n registerable

Then, the package is available to run:

registerable <name> [Options]



You can install locally.

yarn add -D registerable
npm i -D registerable


yarn registerable <name> [Options]
npm run registerable <name> [Options]

You can also install it globally using the following:

yarn global add registerable

registerable <name> [Options]

JavaScript API

The JavaScript API is the best way to call it programmatically.

Type Definition:

declare const registerable: <T extends "" | "npm" | "">(
  name: string,
  option?: Partial<Option<T>> | undefined
) => Promise<RegisterableResult<T>>;


registerable(name, option)

This function accept 2 arguments.

name [required]

name type desc
name string Query name

option [optional]

name type desc default
registry array Pick the package registry to query. choice:, and npm [,, npm]
mode string Specifies where this function is called. choice: server or universal server

What is mode?

You can avoid CORS errors by specifying the mode. For server mode, it queries the public API in the package registry directly.

With the exception of, the public api response headers do not have the Access-Control-Allow-Origin property set. That is, if call this function from browser, you will get a CORS error.

To avoid this, we have prepared a Proxy server. It returns the result of running the registerable function on the server and the response header with Access-Control-Allow-Origin: * added.

You can get the result from the following URL:

Mode of universal queries this URL and gets the same results as server mode without CORS errors.

If there is a possibility of calling the registerable function from a Browser such as SPA or SSR, the mode should be universal.

However, if it is clear that it will be called only on the server side, it is recommended to use in server mode from the viewpoint of performance. Therefore, it is set to server mode by default.

Return value

The return value is a JSONObject that indicates whether it can be registered in the package registry, an error message if there is a validation error in query name, and which query caused the error.

  result: {
    ""?: boolean,
    ""?: boolean,
    npm?: boolean,
  error: {
     ""?: string,
     ""?: string,
      npm?: string,
  hasError: boolean,
  errorRegistry: ("" | "" | npm)[],
  name: string,
name desc
name Same as query name
result Map of registry name and result of registerable or not
error Map of registry name and validation error message
hasError Set this flag to true if each registry query has more than one name validation error.
errorRegistry List the registry names that had validation errors

Definition of error

If the package name exists, it will not be treated as an error. Violation of the package name rules in each package registry will report an error.

Click here for package name validation rules.

For example, if there is a validation error as the package name for and :

const { result, error, errorRegistry } = await registerable('exist-package-name')
// result
  result: {
    "": false,
    "": false,
    npm: true,
  error: {
     "": "Name contains only the characters a-z, 0-9 and _",
     "": "Name contains only the characters a-z, 0-9 and _",
  hasError: true,
  errorRegistry: ["", ""],
  name: "exist-package-name",

errorRegistry.forEach((registry) => console.warn(registry, error[registry]))
// "Name contains only the characters a-z, 0-9 and _"
// "Name contains only the characters a-z, 0-9 and _"


await registerable('not_exist_package')
// result
  result: {
    "": true,
    "": true,
    npm: true,
  error: {},
  hasError: false,
  errorRegistry: [],
  name: "not_exist_package",

await registerable('not_exist_package', {
  registry: ['']
// result
  result: {
    "": true
  error: {},
  hasError: false,
  errorRegistry: [],
  name: "not_exist_package",

💚 Supports

The TypeScript version must be 4.1.0 or higher.

This project provide ES modules and UMD. The range supported by both is different.

ES modules

Limit support to the latest environment to reduce the bundle size.

DenoDeno Node.jsNode.js IE / EdgeEdge FirefoxFirefox ChromeChrome SafariSafari iOS SafariiOS Safari SamsungSamsung OperaOpera
^1.6.0 ^14.16.0 last 2 versions last 2 versions last 2 versions last 2 versions last 2 versions last 2 versions last 2 versions


Browser is supporting since IE11.

Node.jsNode.js IE / EdgeIE / Edge FirefoxFirefox ChromeChrome SafariSafari iOS SafariiOS Safari SamsungSamsung OperaOpera
^6.17.0 IE11 / ^16 ^60 ^61 ^10.1 ^10.3 ^8.2 ^48

Compared to ES modules, UMD has a bundle size increase of about 2.5x. Recommend using ES modules as much as possible.

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues.

🌱 Show your support

Give a ⭐️ if this project helped you!

💡 License

Copyright © 2021-present TomokiMiyauci.

Released under the MIT license

Package Sidebar


npm i registerable

Weekly Downloads






Unpacked Size

97.3 kB

Total Files


Last publish


  • miyauci