Source code
Revision control
Copy as Markdown
Other Tools
{"version":3,"sources":["webpack:///bundle.js","webpack:///webpack/bootstrap 24c582683c5b4b6a8192","webpack:///./test.js","webpack:///./sorted.js"],"names":["modules","__webpack_require__","moduleId","installedModules","exports","module","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","window","test","result","fancySort","console","log","comparer","a","b","ma","exec","mb","na","nb","binaryLookup","ar","length","found","index","r","mid","Math","floor","input","reduce","splice","value"],"mappings":"CAAS,SAAUA,GCIjB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUE,OAGnC,IAAIC,GAASF,EAAiBD,IAC7BI,EAAGJ,EACHK,GAAG,EACHH,WAUD,OANAJ,GAAQE,GAAUM,KAAKH,EAAOD,QAASC,EAAQA,EAAOD,QAASH,GAG/DI,EAAOE,GAAI,EAGJF,EAAOD,QAvBf,GAAID,KA4BJF,GAAoBQ,EAAIT,EAGxBC,EAAoBS,EAAIP,EAGxBF,EAAoBU,EAAI,SAASP,EAASQ,EAAMC,GAC3CZ,EAAoBa,EAAEV,EAASQ,IAClCG,OAAOC,eAAeZ,EAASQ,GAC9BK,cAAc,EACdC,YAAY,EACZC,IAAKN,KAMRZ,EAAoBmB,EAAI,SAASf,GAChC,GAAIQ,GAASR,GAAUA,EAAOgB,WAC7B,WAAwB,MAAOhB,GAAgB,SAC/C,WAA8B,MAAOA,GAEtC,OADAJ,GAAoBU,EAAEE,EAAQ,IAAKA,GAC5BA,GAIRZ,EAAoBa,EAAI,SAASQ,EAAQC,GAAY,MAAOR,QAAOS,UAAUC,eAAejB,KAAKc,EAAQC,IAGzGtB,EAAoByB,EAAI,GAGjBzB,EAAoBA,EAAoB0B,EAAI,KDM/C,SAAUtB,EAAQD,EAASH,GAEjC,YErEA,WAEA2B,QAAOC,KAAO,WACZ,GAAIA,IAAQ,SAAU,IAAK,QAAS,KAChCC,GAAS,IAAAC,WAAUF,EACvBG,SAAQC,IAAIH,KF6ER,SAAUzB,EAAQD,EAASH,GAEjC,YGpFA,SAASiC,GAASC,EAAGC,GACnB,GAAMC,GAAK,aAAaC,KAAKH,GACvBI,EAAK,aAAaD,KAAKF,EAC7B,IAAU,MAANC,GAAoB,MAANE,GAAcF,EAAG,IAAME,EAAG,GAC1C,MAAOJ,GAAIC,GAAK,EAAID,EAAIC,EAAI,EAAI,CAEhC,IAAMI,IAAMH,EAAG,GACbI,GAAMF,EAAG,EACX,OAAOC,GAAKC,GAAM,EAAID,EAAKC,EAAK,EAAI,EAIxC,QAASC,GAAaC,EAAIrC,EAAG4B,GAC3B,GAAiB,GAAbS,EAAGC,OACL,OAASC,OAAO,EAAOC,MAAO,EAIhC,KAFA,GAAIvC,GAAI,EACNwC,EAAIJ,EAAGC,OAAS,EACXrC,EAAIwC,GAAG,CACZ,GAAMC,GAAMC,KAAKC,OAAO3C,EAAIwC,GAAK,EAC7Bb,GAASS,EAAGK,GAAM1C,GAAK,EACzBC,EAAIyC,EAAM,EAEVD,EAAIC,EAGR,GAAMlB,GAASI,EAASS,EAAGpC,GAAID,EAC/B,OAAe,KAAXwB,GACOe,OAAO,EAAMC,MAAOvC,IAG7BsC,OAAO,EACPC,MAAOhB,EAAS,EAAIvB,EAAI,EAAIA,GAIzB,QAASwB,GAAUoB,GACxB,MAAOA,GAAMC,OAAO,SAACT,EAAIrC,GAAM,MACXoC,EAAaC,EAAIrC,EAAG4B,GAA9BY,EADqB,EACrBA,KAER,OADAH,GAAGU,OAAOP,EAAO,EAAGxC,GACbqC,OH+CX5B,OAAOC,eAAeZ,EAAS,cAC7BkD,OAAO,IAETlD,EGtDgB2B","file":"bundle.js","sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _sorted = __webpack_require__(1);\n\nwindow.test = function originalTestName() {\n var test = [\"b (30)\", \"a\", \"b (5)\", \"z\"];\n var result = (0, _sorted.fancySort)(test);\n console.log(result);\n};\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.fancySort = fancySort;\nfunction comparer(a, b) {\n var ma = /.(\\d+)\\W*$/.exec(a);\n var mb = /.(\\d+)\\W*$/.exec(b);\n if (ma == null || mb == null || ma[1] == mb[1]) {\n return a < b ? -1 : a > b ? 1 : 0;\n } else {\n var na = +ma[1],\n nb = +mb[1];\n return na < nb ? -1 : na > nb ? 1 : 0;\n }\n}\n\nfunction binaryLookup(ar, i, comparer) {\n if (ar.length == 0) {\n return { found: false, index: 0 };\n }\n var l = 0,\n r = ar.length - 1;\n while (l < r) {\n var mid = Math.floor((l + r) / 2);\n if (comparer(ar[mid], i) < 0) {\n l = mid + 1;\n } else {\n r = mid;\n }\n }\n var result = comparer(ar[l], i);\n if (result === 0) {\n return { found: true, index: l };\n }\n return {\n found: false,\n index: result < 0 ? l + 1 : l\n };\n}\n\nfunction fancySort(input) {\n return input.reduce(function (ar, i) {\n var _binaryLookup = binaryLookup(ar, i, comparer),\n index = _binaryLookup.index;\n\n ar.splice(index, 0, i);\n return ar;\n }, []);\n}\n\n/***/ })\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// bundle.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 24c582683c5b4b6a8192","import { fancySort } from \"./sorted.js\";\n\nwindow.test = function originalTestName() {\n let test = [\"b (30)\", \"a\", \"b (5)\", \"z\"];\n let result = fancySort(test);\n console.log(result);\n};\n\n\n\n// WEBPACK FOOTER //\n// ./test.js","function comparer(a, b) {\n const ma = /.(\\d+)\\W*$/.exec(a);\n const mb = /.(\\d+)\\W*$/.exec(b);\n if (ma == null || mb == null || ma[1] == mb[1]) {\n return a < b ? -1 : a > b ? 1 : 0;\n } else {\n const na = +ma[1],\n nb = +mb[1];\n return na < nb ? -1 : na > nb ? 1 : 0;\n }\n}\n\nfunction binaryLookup(ar, i, comparer) {\n if (ar.length == 0) {\n return { found: false, index: 0 };\n }\n let l = 0,\n r = ar.length - 1;\n while (l < r) {\n const mid = Math.floor((l + r) / 2);\n if (comparer(ar[mid], i) < 0) {\n l = mid + 1;\n } else {\n r = mid;\n }\n }\n const result = comparer(ar[l], i);\n if (result === 0) {\n return { found: true, index: l };\n }\n return {\n found: false,\n index: result < 0 ? l + 1 : l\n };\n}\n\nexport function fancySort(input) {\n return input.reduce((ar, i) => {\n const { index } = binaryLookup(ar, i, comparer);\n ar.splice(index, 0, i);\n return ar;\n }, []);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./sorted.js"],"sourceRoot":""}