Comparing version 1.5.5 to 1.5.6
@@ -1,1 +0,1 @@ | ||
{"name":"fast-sort","version":"1.5.5","description":"Fast and powerful array sorting. Sort by any property in any direction with easy to read syntax.","main":"sort.js","author":"Stefan Novakovic <stefan.novakovich@gmail.com>","license":"MIT","homepage":"https://github.com/snovakovic/fast-sort#readme","scripts":{"test":"node integration_test/index.js","publish":"node publish"},"repository":{"type":"git","url":"git+https://github.com/snovakovic/js-flock.git"},"bugs":{"url":"https://github.com/snovakovic/js-flock/issues"},"keywords":["sort","sortBy","order","orderBy"]} | ||
{"name":"fast-sort","version":"1.5.6","description":"Fast and powerful array sorting. Sort by any property in any direction with easy to read syntax.","main":"sort.js","author":"Stefan Novakovic <stefan.novakovich@gmail.com>","license":"MIT","homepage":"https://github.com/snovakovic/fast-sort#readme","scripts":{"test":"node integration_test/index.js","publish":"node publish"},"repository":{"type":"git","url":"git+https://github.com/snovakovic/js-flock.git"},"bugs":{"url":"https://github.com/snovakovic/js-flock/issues"},"keywords":["sort","sortBy","order","orderBy"]} |
@@ -12,3 +12,3 @@ # fast-sort | ||
Blazing fast array sorting that **outperforms lodash sorting by ~2x** (in some cases it's more than 5x). | ||
Blazing fast array sorting that **outperforms other popular sort libraries even up to 20x.** | ||
Take a look at the benchmark section for more information about performance. | ||
@@ -25,6 +25,12 @@ | ||
// Sort on multiple properties | ||
sort(users).asc([ | ||
u => u.firstName, | ||
u => u.lastName | ||
]); | ||
// Sort in multiple directions | ||
sort(users).by([ | ||
{ asc: 'name' } | ||
{ desc: 'age' } | ||
{ asc: u => u.name }, | ||
{ desc: u => u.age } | ||
]); | ||
@@ -73,3 +79,3 @@ ``` | ||
sort(users).by([ | ||
{ asc: 'name' } | ||
{ asc: 'name' }, | ||
{ desc: 'age' } | ||
@@ -88,3 +94,3 @@ ]); | ||
const sortedArr = sort(arr).asc(); | ||
console.log(arr) // => [1, 2, 4] | ||
console.log(arr); // => [1, 2, 4] | ||
@@ -94,4 +100,4 @@ // We can easily prevent mutating of input array by using ES6 spread operator | ||
const sortedArr = sort([...arr]).asc(); | ||
console.log(arr) // => [1, 4, 2] | ||
console.log(sortedArr) // => [1, 2, 4] | ||
console.log(arr); // => [1, 4, 2] | ||
console.log(sortedArr); // => [1, 2, 4] | ||
``` | ||
@@ -107,4 +113,3 @@ | ||
Every run of benchmark outputs different results but the results are constantly showing better scores compared to | ||
similar popular sorting libraries. | ||
Every run of benchmark outputs different results but the results are constantly showing better scores compared to similar popular sorting libraries. | ||
@@ -128,8 +133,8 @@ | ||
1) git clone https://github.com/snovakovic/js-flock.git | ||
2) cd js-flock | ||
1) git clone https://github.com/snovakovic/fast-sort.git | ||
2) cd fast-sort/benchmark | ||
3) npm install | ||
4) npm run benchmark:sort | ||
4) npm start | ||
In case you notice any irregularities in benchmark or you want to add sort library to benchmark score | ||
please open issue [here](https://github.com/snovakovic/js-flock/issues) | ||
please open issue [here](https://github.com/snovakovic/fast-sort) |
@@ -50,3 +50,3 @@ (function (global, factory) { | ||
/** | ||
* Used when we have sorting by multyple properties and when current sorter is string | ||
* Used when we have sorting by multiple properties and when current sorter is string | ||
* @example sort(users).asc(['firstName', 'lastName']) | ||
@@ -67,3 +67,3 @@ */ | ||
if (!sortBy) { | ||
throw Error('sort: Invalid \'by\' sorting onfiguration.\n Expecting object with \'asc\' or \'desc\' key'); | ||
throw Error('sort: Invalid \'by\' sorting configuration.\n Expecting object with \'asc\' or \'desc\' key'); | ||
} | ||
@@ -155,3 +155,3 @@ | ||
if (!sortOnProp) { | ||
throw Error('sort: Invalid \'by\' sorting onfiguration.\n Expecting object with \'asc\' or \'desc\' key'); | ||
throw Error('sort: Invalid \'by\' sorting configuration.\n Expecting object with \'asc\' or \'desc\' key'); | ||
} | ||
@@ -158,0 +158,0 @@ return sort(direction, ctx, sortOnProp); |
@@ -1,1 +0,1 @@ | ||
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r.sort=r.sort||{},r.sort.js=n())}(this,function(){"use strict";var r=function(){function r(r,n){var t=[],o=!0,e=!1,i=void 0;try{for(var u,f=r[Symbol.iterator]();!(o=(u=f.next()).done)&&(t.push(u.value),!n||t.length!==n);o=!0);}catch(r){e=!0,i=r}finally{try{!o&&f.return&&f.return()}finally{if(e)throw i}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return r(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n="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},t=function(r,n,t){return n===t?0:n<t?-r:null==n?1:null==t?-1:r},o=function(r,n,o,e){return t(r,o[n],e[n])},e=function(r,n,o,e){return t(r,n(o),n(e))},i=function(r,n,t,o,e,i){return s(r(e),r(i),n,t,o,e,i)},u=function(r,n,t,o,e,i){return s(e[r],i[r],n,t,o,e,i)},f=function(r,n,t,o,e,i){var u=r.asc||r.desc,f=r.asc?1:-1;if(!u)throw Error("sort: Invalid 'by' sorting onfiguration.\n Expecting object with 'asc' or 'desc' key");return c(u)(u,n,t,f,e,i)},c=function(r){var t=void 0===r?"undefined":n(r);return"string"===t?u:"function"===t?i:f},s=function(r,n,o,e,i,u,f){return r===n||null==r&&null==n?o.length>e?c(o[e])(o[e],o,e+1,i,u,f):0:t(i,r,n)},a=function(n,i,u){if(!Array.isArray(i))return i;Array.isArray(u)&&u.length<2&&(u=r(u,1)[0]);var f=void 0;return f=u?"string"==typeof u?o.bind(void 0,n,u):"function"==typeof u?e.bind(void 0,n,u):c(u[0]).bind(void 0,u.shift(),u,0,n):t.bind(void 0,n),i.sort(f)};return function(r){return{asc:function(n){return a(1,r,n)},desc:function(n){return a(-1,r,n)},by:function(n){if(!Array.isArray(r))return r;if(!Array.isArray(n))throw Error("sort: Invalid usage of 'by' sorter. Array syntax is required.\n Did you mean to use 'asc' or 'desc' sorter instead?");if(1===n.length){var t=n[0].asc?1:-1,o=n[0].asc||n[0].desc;if(!o)throw Error("sort: Invalid 'by' sorting onfiguration.\n Expecting object with 'asc' or 'desc' key");return a(t,r,o)}var e=f.bind(void 0,n.shift(),n,0,void 0);return r.sort(e)}}}}); | ||
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r.sort=r.sort||{},r.sort.js=n())}(this,function(){"use strict";var r=function(){function r(r,n){var t=[],o=!0,e=!1,i=void 0;try{for(var u,f=r[Symbol.iterator]();!(o=(u=f.next()).done)&&(t.push(u.value),!n||t.length!==n);o=!0);}catch(r){e=!0,i=r}finally{try{!o&&f.return&&f.return()}finally{if(e)throw i}}return t}return function(n,t){if(Array.isArray(n))return n;if(Symbol.iterator in Object(n))return r(n,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n="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},t=function(r,n,t){return n===t?0:n<t?-r:null==n?1:null==t?-1:r},o=function(r,n,o,e){return t(r,o[n],e[n])},e=function(r,n,o,e){return t(r,n(o),n(e))},i=function(r,n,t,o,e,i){return s(r(e),r(i),n,t,o,e,i)},u=function(r,n,t,o,e,i){return s(e[r],i[r],n,t,o,e,i)},f=function(r,n,t,o,e,i){var u=r.asc||r.desc,f=r.asc?1:-1;if(!u)throw Error("sort: Invalid 'by' sorting configuration.\n Expecting object with 'asc' or 'desc' key");return c(u)(u,n,t,f,e,i)},c=function(r){var t=void 0===r?"undefined":n(r);return"string"===t?u:"function"===t?i:f},s=function(r,n,o,e,i,u,f){return r===n||null==r&&null==n?o.length>e?c(o[e])(o[e],o,e+1,i,u,f):0:t(i,r,n)},a=function(n,i,u){if(!Array.isArray(i))return i;Array.isArray(u)&&u.length<2&&(u=r(u,1)[0]);var f=void 0;return f=u?"string"==typeof u?o.bind(void 0,n,u):"function"==typeof u?e.bind(void 0,n,u):c(u[0]).bind(void 0,u.shift(),u,0,n):t.bind(void 0,n),i.sort(f)};return function(r){return{asc:function(n){return a(1,r,n)},desc:function(n){return a(-1,r,n)},by:function(n){if(!Array.isArray(r))return r;if(!Array.isArray(n))throw Error("sort: Invalid usage of 'by' sorter. Array syntax is required.\n Did you mean to use 'asc' or 'desc' sorter instead?");if(1===n.length){var t=n[0].asc?1:-1,o=n[0].asc||n[0].desc;if(!o)throw Error("sort: Invalid 'by' sorting configuration.\n Expecting object with 'asc' or 'desc' key");return a(t,r,o)}var e=f.bind(void 0,n.shift(),n,0,void 0);return r.sort(e)}}}}); |
@@ -40,3 +40,3 @@ /* eslint no-use-before-define: 0 */ | ||
/** | ||
* Used when we have sorting by multyple properties and when current sorter is string | ||
* Used when we have sorting by multiple properties and when current sorter is string | ||
* @example sort(users).asc(['firstName', 'lastName']) | ||
@@ -57,3 +57,3 @@ */ | ||
if (!sortBy) { | ||
throw Error(`sort: Invalid 'by' sorting onfiguration. | ||
throw Error(`sort: Invalid 'by' sorting configuration. | ||
Expecting object with 'asc' or 'desc' key`); | ||
@@ -140,3 +140,3 @@ } | ||
if (!sortOnProp) { | ||
throw Error(`sort: Invalid 'by' sorting onfiguration. | ||
throw Error(`sort: Invalid 'by' sorting configuration. | ||
Expecting object with 'asc' or 'desc' key`); | ||
@@ -143,0 +143,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18996
134