New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shelf/fast-natural-order-by

Package Overview
Dependencies
Maintainers
54
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shelf/fast-natural-order-by - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

2

lib/index.js

@@ -1,1 +0,1 @@

!function(r,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t=n();for(var e in t)("object"==typeof exports?exports:r)[e]=t[e]}}("undefined"!=typeof self?self:this,(()=>(()=>{"use strict";var r={d:(n,t)=>{for(var e in t)r.o(t,e)&&!r.o(n,e)&&Object.defineProperty(n,e,{enumerable:!0,get:t[e]})},o:(r,n)=>Object.prototype.hasOwnProperty.call(r,n),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},n={};r.r(n),r.d(n,{compare:()=>P,orderBy:()=>T});const t=function(r,n){return r<n?-1:r>n?1:0};var e=/(^0x[\da-fA-F]+$|^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?!\.\d+)(?=\D|\s|$))|\d+)/g,o=/^\s+|\s+$/g,i=/\s+/g,u=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,a=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[/-]\d{1,4}[/-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,f=/^0+[1-9]{1}[0-9]*$/,c=/[^\x00-\x80]/;const s=function(r,n){var t=r.localeCompare(n);return t?t/Math.abs(t):0},l=function(r,n){return r<n?-1:r>n?1:0},y=function(r,n){return r.value===n.value?0:void 0!==r.parsedNumber&&void 0!==n.parsedNumber?t(r.parsedNumber,n.parsedNumber):r.chunks&&n.chunks?function(r,n){for(var e=r.length,o=n.length,i=Math.min(e,o),u=0;u<i;u++){var a=r[u],f=n[u];if(a.normalizedString!==f.normalizedString){if(""===a.normalizedString!=(""===f.normalizedString))return""===a.normalizedString?-1:1;if(void 0!==a.parsedNumber&&void 0!==f.parsedNumber){var y=t(a.parsedNumber,f.parsedNumber);return 0===y?l(a.normalizedString,f.normalizedString):y}return void 0!==a.parsedNumber||void 0!==f.parsedNumber?void 0!==a.parsedNumber?-1:1:c.test(a.normalizedString+f.normalizedString)&&a.normalizedString.localeCompare?s(a.normalizedString,f.normalizedString):l(a.normalizedString,f.normalizedString)}}return e>i||o>i?e<=i?-1:1:0}(r.chunks,n.chunks):function(r,n){return(r.chunks?!n.chunks:n.chunks)?r.chunks?-1:1:(r.isNaN?!n.isNaN:n.isNaN)?r.isNaN?-1:1:(r.isSymbol?!n.isSymbol:n.isSymbol)?r.isSymbol?-1:1:(r.isObject?!n.isObject:n.isObject)?r.isObject?-1:1:(r.isArray?!n.isArray:n.isArray)?r.isArray?-1:1:(r.isFunction?!n.isFunction:n.isFunction)?r.isFunction?-1:1:(r.isNull?!n.isNull:n.isNull)?r.isNull?-1:1:0}(r,n)};function m(r){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},m(r)}const p=function(r){return"function"==typeof r?r:function(n){if(Array.isArray(n)){var t=Number(r);if(Number.isInteger(t))return n[t]}else if(n&&"object"===m(n)&&"function"!=typeof r)return n[r];return n}},d=function(r){if(0!==r.length){var n=Number(r);if(!Number.isNaN(n))return n}},b=function(r){var n=d(r);return void 0!==n?n:function(r){try{var n=Date.parse(r);return!Number.isNaN(n)&&a.test(r)?n:void 0}catch(r){return}}(r)},S=function(r){return r.replace(i," ").replace(o,"")},v=function(r,n,t){if(u.test(r)&&(!f.test(r)||0===n||"."!==t[n-1]))return d(r)||0},g=function(r,n,t){return{parsedNumber:v(r,n,t),normalizedString:S(r)}},N=function(r){return function(r){return r.replace(e,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")}(r).map(g)},A=function(r){return"function"==typeof r},h=function(r){return Number.isNaN(r)||r instanceof Number&&Number.isNaN(r.valueOf())},j=function(r){return null===r};function w(r){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},w(r)}const z=function(r){return!(null===r||"object"!==w(r)||Array.isArray(r)||r instanceof Number||r instanceof String||r instanceof Boolean||r instanceof Date)};function O(r){return O="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},O(r)}const x=function(r){return"symbol"===O(r)},k=function(r){return void 0===r},$=function(r){if("string"==typeof r||r instanceof String||("number"==typeof r||r instanceof Number)&&!h(r)||"boolean"==typeof r||r instanceof Boolean||r instanceof Date){var n=function(r){return"boolean"==typeof r||r instanceof Boolean?Number(r).toString():"number"==typeof r||r instanceof Number?r.toString():r instanceof Date?r.getTime().toString():"string"==typeof r||r instanceof String?r.toLowerCase().replace(o,""):""}(r),t=b(n);return{parsedNumber:t,chunks:N(t?"".concat(t):n),value:r}}return{isArray:Array.isArray(r),isFunction:A(r),isNaN:h(r),isNull:j(r),isObject:z(r),isSymbol:x(r),isUndefined:k(r),value:r}},I=function(r,n,t){var e=n.length?n.map(p):[function(r){return r}],o=r.map((function(r,n){return{index:n,values:e.map((function(n){return n(r)})).map($)}}));return o.sort((function(r,n){return function(r,n,t){for(var e=r.index,o=r.values,i=n.index,u=n.values,a=o.length,f=t.length,c=0;c<a;c++){var s=c<f?t[c]:null;if(s&&"function"==typeof s){var l=s(o[c].value,u[c].value);if(l)return l}else{var m=y(o[c],u[c]);if(m)return m*("desc"===s?-1:1)}}return e-i}(r,n,t)})),o.map((function(n){return function(r,n){return r[n]}(r,n.index)}))};function F(r,n){(null==n||n>r.length)&&(n=r.length);for(var t=0,e=new Array(n);t<n;t++)e[t]=r[t];return e}const M=function(r){if(!r)return[];var n,t=Array.isArray(r)?function(r){if(Array.isArray(r))return F(r)}(n=r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(n)||function(r,n){if(r){if("string"==typeof r)return F(r,n);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?F(r,n):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}():[r];return t.some((function(r){return"string"!=typeof r&&"number"!=typeof r&&"function"!=typeof r}))?[]:t};function C(r,n){(null==n||n>r.length)&&(n=r.length);for(var t=0,e=new Array(n);t<n;t++)e[t]=r[t];return e}const D=function(r){if(!r)return[];var n,t=Array.isArray(r)?function(r){if(Array.isArray(r))return C(r)}(n=r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(n)||function(r,n){if(r){if("string"==typeof r)return C(r,n);var t=Object.prototype.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?C(r,n):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}():[r];return t.some((function(r){return"asc"!==r&&"desc"!==r&&"function"!=typeof r}))?[]:t},T=function(r,n,t){if(!r||!Array.isArray(r))return[];var e=M(n),o=D(t);return I(r,e,o)};function B(r){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},B(r)}var E=function(r){return"string"==typeof r&&("asc"===r||"desc"===r)};const P=function(r){var n,t;return function(r){return function(n,t){var e=$(n),o=$(t);return y(e,o)*("desc"===r.order?-1:1)}}((t="asc","string"==typeof(n=r)&&E(n)?t=n:n&&"object"===B(n)&&n.order&&E(n.order)&&(t=n.order),{order:t}))};return n})()));
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var n=r();for(var t in n)("object"==typeof exports?exports:e)[t]=n[t]}}("undefined"!=typeof self?self:this,(()=>(()=>{"use strict";var e={d:(r,n)=>{for(var t in n)e.o(n,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:n[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{compare:()=>F,orderBy:()=>w});const n=(e,r)=>e<r?-1:e>r?1:0,t=/(^0x[\da-fA-F]+$|^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?!\.\d+)(?=\D|\s|$))|\d+)/g,o=/^\s+|\s+$/g,i=/\s+/g,s=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,a=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[/-]\d{1,4}[/-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,u=/^0+[1-9]{1}[0-9]*$/,c=/[^\x00-\x80]/,d=(e,r)=>{const n=e.localeCompare(r);return n?n/Math.abs(n):0},l=(e,r)=>e<r?-1:e>r?1:0,f=(e,r)=>e.value===r.value?0:void 0!==e.parsedNumber&&void 0!==r.parsedNumber?n(e.parsedNumber,r.parsedNumber):e.chunks&&r.chunks?((e,r)=>{const t=e.length,o=r.length,i=Math.min(t,o);for(let t=0;t<i;t++){const o=e[t],i=r[t];if(o.normalizedString!==i.normalizedString){if(""===o.normalizedString!=(""===i.normalizedString))return""===o.normalizedString?-1:1;if(void 0!==o.parsedNumber&&void 0!==i.parsedNumber){const e=n(o.parsedNumber,i.parsedNumber);return 0===e?l(o.normalizedString,i.normalizedString):e}return void 0!==o.parsedNumber||void 0!==i.parsedNumber?void 0!==o.parsedNumber?-1:1:c.test(o.normalizedString+i.normalizedString)&&o.normalizedString.localeCompare?d(o.normalizedString,i.normalizedString):l(o.normalizedString,i.normalizedString)}}return t>i||o>i?t<=i?-1:1:0})(e.chunks,r.chunks):((e,r)=>(e.chunks?!r.chunks:r.chunks)?e.chunks?-1:1:(e.isNaN?!r.isNaN:r.isNaN)?e.isNaN?-1:1:(e.isSymbol?!r.isSymbol:r.isSymbol)?e.isSymbol?-1:1:(e.isObject?!r.isObject:r.isObject)?e.isObject?-1:1:(e.isArray?!r.isArray:r.isArray)?e.isArray?-1:1:(e.isFunction?!r.isFunction:r.isFunction)?e.isFunction?-1:1:(e.isNull?!r.isNull:r.isNull)?e.isNull?-1:1:0)(e,r),m=e=>"function"==typeof e?e:r=>{if(Array.isArray(r)){const n=Number(e);if(Number.isInteger(n))return r[n]}else if(r&&"object"==typeof r&&"function"!=typeof e)return r[e];return r},p=e=>{if(0!==e.length){const r=Number(e);if(!Number.isNaN(r))return r}},y=e=>{const r=p(e);return void 0!==r?r:(e=>{try{const r=Date.parse(e);return!Number.isNaN(r)&&a.test(e)?r:void 0}catch{return}})(e)},b=e=>e.replace(i," ").replace(o,""),N=(e,r,n)=>{if(s.test(e)&&(!u.test(e)||0===r||"."!==n[r-1]))return p(e)||0},g=(e,r,n)=>({parsedNumber:N(e,r,n),normalizedString:b(e)}),S=function(e){return(e=>e.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"))(e).map(g)},v=function(e){return"function"==typeof e},h=e=>Number.isNaN(e)||e instanceof Number&&Number.isNaN(e.valueOf()),A=e=>null===e,j=e=>!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof Number||e instanceof String||e instanceof Boolean||e instanceof Date),z=e=>"symbol"==typeof e,x=e=>void 0===e,O=e=>{if("string"==typeof e||e instanceof String||("number"==typeof e||e instanceof Number)&&!h(e)||"boolean"==typeof e||e instanceof Boolean||e instanceof Date){const r=(e=>"boolean"==typeof e||e instanceof Boolean?Number(e).toString():"number"==typeof e||e instanceof Number?e.toString():e instanceof Date?e.getTime().toString():"string"==typeof e||e instanceof String?e.toLowerCase().replace(o,""):"")(e),n=y(r);return{parsedNumber:n,chunks:S(n?`${n}`:r),value:e}}return{isArray:Array.isArray(e),isFunction:v(e),isNaN:h(e),isNull:A(e),isObject:j(e),isSymbol:z(e),isUndefined:x(e),value:e}},k=(e,r,n)=>{const t=r.length?r.map(m):[e=>e],o=e.map(((e,r)=>({index:r,values:t.map((r=>r(e))).map(O)})));return o.sort(((e,r)=>((e,r,n)=>{const{index:t,values:o}=e,{index:i,values:s}=r,{length:a}=o,u=n.length;for(let e=0;e<a;e++){const r=e<u?n[e]:null;if(r&&"function"==typeof r){const n=r(o[e].value,s[e].value);if(n)return n}else{const n=f(o[e],s[e]);if(n)return n*("desc"===r?-1:1)}}return t-i})(e,r,n))),o.map((r=>((e,r)=>e[r])(e,r.index)))},w=function(e,r,n){if(!e||!Array.isArray(e))return[];const t=(e=>{if(!e)return[];const r=Array.isArray(e)?[...e]:[e];return r.some((e=>"string"!=typeof e&&"number"!=typeof e&&"function"!=typeof e))?[]:r})(r),o=(e=>{if(!e)return[];const r=Array.isArray(e)?[...e]:[e];return r.some((e=>"asc"!==e&&"desc"!==e&&"function"!=typeof e))?[]:r})(n);return k(e,t,o)},$=e=>"string"==typeof e&&("asc"===e||"desc"===e),F=function(e){return function(e){return(r,n)=>{const t=O(r),o=O(n);return f(t,o)*("desc"===e.order?-1:1)}}((e=>{let r="asc";return"string"==typeof e&&$(e)?r=e:e&&"object"==typeof e&&e.order&&$(e.order)&&({order:r}=e),{order:r}})(e))};return r})()));
{
"name": "@shelf/fast-natural-order-by",
"version": "1.0.2",
"version": "1.1.0",
"description": "Lightweight and performant natural sorting of arrays and collections by differentiating between unicode characters, numbers, dates, etc. 150,000x faster fork of natural-orderby for longer strings",

@@ -43,24 +43,24 @@ "license": "MIT",

"devDependencies": {
"@babel/cli": "7.17.10",
"@babel/core": "7.18.2",
"@shelf/babel-config": "1.0.1",
"@babel/cli": "7.18.6",
"@babel/core": "7.18.6",
"@shelf/babel-config": "1.0.2",
"@shelf/eslint-config": "2.18.0",
"@shelf/prettier-config": "1.0.0",
"@shelf/tsconfig": "0.0.6",
"@types/jest": "27.5.2",
"@types/jest": "28.1.5",
"@types/node": "16",
"babel-loader": "8.2.5",
"benny": "3.7.1",
"eslint": "8.16.0",
"eslint": "8.19.0",
"husky": "8.0.1",
"jest": "28.1.0",
"lint-staged": "13.0.0",
"jest": "28.1.3",
"lint-staged": "13.0.3",
"natural-orderby": "2.0.3",
"prettier": "2.6.2",
"typescript": "4.7.2",
"webpack": "5.72.1",
"webpack-cli": "4.9.2"
"prettier": "2.7.1",
"typescript": "4.7.4",
"webpack": "5.73.0",
"webpack-cli": "4.10.0"
},
"engines": {
"node": ">=16"
"node": ">=14"
},

@@ -67,0 +67,0 @@ "publishConfig": {

@@ -501,2 +501,8 @@ # fast-natural-order-by [![CircleCI](https://circleci.com/gh/shelfio/fast-natural-order-by/tree/master.svg?style=svg)](https://circleci.com/gh/shelfio/fast-natural-order-by/tree/master)![](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)

## See Also
- [fast-normalize-spaces](https://github.com/shelfio/fast-normalize-spaces)
- [fast-uslug](https://github.com/shelfio/fast-uslug)
- [fast-chunk-string](https://github.com/shelfio/fast-chunk-string)
## Credits

@@ -503,0 +509,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc