From 87d1f1fe6308f3fa6f1677bdfe8dd24bf67646c0 Mon Sep 17 00:00:00 2001 From: David Rivera Date: Fri, 23 Jun 2017 15:51:33 -0600 Subject: [PATCH] Accented characters are translated to unicode values --- README.md | 12 ++++++------ dist/sort-by.js | 22 ++++++++++++++++++++-- dist/sort-by.min.js | 4 ++-- dist/sort-by.min.map | 2 +- package.json | 3 +-- src/ignore-accent.js | 22 +++++++++++++++++++++- yarn.lock | 2 +- 7 files changed, 52 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d6861ca..28a4e2c 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ parser(item: Any) : Any - + ``` In the above case, the function [`sortBy`](#examples) is included as @@ -101,7 +101,7 @@ require(['array-sort-by'], function(sortBy) { }); ``` -See an example with RequireJS here: http://jsfiddle.net/FdKTn/73/ +See an example with RequireJS here: http://jsfiddle.net/FdKTn/75/ [☗ Back to Index](#content) @@ -245,8 +245,8 @@ sortBy(arr, item => "DESC:" + item.name); ```javascript let arr = [ - { a: 4, age: 26, name: "pedro" }, - { a: 6, age: 32, name: "Pedro" }, + { a: 9, age: 26, name: "pedro" }, + { a: 6, age: 21, name: "Pedro" }, { a: 7, age: 26, name: "Maria" }, { a: 2, age: 26, name: "maría" } ]; @@ -258,8 +258,8 @@ sortBy(arr, item => [item.name, -item.age, item.a]); * [ * { a: 2, age: 26, name: "maría" }, * { a: 7, age: 26, name: "Maria" }, - * { a: 6, age: 32, name: "Pedro" }, - * { a: 4, age: 26, name: "pedro" } + * { a: 9, age: 26, name: "pedro" }, + * { a: 6, age: 21, name: "Pedro" } * ] */ ``` diff --git a/dist/sort-by.js b/dist/sort-by.js index 7a4bf40..674d70d 100644 --- a/dist/sort-by.js +++ b/dist/sort-by.js @@ -1,4 +1,4 @@ -/*! sortBy@v1.1.0. Jherax 2017. Visit https://github.com/jherax/array-sort-by */ +/*! sortBy@v1.1.2. Jherax 2017. Visit https://github.com/jherax/array-sort-by */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -85,7 +85,25 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = ignoreAccent; -var accent = 'ÂâÀàÁáÄäÃãÅåÊêÈèÉéËëÎîÌìÍíÏïÔôÒòÓóÖöÕõÛûÙùÚúÜüÑñÝýÿ'; +/* +function generateUnicode() { + const charcodes = []; + const chars = 'ÂâÀàÁáÄäÃãÅåÊêÈèÉéËëÎîÌìÍíÏïÔôÒòÓóÖöÕõÛûÙùÚúÜüÑñÝýÿ'; + for (let i = 0; i < chars.length; i += 1) { + charcodes.push(chars.charCodeAt(i)); + } + return charcodes; +} +*/ + +// Unicode values +var accent = String.fromCharCode(194, 226, 192, 224, 193, 225, 196, 228, 195, 227, 197, 229, // ÂâÀàÁáÄäÃãÅå +202, 234, 200, 232, 201, 233, 203, 235, // ÊêÈèÉéËë +206, 238, 204, 236, 205, 237, 207, 239, // ÎîÌìÍíÏï +212, 244, 210, 242, 211, 243, 214, 246, 213, 245, // ÔôÒòÓóÖöÕõ +219, 251, 217, 249, 218, 250, 220, 252, // ÛûÙùÚúÜü +209, 241, 221, 253, 255); // ÑñÝýÿ + var normal = 'AaAaAaAaAaAaEeEeEeEeIiIiIiIiOoOoOoOoOoUuUuUuUuNnYyy'; /** diff --git a/dist/sort-by.min.js b/dist/sort-by.min.js index 8a21786..7ff9ef0 100644 --- a/dist/sort-by.min.js +++ b/dist/sort-by.min.js @@ -1,3 +1,3 @@ -/*! sortBy@v1.1.0. Jherax 2017. Visit https://github.com/jherax/array-sort-by */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.sortBy=t():e.sortBy=t()}(this,function(){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,r){"use strict";function o(e){for(var t=n.length,r=0;rt?1:-1)*r}function u(e,t){var r=void 0,o=void 0;for(r in e)if(o=n(e[r],t[r]))return o;return 0}function f(e,t){var r=void 0,o=void 0,n=e.length;if(void 0===t)return e.sort(l.default);for(r=n;r;)o=e[r-=1],e[r]=[].concat(t.call(null,o,r),o);for(e.sort(u),r=n;r;)o=e[r-=1],e[r]=o[o.length-1];return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=f;var i=r(0),a=o(i),c=r(2),l=o(c),d=/^desc:\s*/i;e.exports=t.default},function(e,t,r){"use strict";function o(e,t){return"string"==typeof e&&(e=(0,u.default)(e),t=(0,u.default)(t)),e===t?0:e>t?1:-1}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var n=r(0),u=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=t.default}])}); +/*! sortBy@v1.1.2. Jherax 2017. Visit https://github.com/jherax/array-sort-by */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.sortBy=t():e.sortBy=t()}(this,function(){return function(e){function t(o){if(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,r){"use strict";function o(e){for(var t=n.length,r=0;rt?1:-1)*r}function u(e,t){var r=void 0,o=void 0;for(r in e)if(o=n(e[r],t[r]))return o;return 0}function f(e,t){var r=void 0,o=void 0,n=e.length;if(void 0===t)return e.sort(l.default);for(r=n;r;)o=e[r-=1],e[r]=[].concat(t.call(null,o,r),o);for(e.sort(u),r=n;r;)o=e[r-=1],e[r]=o[o.length-1];return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=f;var i=r(0),a=o(i),c=r(2),l=o(c),d=/^desc:\s*/i;e.exports=t.default},function(e,t,r){"use strict";function o(e,t){return"string"==typeof e&&(e=(0,u.default)(e),t=(0,u.default)(t)),e===t?0:e>t?1:-1}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var n=r(0),u=function(e){return e&&e.__esModule?e:{default:e}}(n);e.exports=t.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 e476954..7cf3954 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 bda1540a39dc8bbfd555","webpack:///./src/ignore-accent.js","webpack:///./src/sort-by.js","webpack:///./src/default-sort.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","ignoreAccent","text","length","accent","replace","charAt","normal","toUpperCase","value","default","_interopRequireDefault","obj","comparer","prev","next","asc","_DESC","test","_ignoreAccent2","sortItems","aprev","anext","ordered","sortBy","array","parser","item","arrLength","sort","_defaultSort2","concat","_ignoreAccent","_defaultSort","defaultSort"],"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,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AAQwC,QI1NgBwB,CATxB,IAAAF,GAAAxD,EAAA,GJuOI2C,EAEJ,SAAgCP,GAAO,MAAOA,IAAOA,EAAIlB,WAAakB,GAAQF,QAASE,IAF3CoB,EAmB5C7D,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/******/ \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 = 1);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = ignoreAccent;\nvar accent = 'ÂâÀàÁáÄäÃãÅåÊêÈèÉéËëÎîÌìÍíÏïÔôÒòÓóÖöÕõÛûÙùÚúÜüÑñÝýÿ';\nvar normal = 'AaAaAaAaAaAaEeEeEeEeIiIiIiIiOoOoOoOoOoUuUuUuUuNnYyy';\n\n/**\n * Converts the accented characters to its equivalent with no accent\n *\n * @param {String} text: the text to transform\n * @return {String}\n */\nfunction ignoreAccent(text) {\n var length = accent.length;\n for (var i = 0; i < length; i += 1) {\n text = text.replace(accent.charAt(i), normal.charAt(i));\n }\n // ignores case sensitive\n return text.toUpperCase();\n}\nmodule.exports = exports['default'];\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.default = sortBy;\n\nvar _ignoreAccent = __webpack_require__(0);\n\nvar _ignoreAccent2 = _interopRequireDefault(_ignoreAccent);\n\nvar _defaultSort = __webpack_require__(2);\n\nvar _defaultSort2 = _interopRequireDefault(_defaultSort);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Sorts an array and allows multiple sorting 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 */\nvar _DESC = /^desc:\\s*/i;\n\n/**\n * @private\n *\n * Compares each element and defines the sorting order.\n * @see http://ow.ly/UvDD309zozK\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 var asc = 1;\n if (typeof prev === 'string') {\n if (_DESC.test(prev)) asc = -1;\n prev = (0, _ignoreAccent2.default)(prev);\n next = (0, _ignoreAccent2.default)(next);\n }\n if (prev === next) return 0;\n return (prev > next ? 1 : -1) * asc;\n}\n\n/**\n * @private\n *\n * Compares each decorated element.\n *\n * @param {Array} aprev: decorated element at n index to compare\n * @param {Array} anext: decorated element at n+1 index to compare\n * @return {Number}\n */\nfunction sortItems(aprev, anext) {\n var i = void 0,\n ordered = void 0;\n for (i in aprev) {\n // eslint-disable-line\n ordered = comparer(aprev[i], anext[i]);\n if (ordered) return ordered;\n }\n return 0;\n}\n\n/**\n * @public\n *\n * Sorts an array and allows multiple sorting criteria.\n *\n * @param {Array} array: the collection to sort\n * @param {Function} parser: transforms each item and specifies the sorting order\n * @return {Array}\n */\nfunction sortBy(array, parser) {\n var i = void 0,\n item = void 0;\n var arrLength = array.length;\n if (typeof parser === 'undefined') {\n return array.sort(_defaultSort2.default);\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}\nmodule.exports = exports['default'];\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = defaultSort;\n\nvar _ignoreAccent = __webpack_require__(0);\n\nvar _ignoreAccent2 = _interopRequireDefault(_ignoreAccent);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Defines the default sorting order (ASC)\n *\n * @param {Any} prev: element at n index to compare\n * @param {Any} next: element at n+1 index to compare\n * @return {Number}\n */\nfunction defaultSort(prev, next) {\n if (typeof prev === 'string') {\n prev = (0, _ignoreAccent2.default)(prev);\n next = (0, _ignoreAccent2.default)(next);\n }\n if (prev === next) return 0;\n return prev > next ? 1 : -1;\n}\nmodule.exports = exports['default'];\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 \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 = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap bda1540a39dc8bbfd555","const accent = 'ÂâÀàÁáÄäÃãÅåÊêÈèÉéËëÎîÌìÍíÏïÔôÒòÓóÖöÕõÛûÙùÚúÜüÑñÝýÿ';\nconst normal = 'AaAaAaAaAaAaEeEeEeEeIiIiIiIiOoOoOoOoOoUuUuUuUuNnYyy';\n\n/**\n * Converts the accented characters to its equivalent with no accent\n *\n * @param {String} text: the text to transform\n * @return {String}\n */\nexport default function ignoreAccent(text) {\n const length = accent.length;\n for (let i = 0; i < length; i += 1) {\n text = text.replace(accent.charAt(i), normal.charAt(i));\n }\n // ignores case sensitive\n return text.toUpperCase();\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ignore-accent.js","/**\n * Sorts an array and allows multiple sorting 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 */\nimport ignoreAccent from './ignore-accent';\nimport defaultSort from './default-sort';\n\nconst _DESC = /^desc:\\s*/i;\n\n/**\n * @private\n *\n * Compares each element and defines the sorting order.\n * @see http://ow.ly/UvDD309zozK\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 (typeof prev === 'string') {\n if (_DESC.test(prev)) asc = -1;\n prev = ignoreAccent(prev);\n next = ignoreAccent(next);\n }\n if (prev === next) return 0;\n return (prev > next ? 1 : -1) * asc;\n}\n\n/**\n * @private\n *\n * Compares each decorated element.\n *\n * @param {Array} aprev: decorated element at n index to compare\n * @param {Array} anext: decorated element at n+1 index to compare\n * @return {Number}\n */\nfunction sortItems(aprev, anext) {\n let i, ordered;\n for (i in aprev) { // eslint-disable-line\n ordered = comparer(aprev[i], anext[i]);\n if (ordered) return ordered;\n }\n return 0;\n}\n\n/**\n * @public\n *\n * Sorts an array and allows multiple sorting criteria.\n *\n * @param {Array} array: the collection to sort\n * @param {Function} parser: transforms each item and specifies the sorting order\n * @return {Array}\n */\nexport default function sortBy(array, parser) {\n let i, 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","import ignoreAccent from './ignore-accent';\n\n/**\n * Defines the default sorting order (ASC)\n *\n * @param {Any} prev: element at n index to compare\n * @param {Any} next: element at n+1 index to compare\n * @return {Number}\n */\nexport default function defaultSort(prev, next) {\n if (typeof prev === 'string') {\n prev = ignoreAccent(prev);\n next = ignoreAccent(next);\n }\n if (prev === next) return 0;\n return (prev > next ? 1 : -1);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/default-sort.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///sort-by.min.js","webpack:///webpack/bootstrap 1becb939e3ddc6d31fb1","webpack:///./src/ignore-accent.js","webpack:///./src/sort-by.js","webpack:///./src/default-sort.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","ignoreAccent","text","length","accent","replace","charAt","normal","toUpperCase","value","default","String","fromCharCode","_interopRequireDefault","obj","comparer","prev","next","asc","_DESC","test","_ignoreAccent2","sortItems","aprev","anext","ordered","sortBy","array","parser","item","arrLength","sort","_defaultSort2","concat","_ignoreAccent","_defaultSort","defaultSort"],"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,IACAE,EAAAF,EACAG,GAAA,EACAV,WAUA,OANAK,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,GAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KA4DA,OAhCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,SAAAd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OgB0B,CATxB,IAAAF,GAAA1D,EAAA,GJyPI6C,EAEJ,SAAgCP,GAAO,MAAOA,IAAOA,EAAIpB,WAAaoB,GAAQJ,QAASI,IAF3CoB,EAmB5C/D,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/******/ \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 = 1);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = ignoreAccent;\n/*\nfunction generateUnicode() {\n const charcodes = [];\n const chars = 'ÂâÀàÁáÄäÃãÅåÊêÈèÉéËëÎîÌìÍíÏïÔôÒòÓóÖöÕõÛûÙùÚúÜüÑñÝýÿ';\n for (let i = 0; i < chars.length; i += 1) {\n charcodes.push(chars.charCodeAt(i));\n }\n return charcodes;\n}\n*/\n\n// Unicode values\nvar accent = String.fromCharCode(194, 226, 192, 224, 193, 225, 196, 228, 195, 227, 197, 229, // ÂâÀàÁáÄäÃãÅå\n202, 234, 200, 232, 201, 233, 203, 235, // ÊêÈèÉéËë\n206, 238, 204, 236, 205, 237, 207, 239, // ÎîÌìÍíÏï\n212, 244, 210, 242, 211, 243, 214, 246, 213, 245, // ÔôÒòÓóÖöÕõ\n219, 251, 217, 249, 218, 250, 220, 252, // ÛûÙùÚúÜü\n209, 241, 221, 253, 255); // ÑñÝýÿ\n\nvar normal = 'AaAaAaAaAaAaEeEeEeEeIiIiIiIiOoOoOoOoOoUuUuUuUuNnYyy';\n\n/**\n * Converts the accented characters to its equivalent with no accent\n *\n * @param {String} text: the text to transform\n * @return {String}\n */\nfunction ignoreAccent(text) {\n var length = accent.length;\n for (var i = 0; i < length; i += 1) {\n text = text.replace(accent.charAt(i), normal.charAt(i));\n }\n // ignores case sensitive\n return text.toUpperCase();\n}\nmodule.exports = exports['default'];\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.default = sortBy;\n\nvar _ignoreAccent = __webpack_require__(0);\n\nvar _ignoreAccent2 = _interopRequireDefault(_ignoreAccent);\n\nvar _defaultSort = __webpack_require__(2);\n\nvar _defaultSort2 = _interopRequireDefault(_defaultSort);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Sorts an array and allows multiple sorting 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 */\nvar _DESC = /^desc:\\s*/i;\n\n/**\n * @private\n *\n * Compares each element and defines the sorting order.\n * @see http://ow.ly/UvDD309zozK\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 var asc = 1;\n if (typeof prev === 'string') {\n if (_DESC.test(prev)) asc = -1;\n prev = (0, _ignoreAccent2.default)(prev);\n next = (0, _ignoreAccent2.default)(next);\n }\n if (prev === next) return 0;\n return (prev > next ? 1 : -1) * asc;\n}\n\n/**\n * @private\n *\n * Compares each decorated element.\n *\n * @param {Array} aprev: decorated element at n index to compare\n * @param {Array} anext: decorated element at n+1 index to compare\n * @return {Number}\n */\nfunction sortItems(aprev, anext) {\n var i = void 0,\n ordered = void 0;\n for (i in aprev) {\n // eslint-disable-line\n ordered = comparer(aprev[i], anext[i]);\n if (ordered) return ordered;\n }\n return 0;\n}\n\n/**\n * @public\n *\n * Sorts an array and allows multiple sorting criteria.\n *\n * @param {Array} array: the collection to sort\n * @param {Function} parser: transforms each item and specifies the sorting order\n * @return {Array}\n */\nfunction sortBy(array, parser) {\n var i = void 0,\n item = void 0;\n var arrLength = array.length;\n if (typeof parser === 'undefined') {\n return array.sort(_defaultSort2.default);\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}\nmodule.exports = exports['default'];\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = defaultSort;\n\nvar _ignoreAccent = __webpack_require__(0);\n\nvar _ignoreAccent2 = _interopRequireDefault(_ignoreAccent);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * Defines the default sorting order (ASC)\n *\n * @param {Any} prev: element at n index to compare\n * @param {Any} next: element at n+1 index to compare\n * @return {Number}\n */\nfunction defaultSort(prev, next) {\n if (typeof prev === 'string') {\n prev = (0, _ignoreAccent2.default)(prev);\n next = (0, _ignoreAccent2.default)(next);\n }\n if (prev === next) return 0;\n return prev > next ? 1 : -1;\n}\nmodule.exports = exports['default'];\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 \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 = 1);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 1becb939e3ddc6d31fb1","/*\nfunction generateUnicode() {\n const charcodes = [];\n const chars = 'ÂâÀàÁáÄäÃãÅåÊêÈèÉéËëÎîÌìÍíÏïÔôÒòÓóÖöÕõÛûÙùÚúÜüÑñÝýÿ';\n for (let i = 0; i < chars.length; i += 1) {\n charcodes.push(chars.charCodeAt(i));\n }\n return charcodes;\n}\n*/\n\n// Unicode values\nconst accent =\n String.fromCharCode(\n 194, 226, 192, 224, 193, 225, 196, 228, 195, 227, 197, 229, // ÂâÀàÁáÄäÃãÅå\n 202, 234, 200, 232, 201, 233, 203, 235, // ÊêÈèÉéËë\n 206, 238, 204, 236, 205, 237, 207, 239, // ÎîÌìÍíÏï\n 212, 244, 210, 242, 211, 243, 214, 246, 213, 245, // ÔôÒòÓóÖöÕõ\n 219, 251, 217, 249, 218, 250, 220, 252, // ÛûÙùÚúÜü\n 209, 241, 221, 253, 255); // ÑñÝýÿ\n\nconst normal = 'AaAaAaAaAaAaEeEeEeEeIiIiIiIiOoOoOoOoOoUuUuUuUuNnYyy';\n\n/**\n * Converts the accented characters to its equivalent with no accent\n *\n * @param {String} text: the text to transform\n * @return {String}\n */\nexport default function ignoreAccent(text) {\n const length = accent.length;\n for (let i = 0; i < length; i += 1) {\n text = text.replace(accent.charAt(i), normal.charAt(i));\n }\n // ignores case sensitive\n return text.toUpperCase();\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/ignore-accent.js","/**\n * Sorts an array and allows multiple sorting 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 */\nimport ignoreAccent from './ignore-accent';\nimport defaultSort from './default-sort';\n\nconst _DESC = /^desc:\\s*/i;\n\n/**\n * @private\n *\n * Compares each element and defines the sorting order.\n * @see http://ow.ly/UvDD309zozK\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 (typeof prev === 'string') {\n if (_DESC.test(prev)) asc = -1;\n prev = ignoreAccent(prev);\n next = ignoreAccent(next);\n }\n if (prev === next) return 0;\n return (prev > next ? 1 : -1) * asc;\n}\n\n/**\n * @private\n *\n * Compares each decorated element.\n *\n * @param {Array} aprev: decorated element at n index to compare\n * @param {Array} anext: decorated element at n+1 index to compare\n * @return {Number}\n */\nfunction sortItems(aprev, anext) {\n let i, ordered;\n for (i in aprev) { // eslint-disable-line\n ordered = comparer(aprev[i], anext[i]);\n if (ordered) return ordered;\n }\n return 0;\n}\n\n/**\n * @public\n *\n * Sorts an array and allows multiple sorting criteria.\n *\n * @param {Array} array: the collection to sort\n * @param {Function} parser: transforms each item and specifies the sorting order\n * @return {Array}\n */\nexport default function sortBy(array, parser) {\n let i, 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","import ignoreAccent from './ignore-accent';\n\n/**\n * Defines the default sorting order (ASC)\n *\n * @param {Any} prev: element at n index to compare\n * @param {Any} next: element at n+1 index to compare\n * @return {Number}\n */\nexport default function defaultSort(prev, next) {\n if (typeof prev === 'string') {\n prev = ignoreAccent(prev);\n next = ignoreAccent(next);\n }\n if (prev === next) return 0;\n return (prev > next ? 1 : -1);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/default-sort.js"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 8334d6d..65f59df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "array-sort-by", - "version": "1.1.0", + "version": "1.1.2", "description": "Sorts an array and allows multiple sorting criteria", "author": "David Rivera ", "main": "dist/sort-by.js", @@ -39,7 +39,6 @@ "eslint-config-airbnb-base": "^11.2.0", "eslint-loader": "^1.8.0", "eslint-plugin-import": "^2.5.0", - "uglifyjs-webpack-plugin": "^0.4.6", "webpack": "^3.0.0" }, "babel": { diff --git a/src/ignore-accent.js b/src/ignore-accent.js index 70db11f..bedb90e 100644 --- a/src/ignore-accent.js +++ b/src/ignore-accent.js @@ -1,4 +1,24 @@ -const accent = 'ÂâÀàÁáÄäÃãÅåÊêÈèÉéËëÎîÌìÍíÏïÔôÒòÓóÖöÕõÛûÙùÚúÜüÑñÝýÿ'; +/* +function generateUnicode() { + const charcodes = []; + const chars = 'ÂâÀàÁáÄäÃãÅåÊêÈèÉéËëÎîÌìÍíÏïÔôÒòÓóÖöÕõÛûÙùÚúÜüÑñÝýÿ'; + for (let i = 0; i < chars.length; i += 1) { + charcodes.push(chars.charCodeAt(i)); + } + return charcodes; +} +*/ + +// Unicode values +const accent = + String.fromCharCode( + 194, 226, 192, 224, 193, 225, 196, 228, 195, 227, 197, 229, // ÂâÀàÁáÄäÃãÅå + 202, 234, 200, 232, 201, 233, 203, 235, // ÊêÈèÉéËë + 206, 238, 204, 236, 205, 237, 207, 239, // ÎîÌìÍíÏï + 212, 244, 210, 242, 211, 243, 214, 246, 213, 245, // ÔôÒòÓóÖöÕõ + 219, 251, 217, 249, 218, 250, 220, 252, // ÛûÙùÚúÜü + 209, 241, 221, 253, 255); // ÑñÝýÿ + const normal = 'AaAaAaAaAaAaEeEeEeEeIiIiIiIiOoOoOoOoOoUuUuUuUuNnYyy'; /** diff --git a/yarn.lock b/yarn.lock index ec25559..abe4745 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3076,7 +3076,7 @@ uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" -uglifyjs-webpack-plugin@^0.4.4, uglifyjs-webpack-plugin@^0.4.6: +uglifyjs-webpack-plugin@^0.4.4: version "0.4.6" resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-0.4.6.tgz#b951f4abb6bd617e66f63eb891498e391763e309" dependencies: