summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/array/reset.js.map
blob: 2919d4febf9ebe462889ab2e5a1ed3acbc355f5a (plain) (blame)
1
{"version":3,"sources":["../../../src/php/array/reset.js"],"names":["module","exports","reset","arr","$global","window","global","$locutus","php","pointers","indexOf","value","i","length","push","arrpos","Object","prototype","toString","call","k"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,KAAT,CAAgBC,GAAhB,EAAqB;AACpC;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAIC,UAAW,OAAOC,MAAP,KAAkB,WAAlB,GAAgCA,MAAhC,GAAyCC,MAAxD;AACAF,UAAQG,QAAR,GAAmBH,QAAQG,QAAR,IAAoB,EAAvC;AACA,MAAIA,WAAWH,QAAQG,QAAvB;AACAA,WAASC,GAAT,GAAeD,SAASC,GAAT,IAAgB,EAA/B;AACAD,WAASC,GAAT,CAAaC,QAAb,GAAwBF,SAASC,GAAT,CAAaC,QAAb,IAAyB,EAAjD;AACA,MAAIA,WAAWF,SAASC,GAAT,CAAaC,QAA5B;;AAEA,MAAIC,UAAU,SAAVA,OAAU,CAAUC,KAAV,EAAiB;AAC7B,SAAK,IAAIC,IAAI,CAAR,EAAWC,SAAS,KAAKA,MAA9B,EAAsCD,IAAIC,MAA1C,EAAkDD,GAAlD,EAAuD;AACrD,UAAI,KAAKA,CAAL,MAAYD,KAAhB,EAAuB;AACrB,eAAOC,CAAP;AACD;AACF;AACD,WAAO,CAAC,CAAR;AACD,GAPD;;AASA,MAAI,CAACH,SAASC,OAAd,EAAuB;AACrBD,aAASC,OAAT,GAAmBA,OAAnB;AACD;AACD,MAAID,SAASC,OAAT,CAAiBP,GAAjB,MAA0B,CAAC,CAA/B,EAAkC;AAChCM,aAASK,IAAT,CAAcX,GAAd,EAAmB,CAAnB;AACD;AACD,MAAIY,SAASN,SAASC,OAAT,CAAiBP,GAAjB,CAAb;AACA,MAAIa,OAAOC,SAAP,CAAiBC,QAAjB,CAA0BC,IAA1B,CAA+BhB,GAA/B,MAAwC,gBAA5C,EAA8D;AAC5D,SAAK,IAAIiB,CAAT,IAAcjB,GAAd,EAAmB;AACjB,UAAIM,SAASC,OAAT,CAAiBP,GAAjB,MAA0B,CAAC,CAA/B,EAAkC;AAChCM,iBAASK,IAAT,CAAcX,GAAd,EAAmB,CAAnB;AACD,OAFD,MAEO;AACLM,iBAASM,SAAS,CAAlB,IAAuB,CAAvB;AACD;AACD,aAAOZ,IAAIiB,CAAJ,CAAP;AACD;AACD;AACA,WAAO,KAAP;AACD;AACD,MAAIjB,IAAIU,MAAJ,KAAe,CAAnB,EAAsB;AACpB,WAAO,KAAP;AACD;AACDJ,WAASM,SAAS,CAAlB,IAAuB,CAAvB;AACA,SAAOZ,IAAIM,SAASM,SAAS,CAAlB,CAAJ,CAAP;AACD,CAjDD","file":"reset.js","sourcesContent":["module.exports = function reset (arr) {\n  //  discuss at: http://locutus.io/php/reset/\n  // original by: Kevin van Zonneveld (http://kvz.io)\n  // bugfixed by: Legaev Andrey\n  //  revised by: Brett Zamir (http://brett-zamir.me)\n  //      note 1: Uses global: locutus to store the array pointer\n  //   example 1: reset({0: 'Kevin', 1: 'van', 2: 'Zonneveld'})\n  //   returns 1: 'Kevin'\n\n  var $global = (typeof window !== 'undefined' ? window : global)\n  $global.$locutus = $global.$locutus || {}\n  var $locutus = $global.$locutus\n  $locutus.php = $locutus.php || {}\n  $locutus.php.pointers = $locutus.php.pointers || []\n  var pointers = $locutus.php.pointers\n\n  var indexOf = function (value) {\n    for (var i = 0, length = this.length; i < length; i++) {\n      if (this[i] === value) {\n        return i\n      }\n    }\n    return -1\n  }\n\n  if (!pointers.indexOf) {\n    pointers.indexOf = indexOf\n  }\n  if (pointers.indexOf(arr) === -1) {\n    pointers.push(arr, 0)\n  }\n  var arrpos = pointers.indexOf(arr)\n  if (Object.prototype.toString.call(arr) !== '[object Array]') {\n    for (var k in arr) {\n      if (pointers.indexOf(arr) === -1) {\n        pointers.push(arr, 0)\n      } else {\n        pointers[arrpos + 1] = 0\n      }\n      return arr[k]\n    }\n    // Empty\n    return false\n  }\n  if (arr.length === 0) {\n    return false\n  }\n  pointers[arrpos + 1] = 0\n  return arr[pointers[arrpos + 1]]\n}\n"]}