react / wstein / node_modules / react / node_modules / envify / node_modules / jstransform / visitors / reserved-words-helper.js
80540 views/**1* Copyright 2014 Facebook, Inc.2*3* Licensed under the Apache License, Version 2.0 (the "License");4* you may not use this file except in compliance with the License.5* You may obtain a copy of the License at6*7* http://www.apache.org/licenses/LICENSE-2.08*9* Unless required by applicable law or agreed to in writing, software10* distributed under the License is distributed on an "AS IS" BASIS,11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12* See the License for the specific language governing permissions and13* limitations under the License.14*/1516var KEYWORDS = [17'break', 'do', 'in', 'typeof', 'case', 'else', 'instanceof', 'var', 'catch',18'export', 'new', 'void', 'class', 'extends', 'return', 'while', 'const',19'finally', 'super', 'with', 'continue', 'for', 'switch', 'yield', 'debugger',20'function', 'this', 'default', 'if', 'throw', 'delete', 'import', 'try'21];2223var FUTURE_RESERVED_WORDS = [24'enum', 'await', 'implements', 'package', 'protected', 'static', 'interface',25'private', 'public'26];2728var LITERALS = [29'null',30'true',31'false'32];3334// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-reserved-words35var RESERVED_WORDS = [].concat(36KEYWORDS,37FUTURE_RESERVED_WORDS,38LITERALS39);4041var reservedWordsMap = Object.create(null);42RESERVED_WORDS.forEach(function(k) {43reservedWordsMap[k] = true;44});4546/**47* This list should not grow as new reserved words are introdued. This list is48* of words that need to be quoted because ES3-ish browsers do not allow their49* use as identifier names.50*/51var ES3_FUTURE_RESERVED_WORDS = [52'enum', 'implements', 'package', 'protected', 'static', 'interface',53'private', 'public'54];5556var ES3_RESERVED_WORDS = [].concat(57KEYWORDS,58ES3_FUTURE_RESERVED_WORDS,59LITERALS60);6162var es3ReservedWordsMap = Object.create(null);63ES3_RESERVED_WORDS.forEach(function(k) {64es3ReservedWordsMap[k] = true;65});6667exports.isReservedWord = function(word) {68return !!reservedWordsMap[word];69};7071exports.isES3ReservedWord = function(word) {72return !!es3ReservedWordsMap[word];73};747576