From efcc1283c0219d41dc3024245ac6dc69256e68f7 Mon Sep 17 00:00:00 2001 From: David Rivera Date: Sun, 21 May 2017 18:27:39 -0600 Subject: [PATCH] Added section for Polyfills in the README --- README.md | 46 +++++++++++++++++++++++++++++++++++++++++++- dist/sort-by.js | 5 ++++- dist/sort-by.min.js | 2 +- dist/sort-by.min.map | 2 +- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6441690..72ba669 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,14 @@ The motivation for creating this utility was to provide a mechanism to organize elements, with the ability to specify multiple ordering criteria. +## Content + +1. [Getting started](#getting-started) +1. [Including the library](#including-the-library) +1. [Examples](#examples) +1. [Shimming-polyfills](#shimming-polyfills) +1. [Running the project](#running-the-project) + ## Getting started To include this library into your package manager with `npm` or `yarn` @@ -203,6 +211,42 @@ sortBy(arr, (o) => [o.name.toUpperCase(), -o.age, o.a]); */ ``` +## Shimming-polyfills + +This library is written using some of the new ES5/ES6 features. If you have +to support Non-standard-compliant browsers like Internet Explorer, you can +polyfill some of the missing features with the following alternatives: + +**Using [es6-shim](https://github.com/paulmillr/es6-shim)** + +```html + + +``` + +**Using [polyfill.io](https://polyfill.io/v2/docs/)** + +```html + + +``` + +[Polyfill.io](https://polyfill.io/v2/docs/examples) reads the `User-Agent` +header of each request and returns the polyfills that are suitable for the +requesting browser. + +If you want to request specific polyfills, you can pass a query parameter +to the url, for example: + +```html + +``` + +Read the list of available features: +[Features and Browsers Supported](https://polyfill.io/v2/docs/features/). + ## Running the project If you want to fork or build your own, you must run this project. @@ -272,7 +316,7 @@ Given a version number MAJOR.MINOR.PATCH, increment the: To report an issue and keep traceability of bug-fixes, please report to: -* https://github.com/jherax/array-sort-by/issues +- https://github.com/jherax/array-sort-by/issues ## License diff --git a/dist/sort-by.js b/dist/sort-by.js index 81d0af5..8425632 100644 --- a/dist/sort-by.js +++ b/dist/sort-by.js @@ -1,4 +1,4 @@ -/*! sortBy@v1.0.3. Jherax 2017. Visit https://github.com/jherax/array-sort-by */ +/*! sortBy@v1.0.3a. Jherax 2017. Visit https://github.com/jherax/array-sort-by */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -100,6 +100,9 @@ return /******/ (function(modules) { // webpackBootstrap */ function comparer(prev, next) { var asc = 1; + // TODO: Add support for accented characters + // See http://ow.ly/UvDD309zozK + // e.g. return a.localeCompare(b); if (prev === next) return 0; if (isDesc(prev)) asc = -1; return (prev > next ? 1 : -1) * asc; diff --git a/dist/sort-by.min.js b/dist/sort-by.min.js index f617a68..e068e98 100644 --- a/dist/sort-by.min.js +++ b/dist/sort-by.min.js @@ -1,3 +1,3 @@ -/*! sortBy@v1.0.3. Jherax 2017. Visit https://github.com/jherax/array-sort-by */ +/*! sortBy@v1.0.3a. Jherax 2017. Visit https://github.com/jherax/array-sort-by */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.sortBy=e():t.sortBy=e()}(this,function(){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e){"use strict";function r(t,e){var r=1;return t===e?0:(i(t)&&(r=-1),(t>e?1:-1)*r)}function o(t,e){var o=void 0,n=void 0;for(o in t)if(n=r(t[o],e[o]))return n;return 0}function n(t,e){return te)}function u(t,e){var r=void 0,u=void 0,f=t.length;if("undefined"==typeof e)return t.sort(n);for(r=f;r;)u=t[r-=1],t[r]=[].concat(e.call(null,u,r),u);for(t.sort(o),r=f;r;)u=t[r-=1],t[r]=u[u.length-1];return t}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var f=/^desc:\s*/i,i=function(t){return"string"==typeof t&&f.test(t)};t.exports=e.default}])}); //# sourceMappingURL=sort-by.min.map \ No newline at end of file diff --git a/dist/sort-by.min.map b/dist/sort-by.min.map index 73cca4c..8afa2c9 100644 --- a/dist/sort-by.min.map +++ b/dist/sort-by.min.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///sort-by.min.js","webpack:///webpack/bootstrap a8248275c9383f2dc822","webpack:///./src/sort-by.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","comparer","prev","next","asc","isDesc","sortItems","aprev","anext","i","sorted","defaultSort","sortBy","array","parser","item","arrLength","length","sort","concat","Object","defineProperty","value","default","_DESC","v","test"],"mappings":";CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,OAAAD,IAEAD,EAAA,OAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAP,WACAS,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,QAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDgBM,SAASL,EAAQD,GAEtB,YErBD,SAASe,GAASC,EAAMC,GACtB,GAAIC,GAAM,CACV,OAAIF,KAASC,EAAa,GACtBE,EAAOH,KAAOE,GAAM,IAChBF,EAAOC,EAAO,GAAI,GAAMC,GAYlC,QAASE,GAAUC,EAAOC,GACxB,GAAIC,UACFC,QACF,KAAKD,IAAKF,GAER,GADAG,EAAST,EAASM,EAAME,GAAID,EAAMC,IACtB,MAAOC,EAErB,OAAO,GAYT,QAASC,GAAYT,EAAMC,GACzB,MAAOD,GAAOC,GAAO,IAAOD,EAAOC,GAatB,QAASS,GAAOC,EAAOC,GACpC,GAAIL,UACFM,SACIC,EAAYH,EAAMI,MACxB,IAAsB,mBAAXH,GACT,MAAOD,GAAMK,KAAKP,EAGpB,KAAKF,EAAIO,EAAWP,GAClBM,EAAOF,EAAMJ,GAAK,GAElBI,EAAMJ,MAAQU,OAAOL,EAAOjB,KAAK,KAAMkB,EAAMN,GAAIM,EAMnD,KAFAF,EAAMK,KAAKZ,GAENG,EAAIO,EAAWP,GAClBM,EAAOF,EAAMJ,GAAK,GAClBI,EAAMJ,GAAKM,EAAKA,EAAKE,OAAS,EAEhC,OAAOJ,GF/CRO,OAAOC,eAAenC,EAAS,cAC7BoC,OAAO,IAETpC,EAAQqC,QEuBeX,CAtExB,IAAMY,GAAS,aAUTnB,EAAS,SAAAoB,GAAA,MAAkB,gBAANA,IAAkBD,EAAME,KAAKD,GFoJvDtC,GAAOD,QAAUA,EAAiB","file":"sort-by.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"sortBy\"] = factory();\n\telse\n\t\troot[\"sortBy\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"sortBy\"] = factory();\n\telse\n\t\troot[\"sortBy\"] = factory();\n})(this, function() {\nreturn /******/ (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/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\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.loaded = 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// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\texports.default = sortBy;\n\t/**\n\t * Sorts an array and allows multiple sort criteria.\n\t *\n\t * It applies the Schwartzian transform:\n\t * https://en.wikipedia.org/wiki/Schwartzian_transform\n\t *\n\t * Author: David Rivera\n\t * Github: https://github.com/jherax\n\t * License: \"MIT\"\n\t *\n\t * You can fork this project on github:\n\t * https://github.com/jherax/array-sort-by.git\n\t */\n\t\n\tvar _DESC = /^desc:\\s*/i;\n\t\n\t/**\n\t * @private\n\t *\n\t * Tests whether the input value is a string and has set the flag for descending order.\n\t *\n\t * @param {Any} v: the value to test\n\t * @return {Boolean}\n\t */\n\tvar isDesc = function isDesc(v) {\n\t return typeof v === 'string' && _DESC.test(v);\n\t};\n\t\n\t/**\n\t * @private\n\t *\n\t * Compares each element and defines the sort order.\n\t *\n\t * @param {Any} prev: n element to compare\n\t * @param {Any} next: n+1 element to compare\n\t * @return {Number}\n\t */\n\tfunction comparer(prev, next) {\n\t var asc = 1;\n\t if (prev === next) return 0;\n\t if (isDesc(prev)) asc = -1;\n\t return (prev > next ? 1 : -1) * asc;\n\t}\n\t\n\t/**\n\t * @private\n\t *\n\t * Compares each decorated element.\n\t *\n\t * @param {Array} aprev: n decorated element to compare\n\t * @param {Array} anext: n+1 decorated element to compare\n\t * @return {Number}\n\t */\n\tfunction sortItems(aprev, anext) {\n\t var i = void 0,\n\t sorted = void 0;\n\t for (i in aprev) {\n\t // eslint-disable-line\n\t sorted = comparer(aprev[i], anext[i]);\n\t if (sorted) return sorted;\n\t }\n\t return 0;\n\t}\n\t\n\t/**\n\t * @private\n\t *\n\t * Defines the default sort order (ASC)\n\t *\n\t * @param {Any} prev: n element to compare\n\t * @param {Any} next: n+1 element to compare\n\t * @return {Number}\n\t */\n\tfunction defaultSort(prev, next) {\n\t return prev < next ? -1 : +(prev > next);\n\t}\n\t\n\t/**\n\t * @public\n\t *\n\t * Sorts an array and allows multiple sort criteria.\n\t *\n\t * @export\n\t * @param {Array} array: the collection to sort\n\t * @param {Function} parser: transforms each item and specifies the sort order\n\t * @return {Array}\n\t */\n\tfunction sortBy(array, parser) {\n\t var i = void 0,\n\t item = void 0;\n\t var arrLength = array.length;\n\t if (typeof parser === 'undefined') {\n\t return array.sort(defaultSort);\n\t }\n\t // Schwartzian transform (decorate-sort-undecorate)\n\t for (i = arrLength; i;) {\n\t item = array[i -= 1];\n\t // decorate the array\n\t array[i] = [].concat(parser.call(null, item, i), item);\n\t // console.log('decorated: ', array[i]);\n\t }\n\t // sort the array\n\t array.sort(sortItems);\n\t // undecorate the array\n\t for (i = arrLength; i;) {\n\t item = array[i -= 1];\n\t array[i] = item[item.length - 1];\n\t }\n\t return array;\n\t}\n\tmodule.exports = exports['default'];\n\n/***/ }\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// sort-by.min.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\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\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.loaded = 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// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap a8248275c9383f2dc822","/**\n * Sorts an array and allows multiple sort criteria.\n *\n * It applies the Schwartzian transform:\n * https://en.wikipedia.org/wiki/Schwartzian_transform\n *\n * Author: David Rivera\n * Github: https://github.com/jherax\n * License: \"MIT\"\n *\n * You can fork this project on github:\n * https://github.com/jherax/array-sort-by.git\n */\n\nconst _DESC = (/^desc:\\s*/i);\n\n/**\n * @private\n *\n * Tests whether the input value is a string and has set the flag for descending order.\n *\n * @param {Any} v: the value to test\n * @return {Boolean}\n */\nconst isDesc = v => typeof v === 'string' && _DESC.test(v);\n\n/**\n * @private\n *\n * Compares each element and defines the sort order.\n *\n * @param {Any} prev: n element to compare\n * @param {Any} next: n+1 element to compare\n * @return {Number}\n */\nfunction comparer(prev, next) {\n let asc = 1;\n if (prev === next) return 0;\n if (isDesc(prev)) asc = -1;\n return (prev > next ? 1 : -1) * asc;\n}\n\n/**\n * @private\n *\n * Compares each decorated element.\n *\n * @param {Array} aprev: n decorated element to compare\n * @param {Array} anext: n+1 decorated element to compare\n * @return {Number}\n */\nfunction sortItems(aprev, anext) {\n let i,\n sorted;\n for (i in aprev) { // eslint-disable-line\n sorted = comparer(aprev[i], anext[i]);\n if (sorted) return sorted;\n }\n return 0;\n}\n\n/**\n * @private\n *\n * Defines the default sort order (ASC)\n *\n * @param {Any} prev: n element to compare\n * @param {Any} next: n+1 element to compare\n * @return {Number}\n */\nfunction defaultSort(prev, next) {\n return prev < next ? -1 : +(prev > next);\n}\n\n/**\n * @public\n *\n * Sorts an array and allows multiple sort criteria.\n *\n * @export\n * @param {Array} array: the collection to sort\n * @param {Function} parser: transforms each item and specifies the sort order\n * @return {Array}\n */\nexport default function sortBy(array, parser) {\n let i,\n item;\n const arrLength = array.length;\n if (typeof parser === 'undefined') {\n return array.sort(defaultSort);\n }\n // Schwartzian transform (decorate-sort-undecorate)\n for (i = arrLength; i;) {\n item = array[i -= 1];\n // decorate the array\n array[i] = [].concat(parser.call(null, item, i), item);\n // console.log('decorated: ', array[i]);\n }\n // sort the array\n array.sort(sortItems);\n // undecorate the array\n for (i = arrLength; i;) {\n item = array[i -= 1];\n array[i] = item[item.length - 1];\n }\n return array;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/sort-by.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///sort-by.min.js","webpack:///webpack/bootstrap 9bcb720a82b73f3b18fd","webpack:///./src/sort-by.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","comparer","prev","next","asc","isDesc","sortItems","aprev","anext","i","sorted","defaultSort","sortBy","array","parser","item","arrLength","length","sort","concat","Object","defineProperty","value","default","_DESC","v","test"],"mappings":";CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,OAAAD,IAEAD,EAAA,OAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAP,WACAS,GAAAF,EACAG,QAAA,EAUA,OANAL,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,QAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KAqCA,OATAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,GAGAR,EAAA,KDgBM,SAASL,EAAQD,GAEtB,YErBD,SAASe,GAASC,EAAMC,GACtB,GAAIC,GAAM,CAIV,OAAIF,KAASC,EAAa,GACtBE,EAAOH,KAAOE,GAAM,IAChBF,EAAOC,EAAO,GAAI,GAAMC,GAYlC,QAASE,GAAUC,EAAOC,GACxB,GAAIC,UACFC,QACF,KAAKD,IAAKF,GAER,GADAG,EAAST,EAASM,EAAME,GAAID,EAAMC,IACtB,MAAOC,EAErB,OAAO,GAYT,QAASC,GAAYT,EAAMC,GACzB,MAAOD,GAAOC,GAAO,IAAOD,EAAOC,GAatB,QAASS,GAAOC,EAAOC,GACpC,GAAIL,UACFM,SACIC,EAAYH,EAAMI,MACxB,IAAsB,mBAAXH,GACT,MAAOD,GAAMK,KAAKP,EAGpB,KAAKF,EAAIO,EAAWP,GAClBM,EAAOF,EAAMJ,GAAK,GAElBI,EAAMJ,MAAQU,OAAOL,EAAOjB,KAAK,KAAMkB,EAAMN,GAAIM,EAMnD,KAFAF,EAAMK,KAAKZ,GAENG,EAAIO,EAAWP,GAClBM,EAAOF,EAAMJ,GAAK,GAClBI,EAAMJ,GAAKM,EAAKA,EAAKE,OAAS,EAEhC,OAAOJ,GFlDRO,OAAOC,eAAenC,EAAS,cAC7BoC,OAAO,IAETpC,EAAQqC,QE0BeX,CAzExB,IAAMY,GAAS,aAUTnB,EAAS,SAAAoB,GAAA,MAAkB,gBAANA,IAAkBD,EAAME,KAAKD,GFuJvDtC,GAAOD,QAAUA,EAAiB","file":"sort-by.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"sortBy\"] = factory();\n\telse\n\t\troot[\"sortBy\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"sortBy\"] = factory();\n\telse\n\t\troot[\"sortBy\"] = factory();\n})(this, function() {\nreturn /******/ (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/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\texports: {},\n/******/ \t\t\tid: moduleId,\n/******/ \t\t\tloaded: false\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.loaded = 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// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ function(module, exports) {\n\n\t'use strict';\n\t\n\tObject.defineProperty(exports, \"__esModule\", {\n\t value: true\n\t});\n\texports.default = sortBy;\n\t/**\n\t * Sorts an array and allows multiple sort criteria.\n\t *\n\t * It applies the Schwartzian transform:\n\t * https://en.wikipedia.org/wiki/Schwartzian_transform\n\t *\n\t * Author: David Rivera\n\t * Github: https://github.com/jherax\n\t * License: \"MIT\"\n\t *\n\t * You can fork this project on github:\n\t * https://github.com/jherax/array-sort-by.git\n\t */\n\t\n\tvar _DESC = /^desc:\\s*/i;\n\t\n\t/**\n\t * @private\n\t *\n\t * Tests whether the input value is a string and has set the flag for descending order.\n\t *\n\t * @param {Any} v: the value to test\n\t * @return {Boolean}\n\t */\n\tvar isDesc = function isDesc(v) {\n\t return typeof v === 'string' && _DESC.test(v);\n\t};\n\t\n\t/**\n\t * @private\n\t *\n\t * Compares each element and defines the sort order.\n\t *\n\t * @param {Any} prev: n element to compare\n\t * @param {Any} next: n+1 element to compare\n\t * @return {Number}\n\t */\n\tfunction comparer(prev, next) {\n\t var asc = 1;\n\t // TODO: Add support for accented characters\n\t // See http://ow.ly/UvDD309zozK\n\t // e.g. return a.localeCompare(b);\n\t if (prev === next) return 0;\n\t if (isDesc(prev)) asc = -1;\n\t return (prev > next ? 1 : -1) * asc;\n\t}\n\t\n\t/**\n\t * @private\n\t *\n\t * Compares each decorated element.\n\t *\n\t * @param {Array} aprev: n decorated element to compare\n\t * @param {Array} anext: n+1 decorated element to compare\n\t * @return {Number}\n\t */\n\tfunction sortItems(aprev, anext) {\n\t var i = void 0,\n\t sorted = void 0;\n\t for (i in aprev) {\n\t // eslint-disable-line\n\t sorted = comparer(aprev[i], anext[i]);\n\t if (sorted) return sorted;\n\t }\n\t return 0;\n\t}\n\t\n\t/**\n\t * @private\n\t *\n\t * Defines the default sort order (ASC)\n\t *\n\t * @param {Any} prev: n element to compare\n\t * @param {Any} next: n+1 element to compare\n\t * @return {Number}\n\t */\n\tfunction defaultSort(prev, next) {\n\t return prev < next ? -1 : +(prev > next);\n\t}\n\t\n\t/**\n\t * @public\n\t *\n\t * Sorts an array and allows multiple sort criteria.\n\t *\n\t * @export\n\t * @param {Array} array: the collection to sort\n\t * @param {Function} parser: transforms each item and specifies the sort order\n\t * @return {Array}\n\t */\n\tfunction sortBy(array, parser) {\n\t var i = void 0,\n\t item = void 0;\n\t var arrLength = array.length;\n\t if (typeof parser === 'undefined') {\n\t return array.sort(defaultSort);\n\t }\n\t // Schwartzian transform (decorate-sort-undecorate)\n\t for (i = arrLength; i;) {\n\t item = array[i -= 1];\n\t // decorate the array\n\t array[i] = [].concat(parser.call(null, item, i), item);\n\t // console.log('decorated: ', array[i]);\n\t }\n\t // sort the array\n\t array.sort(sortItems);\n\t // undecorate the array\n\t for (i = arrLength; i;) {\n\t item = array[i -= 1];\n\t array[i] = item[item.length - 1];\n\t }\n\t return array;\n\t}\n\tmodule.exports = exports['default'];\n\n/***/ }\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// sort-by.min.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\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\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.loaded = 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// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 9bcb720a82b73f3b18fd","/**\n * Sorts an array and allows multiple sort criteria.\n *\n * It applies the Schwartzian transform:\n * https://en.wikipedia.org/wiki/Schwartzian_transform\n *\n * Author: David Rivera\n * Github: https://github.com/jherax\n * License: \"MIT\"\n *\n * You can fork this project on github:\n * https://github.com/jherax/array-sort-by.git\n */\n\nconst _DESC = (/^desc:\\s*/i);\n\n/**\n * @private\n *\n * Tests whether the input value is a string and has set the flag for descending order.\n *\n * @param {Any} v: the value to test\n * @return {Boolean}\n */\nconst isDesc = v => typeof v === 'string' && _DESC.test(v);\n\n/**\n * @private\n *\n * Compares each element and defines the sort order.\n *\n * @param {Any} prev: n element to compare\n * @param {Any} next: n+1 element to compare\n * @return {Number}\n */\nfunction comparer(prev, next) {\n let asc = 1;\n // TODO: Add support for accented characters\n // See http://ow.ly/UvDD309zozK\n // e.g. return a.localeCompare(b);\n if (prev === next) return 0;\n if (isDesc(prev)) asc = -1;\n return (prev > next ? 1 : -1) * asc;\n}\n\n/**\n * @private\n *\n * Compares each decorated element.\n *\n * @param {Array} aprev: n decorated element to compare\n * @param {Array} anext: n+1 decorated element to compare\n * @return {Number}\n */\nfunction sortItems(aprev, anext) {\n let i,\n sorted;\n for (i in aprev) { // eslint-disable-line\n sorted = comparer(aprev[i], anext[i]);\n if (sorted) return sorted;\n }\n return 0;\n}\n\n/**\n * @private\n *\n * Defines the default sort order (ASC)\n *\n * @param {Any} prev: n element to compare\n * @param {Any} next: n+1 element to compare\n * @return {Number}\n */\nfunction defaultSort(prev, next) {\n return prev < next ? -1 : +(prev > next);\n}\n\n/**\n * @public\n *\n * Sorts an array and allows multiple sort criteria.\n *\n * @export\n * @param {Array} array: the collection to sort\n * @param {Function} parser: transforms each item and specifies the sort order\n * @return {Array}\n */\nexport default function sortBy(array, parser) {\n let i,\n item;\n const arrLength = array.length;\n if (typeof parser === 'undefined') {\n return array.sort(defaultSort);\n }\n // Schwartzian transform (decorate-sort-undecorate)\n for (i = arrLength; i;) {\n item = array[i -= 1];\n // decorate the array\n array[i] = [].concat(parser.call(null, item, i), item);\n // console.log('decorated: ', array[i]);\n }\n // sort the array\n array.sort(sortItems);\n // undecorate the array\n for (i = arrLength; i;) {\n item = array[i -= 1];\n array[i] = item[item.length - 1];\n }\n return array;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/sort-by.js"],"sourceRoot":""} \ No newline at end of file