Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,59 @@
export type Options = {
/**
Include the [global properties](https://tc39.es/ecma262/#sec-value-properties-of-the-global-object) `globalThis`, `Infinity`, `NaN`, and `undefined`. Although not officially reserved, they should typically [not be used as identifiers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined#sect1).
@default false
*/
readonly includeGlobalProperties?: boolean;
};
/**
Provides a list of [reserved identifiers](https://262.ecma-international.org/14.0/#sec-keywords-and-reserved-words) for JavaScript.
@example
```
import reservedIdentifiers from 'reserved-identifiers';
const identifiers = reservedIdentifiers();
const isReserved = identifier => identifiers.has(identifier);
console.log(isReserved('await'));
//=> true
```
*/
export default function reservedIdentifiers(options?: Options): Set<string>;
/**
TypeScript's built-in types that are reserved and cannot be used for type names (interfaces, type aliases, enums, classes, type parameters).
*/
export type TypeScriptReservedType =
| 'any'
| 'bigint'
| 'boolean'
| 'never'
| 'null'
| 'number'
| 'object'
| 'string'
| 'symbol'
| 'undefined'
| 'unknown'
| 'void';
/**
Provides a list of TypeScript's built-in types that are reserved and cannot be used for type names (interfaces, type aliases, enums, classes, type parameters).
@example
```
import {typeScriptReservedTypes} from 'reserved-identifiers';
const types = typeScriptReservedTypes();
console.log(types.has('any'));
//=> true
console.log(types.has('unknown'));
//=> true
```
*/
export function typeScriptReservedTypes(): Set<string>;

View file

@ -0,0 +1,92 @@
// https://262.ecma-international.org/14.0/#sec-keywords-and-reserved-words
// 14 is ES2023
const identifiers = [
// Keywords
'await',
'break',
'case',
'catch',
'class',
'const',
'continue',
'debugger',
'default',
'delete',
'do',
'else',
'enum',
'export',
'extends',
'false',
'finally',
'for',
'function',
'if',
'import',
'in',
'instanceof',
'new',
'null',
'return',
'super',
'switch',
'this',
'throw',
'true',
'try',
'typeof',
'var',
'void',
'while',
'with',
'yield',
// Future reserved keywords (strict mode)
'implements',
'interface',
'let',
'package',
'private',
'protected',
'public',
'static',
// Not keywords, but still restricted
'arguments',
'eval',
];
// https://262.ecma-international.org/14.0/#sec-value-properties-of-the-global-object
const globalProperties = [
'globalThis',
'Infinity',
'NaN',
'undefined',
];
// These are TypeScript's built-in types that are reserved and cannot be used for type names
const typeScriptTypes = [
'any',
'bigint',
'boolean',
'never',
'null',
'number',
'object',
'string',
'symbol',
'undefined',
'unknown',
'void',
];
export default function reservedIdentifiers({includeGlobalProperties = false} = {}) {
return new Set([
...identifiers,
...(includeGlobalProperties ? globalProperties : []),
]);
}
export function typeScriptReservedTypes() {
return new Set(typeScriptTypes);
}

View file

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,47 @@
{
"name": "reserved-identifiers",
"version": "1.2.0",
"description": "Provides a list of reserved identifiers for JavaScript",
"license": "MIT",
"repository": "sindresorhus/reserved-identifiers",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=18"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"reserved",
"identifiers",
"keywords",
"words",
"restricted",
"javascript",
"ecmascript",
"identifier",
"variable",
"function",
"property",
"set"
],
"devDependencies": {
"ava": "^6.1.2",
"xo": "^0.58.0"
}
}

View file

@ -0,0 +1,60 @@
# reserved-identifiers
> Provides a list of [reserved identifiers](https://262.ecma-international.org/14.0/#sec-keywords-and-reserved-words) for JavaScript
It assumes the latest JavaScript version (ES2023) and module context. Supporting older JavaScript versions is a non-goal.
## Install
```sh
npm install reserved-identifiers
```
## Usage
```js
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](https://tc39.es/ecma262/#sec-value-properties-of-the-global-object) `globalThis`, `Infinity`, `NaN`, and `undefined`. Although not officially reserved, they should typically [not be used as identifiers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined#sect1).
### 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).
```js
import {typeScriptReservedTypes} from 'reserved-identifiers';
const types = typeScriptReservedTypes();
console.log(types.has('any'));
//=> true
console.log(types.has('unknown'));
//=> true
```
## Related
- [is-identifier](https://github.com/sindresorhus/is-identifier) - Check if a string is a valid JavaScript identifier