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 2.0.1 to 2.0.2

71

cjs/natural-orderby.js

@@ -28,3 +28,2 @@ 'use strict';

var RE_UNICODE_CHARACTERS = /[^\x00-\x80]/;
var RE_ASCII_CHARACTERS = /[A-Za-z_]/;

@@ -57,20 +56,32 @@ var compareUnicode = function compareUnicode(stringA, stringB) {

if (chunkA !== chunkB) {
if (chunkA === '' !== (chunkB === '')) {
if (chunkA.normalizedString !== chunkB.normalizedString) {
if (chunkA.normalizedString === '' !== (chunkB.normalizedString === '')) {
// empty strings have lowest value
return chunkA === '' ? -1 : 1;
return chunkA.normalizedString === '' ? -1 : 1;
}
if (typeof chunkA === 'number' && typeof chunkB === 'number') {
if (chunkA.parsedNumber !== undefined && chunkB.parsedNumber !== undefined) {
// compare numbers
return compareNumbers(chunkA, chunkB);
} else if (typeof chunkA === 'number' || typeof chunkB === 'number') {
var result = compareNumbers(chunkA.parsedNumber, chunkB.parsedNumber);
if (result === 0) {
// compare string value, if parsed numbers are equal
// Example:
// chunkA = { parsedNumber: 1, normalizedString: "001" }
// chunkB = { parsedNumber: 1, normalizedString: "01" }
// chunkA.parsedNumber === chunkB.parsedNumber
// chunkA.normalizedString < chunkB.normalizedString
return stringCompare(chunkA.normalizedString, chunkB.normalizedString);
}
return result;
} else if (chunkA.parsedNumber !== undefined || chunkB.parsedNumber !== undefined) {
// number < string
return typeof chunkA === 'number' ? -1 : 1;
} else if (RE_UNICODE_CHARACTERS.test(chunkA + chunkB) && chunkA.localeCompare) {
return chunkA.parsedNumber !== undefined ? -1 : 1;
} else if (RE_UNICODE_CHARACTERS.test(chunkA.normalizedString + chunkB.normalizedString) && chunkA.normalizedString.localeCompare) {
// use locale comparison only if one of the chunks contains unicode characters
return compareUnicode(chunkA, chunkB);
return compareUnicode(chunkA.normalizedString, chunkB.normalizedString);
} else {
// use common string comparison for performance reason
return stringCompare(chunkA, chunkB);
return stringCompare(chunkA.normalizedString, chunkB.normalizedString);
}

@@ -244,19 +255,12 @@ }

var normalizeChunk = function normalizeChunk(chunk, index, chunks) {
var normalizeAlphaChunk = function normalizeAlphaChunk(chunk) {
return chunk.replace(RE_WHITESPACES, ' ').replace(RE_LEADING_OR_TRAILING_WHITESPACES, '');
};
var normalizeNumericChunk = function normalizeNumericChunk(chunk, index, chunks) {
if (RE_INT_OR_FLOAT.test(chunk)) {
if (!RE_LEADING_ZERO.test(chunk)) {
return parseNumber(chunk) || 0;
} // only parse a leading number, if it´s not followed by characters
// to be able to sort filenames prefixed with numbers containing leading zeros
// e.g. 001filename.txt, 01filename.txt
if (index === 0 && chunks.length > 1 && !RE_UNICODE_CHARACTERS.test(chunks[1].toString()) && !RE_ASCII_CHARACTERS.test(chunks[1].toString())) {
return parseNumber(chunk) || 0;
} // don´t parse a number, if there´s a preceding decimal point
// don´t parse a number, if there´s a preceding decimal point
// to keep significance
// e.g. 1.0020, 1.020
if (index > 0 && chunks[index - 1] !== '.') {
if (!RE_LEADING_ZERO.test(chunk) || index === 0 || chunks[index - 1] !== '.') {
return parseNumber(chunk) || 0;

@@ -266,10 +270,17 @@ }

return chunk.replace(RE_WHITESPACES, ' ').replace(RE_LEADING_OR_TRAILING_WHITESPACES, '');
return undefined;
};
var createChunksList = function createChunksList(value) {
var chunks = createChunks(value).map(normalizeChunk);
return chunks;
var createChunkMap = function createChunkMap(chunk, index, chunks) {
return {
parsedNumber: normalizeNumericChunk(chunk, index, chunks),
normalizedString: normalizeAlphaChunk(chunk)
};
};
var createChunkMaps = function createChunkMaps(value) {
var chunksMaps = createChunks(value).map(createChunkMap);
return chunksMaps;
};
var isFunction = function isFunction(value) {

@@ -303,3 +314,3 @@ return typeof value === 'function';

var parsedNumber = numberify(stringValue);
var chunks = createChunksList(parsedNumber ? "" + parsedNumber : stringValue);
var chunks = createChunkMaps(parsedNumber ? "" + parsedNumber : stringValue);
return {

@@ -306,0 +317,0 @@ parsedNumber: parsedNumber,

@@ -24,3 +24,2 @@ var compareNumbers = function compareNumbers(numberA, numberB) {

var RE_UNICODE_CHARACTERS = /[^\x00-\x80]/;
var RE_ASCII_CHARACTERS = /[A-Za-z_]/;

@@ -53,20 +52,32 @@ var compareUnicode = function compareUnicode(stringA, stringB) {

if (chunkA !== chunkB) {
if (chunkA === '' !== (chunkB === '')) {
if (chunkA.normalizedString !== chunkB.normalizedString) {
if (chunkA.normalizedString === '' !== (chunkB.normalizedString === '')) {
// empty strings have lowest value
return chunkA === '' ? -1 : 1;
return chunkA.normalizedString === '' ? -1 : 1;
}
if (typeof chunkA === 'number' && typeof chunkB === 'number') {
if (chunkA.parsedNumber !== undefined && chunkB.parsedNumber !== undefined) {
// compare numbers
return compareNumbers(chunkA, chunkB);
} else if (typeof chunkA === 'number' || typeof chunkB === 'number') {
var result = compareNumbers(chunkA.parsedNumber, chunkB.parsedNumber);
if (result === 0) {
// compare string value, if parsed numbers are equal
// Example:
// chunkA = { parsedNumber: 1, normalizedString: "001" }
// chunkB = { parsedNumber: 1, normalizedString: "01" }
// chunkA.parsedNumber === chunkB.parsedNumber
// chunkA.normalizedString < chunkB.normalizedString
return stringCompare(chunkA.normalizedString, chunkB.normalizedString);
}
return result;
} else if (chunkA.parsedNumber !== undefined || chunkB.parsedNumber !== undefined) {
// number < string
return typeof chunkA === 'number' ? -1 : 1;
} else if (RE_UNICODE_CHARACTERS.test(chunkA + chunkB) && chunkA.localeCompare) {
return chunkA.parsedNumber !== undefined ? -1 : 1;
} else if (RE_UNICODE_CHARACTERS.test(chunkA.normalizedString + chunkB.normalizedString) && chunkA.normalizedString.localeCompare) {
// use locale comparison only if one of the chunks contains unicode characters
return compareUnicode(chunkA, chunkB);
return compareUnicode(chunkA.normalizedString, chunkB.normalizedString);
} else {
// use common string comparison for performance reason
return stringCompare(chunkA, chunkB);
return stringCompare(chunkA.normalizedString, chunkB.normalizedString);
}

@@ -240,19 +251,12 @@ }

var normalizeChunk = function normalizeChunk(chunk, index, chunks) {
var normalizeAlphaChunk = function normalizeAlphaChunk(chunk) {
return chunk.replace(RE_WHITESPACES, ' ').replace(RE_LEADING_OR_TRAILING_WHITESPACES, '');
};
var normalizeNumericChunk = function normalizeNumericChunk(chunk, index, chunks) {
if (RE_INT_OR_FLOAT.test(chunk)) {
if (!RE_LEADING_ZERO.test(chunk)) {
return parseNumber(chunk) || 0;
} // only parse a leading number, if it´s not followed by characters
// to be able to sort filenames prefixed with numbers containing leading zeros
// e.g. 001filename.txt, 01filename.txt
if (index === 0 && chunks.length > 1 && !RE_UNICODE_CHARACTERS.test(chunks[1].toString()) && !RE_ASCII_CHARACTERS.test(chunks[1].toString())) {
return parseNumber(chunk) || 0;
} // don´t parse a number, if there´s a preceding decimal point
// don´t parse a number, if there´s a preceding decimal point
// to keep significance
// e.g. 1.0020, 1.020
if (index > 0 && chunks[index - 1] !== '.') {
if (!RE_LEADING_ZERO.test(chunk) || index === 0 || chunks[index - 1] !== '.') {
return parseNumber(chunk) || 0;

@@ -262,10 +266,17 @@ }

return chunk.replace(RE_WHITESPACES, ' ').replace(RE_LEADING_OR_TRAILING_WHITESPACES, '');
return undefined;
};
var createChunksList = function createChunksList(value) {
var chunks = createChunks(value).map(normalizeChunk);
return chunks;
var createChunkMap = function createChunkMap(chunk, index, chunks) {
return {
parsedNumber: normalizeNumericChunk(chunk, index, chunks),
normalizedString: normalizeAlphaChunk(chunk)
};
};
var createChunkMaps = function createChunkMaps(value) {
var chunksMaps = createChunks(value).map(createChunkMap);
return chunksMaps;
};
var isFunction = function isFunction(value) {

@@ -299,3 +310,3 @@ return typeof value === 'function';

var parsedNumber = numberify(stringValue);
var chunks = createChunksList(parsedNumber ? "" + parsedNumber : stringValue);
var chunks = createChunkMaps(parsedNumber ? "" + parsedNumber : stringValue);
return {

@@ -302,0 +313,0 @@ parsedNumber: parsedNumber,

@@ -27,3 +27,2 @@ var naturalOrderBy = (function (exports) {

var RE_UNICODE_CHARACTERS = /[^\x00-\x80]/;
var RE_ASCII_CHARACTERS = /[A-Za-z_]/;

@@ -56,20 +55,32 @@ var compareUnicode = function compareUnicode(stringA, stringB) {

if (chunkA !== chunkB) {
if (chunkA === '' !== (chunkB === '')) {
if (chunkA.normalizedString !== chunkB.normalizedString) {
if (chunkA.normalizedString === '' !== (chunkB.normalizedString === '')) {
// empty strings have lowest value
return chunkA === '' ? -1 : 1;
return chunkA.normalizedString === '' ? -1 : 1;
}
if (typeof chunkA === 'number' && typeof chunkB === 'number') {
if (chunkA.parsedNumber !== undefined && chunkB.parsedNumber !== undefined) {
// compare numbers
return compareNumbers(chunkA, chunkB);
} else if (typeof chunkA === 'number' || typeof chunkB === 'number') {
var result = compareNumbers(chunkA.parsedNumber, chunkB.parsedNumber);
if (result === 0) {
// compare string value, if parsed numbers are equal
// Example:
// chunkA = { parsedNumber: 1, normalizedString: "001" }
// chunkB = { parsedNumber: 1, normalizedString: "01" }
// chunkA.parsedNumber === chunkB.parsedNumber
// chunkA.normalizedString < chunkB.normalizedString
return stringCompare(chunkA.normalizedString, chunkB.normalizedString);
}
return result;
} else if (chunkA.parsedNumber !== undefined || chunkB.parsedNumber !== undefined) {
// number < string
return typeof chunkA === 'number' ? -1 : 1;
} else if (RE_UNICODE_CHARACTERS.test(chunkA + chunkB) && chunkA.localeCompare) {
return chunkA.parsedNumber !== undefined ? -1 : 1;
} else if (RE_UNICODE_CHARACTERS.test(chunkA.normalizedString + chunkB.normalizedString) && chunkA.normalizedString.localeCompare) {
// use locale comparison only if one of the chunks contains unicode characters
return compareUnicode(chunkA, chunkB);
return compareUnicode(chunkA.normalizedString, chunkB.normalizedString);
} else {
// use common string comparison for performance reason
return stringCompare(chunkA, chunkB);
return stringCompare(chunkA.normalizedString, chunkB.normalizedString);
}

@@ -243,19 +254,12 @@ }

var normalizeChunk = function normalizeChunk(chunk, index, chunks) {
var normalizeAlphaChunk = function normalizeAlphaChunk(chunk) {
return chunk.replace(RE_WHITESPACES, ' ').replace(RE_LEADING_OR_TRAILING_WHITESPACES, '');
};
var normalizeNumericChunk = function normalizeNumericChunk(chunk, index, chunks) {
if (RE_INT_OR_FLOAT.test(chunk)) {
if (!RE_LEADING_ZERO.test(chunk)) {
return parseNumber(chunk) || 0;
} // only parse a leading number, if it´s not followed by characters
// to be able to sort filenames prefixed with numbers containing leading zeros
// e.g. 001filename.txt, 01filename.txt
if (index === 0 && chunks.length > 1 && !RE_UNICODE_CHARACTERS.test(chunks[1].toString()) && !RE_ASCII_CHARACTERS.test(chunks[1].toString())) {
return parseNumber(chunk) || 0;
} // don´t parse a number, if there´s a preceding decimal point
// don´t parse a number, if there´s a preceding decimal point
// to keep significance
// e.g. 1.0020, 1.020
if (index > 0 && chunks[index - 1] !== '.') {
if (!RE_LEADING_ZERO.test(chunk) || index === 0 || chunks[index - 1] !== '.') {
return parseNumber(chunk) || 0;

@@ -265,10 +269,17 @@ }

return chunk.replace(RE_WHITESPACES, ' ').replace(RE_LEADING_OR_TRAILING_WHITESPACES, '');
return undefined;
};
var createChunksList = function createChunksList(value) {
var chunks = createChunks(value).map(normalizeChunk);
return chunks;
var createChunkMap = function createChunkMap(chunk, index, chunks) {
return {
parsedNumber: normalizeNumericChunk(chunk, index, chunks),
normalizedString: normalizeAlphaChunk(chunk)
};
};
var createChunkMaps = function createChunkMaps(value) {
var chunksMaps = createChunks(value).map(createChunkMap);
return chunksMaps;
};
var isFunction = function isFunction(value) {

@@ -302,3 +313,3 @@ return typeof value === 'function';

var parsedNumber = numberify(stringValue);
var chunks = createChunksList(parsedNumber ? "" + parsedNumber : stringValue);
var chunks = createChunkMaps(parsedNumber ? "" + parsedNumber : stringValue);
return {

@@ -305,0 +316,0 @@ parsedNumber: parsedNumber,

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

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

@@ -64,31 +64,31 @@ "main": "cjs/natural-orderby.js",

"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.3",
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
"@babel/plugin-transform-flow-strip-types": "^7.2.3",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@commitlint/cli": "^7.5.2",
"@commitlint/config-conventional": "^7.5.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.0.0",
"cross-env": "^5.2.0",
"docsify-cli": "^4.2.1",
"eslint": "^5.14.1",
"eslint-config-airbnb-base": "^13.0.0",
"eslint-config-prettier": "^4.0.0",
"eslint-plugin-flowtype": "^3.4.2",
"eslint-plugin-import": "^2.16.0",
"flow-bin": "^0.93.0",
"husky": "^1.1.4",
"jest": "^24.0.0",
"lint-staged": "^8.0.5",
"prettier": "^1.6.1",
"rimraf": "^2.6.2",
"rollup": "^1.1.0",
"rollup-plugin-babel": "^4.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-size-snapshot": "^0.8.0",
"rollup-plugin-uglify": "^6.0.0"
"@babel/cli": "7.2.3",
"@babel/core": "7.3.4",
"@babel/plugin-proposal-object-rest-spread": "7.3.4",
"@babel/plugin-transform-flow-strip-types": "7.3.4",
"@babel/plugin-transform-runtime": "7.3.4",
"@babel/preset-env": "7.3.4",
"@commitlint/cli": "7.5.2",
"@commitlint/config-conventional": "7.5.0",
"babel-eslint": "10.0.1",
"babel-jest": "24.5.0",
"cross-env": "5.2.0",
"docsify-cli": "4.3.0",
"eslint": "5.15.3",
"eslint-config-airbnb-base": "13.1.0",
"eslint-config-prettier": "4.1.0",
"eslint-plugin-flowtype": "3.4.2",
"eslint-plugin-import": "2.16.0",
"flow-bin": "0.95.1",
"husky": "1.3.1",
"jest": "24.5.0",
"lint-staged": "8.1.5",
"prettier": "1.16.4",
"rimraf": "2.6.3",
"rollup": "1.6.0",
"rollup-plugin-babel": "4.3.2",
"rollup-plugin-node-resolve": "4.0.1",
"rollup-plugin-replace": "2.1.1",
"rollup-plugin-size-snapshot": "0.8.0",
"rollup-plugin-uglify": "6.0.2"
},

@@ -95,0 +95,0 @@ "lint-staged": {

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