reserved-identifiers
Provides a list of reserved identifiers for JavaScript
Last updated a year ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install reserved-identifiers 
SYNC missed versions from official npm registry.

reserved-identifiers

Provides a list of reserved identifiers for JavaScript

It assumes the latest JavaScript version (ES2023) and module context. Supporting older JavaScript versions is a non-goal.

Install

npm install reserved-identifiers

Usage

import reservedIdentifiers from 'reserved-identifiers';

const identifiers = reservedIdentifiers();
const isReserved = identifier => identifiers.has(identifier);

console.log(isReserved('await'));
//=> true

API

reservedIdentifiers(options?)

Returns a Set with the identifiers.

options

Type: object

includeGlobalProperties

Type: boolean
Default: false

Include the global properties globalThis, Infinity, NaN, and undefined. Although not officially reserved, they should typically not be used as identifiers.

typeScriptReservedTypes()

Returns a Set with TypeScript's built-in types that are reserved and cannot be used for type names (interfaces, type aliases, enums, classes, type parameters).

import {typeScriptReservedTypes} from 'reserved-identifiers';

const types = typeScriptReservedTypes();

console.log(types.has('any'));
//=> true

console.log(types.has('unknown'));
//=> true

Related

  • is-identifier - Check if a string is a valid JavaScript identifier

Current Tags

  • 1.2.0                                ...           latest (a year ago)

3 Versions

  • 1.2.0                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Total 10
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 6
Dependencies (0)
None
Dev Dependencies (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE