From d162fe1cfcfc5a3ba3e20f360b846e5f1927be98 Mon Sep 17 00:00:00 2001 From: David Majda Date: Fri, 19 Aug 2016 17:18:43 +0200 Subject: [PATCH] Replace arrays.every with Array.prototype.every See #441. --- lib/compiler/asts.js | 2 +- lib/compiler/passes/report-infinite-recursion.js | 2 +- lib/utils/arrays.js | 12 ------------ 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/lib/compiler/asts.js b/lib/compiler/asts.js index 7dac649..90c6a3a 100644 --- a/lib/compiler/asts.js +++ b/lib/compiler/asts.js @@ -26,7 +26,7 @@ var asts = { named: consumesExpression, choice: function(node) { - return arrays.every(node.alternatives, consumes); + return node.alternatives.every(consumes); }, action: consumesExpression, diff --git a/lib/compiler/passes/report-infinite-recursion.js b/lib/compiler/passes/report-infinite-recursion.js index 1230a2f..6623a8b 100644 --- a/lib/compiler/passes/report-infinite-recursion.js +++ b/lib/compiler/passes/report-infinite-recursion.js @@ -28,7 +28,7 @@ function reportInfiniteRecursion(ast) { }, sequence: function(node) { - arrays.every(node.elements, function(element) { + node.elements.every(function(element) { check(element); return !asts.alwaysConsumesOnSuccess(ast, element); diff --git a/lib/utils/arrays.js b/lib/utils/arrays.js index 3b687aa..2c03705 100644 --- a/lib/utils/arrays.js +++ b/lib/utils/arrays.js @@ -60,18 +60,6 @@ var arrays = { return array.map(function (e) { return e[key]; }); }, - every: function(array, predicate) { - var length = array.length, i; - - for (i = 0; i < length; i++) { - if (!predicate(array[i])) { - return false; - } - } - - return true; - }, - some: function(array, predicate) { var length = array.length, i;