init
This commit is contained in:
40
node_modules/estree-util-is-identifier-name/lib/index.d.ts
generated
vendored
Normal file
40
node_modules/estree-util-is-identifier-name/lib/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Checks if the given code point can start an identifier.
|
||||
*
|
||||
* @param {number | undefined} code
|
||||
* Code point to check.
|
||||
* @returns {boolean}
|
||||
* Whether `code` can start an identifier.
|
||||
*/
|
||||
export function start(code: number | undefined): boolean;
|
||||
/**
|
||||
* Checks if the given code point can continue an identifier.
|
||||
*
|
||||
* @param {number | undefined} code
|
||||
* Code point to check.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {boolean}
|
||||
* Whether `code` can continue an identifier.
|
||||
*/
|
||||
export function cont(code: number | undefined, options?: Options | null | undefined): boolean;
|
||||
/**
|
||||
* Checks if the given value is a valid identifier name.
|
||||
*
|
||||
* @param {string} name
|
||||
* Identifier to check.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {boolean}
|
||||
* Whether `name` can be an identifier.
|
||||
*/
|
||||
export function name(name: string, options?: Options | null | undefined): boolean;
|
||||
/**
|
||||
* Configuration.
|
||||
*/
|
||||
export type Options = {
|
||||
/**
|
||||
* Support JSX identifiers (default: `false`).
|
||||
*/
|
||||
jsx?: boolean | null | undefined;
|
||||
};
|
||||
61
node_modules/estree-util-is-identifier-name/lib/index.js
generated
vendored
Normal file
61
node_modules/estree-util-is-identifier-name/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @typedef Options
|
||||
* Configuration.
|
||||
* @property {boolean | null | undefined} [jsx=false]
|
||||
* Support JSX identifiers (default: `false`).
|
||||
*/
|
||||
|
||||
const startRe = /[$_\p{ID_Start}]/u
|
||||
const contRe = /[$_\u{200C}\u{200D}\p{ID_Continue}]/u
|
||||
const contReJsx = /[-$_\u{200C}\u{200D}\p{ID_Continue}]/u
|
||||
const nameRe = /^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u
|
||||
const nameReJsx = /^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u
|
||||
|
||||
/** @type {Options} */
|
||||
const emptyOptions = {}
|
||||
|
||||
/**
|
||||
* Checks if the given code point can start an identifier.
|
||||
*
|
||||
* @param {number | undefined} code
|
||||
* Code point to check.
|
||||
* @returns {boolean}
|
||||
* Whether `code` can start an identifier.
|
||||
*/
|
||||
// Note: `undefined` is supported so you can pass the result from `''.codePointAt`.
|
||||
export function start(code) {
|
||||
return code ? startRe.test(String.fromCodePoint(code)) : false
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given code point can continue an identifier.
|
||||
*
|
||||
* @param {number | undefined} code
|
||||
* Code point to check.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {boolean}
|
||||
* Whether `code` can continue an identifier.
|
||||
*/
|
||||
// Note: `undefined` is supported so you can pass the result from `''.codePointAt`.
|
||||
export function cont(code, options) {
|
||||
const settings = options || emptyOptions
|
||||
const re = settings.jsx ? contReJsx : contRe
|
||||
return code ? re.test(String.fromCodePoint(code)) : false
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given value is a valid identifier name.
|
||||
*
|
||||
* @param {string} name
|
||||
* Identifier to check.
|
||||
* @param {Options | null | undefined} [options]
|
||||
* Configuration (optional).
|
||||
* @returns {boolean}
|
||||
* Whether `name` can be an identifier.
|
||||
*/
|
||||
export function name(name, options) {
|
||||
const settings = options || emptyOptions
|
||||
const re = settings.jsx ? nameReJsx : nameRe
|
||||
return re.test(name)
|
||||
}
|
||||
Reference in New Issue
Block a user