UNPKG

1.77 kBJavaScriptView Raw
1/**
2 * Copyright 2014 Shape Security, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17"use strict";
18
19exports.isStrictModeReservedWord = isStrictModeReservedWord;
20exports.getHexValue = getHexValue;
21
22var _esutils = require("esutils");
23
24var isReservedWordES6 = _esutils.keyword.isReservedWordES6;
25var isRestrictedWord = _esutils.keyword.isRestrictedWord;
26var isIdentifierStartES6 = _esutils.code.isIdentifierStartES6;
27var isIdentifierPartES6 = _esutils.code.isIdentifierPartES6;
28var isWhiteSpace = _esutils.code.isWhiteSpace;
29var isLineTerminator = _esutils.code.isLineTerminator;
30var isDecimalDigit = _esutils.code.isDecimalDigit;
31exports.isRestrictedWord = isRestrictedWord;
32exports.isIdentifierStart = isIdentifierStartES6;
33exports.isIdentifierPart = isIdentifierPartES6;
34exports.isWhiteSpace = isWhiteSpace;
35exports.isLineTerminator = isLineTerminator;
36exports.isDecimalDigit = isDecimalDigit;
37
38function isStrictModeReservedWord(id) {
39 return isReservedWordES6(id, true);
40}
41
42function getHexValue(rune) {
43 if ("0" <= rune && rune <= "9") {
44 return rune.charCodeAt(0) - 48;
45 }
46 if ("a" <= rune && rune <= "f") {
47 return rune.charCodeAt(0) - 87;
48 }
49 if ("A" <= rune && rune <= "F") {
50 return rune.charCodeAt(0) - 55;
51 }
52 return -1;
53}
\No newline at end of file