Replace "... instanceof Array" with "Array.isArray(...)"

See #441.
redux
David Majda 8 years ago
parent d346d2a66d
commit 1c3fbf6cb0

@ -575,7 +575,7 @@ function generateBytecode(ast) {
regexp = '/^['
+ (node.inverted ? '^' : '')
+ node.parts.map(function(part) {
return part instanceof Array
return Array.isArray(part)
? js.regexpClassEscape(part[0])
+ '-'
+ js.regexpClassEscape(part[1])
@ -592,7 +592,7 @@ function generateBytecode(ast) {
parts = '['
+ node.parts.map(function(part) {
return part instanceof Array
return Array.isArray(part)
? '["' + js.stringEscape(part[0]) + '", "' + js.stringEscape(part[1]) + '"]'
: '"' + js.stringEscape(part) + '"';
}).join(', ')

@ -790,7 +790,7 @@ function generateJS(ast, options) {
' i;',
'',
' for (i = 0; i < expectation.parts.length; i++) {',
' escapedParts += expectation.parts[i] instanceof Array',
' escapedParts += Array.isArray(expectation.parts[i])',
' ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])',
' : classEscape(expectation.parts[i]);',
' }',

@ -40,7 +40,7 @@ peg$SyntaxError.buildMessage = function(expected, found) {
i;
for (i = 0; i < expectation.parts.length; i++) {
escapedParts += expectation.parts[i] instanceof Array
escapedParts += Array.isArray(expectation.parts[i])
? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
: classEscape(expectation.parts[i]);
}

Loading…
Cancel
Save