File: //proc/1526/cwd/tana/frontend/node_modules/locutus/php/array/usort.js.map
{"version":3,"sources":["../../../src/php/array/usort.js"],"names":["module","exports","usort","inputArr","sorter","valArr","k","i","sortByReference","populateArr","Object","prototype","toString","call","iniVal","require","undefined","hasOwnProperty","push","sort","e","length"],"mappings":";;AAAAA,OAAOC,OAAP,GAAiB,SAASC,KAAT,CAAgBC,QAAhB,EAA0BC,MAA1B,EAAkC;AACjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAIC,SAAS,EAAb;AACA,MAAIC,IAAI,EAAR;AACA,MAAIC,IAAI,CAAR;AACA,MAAIC,kBAAkB,KAAtB;AACA,MAAIC,cAAc,EAAlB;;AAEA,MAAI,OAAOL,MAAP,KAAkB,QAAtB,EAAgC;AAC9BA,aAAS,KAAKA,MAAL,CAAT;AACD,GAFD,MAEO,IAAIM,OAAOC,SAAP,CAAiBC,QAAjB,CAA0BC,IAA1B,CAA+BT,MAA/B,MAA2C,gBAA/C,EAAiE;AACtEA,aAAS,KAAKA,OAAO,CAAP,CAAL,EAAgBA,OAAO,CAAP,CAAhB,CAAT;AACD;;AAED,MAAIU,SAAS,CAAC,OAAOC,OAAP,KAAmB,WAAnB,GAAiCA,QAAQ,iBAAR,EAA2B,yBAA3B,CAAjC,GAAyFC,SAA1F,KAAwG,IAArH;AACAR,oBAAkBM,WAAW,IAA7B;AACAL,gBAAcD,kBAAkBL,QAAlB,GAA6BM,WAA3C;;AAEA,OAAKH,CAAL,IAAUH,QAAV,EAAoB;AAClB;AACA,QAAIA,SAASc,cAAT,CAAwBX,CAAxB,CAAJ,EAAgC;AAC9BD,aAAOa,IAAP,CAAYf,SAASG,CAAT,CAAZ;AACA,UAAIE,eAAJ,EAAqB;AACnB,eAAOL,SAASG,CAAT,CAAP;AACD;AACF;AACF;AACD,MAAI;AACFD,WAAOc,IAAP,CAAYf,MAAZ;AACD,GAFD,CAEE,OAAOgB,CAAP,EAAU;AACV,WAAO,KAAP;AACD;AACD,OAAKb,IAAI,CAAT,EAAYA,IAAIF,OAAOgB,MAAvB,EAA+Bd,GAA/B,EAAoC;AAClC;AACAE,gBAAYF,CAAZ,IAAiBF,OAAOE,CAAP,CAAjB;AACD;;AAED,SAAOC,mBAAmBC,WAA1B;AACD,CAtDD","file":"usort.js","sourcesContent":["module.exports = function usort (inputArr, sorter) {\n // discuss at: http://locutus.io/php/usort/\n // original by: Brett Zamir (http://brett-zamir.me)\n // improved by: Brett Zamir (http://brett-zamir.me)\n // note 1: This function deviates from PHP in returning a copy of the array instead\n // note 1: of acting by reference and returning true; this was necessary because\n // note 1: IE does not allow deleting and re-adding of properties without caching\n // note 1: of property position; you can set the ini of \"locutus.sortByReference\" to true to\n // note 1: get the PHP behavior, but use this only if you are in an environment\n // note 1: such as Firefox extensions where for-in iteration order is fixed and true\n // note 1: property deletion is supported. Note that we intend to implement the PHP\n // note 1: behavior by default if IE ever does allow it; only gives shallow copy since\n // note 1: is by reference in PHP anyways\n // example 1: var $stuff = {d: '3', a: '1', b: '11', c: '4'}\n // example 1: usort($stuff, function (a, b) { return (a - b) })\n // example 1: var $result = $stuff\n // returns 1: {0: '1', 1: '3', 2: '4', 3: '11'}\n\n var valArr = []\n var k = ''\n var i = 0\n var sortByReference = false\n var populateArr = {}\n\n if (typeof sorter === 'string') {\n sorter = this[sorter]\n } else if (Object.prototype.toString.call(sorter) === '[object Array]') {\n sorter = this[sorter[0]][sorter[1]]\n }\n\n var iniVal = (typeof require !== 'undefined' ? require('../info/ini_get')('locutus.sortByReference') : undefined) || 'on'\n sortByReference = iniVal === 'on'\n populateArr = sortByReference ? inputArr : populateArr\n\n for (k in inputArr) {\n // Get key and value arrays\n if (inputArr.hasOwnProperty(k)) {\n valArr.push(inputArr[k])\n if (sortByReference) {\n delete inputArr[k]\n }\n }\n }\n try {\n valArr.sort(sorter)\n } catch (e) {\n return false\n }\n for (i = 0; i < valArr.length; i++) {\n // Repopulate the old array\n populateArr[i] = valArr[i]\n }\n\n return sortByReference || populateArr\n}\n"]}