Comparing version 3.2.1 to 3.3.0
@@ -8,4 +8,8 @@ # Changelog | ||
## [3.2.0] - 2022-06-06 | ||
## [3.3.0] - 2023-04-14 | ||
Added proper support for ESM modules | ||
## [3.2.1] - 2023-01-06 | ||
### Added | ||
@@ -12,0 +16,0 @@ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['fast-sort'] = {})); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.fastSort = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
@@ -6,0 +6,0 @@ |
@@ -1,1 +0,1 @@ | ||
!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)["fast-sort"]={})}(this,function(r){"use strict";function u(t){return function(r,n,e){return t(r,n,e)*e}}var c=function(r,n){if(r)throw Error("Invalid sort config: "+n)},d=function(r){var n=r||{},e=n.asc,t=n.desc,o=e?1:-1,i=e||t;return c(!i,"Expected `asc` or `desc` property"),c(e&&t,"Ambiguous object with `asc` and `desc` config properties"),{order:o,sortBy:i,comparer:r.comparer&&u(r.comparer)}},f=function(p){return function r(n,e,t,o,i,u,c){var f,a;if("string"==typeof n)f=u[n],a=c[n];else{if("function"!=typeof n){var s=d(n);return r(s.sortBy,e,t,s.order,s.comparer||p,u,c)}f=n(u),a=n(c)}var l=i(f,a,o);return(0===l||null==f&&null==a)&&e.length>t?r(e[t],e,t+1,o,i,u,c):l}};function o(r,n,e,t){return Array.isArray(n)?(Array.isArray(e)&&e.length<2&&(e=e[0]),n.sort(function r(e,t,o){if(void 0===e||!0===e)return function(r,n){return t(r,n,o)};if("string"==typeof e)return c(e.includes("."),"String syntax not allowed for nested properties."),function(r,n){return t(r[e],n[e],o)};if("function"==typeof e)return function(r,n){return t(e(r),e(n),o)};if(Array.isArray(e)){var i=f(t);return function(r,n){return i(e[0],e,1,o,t,r,n)}}var n=d(e);return r(n.sortBy,n.comparer||t,n.order)}(e,t,r))):n}function n(e){var t=u(e.comparer);return function(r){var n=Array.isArray(r)&&!e.inPlaceSorting?r.slice():r;return{asc:function(r){return o(1,n,r,t)},desc:function(r){return o(-1,n,r,t)},by:function(r){return o(1,n,r,t)}}}}function e(r,n,e){return null==r?e:null==n?-e:r<n?-1:n<r?1:0}var t=n({comparer:e}),i=n({comparer:e,inPlaceSorting:!0});r.createNewSortInstance=n,r.defaultComparer=e,r.inPlaceSort=i,r.sort=t,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).fastSort={})}(this,function(r){"use strict";function u(t){return function(r,n,e){return t(r,n,e)*e}}var c=function(r,n){if(r)throw Error("Invalid sort config: "+n)},d=function(r){var n=r||{},e=n.asc,t=n.desc,o=e?1:-1,i=e||t;return c(!i,"Expected `asc` or `desc` property"),c(e&&t,"Ambiguous object with `asc` and `desc` config properties"),{order:o,sortBy:i,comparer:r.comparer&&u(r.comparer)}},f=function(p){return function r(n,e,t,o,i,u,c){var f,a;if("string"==typeof n)f=u[n],a=c[n];else{if("function"!=typeof n){var s=d(n);return r(s.sortBy,e,t,s.order,s.comparer||p,u,c)}f=n(u),a=n(c)}var l=i(f,a,o);return(0===l||null==f&&null==a)&&e.length>t?r(e[t],e,t+1,o,i,u,c):l}};function o(r,n,e,t){return Array.isArray(n)?(Array.isArray(e)&&e.length<2&&(e=e[0]),n.sort(function r(e,t,o){if(void 0===e||!0===e)return function(r,n){return t(r,n,o)};if("string"==typeof e)return c(e.includes("."),"String syntax not allowed for nested properties."),function(r,n){return t(r[e],n[e],o)};if("function"==typeof e)return function(r,n){return t(e(r),e(n),o)};if(Array.isArray(e)){var i=f(t);return function(r,n){return i(e[0],e,1,o,t,r,n)}}var n=d(e);return r(n.sortBy,n.comparer||t,n.order)}(e,t,r))):n}function n(e){var t=u(e.comparer);return function(r){var n=Array.isArray(r)&&!e.inPlaceSorting?r.slice():r;return{asc:function(r){return o(1,n,r,t)},desc:function(r){return o(-1,n,r,t)},by:function(r){return o(1,n,r,t)}}}}function e(r,n,e){return null==r?e:null==n?-e:r<n?-1:n<r?1:0}var t=n({comparer:e}),i=n({comparer:e,inPlaceSorting:!0});r.createNewSortInstance=n,r.defaultComparer=e,r.inPlaceSort=i,r.sort=t,Object.defineProperty(r,"__esModule",{value:!0})}); |
{ | ||
"name": "fast-sort", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"description": "Fast easy to use and flexible sorting with TypeScript support", | ||
"main": "dist/sort.min.js", | ||
"module": "dist/sort.es.js", | ||
"author": "Stefan Novakovic <stefan.novakovich@gmail.com>", | ||
@@ -15,2 +13,11 @@ "contributors": [ | ||
"homepage": "https://github.com/snovakovic/fast-sort", | ||
"main": "dist/sort.cjs.js", | ||
"module": "dist/sort.mjs", | ||
"types": "dist/sort.d.ts", | ||
"exports": { | ||
".": { | ||
"require": "./dist/sort.cjs.js", | ||
"import": "./dist/sort.mjs" | ||
} | ||
}, | ||
"scripts": { | ||
@@ -17,0 +24,0 @@ "test": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha -r ts-node/register test/*.spec.ts", |
@@ -11,5 +11,4 @@ # fast-sort | ||
Fast easy to use and flexible sorting with TypeScript support. | ||
For speed comparison of `fast-sort` vs other popular sort libraries check [benchmark](#benchmark) section. | ||
For list of all available features check [highlights](#highlights) section. | ||
Fast-sort is a lightweight (850 bytes gzip), zero-dependency sorting library with TypeScript support. | ||
Its easy-to-use and flexible syntax, combined with [incredible speed](#benchmark) , make it a top choice for developers seeking efficient, reliable, and customizable sorting solutions. | ||
@@ -50,26 +49,5 @@ ## Quick examples | ||
## Highlights | ||
* Sort flat arrays | ||
* Sort array of objects by one or more properties | ||
* Sort in multiple directions | ||
* [Natural sort](#natural-sorting--language-sensitive-sorting) support | ||
* Support for [custom sort](#custom-sorting) instances | ||
* Easy to read syntax | ||
* [Faster](#benchmark) than other popular sort alternatives | ||
* Undefined and null values are always sorted to bottom (with default comparer) | ||
* TypeScript support | ||
* Packed with features in small footprint with 0 dependencies (~ 850 bytes gzip) | ||
* Compatible with any JS environment as Node, Web, etc.. | ||
## Migrating from older versions | ||
Documentation for v2 and older versions is available [here](https://github.com/snovakovic/fast-sort/blob/v2/README.md). | ||
For migrating to v3 you can reference [CHANGELOG](https://github.com/snovakovic/fast-sort/blob/master/CHANGELOG.md) for what has been changed. | ||
## In place sorting | ||
By default `sort` does not mutate provided array it creates new "sorted" instance of array. `inPlaceSort` on other hand mutates provided array by sorting it without creating new array instance. Benefits of `inPlaceSort` is that it's slightly faster and more generous on memory as it's not creating new array instance every time sorting is done. Other than that there is no difference between using one or another. | ||
Fast-sort provides an inPlace sorting option that mutates the original array instead of creating a new instance, resulting in marginally faster and more memory-efficient sorting. However, both the inPlaceSort and default sort methods offer exactly the same functionality. | ||
@@ -178,2 +156,9 @@ ```javascript | ||
## Migrating from older versions | ||
Documentation for v2 and older versions is available [here](https://github.com/snovakovic/fast-sort/blob/v2/README.md). | ||
For migrating to v3 you can reference [CHANGELOG](https://github.com/snovakovic/fast-sort/blob/master/CHANGELOG.md) for what has been changed. | ||
## Benchmark | ||
@@ -211,1 +196,2 @@ | ||
please open issue [here](https://github.com/snovakovic/fast-sort) | ||
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
33821
10
486
194