summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/array/prev.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/locutus/php/array/prev.js')
-rw-r--r--node_modules/locutus/php/array/prev.js52
1 files changed, 0 insertions, 52 deletions
diff --git a/node_modules/locutus/php/array/prev.js b/node_modules/locutus/php/array/prev.js
deleted file mode 100644
index 88f5511..0000000
--- a/node_modules/locutus/php/array/prev.js
+++ /dev/null
@@ -1,52 +0,0 @@
-'use strict';
-
-module.exports = function prev(arr) {
- // discuss at: http://locutus.io/php/prev/
- // original by: Brett Zamir (http://brett-zamir.me)
- // note 1: Uses global: locutus to store the array pointer
- // example 1: var $transport = ['foot', 'bike', 'car', 'plane']
- // example 1: prev($transport)
- // returns 1: false
-
- var $global = typeof window !== 'undefined' ? window : global;
- $global.$locutus = $global.$locutus || {};
- var $locutus = $global.$locutus;
- $locutus.php = $locutus.php || {};
- $locutus.php.pointers = $locutus.php.pointers || [];
- var pointers = $locutus.php.pointers;
-
- var indexOf = function indexOf(value) {
- for (var i = 0, length = this.length; i < length; i++) {
- if (this[i] === value) {
- return i;
- }
- }
- return -1;
- };
-
- if (!pointers.indexOf) {
- pointers.indexOf = indexOf;
- }
- var arrpos = pointers.indexOf(arr);
- var cursor = pointers[arrpos + 1];
- if (pointers.indexOf(arr) === -1 || cursor === 0) {
- return false;
- }
- if (Object.prototype.toString.call(arr) !== '[object Array]') {
- var ct = 0;
- for (var k in arr) {
- if (ct === cursor - 1) {
- pointers[arrpos + 1] -= 1;
- return arr[k];
- }
- ct++;
- }
- // Shouldn't reach here
- }
- if (arr.length === 0) {
- return false;
- }
- pointers[arrpos + 1] -= 1;
- return arr[pointers[arrpos + 1]];
-};
-//# sourceMappingURL=prev.js.map \ No newline at end of file