summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/array/array_pop.js.map
blob: 81bb95a24873af4f0ddb0f06f59f1baf1df76a7d (plain) (blame)
1
{"version":3,"sources":["../../../src/php/array/array_pop.js"],"names":["module","exports","array_pop","inputArr","key","lastKey","hasOwnProperty","length","pop","tmp"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,SAAT,CAAoBC,QAApB,EAA8B;AAAE;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAIC,MAAM,EAAV;AACA,MAAIC,UAAU,EAAd;;AAEA,MAAIF,SAASG,cAAT,CAAwB,QAAxB,CAAJ,EAAuC;AACrC;AACA,QAAI,CAACH,SAASI,MAAd,EAAsB;AACpB;AACA,aAAO,IAAP;AACD;AACD,WAAOJ,SAASK,GAAT,EAAP;AACD,GAPD,MAOO;AACL;AACA,SAAKJ,GAAL,IAAYD,QAAZ,EAAsB;AACpB,UAAIA,SAASG,cAAT,CAAwBF,GAAxB,CAAJ,EAAkC;AAChCC,kBAAUD,GAAV;AACD;AACF;AACD,QAAIC,OAAJ,EAAa;AACX,UAAII,MAAMN,SAASE,OAAT,CAAV;AACA,aAAQF,SAASE,OAAT,CAAR;AACA,aAAOI,GAAP;AACD,KAJD,MAIO;AACL,aAAO,IAAP;AACD;AACF;AACF,CA9CD","file":"array_pop.js","sourcesContent":["module.exports = function array_pop (inputArr) { // eslint-disable-line camelcase\n  //  discuss at: http://locutus.io/php/array_pop/\n  // original by: Kevin van Zonneveld (http://kvz.io)\n  // improved by: Kevin van Zonneveld (http://kvz.io)\n  //    input by: Brett Zamir (http://brett-zamir.me)\n  //    input by: Theriault (https://github.com/Theriault)\n  // bugfixed by: Kevin van Zonneveld (http://kvz.io)\n  // bugfixed by: Brett Zamir (http://brett-zamir.me)\n  //      note 1: While IE (and other browsers) support iterating an object's\n  //      note 1: own properties in order, if one attempts to add back properties\n  //      note 1: in IE, they may end up in their former position due to their position\n  //      note 1: being retained. So use of this function with \"associative arrays\"\n  //      note 1: (objects) may lead to unexpected behavior in an IE environment if\n  //      note 1: you add back properties with the same keys that you removed\n  //   example 1: array_pop([0,1,2])\n  //   returns 1: 2\n  //   example 2: var $data = {firstName: 'Kevin', surName: 'van Zonneveld'}\n  //   example 2: var $lastElem = array_pop($data)\n  //   example 2: var $result = $data\n  //   returns 2: {firstName: 'Kevin'}\n\n  var key = ''\n  var lastKey = ''\n\n  if (inputArr.hasOwnProperty('length')) {\n    // Indexed\n    if (!inputArr.length) {\n      // Done popping, are we?\n      return null\n    }\n    return inputArr.pop()\n  } else {\n    // Associative\n    for (key in inputArr) {\n      if (inputArr.hasOwnProperty(key)) {\n        lastKey = key\n      }\n    }\n    if (lastKey) {\n      var tmp = inputArr[lastKey]\n      delete (inputArr[lastKey])\n      return tmp\n    } else {\n      return null\n    }\n  }\n}\n"]}