From 6e0d0b1a124ac72a627113a73bf3ba4995f49bf5 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sun, 2 Apr 2017 09:48:14 -0400 Subject: [PATCH] use a map to avoid false positives --- src/parse/read/expression.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/parse/read/expression.js b/src/parse/read/expression.js index e896f647cd..7aa34b9bdc 100644 --- a/src/parse/read/expression.js +++ b/src/parse/read/expression.js @@ -1,10 +1,10 @@ import { parseExpressionAt } from 'acorn'; -const literals = { - true: true, - false: false, - null: null -}; +const literals = new Map([ + [ 'true', true ], + [ 'false', false ], + [ 'null', null ] +]); export default function readExpression ( parser ) { const start = parser.index; @@ -13,12 +13,12 @@ export default function readExpression ( parser ) { if ( name && /^[a-z]+$/.test( name ) ) { const end = start + name.length; - if ( name in literals ) { + if ( literals.has( name ) ) { return { type: 'Literal', start, end, - value: literals[ name ], + value: literals.get( name ), raw: name }; }