Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

natural-orderby

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

natural-orderby - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

6

CHANGELOG.md
# natural-orderby
## 3.0.2
### Patch Changes
- fix: performance issue when parsing date strings
## 3.0.1

@@ -4,0 +10,0 @@

12

dist/index.js
/**
* natural-orderby v3.0.1
* natural-orderby v3.0.2
*

@@ -194,9 +194,13 @@ * Copyright (c) Olaf Ennen

var parseDate = function parseDate(value) {
if (RE_DATE.test(value)) {
try {
var parsedDate = Date.parse(value);
if (!Number.isNaN(parsedDate)) {
return parsedDate;
if (RE_DATE.test(value)) {
return parsedDate;
}
}
return undefined;
} catch (_unused) {
return undefined;
}
return undefined;
};

@@ -203,0 +207,0 @@

/**
* natural-orderby v3.0.1
* natural-orderby v3.0.2
*

@@ -4,0 +4,0 @@ * Copyright (c) Olaf Ennen

/**
* natural-orderby v3.0.1
* natural-orderby v3.0.2
*

@@ -178,9 +178,13 @@ * Copyright (c) Olaf Ennen

const parseDate = value => {
if (RE_DATE.test(value)) {
try {
const parsedDate = Date.parse(value);
if (!Number.isNaN(parsedDate)) {
return parsedDate;
if (RE_DATE.test(value)) {
return parsedDate;
}
}
return undefined;
} catch {
return undefined;
}
return undefined;
};

@@ -187,0 +191,0 @@

/**
* natural-orderby v3.0.1
* natural-orderby v3.0.2
*

@@ -11,2 +11,2 @@ * Copyright (c) Olaf Ennen

*/
const e=(e,r)=>e<r?-1:e>r?1:0,r=(e,r)=>{const n=e.localeCompare(r);return n?n/Math.abs(n):0},n=/(^0x[\da-fA-F]+$|^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?!\.\d+)(?=\D|\s|$))|\d+)/g,t=/^\s+|\s+$/g,i=/\s+/g,s=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[/-]\d{1,4}[/-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,a=/^0+[1-9]{1}[0-9]*$/,u=/[^\x00-\x80]/,c=(e,r)=>e<r?-1:e>r?1:0,l=(n,t)=>n.value===t.value?0:void 0!==n.parsedNumber&&void 0!==t.parsedNumber?e(n.parsedNumber,t.parsedNumber):n.chunks&&t.chunks?((n,t)=>{const i=n.length,s=t.length,o=Math.min(i,s);for(let a=0;a<o;a++){const i=n[a],s=t[a];if(i.normalizedString!==s.normalizedString){if(""===i.normalizedString!=(""===s.normalizedString))return""===i.normalizedString?-1:1;if(void 0!==i.parsedNumber&&void 0!==s.parsedNumber){const r=e(i.parsedNumber,s.parsedNumber);return 0===r?c(i.normalizedString,s.normalizedString):r}return void 0!==i.parsedNumber||void 0!==s.parsedNumber?void 0!==i.parsedNumber?-1:1:u.test(i.normalizedString+s.normalizedString)?r(i.normalizedString,s.normalizedString):c(i.normalizedString,s.normalizedString)}}return i>o||s>o?i<=o?-1:1:0})(n.chunks,t.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)(n,t),d=e=>e.replace(i," ").replace(t,""),f=e=>{if(0!==e.length){const r=Number(e);if(!Number.isNaN(r))return r}},m=(e,r,n)=>{if(s.test(e)&&(!a.test(e)||0===r||"."!==n[r-1]))return f(e)||0},p=(e,r,n)=>({parsedNumber:m(e,r,n),normalizedString:d(e)}),N=e=>{const r=(e=>e.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"))(e).map(p);return r},b=e=>"function"==typeof e,y=e=>Number.isNaN(e)||e instanceof Number&&Number.isNaN(e.valueOf()),g=e=>null===e,S=e=>!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof Number||e instanceof String||e instanceof Boolean||e instanceof Date),v=e=>"symbol"==typeof e,A=e=>void 0===e,h=e=>{const r=f(e);return void 0!==r?r:(e=>{if(o.test(e)){const r=Date.parse(e);if(!Number.isNaN(r))return r}})(e)},z=e=>{if("string"==typeof e||e instanceof String||("number"==typeof e||e instanceof Number)&&!y(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(t,""):"")(e),n=h(r);return{parsedNumber:n,chunks:N(n?`${n}`:r),value:e}}return{isArray:Array.isArray(e),isFunction:b(e),isNaN:y(e),isNull:g(e),isObject:S(e),isSymbol:v(e),isUndefined:A(e),value:e}},j=e=>"string"==typeof e&&("asc"===e||"desc"===e);function k(e){return(e=>(r,n)=>{const t=z(r),i=z(n);return l(t,i)*("desc"===e.order?-1:1)})((e=>{let r="asc";return"string"==typeof e&&j(e)?r=e:e&&"object"==typeof e&&e.order&&j(e.order)&&({order:r}=e),{order:r}})(e))}const w=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){return Object.getOwnPropertyDescriptor(r,e)?.value}return r},x=(e,r,n)=>{const t=r.length?r.map(w):[e=>e],i=e.map(((e,r)=>({index:r,values:t.map((r=>r(e))).map(z)})));return i.sort(((e,r)=>((e,r,n)=>{const{index:t,values:i}=e,{index:s,values:o}=r,{length:a}=i,u=n.length;for(let c=0;c<a;c++){const e=c<u?n[c]:null;if(e&&"function"==typeof e){const r=e(i[c].value,o[c].value);if(r)return r}else{const r=l(i[c],o[c]);if(r)return r*("desc"===e?-1:1)}}return t-s})(e,r,n))),i.map((r=>((e,r)=>e[r])(e,r.index)))};function O(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),i=(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 x(e,t,i)}export{k as compare,O as orderBy};
const e=(e,r)=>e<r?-1:e>r?1:0,r=(e,r)=>{const n=e.localeCompare(r);return n?n/Math.abs(n):0},n=/(^0x[\da-fA-F]+$|^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?!\.\d+)(?=\D|\s|$))|\d+)/g,t=/^\s+|\s+$/g,i=/\s+/g,s=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/,o=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[/-]\d{1,4}[/-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,a=/^0+[1-9]{1}[0-9]*$/,u=/[^\x00-\x80]/,c=(e,r)=>e<r?-1:e>r?1:0,l=(n,t)=>n.value===t.value?0:void 0!==n.parsedNumber&&void 0!==t.parsedNumber?e(n.parsedNumber,t.parsedNumber):n.chunks&&t.chunks?((n,t)=>{const i=n.length,s=t.length,o=Math.min(i,s);for(let a=0;a<o;a++){const i=n[a],s=t[a];if(i.normalizedString!==s.normalizedString){if(""===i.normalizedString!=(""===s.normalizedString))return""===i.normalizedString?-1:1;if(void 0!==i.parsedNumber&&void 0!==s.parsedNumber){const r=e(i.parsedNumber,s.parsedNumber);return 0===r?c(i.normalizedString,s.normalizedString):r}return void 0!==i.parsedNumber||void 0!==s.parsedNumber?void 0!==i.parsedNumber?-1:1:u.test(i.normalizedString+s.normalizedString)?r(i.normalizedString,s.normalizedString):c(i.normalizedString,s.normalizedString)}}return i>o||s>o?i<=o?-1:1:0})(n.chunks,t.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)(n,t),d=e=>e.replace(i," ").replace(t,""),f=e=>{if(0!==e.length){const r=Number(e);if(!Number.isNaN(r))return r}},m=(e,r,n)=>{if(s.test(e)&&(!a.test(e)||0===r||"."!==n[r-1]))return f(e)||0},p=(e,r,n)=>({parsedNumber:m(e,r,n),normalizedString:d(e)}),N=e=>{const r=(e=>e.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"))(e).map(p);return r},b=e=>"function"==typeof e,y=e=>Number.isNaN(e)||e instanceof Number&&Number.isNaN(e.valueOf()),g=e=>null===e,S=e=>!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof Number||e instanceof String||e instanceof Boolean||e instanceof Date),v=e=>"symbol"==typeof e,h=e=>void 0===e,A=e=>{const r=f(e);return void 0!==r?r:(e=>{try{const r=Date.parse(e);return!Number.isNaN(r)&&o.test(e)?r:void 0}catch{return}})(e)},z=e=>{if("string"==typeof e||e instanceof String||("number"==typeof e||e instanceof Number)&&!y(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(t,""):"")(e),n=A(r);return{parsedNumber:n,chunks:N(n?`${n}`:r),value:e}}return{isArray:Array.isArray(e),isFunction:b(e),isNaN:y(e),isNull:g(e),isObject:S(e),isSymbol:v(e),isUndefined:h(e),value:e}},j=e=>"string"==typeof e&&("asc"===e||"desc"===e);function k(e){return(e=>(r,n)=>{const t=z(r),i=z(n);return l(t,i)*("desc"===e.order?-1:1)})((e=>{let r="asc";return"string"==typeof e&&j(e)?r=e:e&&"object"==typeof e&&e.order&&j(e.order)&&({order:r}=e),{order:r}})(e))}const w=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){return Object.getOwnPropertyDescriptor(r,e)?.value}return r},x=(e,r,n)=>{const t=r.length?r.map(w):[e=>e],i=e.map(((e,r)=>({index:r,values:t.map((r=>r(e))).map(z)})));return i.sort(((e,r)=>((e,r,n)=>{const{index:t,values:i}=e,{index:s,values:o}=r,{length:a}=i,u=n.length;for(let c=0;c<a;c++){const e=c<u?n[c]:null;if(e&&"function"==typeof e){const r=e(i[c].value,o[c].value);if(r)return r}else{const r=l(i[c],o[c]);if(r)return r*("desc"===e?-1:1)}}return t-s})(e,r,n))),i.map((r=>((e,r)=>e[r])(e,r.index)))};function O(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),i=(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 x(e,t,i)}export{k as compare,O as orderBy};
/**
* natural-orderby v3.0.1
* natural-orderby v3.0.2
*

@@ -200,9 +200,13 @@ * Copyright (c) Olaf Ennen

var parseDate = function parseDate(value) {
if (RE_DATE.test(value)) {
try {
var parsedDate = Date.parse(value);
if (!Number.isNaN(parsedDate)) {
return parsedDate;
if (RE_DATE.test(value)) {
return parsedDate;
}
}
return undefined;
} catch (_unused) {
return undefined;
}
return undefined;
};

@@ -209,0 +213,0 @@

/**
* natural-orderby v3.0.1
* natural-orderby v3.0.2
*

@@ -11,2 +11,2 @@ * Copyright (c) Olaf Ennen

*/
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((r="undefined"!=typeof globalThis?globalThis:r||self).naturalOrderBy={})}(this,(function(r){"use strict";var n=function(r,n){return r<n?-1:r>n?1:0},e=function(r,n){var e=r.localeCompare(n);return e?e/Math.abs(e):0},t=/(^0x[\da-fA-F]+$|^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?!\.\d+)(?=\D|\s|$))|\d+)/g,i=/^\s+|\s+$/g,u=/\s+/g,o=/^[+-]?(?:\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})/,s=/^0+[1-9]{1}[0-9]*$/,f=/[^\x00-\x80]/,c=function(r,n){return r<n?-1:r>n?1:0},d=function(r,t){return r.value===t.value?0:void 0!==r.parsedNumber&&void 0!==t.parsedNumber?n(r.parsedNumber,t.parsedNumber):r.chunks&&t.chunks?function(r,t){for(var i=r.length,u=t.length,o=Math.min(i,u),a=0;a<o;a++){var s=r[a],d=t[a];if(s.normalizedString!==d.normalizedString){if(""===s.normalizedString!=(""===d.normalizedString))return""===s.normalizedString?-1:1;if(void 0!==s.parsedNumber&&void 0!==d.parsedNumber){var l=n(s.parsedNumber,d.parsedNumber);return 0===l?c(s.normalizedString,d.normalizedString):l}return void 0!==s.parsedNumber||void 0!==d.parsedNumber?void 0!==s.parsedNumber?-1:1:f.test(s.normalizedString+d.normalizedString)?e(s.normalizedString,d.normalizedString):c(s.normalizedString,d.normalizedString)}}return i>o||u>o?i<=o?-1:1:0}(r.chunks,t.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,t)},l=function(r){return r.replace(u," ").replace(i,"")},m=function(r){if(0!==r.length){var n=Number(r);if(!Number.isNaN(n))return n}},p=function(r,n,e){if(o.test(r)&&(!s.test(r)||0===n||"."!==e[n-1]))return m(r)||0},b=function(r,n,e){return{parsedNumber:p(r,n,e),normalizedString:l(r)}},y=function(r){var n=function(r){return r.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")}(r).map(b);return n},N=function(r){return"function"==typeof r},v=function(r){return Number.isNaN(r)||r instanceof Number&&Number.isNaN(r.valueOf())},g=function(r){return null===r},S=function(r){return!(null===r||"object"!=typeof r||Array.isArray(r)||r instanceof Number||r instanceof String||r instanceof Boolean||r instanceof Date)},h=function(r){return"symbol"==typeof r},A=function(r){return void 0===r},z=function(r){var n=m(r);return void 0!==n?n:function(r){if(a.test(r)){var n=Date.parse(r);if(!Number.isNaN(n))return n}}(r)},j=function(r){if("string"==typeof r||r instanceof String||("number"==typeof r||r instanceof Number)&&!v(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(i,""):""}(r),e=z(n);return{parsedNumber:e,chunks:y(e?""+e:n),value:r}}return{isArray:Array.isArray(r),isFunction:N(r),isNaN:v(r),isNull:g(r),isObject:S(r),isSymbol:h(r),isUndefined:A(r),value:r}},x=function(r){return"string"==typeof r&&("asc"===r||"desc"===r)};var O=function(r){return"function"==typeof r?r:function(n){if(Array.isArray(n)){var e=Number(r);if(Number.isInteger(e))return n[e]}else if(n&&"object"==typeof n){var t=Object.getOwnPropertyDescriptor(n,r);return null==t?void 0:t.value}return n}},k=function(r,n,e){var t=n.length?n.map(O):[function(r){return r}],i=r.map((function(r,n){return{index:n,values:t.map((function(n){return n(r)})).map(j)}}));return i.sort((function(r,n){return function(r,n,e){for(var t=r.index,i=r.values,u=n.index,o=n.values,a=i.length,s=e.length,f=0;f<a;f++){var c=f<s?e[f]:null;if(c&&"function"==typeof c){var l=c(i[f].value,o[f].value);if(l)return l}else{var m=d(i[f],o[f]);if(m)return m*("desc"===c?-1:1)}}return t-u}(r,n,e)})),i.map((function(n){return function(r,n){return r[n]}(r,n.index)}))};r.compare=function(r){var n,e;return function(r){return function(n,e){var t=j(n),i=j(e);return d(t,i)*("desc"===r.order?-1:1)}}((e="asc","string"==typeof(n=r)&&x(n)?e=n:n&&"object"==typeof n&&n.order&&x(n.order)&&(e=n.order),{order:e}))},r.orderBy=function(r,n,e){if(!r||!Array.isArray(r))return[];var t=function(r){if(!r)return[];var n=Array.isArray(r)?[].concat(r):[r];return n.some((function(r){return"string"!=typeof r&&"number"!=typeof r&&"function"!=typeof r}))?[]:n}(n),i=function(r){if(!r)return[];var n=Array.isArray(r)?[].concat(r):[r];return n.some((function(r){return"asc"!==r&&"desc"!==r&&"function"!=typeof r}))?[]:n}(e);return k(r,t,i)},Object.defineProperty(r,"__esModule",{value:!0})}));
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((r="undefined"!=typeof globalThis?globalThis:r||self).naturalOrderBy={})}(this,(function(r){"use strict";var n=function(r,n){return r<n?-1:r>n?1:0},e=function(r,n){var e=r.localeCompare(n);return e?e/Math.abs(e):0},t=/(^0x[\da-fA-F]+$|^([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?(?!\.\d+)(?=\D|\s|$))|\d+)/g,i=/^\s+|\s+$/g,u=/\s+/g,o=/^[+-]?(?:\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})/,s=/^0+[1-9]{1}[0-9]*$/,f=/[^\x00-\x80]/,c=function(r,n){return r<n?-1:r>n?1:0},d=function(r,t){return r.value===t.value?0:void 0!==r.parsedNumber&&void 0!==t.parsedNumber?n(r.parsedNumber,t.parsedNumber):r.chunks&&t.chunks?function(r,t){for(var i=r.length,u=t.length,o=Math.min(i,u),a=0;a<o;a++){var s=r[a],d=t[a];if(s.normalizedString!==d.normalizedString){if(""===s.normalizedString!=(""===d.normalizedString))return""===s.normalizedString?-1:1;if(void 0!==s.parsedNumber&&void 0!==d.parsedNumber){var l=n(s.parsedNumber,d.parsedNumber);return 0===l?c(s.normalizedString,d.normalizedString):l}return void 0!==s.parsedNumber||void 0!==d.parsedNumber?void 0!==s.parsedNumber?-1:1:f.test(s.normalizedString+d.normalizedString)?e(s.normalizedString,d.normalizedString):c(s.normalizedString,d.normalizedString)}}return i>o||u>o?i<=o?-1:1:0}(r.chunks,t.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,t)},l=function(r){return r.replace(u," ").replace(i,"")},m=function(r){if(0!==r.length){var n=Number(r);if(!Number.isNaN(n))return n}},p=function(r,n,e){if(o.test(r)&&(!s.test(r)||0===n||"."!==e[n-1]))return m(r)||0},y=function(r,n,e){return{parsedNumber:p(r,n,e),normalizedString:l(r)}},b=function(r){var n=function(r){return r.replace(t,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0")}(r).map(y);return n},N=function(r){return"function"==typeof r},v=function(r){return Number.isNaN(r)||r instanceof Number&&Number.isNaN(r.valueOf())},g=function(r){return null===r},S=function(r){return!(null===r||"object"!=typeof r||Array.isArray(r)||r instanceof Number||r instanceof String||r instanceof Boolean||r instanceof Date)},h=function(r){return"symbol"==typeof r},A=function(r){return void 0===r},z=function(r){var n=m(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)},j=function(r){if("string"==typeof r||r instanceof String||("number"==typeof r||r instanceof Number)&&!v(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(i,""):""}(r),e=z(n);return{parsedNumber:e,chunks:b(e?""+e:n),value:r}}return{isArray:Array.isArray(r),isFunction:N(r),isNaN:v(r),isNull:g(r),isObject:S(r),isSymbol:h(r),isUndefined:A(r),value:r}},x=function(r){return"string"==typeof r&&("asc"===r||"desc"===r)};var O=function(r){return"function"==typeof r?r:function(n){if(Array.isArray(n)){var e=Number(r);if(Number.isInteger(e))return n[e]}else if(n&&"object"==typeof n){var t=Object.getOwnPropertyDescriptor(n,r);return null==t?void 0:t.value}return n}},k=function(r,n,e){var t=n.length?n.map(O):[function(r){return r}],i=r.map((function(r,n){return{index:n,values:t.map((function(n){return n(r)})).map(j)}}));return i.sort((function(r,n){return function(r,n,e){for(var t=r.index,i=r.values,u=n.index,o=n.values,a=i.length,s=e.length,f=0;f<a;f++){var c=f<s?e[f]:null;if(c&&"function"==typeof c){var l=c(i[f].value,o[f].value);if(l)return l}else{var m=d(i[f],o[f]);if(m)return m*("desc"===c?-1:1)}}return t-u}(r,n,e)})),i.map((function(n){return function(r,n){return r[n]}(r,n.index)}))};r.compare=function(r){var n,e;return function(r){return function(n,e){var t=j(n),i=j(e);return d(t,i)*("desc"===r.order?-1:1)}}((e="asc","string"==typeof(n=r)&&x(n)?e=n:n&&"object"==typeof n&&n.order&&x(n.order)&&(e=n.order),{order:e}))},r.orderBy=function(r,n,e){if(!r||!Array.isArray(r))return[];var t=function(r){if(!r)return[];var n=Array.isArray(r)?[].concat(r):[r];return n.some((function(r){return"string"!=typeof r&&"number"!=typeof r&&"function"!=typeof r}))?[]:n}(n),i=function(r){if(!r)return[];var n=Array.isArray(r)?[].concat(r):[r];return n.some((function(r){return"asc"!==r&&"desc"!==r&&"function"!=typeof r}))?[]:n}(e);return k(r,t,i)},Object.defineProperty(r,"__esModule",{value:!0})}));
{
"name": "natural-orderby",
"version": "3.0.1",
"version": "3.0.2",
"description": "Lightweight and performant natural sorting of arrays and collections by differentiating between unicode characters, numbers, dates, etc.",

@@ -77,4 +77,4 @@ "sideEffects": false,

"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.1.0",
"@types/jest": "29.2.2",
"@rollup/plugin-terser": "^0.3.0",
"@types/jest": "29.2.6",
"@typescript-eslint/eslint-plugin": "^5.42.1",

@@ -81,0 +81,0 @@ "@typescript-eslint/parser": "^5.42.1",

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