refactor(core): use makeMap for faster string match checks (#282)

This commit is contained in:
Ayush Goyal
2019-10-15 21:41:08 +05:30
committed by Evan You
parent eb28d45933
commit 58fffcb987
6 changed files with 53 additions and 202 deletions

View File

@@ -1,25 +1,8 @@
export const globalsWhitelist = new Set([
'Infinity',
'undefined',
'NaN',
'isFinite',
'isNaN',
'parseFloat',
'parseInt',
'decodeURI',
'decodeURIComponent',
'encodeURI',
'encodeURIComponent',
'Math',
'Number',
'Date',
'Array',
'Object',
'Boolean',
'String',
'RegExp',
'Map',
'Set',
'JSON',
'Intl'
])
import { makeMap } from './makeMap'
const GLOBALS_WHITE_LISTED =
'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl'
export const isGloballyWhitelisted = makeMap(GLOBALS_WHITE_LISTED)