From 4dec5e52ba0cbb24a42168f07b1e03e66c30236c Mon Sep 17 00:00:00 2001 From: David Majda Date: Tue, 13 Sep 2016 16:08:45 +0200 Subject: [PATCH] Don't use "arrays" in lib/compiler/asts.js The "arrays" module will be removed. See #442. --- lib/compiler/asts.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/compiler/asts.js b/lib/compiler/asts.js index 559e75d..f87702d 100644 --- a/lib/compiler/asts.js +++ b/lib/compiler/asts.js @@ -1,16 +1,27 @@ "use strict"; -let arrays = require("../utils/arrays"), - visitor = require("./visitor"); +let visitor = require("./visitor"); /* AST utilities. */ let asts = { findRule: function(ast, name) { - return arrays.find(ast.rules, r => r.name === name); + for (let i = 0; i < ast.rules.length; i++) { + if (ast.rules[i].name === name) { + return ast.rules[i]; + } + } + + return undefined; }, indexOfRule: function(ast, name) { - return arrays.indexOf(ast.rules, r => r.name === name); + for (let i = 0; i < ast.rules.length; i++) { + if (ast.rules[i].name === name) { + return i; + } + } + + return -1; }, alwaysConsumesOnSuccess: function(ast, node) {