UNPKG

451 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const identifierRegex = /^[a-z$_][$\w]*$/i;
4const reservedSet = new Set([
5 'undefined',
6 'null',
7 'true',
8 'false',
9 'super',
10 'this',
11 'Infinity',
12 'NaN'
13]);
14/**
15Test if the string is a valid JavaScript identifier.
16
17@param string - String to test.
18*/
19exports.default = (string) => string && !reservedSet.has(string) && identifierRegex.test(string);