epiphany/node_modules/fast-sort/dist/sort.min.js
2023-12-09 22:48:07 -08:00

1 line
1.8 KiB
JavaScript

!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 f=function(r,n){if(r)throw Error("Invalid sort config: "+n)},y=function(r){var n=r||{},e=n.asc,t=n.desc,o=e?1:-1,i=e||t;return f(!i,"Expected `asc` or `desc` property"),f(e&&t,"Ambiguous object with `asc` and `desc` config properties"),{order:o,sortBy:i,comparer:r.comparer&&u(r.comparer)}},c=function(l){return function r(n,e,t,o,i,u,f){var c,a;if("string"==typeof n)c=u[n],a=f[n];else{if("function"!=typeof n){var s=y(n);return r(s.sortBy,e,t,s.order,s.comparer||l,u,f)}c=n(u),a=n(f)}var p=i(c,a,o);return(0===p||null==c&&null==a)&&e.length>t?r(e[t],e,t+1,o,i,u,f):p}};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 f(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=c(t);return function(r,n){return i(e[0],e,1,o,t,r,n)}}var n=y(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:typeof r!=typeof n?typeof r<typeof n?-1:1: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})});