From dcdfc94cb39dfe2c39925a0145ffa45e2d061c30 Mon Sep 17 00:00:00 2001 From: Kumar Priyansh Date: Sat, 19 Jan 2019 12:37:14 +0530 Subject: Initial Upload via GIT --- cordova/node_modules/pegjs/lib/utils/arrays.js | 108 +++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 cordova/node_modules/pegjs/lib/utils/arrays.js (limited to 'cordova/node_modules/pegjs/lib/utils/arrays.js') diff --git a/cordova/node_modules/pegjs/lib/utils/arrays.js b/cordova/node_modules/pegjs/lib/utils/arrays.js new file mode 100644 index 0000000..93a833c --- /dev/null +++ b/cordova/node_modules/pegjs/lib/utils/arrays.js @@ -0,0 +1,108 @@ +"use strict"; + +/* Array utilities. */ +var arrays = { + range: function(start, stop) { + var length = stop - start, + result = new Array(length), + i, j; + + for (i = 0, j = start; i < length; i++, j++) { + result[i] = j; + } + + return result; + }, + + find: function(array, valueOrPredicate) { + var length = array.length, i; + + if (typeof valueOrPredicate === "function") { + for (i = 0; i < length; i++) { + if (valueOrPredicate(array[i])) { + return array[i]; + } + } + } else { + for (i = 0; i < length; i++) { + if (array[i] === valueOrPredicate) { + return array[i]; + } + } + } + }, + + indexOf: function(array, valueOrPredicate) { + var length = array.length, i; + + if (typeof valueOrPredicate === "function") { + for (i = 0; i < length; i++) { + if (valueOrPredicate(array[i])) { + return i; + } + } + } else { + for (i = 0; i < length; i++) { + if (array[i] === valueOrPredicate) { + return i; + } + } + } + + return -1; + }, + + contains: function(array, valueOrPredicate) { + return arrays.indexOf(array, valueOrPredicate) !== -1; + }, + + each: function(array, iterator) { + var length = array.length, i; + + for (i = 0; i < length; i++) { + iterator(array[i], i); + } + }, + + map: function(array, iterator) { + var length = array.length, + result = new Array(length), + i; + + for (i = 0; i < length; i++) { + result[i] = iterator(array[i], i); + } + + return result; + }, + + pluck: function(array, key) { + return arrays.map(array, 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; + + for (i = 0; i < length; i++) { + if (predicate(array[i])) { + return true; + } + } + + return false; + } +}; + +module.exports = arrays; -- cgit v1.2.3