diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /services/sync/tps/extensions/mozmill/resource/stdlib/arrays.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'services/sync/tps/extensions/mozmill/resource/stdlib/arrays.js')
-rw-r--r-- | services/sync/tps/extensions/mozmill/resource/stdlib/arrays.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/services/sync/tps/extensions/mozmill/resource/stdlib/arrays.js b/services/sync/tps/extensions/mozmill/resource/stdlib/arrays.js new file mode 100644 index 000000000..c70a262c9 --- /dev/null +++ b/services/sync/tps/extensions/mozmill/resource/stdlib/arrays.js @@ -0,0 +1,78 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at http://mozilla.org/MPL/2.0/. */ + +var EXPORTED_SYMBOLS = ['inArray', 'getSet', 'indexOf', + 'remove', 'rindexOf', 'compare']; + + +function remove(array, from, to) { + var rest = array.slice((to || from) + 1 || array.length); + array.length = from < 0 ? array.length + from : from; + + return array.push.apply(array, rest); +} + +function inArray(array, value) { + for (var i in array) { + if (value == array[i]) { + return true; + } + } + + return false; +} + +function getSet(array) { + var narray = []; + + for (var i in array) { + if (!inArray(narray, array[i])) { + narray.push(array[i]); + } + } + + return narray; +} + +function indexOf(array, v, offset) { + for (var i in array) { + if (offset == undefined || i >= offset) { + if (!isNaN(i) && array[i] == v) { + return new Number(i); + } + } + } + + return -1; +} + +function rindexOf (array, v) { + var l = array.length; + + for (var i in array) { + if (!isNaN(i)) { + var i = new Number(i); + } + + if (!isNaN(i) && array[l - i] == v) { + return l - i; + } + } + + return -1; +} + +function compare (array, carray) { + if (array.length != carray.length) { + return false; + } + + for (var i in array) { + if (array[i] != carray[i]) { + return false; + } + } + + return true; +} |