exsorted 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +91 -0
  3. package/dist/base/bubble.cjs +1 -0
  4. package/dist/base/bubble.d.mts +18 -0
  5. package/dist/base/bubble.d.ts +18 -0
  6. package/dist/base/bubble.mjs +1 -0
  7. package/dist/base/heap.cjs +1 -0
  8. package/dist/base/heap.d.mts +18 -0
  9. package/dist/base/heap.d.ts +18 -0
  10. package/dist/base/heap.mjs +1 -0
  11. package/dist/base/index.cjs +1 -0
  12. package/dist/base/index.d.mts +7 -0
  13. package/dist/base/index.d.ts +7 -0
  14. package/dist/base/index.mjs +1 -0
  15. package/dist/base/insertion.cjs +1 -0
  16. package/dist/base/insertion.d.mts +18 -0
  17. package/dist/base/insertion.d.ts +18 -0
  18. package/dist/base/insertion.mjs +1 -0
  19. package/dist/base/merge.cjs +1 -0
  20. package/dist/base/merge.d.mts +18 -0
  21. package/dist/base/merge.d.ts +18 -0
  22. package/dist/base/merge.mjs +1 -0
  23. package/dist/base/quick.cjs +1 -0
  24. package/dist/base/quick.d.mts +19 -0
  25. package/dist/base/quick.d.ts +19 -0
  26. package/dist/base/quick.mjs +1 -0
  27. package/dist/base/selection.cjs +1 -0
  28. package/dist/base/selection.d.mts +19 -0
  29. package/dist/base/selection.d.ts +19 -0
  30. package/dist/base/selection.mjs +1 -0
  31. package/dist/chunk-3JE3MTR3.mjs +1 -0
  32. package/dist/chunk-6OACJ5NV.mjs +1 -0
  33. package/dist/chunk-F7APGQXB.mjs +1 -0
  34. package/dist/chunk-FZMEZVLG.mjs +1 -0
  35. package/dist/chunk-J5DRKNXL.mjs +1 -0
  36. package/dist/chunk-KESA4OWP.mjs +1 -0
  37. package/dist/chunk-YWVRJOGW.mjs +1 -0
  38. package/dist/function-type-BAHbNN5P.d.mts +5 -0
  39. package/dist/function-type-BAHbNN5P.d.ts +5 -0
  40. package/dist/index.cjs +1 -0
  41. package/dist/index.d.mts +14 -0
  42. package/dist/index.d.ts +14 -0
  43. package/dist/index.mjs +1 -0
  44. package/dist/meme/index.cjs +1 -0
  45. package/dist/meme/index.d.mts +2 -0
  46. package/dist/meme/index.d.ts +2 -0
  47. package/dist/meme/index.mjs +0 -0
  48. package/package.json +114 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ink01101011
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # exsorted
2
+
3
+ [![npm version](https://img.shields.io/npm/v/exsorted.svg)](https://www.npmjs.com/package/exsorted)
4
+ [![npm downloads](https://img.shields.io/npm/dm/exsorted.svg)](https://www.npmjs.com/package/exsorted)
5
+ [![CI](https://github.com/Ink01101011/exsorted/actions/workflows/ci.yml/badge.svg)](https://github.com/Ink01101011/exsorted/actions/workflows/ci.yml)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
7
+ [![Bundle size](https://img.shields.io/bundlephobia/minzip/exsorted)](https://bundlephobia.com/package/exsorted)
8
+ [![Node.js](https://img.shields.io/node/v/exsorted)](https://www.npmjs.com/package/exsorted)
9
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
10
+
11
+ A lightweight, fully-typed TypeScript library of sorting algorithms — ready to use in any TypeScript or JavaScript project.
12
+
13
+ ## Algorithms
14
+
15
+ | Algorithm | Average Time | Worst Time | Space | Stable | In-place |
16
+ | -------------- | ------------ | ---------- | -------- | ------ | -------- |
17
+ | Bubble Sort | O(n²) | O(n²) | O(1) | ✅ | ✅ |
18
+ | Insertion Sort | O(n²) | O(n²) | O(1) | ✅ | ✅ |
19
+ | Selection Sort | O(n²) | O(n²) | O(1) | ❌ | ✅ |
20
+ | Merge Sort | O(n log n) | O(n log n) | O(n) | ✅ | ❌ |
21
+ | Quick Sort | O(n log n) | O(n²) | O(log n) | ❌ | ✅ |
22
+ | Heap Sort | O(n log n) | O(n log n) | O(1) | ❌ | ✅ |
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ npm install exsorted
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ```typescript
33
+ import { bubbleSort, insertionSort, selectionSort, mergeSort, quickSort, heapSort, compareBy } from 'exsorted';
34
+
35
+ // Sort numbers ascending (default)
36
+ bubbleSort([5, 3, 8, 1, 2]); // [1, 2, 3, 5, 8]
37
+ mergeSort([5, 3, 8, 1, 2]); // [1, 2, 3, 5, 8]
38
+
39
+ // Sort numbers descending (custom comparator)
40
+ quickSort([5, 3, 8, 1, 2], (a, b) => b - a); // [8, 5, 3, 2, 1]
41
+
42
+ // Sort strings
43
+ insertionSort(['banana', 'apple', 'cherry']); // ['apple', 'banana', 'cherry']
44
+
45
+ // Sort objects
46
+ interface Person {
47
+ name: string;
48
+ age: number;
49
+ }
50
+ const people: Person[] = [
51
+ { name: 'Alice', age: 30 },
52
+ { name: 'Bob', age: 25 },
53
+ { name: 'Charlie', age: 35 },
54
+ ];
55
+ heapSort(people, (a, b) => a.age - b.age);
56
+ // [{ name: 'Bob', age: 25 }, { name: 'Alice', age: 30 }, { name: 'Charlie', age: 35 }]
57
+
58
+ // Or use compareBy helper for cleaner typed comparators
59
+ quickSort(
60
+ people,
61
+ compareBy((p) => p.age),
62
+ );
63
+
64
+ // Subpath import (new namespace structure)
65
+ import { selectionSort as baseSelectionSort } from 'exsorted/selection';
66
+ baseSelectionSort([3, 1, 2]); // [1, 2, 3]
67
+ ```
68
+
69
+ ### API
70
+
71
+ Every function shares the same signature:
72
+
73
+ ```typescript
74
+ function algorithmName<T>(arr: T[], compareFn?: (a: T, b: T) => number): T[];
75
+ ```
76
+
77
+ - **`arr`** — the array to sort.
78
+ _Most algorithms sort in-place (mutate `arr`). `mergeSort` is the exception — it returns a new array and leaves the original untouched._
79
+ - **`compareFn`** _(optional)_ — behaves like the native `Array.prototype.sort` comparator:
80
+ - return **negative** if `a` should come before `b`
81
+ - return **positive** if `a` should come after `b`
82
+ - return **0** if order does not matter
83
+ Defaults to a dynamic deterministic comparator:
84
+ supports `number`, `string`, `bigint`, `boolean`, `Date`, arrays, and objects.
85
+ For domain-specific object ordering, passing an explicit `compareFn` is still recommended.
86
+
87
+ `compareBy(selector, compareFn?)` helper is exported to build typed object comparators.
88
+
89
+ ## License
90
+
91
+ [MIT](LICENSE)
@@ -0,0 +1 @@
1
+ 'use strict';function N(e,n){let i=p(e),o=p(n);if(i!==o)return i-o;if(typeof e=="number"&&typeof n=="number")return Number.isNaN(e)&&Number.isNaN(n)?0:Number.isNaN(e)?1:Number.isNaN(n)?-1:e-n;if(typeof e=="bigint"&&typeof n=="bigint")return e<n?-1:e>n?1:0;if(typeof e=="boolean"&&typeof n=="boolean")return Number(e)-Number(n);if(e instanceof Date&&n instanceof Date){let t=e.getTime(),f=n.getTime();return Number.isNaN(t)&&Number.isNaN(f)?0:Number.isNaN(t)?1:Number.isNaN(f)?-1:t-f}let u=b(e),r=b(n);return u<r?-1:u>r?1:0}function p(e){return e===void 0?0:e===null?1:typeof e=="boolean"?2:typeof e=="number"?3:typeof e=="bigint"?4:typeof e=="string"?5:e instanceof Date?6:Array.isArray(e)?7:typeof e=="object"?8:typeof e=="symbol"?9:10}function b(e){return e===void 0?"undefined":e===null?"null":typeof e=="symbol"?e.toString():typeof e=="function"?e.name||"anonymous":d(e)}function d(e){let n=new Set,i=new WeakMap,o=1;function u(t){let f=i.get(t);if(f!==void 0)return f;let s=o++;return i.set(t,s),s}function r(t){if(t===null)return "null";if(typeof t!="object")return String(t);let f=u(t);if(n.has(t))return `[Circular#${f}]`;n.add(t);let s;return Array.isArray(t)?s=`[${t.map(r).join(",")}]`:t instanceof Date?s=`Date:${t.toISOString()}`:s=`{${Object.entries(t).sort(([m],[c])=>m<c?-1:m>c?1:0).map(([m,c])=>`${m}:${r(c)}`).join(",")}}`,n.delete(t),s}return r(e)}function y(e,n=N){let i=e.length;for(let o=0;o<i-1;o++){let u=false;for(let r=0;r<i-1-o;r++)n(e[r],e[r+1])>0&&([e[r],e[r+1]]=[e[r+1],e[r]],u=true);if(!u)break}return e}exports.bubbleSort=y;
@@ -0,0 +1,18 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.mjs';
2
+
3
+ /**
4
+ * Bubble Sort
5
+ *
6
+ * Repeatedly steps through the list, compares adjacent elements, and swaps
7
+ * them if they are in the wrong order.
8
+ *
9
+ * Time complexity: O(n²) average and worst case, O(n) best case
10
+ * Space complexity: O(1)
11
+ *
12
+ * @param arr - The array to sort (mutated in place)
13
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
14
+ * @returns The sorted array
15
+ */
16
+ declare function bubbleSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
17
+
18
+ export { bubbleSort };
@@ -0,0 +1,18 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.js';
2
+
3
+ /**
4
+ * Bubble Sort
5
+ *
6
+ * Repeatedly steps through the list, compares adjacent elements, and swaps
7
+ * them if they are in the wrong order.
8
+ *
9
+ * Time complexity: O(n²) average and worst case, O(n) best case
10
+ * Space complexity: O(1)
11
+ *
12
+ * @param arr - The array to sort (mutated in place)
13
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
14
+ * @returns The sorted array
15
+ */
16
+ declare function bubbleSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
17
+
18
+ export { bubbleSort };
@@ -0,0 +1 @@
1
+ export{a as bubbleSort}from'../chunk-6OACJ5NV.mjs';import'../chunk-J5DRKNXL.mjs';
@@ -0,0 +1 @@
1
+ 'use strict';function b(n,e){let i=y(n),r=y(e);if(i!==r)return i-r;if(typeof n=="number"&&typeof e=="number")return Number.isNaN(n)&&Number.isNaN(e)?0:Number.isNaN(n)?1:Number.isNaN(e)?-1:n-e;if(typeof n=="bigint"&&typeof e=="bigint")return n<e?-1:n>e?1:0;if(typeof n=="boolean"&&typeof e=="boolean")return Number(n)-Number(e);if(n instanceof Date&&e instanceof Date){let t=n.getTime(),u=e.getTime();return Number.isNaN(t)&&Number.isNaN(u)?0:Number.isNaN(t)?1:Number.isNaN(u)?-1:t-u}let o=N(n),f=N(e);return o<f?-1:o>f?1:0}function y(n){return n===void 0?0:n===null?1:typeof n=="boolean"?2:typeof n=="number"?3:typeof n=="bigint"?4:typeof n=="string"?5:n instanceof Date?6:Array.isArray(n)?7:typeof n=="object"?8:typeof n=="symbol"?9:10}function N(n){return n===void 0?"undefined":n===null?"null":typeof n=="symbol"?n.toString():typeof n=="function"?n.name||"anonymous":d(n)}function d(n){let e=new Set,i=new WeakMap,r=1;function o(t){let u=i.get(t);if(u!==void 0)return u;let s=r++;return i.set(t,s),s}function f(t){if(t===null)return "null";if(typeof t!="object")return String(t);let u=o(t);if(e.has(t))return `[Circular#${u}]`;e.add(t);let s;return Array.isArray(t)?s=`[${t.map(f).join(",")}]`:t instanceof Date?s=`Date:${t.toISOString()}`:s=`{${Object.entries(t).sort(([m],[c])=>m<c?-1:m>c?1:0).map(([m,c])=>`${m}:${f(c)}`).join(",")}}`,e.delete(t),s}return f(n)}function g(n,e=b){let i=n.length;for(let r=Math.floor(i/2)-1;r>=0;r--)p(n,i,r,e);for(let r=i-1;r>0;r--)[n[0],n[r]]=[n[r],n[0]],p(n,r,0,e);return n}function p(n,e,i,r){let o=i,f=2*i+1,t=2*i+2;f<e&&r(n[f],n[o])>0&&(o=f),t<e&&r(n[t],n[o])>0&&(o=t),o!==i&&([n[i],n[o]]=[n[o],n[i]],p(n,e,o,r));}exports.heapSort=g;
@@ -0,0 +1,18 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.mjs';
2
+
3
+ /**
4
+ * Heap Sort
5
+ *
6
+ * Builds a max-heap from the array and then repeatedly extracts the maximum
7
+ * element, placing it at the end of the array.
8
+ *
9
+ * Time complexity: O(n log n) in all cases
10
+ * Space complexity: O(1)
11
+ *
12
+ * @param arr - The array to sort (mutated in place)
13
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
14
+ * @returns The sorted array
15
+ */
16
+ declare function heapSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
17
+
18
+ export { heapSort };
@@ -0,0 +1,18 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.js';
2
+
3
+ /**
4
+ * Heap Sort
5
+ *
6
+ * Builds a max-heap from the array and then repeatedly extracts the maximum
7
+ * element, placing it at the end of the array.
8
+ *
9
+ * Time complexity: O(n log n) in all cases
10
+ * Space complexity: O(1)
11
+ *
12
+ * @param arr - The array to sort (mutated in place)
13
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
14
+ * @returns The sorted array
15
+ */
16
+ declare function heapSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
17
+
18
+ export { heapSort };
@@ -0,0 +1 @@
1
+ export{a as heapSort}from'../chunk-FZMEZVLG.mjs';import'../chunk-J5DRKNXL.mjs';
@@ -0,0 +1 @@
1
+ 'use strict';function m(t,e){let n=y(t),o=y(e);if(n!==o)return n-o;if(typeof t=="number"&&typeof e=="number")return Number.isNaN(t)&&Number.isNaN(e)?0:Number.isNaN(t)?1:Number.isNaN(e)?-1:t-e;if(typeof t=="bigint"&&typeof e=="bigint")return t<e?-1:t>e?1:0;if(typeof t=="boolean"&&typeof e=="boolean")return Number(t)-Number(e);if(t instanceof Date&&e instanceof Date){let f=t.getTime(),u=e.getTime();return Number.isNaN(f)&&Number.isNaN(u)?0:Number.isNaN(f)?1:Number.isNaN(u)?-1:f-u}let i=S(t),r=S(e);return i<r?-1:i>r?1:0}function y(t){return t===void 0?0:t===null?1:typeof t=="boolean"?2:typeof t=="number"?3:typeof t=="bigint"?4:typeof t=="string"?5:t instanceof Date?6:Array.isArray(t)?7:typeof t=="object"?8:typeof t=="symbol"?9:10}function S(t){return t===void 0?"undefined":t===null?"null":typeof t=="symbol"?t.toString():typeof t=="function"?t.name||"anonymous":b(t)}function b(t){let e=new Set,n=new WeakMap,o=1;function i(f){let u=n.get(f);if(u!==void 0)return u;let s=o++;return n.set(f,s),s}function r(f){if(f===null)return "null";if(typeof f!="object")return String(f);let u=i(f);if(e.has(f))return `[Circular#${u}]`;e.add(f);let s;return Array.isArray(f)?s=`[${f.map(r).join(",")}]`:f instanceof Date?s=`Date:${f.toISOString()}`:s=`{${Object.entries(f).sort(([p],[c])=>p<c?-1:p>c?1:0).map(([p,c])=>`${p}:${r(c)}`).join(",")}}`,e.delete(f),s}return r(t)}function N(t,e=m){let n=t.length;for(let o=0;o<n-1;o++){let i=false;for(let r=0;r<n-1-o;r++)e(t[r],t[r+1])>0&&([t[r],t[r+1]]=[t[r+1],t[r]],i=true);if(!i)break}return t}function C(t,e=m){let n=t.length;for(let o=Math.floor(n/2)-1;o>=0;o--)l(t,n,o,e);for(let o=n-1;o>0;o--)[t[0],t[o]]=[t[o],t[0]],l(t,o,0,e);return t}function l(t,e,n,o){let i=n,r=2*n+1,f=2*n+2;r<e&&o(t[r],t[i])>0&&(i=r),f<e&&o(t[f],t[i])>0&&(i=f),i!==n&&([t[n],t[i]]=[t[i],t[n]],l(t,e,i,o));}function x(t,e=m){for(let n=1;n<t.length;n++){let o=t[n],i=n-1;for(;i>=0&&e(t[i],o)>0;)t[i+1]=t[i],i--;t[i+1]=o;}return t}function d(t,e=m){if(t.length<=1)return t.slice();let n=Math.floor(t.length/2),o=d(t.slice(0,n),e),i=d(t.slice(n),e);return A(o,i,e)}function A(t,e,n){let o=[],i=0,r=0;for(;i<t.length&&r<e.length;)n(t[i],e[r])<=0?o.push(t[i++]):o.push(e[r++]);for(;i<t.length;)o.push(t[i++]);for(;r<e.length;)o.push(e[r++]);return o}function g(t,e=m){return T(t,0,t.length-1,e),t}function T(t,e,n,o){if(e<n){let i=k(t,e,n,o);T(t,e,i-1,o),T(t,i+1,n,o);}}function k(t,e,n,o){let i=Math.floor((e+n)/2);o(t[i],t[e])<0&&([t[e],t[i]]=[t[i],t[e]]),o(t[n],t[e])<0&&([t[e],t[n]]=[t[n],t[e]]),o(t[i],t[n])>0&&([t[i],t[n]]=[t[n],t[i]]),[t[i],t[n]]=[t[n],t[i]];let r=t[n],f=e-1;for(let u=e;u<n;u++)o(t[u],r)<=0&&(f++,[t[f],t[u]]=[t[u],t[f]]);return [t[f+1],t[n]]=[t[n],t[f+1]],f+1}function j(t,e=m){let n=t.length;for(let o=0;o<n-1;o++){let i=o;for(let r=o+1;r<n;r++)e(t[r],t[i])<0&&(i=r);i!==o&&([t[o],t[i]]=[t[i],t[o]]);}return t}exports.bubbleSort=N;exports.heapSort=C;exports.insertionSort=x;exports.mergeSort=d;exports.quickSort=g;exports.selectionSort=j;
@@ -0,0 +1,7 @@
1
+ export { bubbleSort } from './bubble.mjs';
2
+ export { heapSort } from './heap.mjs';
3
+ export { insertionSort } from './insertion.mjs';
4
+ export { mergeSort } from './merge.mjs';
5
+ export { quickSort } from './quick.mjs';
6
+ export { selectionSort } from './selection.mjs';
7
+ import '../function-type-BAHbNN5P.mjs';
@@ -0,0 +1,7 @@
1
+ export { bubbleSort } from './bubble.js';
2
+ export { heapSort } from './heap.js';
3
+ export { insertionSort } from './insertion.js';
4
+ export { mergeSort } from './merge.js';
5
+ export { quickSort } from './quick.js';
6
+ export { selectionSort } from './selection.js';
7
+ import '../function-type-BAHbNN5P.js';
@@ -0,0 +1 @@
1
+ export{a as bubbleSort}from'../chunk-6OACJ5NV.mjs';export{a as heapSort}from'../chunk-FZMEZVLG.mjs';export{a as insertionSort}from'../chunk-YWVRJOGW.mjs';export{a as mergeSort}from'../chunk-3JE3MTR3.mjs';export{a as quickSort}from'../chunk-F7APGQXB.mjs';export{a as selectionSort}from'../chunk-KESA4OWP.mjs';import'../chunk-J5DRKNXL.mjs';
@@ -0,0 +1 @@
1
+ 'use strict';function N(n,e){let i=p(n),f=p(e);if(i!==f)return i-f;if(typeof n=="number"&&typeof e=="number")return Number.isNaN(n)&&Number.isNaN(e)?0:Number.isNaN(n)?1:Number.isNaN(e)?-1:n-e;if(typeof n=="bigint"&&typeof e=="bigint")return n<e?-1:n>e?1:0;if(typeof n=="boolean"&&typeof e=="boolean")return Number(n)-Number(e);if(n instanceof Date&&e instanceof Date){let t=n.getTime(),o=e.getTime();return Number.isNaN(t)&&Number.isNaN(o)?0:Number.isNaN(t)?1:Number.isNaN(o)?-1:t-o}let r=y(n),s=y(e);return r<s?-1:r>s?1:0}function p(n){return n===void 0?0:n===null?1:typeof n=="boolean"?2:typeof n=="number"?3:typeof n=="bigint"?4:typeof n=="string"?5:n instanceof Date?6:Array.isArray(n)?7:typeof n=="object"?8:typeof n=="symbol"?9:10}function y(n){return n===void 0?"undefined":n===null?"null":typeof n=="symbol"?n.toString():typeof n=="function"?n.name||"anonymous":d(n)}function d(n){let e=new Set,i=new WeakMap,f=1;function r(t){let o=i.get(t);if(o!==void 0)return o;let u=f++;return i.set(t,u),u}function s(t){if(t===null)return "null";if(typeof t!="object")return String(t);let o=r(t);if(e.has(t))return `[Circular#${o}]`;e.add(t);let u;return Array.isArray(t)?u=`[${t.map(s).join(",")}]`:t instanceof Date?u=`Date:${t.toISOString()}`:u=`{${Object.entries(t).sort(([m],[c])=>m<c?-1:m>c?1:0).map(([m,c])=>`${m}:${s(c)}`).join(",")}}`,e.delete(t),u}return s(n)}function b(n,e=N){for(let i=1;i<n.length;i++){let f=n[i],r=i-1;for(;r>=0&&e(n[r],f)>0;)n[r+1]=n[r],r--;n[r+1]=f;}return n}exports.insertionSort=b;
@@ -0,0 +1,18 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.mjs';
2
+
3
+ /**
4
+ * Insertion Sort
5
+ *
6
+ * Builds the sorted array one element at a time by inserting each new element
7
+ * into its correct position among the already-sorted elements.
8
+ *
9
+ * Time complexity: O(n²) average and worst case, O(n) best case
10
+ * Space complexity: O(1)
11
+ *
12
+ * @param arr - The array to sort (mutated in place)
13
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
14
+ * @returns The sorted array
15
+ */
16
+ declare function insertionSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
17
+
18
+ export { insertionSort };
@@ -0,0 +1,18 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.js';
2
+
3
+ /**
4
+ * Insertion Sort
5
+ *
6
+ * Builds the sorted array one element at a time by inserting each new element
7
+ * into its correct position among the already-sorted elements.
8
+ *
9
+ * Time complexity: O(n²) average and worst case, O(n) best case
10
+ * Space complexity: O(1)
11
+ *
12
+ * @param arr - The array to sort (mutated in place)
13
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
14
+ * @returns The sorted array
15
+ */
16
+ declare function insertionSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
17
+
18
+ export { insertionSort };
@@ -0,0 +1 @@
1
+ export{a as insertionSort}from'../chunk-YWVRJOGW.mjs';import'../chunk-J5DRKNXL.mjs';
@@ -0,0 +1 @@
1
+ 'use strict';function y(e,n){let u=N(e),r=N(n);if(u!==r)return u-r;if(typeof e=="number"&&typeof n=="number")return Number.isNaN(e)&&Number.isNaN(n)?0:Number.isNaN(e)?1:Number.isNaN(n)?-1:e-n;if(typeof e=="bigint"&&typeof n=="bigint")return e<n?-1:e>n?1:0;if(typeof e=="boolean"&&typeof n=="boolean")return Number(e)-Number(n);if(e instanceof Date&&n instanceof Date){let t=e.getTime(),f=n.getTime();return Number.isNaN(t)&&Number.isNaN(f)?0:Number.isNaN(t)?1:Number.isNaN(f)?-1:t-f}let i=d(e),o=d(n);return i<o?-1:i>o?1:0}function N(e){return e===void 0?0:e===null?1:typeof e=="boolean"?2:typeof e=="number"?3:typeof e=="bigint"?4:typeof e=="string"?5:e instanceof Date?6:Array.isArray(e)?7:typeof e=="object"?8:typeof e=="symbol"?9:10}function d(e){return e===void 0?"undefined":e===null?"null":typeof e=="symbol"?e.toString():typeof e=="function"?e.name||"anonymous":g(e)}function g(e){let n=new Set,u=new WeakMap,r=1;function i(t){let f=u.get(t);if(f!==void 0)return f;let s=r++;return u.set(t,s),s}function o(t){if(t===null)return "null";if(typeof t!="object")return String(t);let f=i(t);if(n.has(t))return `[Circular#${f}]`;n.add(t);let s;return Array.isArray(t)?s=`[${t.map(o).join(",")}]`:t instanceof Date?s=`Date:${t.toISOString()}`:s=`{${Object.entries(t).sort(([m],[c])=>m<c?-1:m>c?1:0).map(([m,c])=>`${m}:${o(c)}`).join(",")}}`,n.delete(t),s}return o(e)}function p(e,n=y){if(e.length<=1)return e.slice();let u=Math.floor(e.length/2),r=p(e.slice(0,u),n),i=p(e.slice(u),n);return l(r,i,n)}function l(e,n,u){let r=[],i=0,o=0;for(;i<e.length&&o<n.length;)u(e[i],n[o])<=0?r.push(e[i++]):r.push(n[o++]);for(;i<e.length;)r.push(e[i++]);for(;o<n.length;)r.push(n[o++]);return r}exports.mergeSort=p;
@@ -0,0 +1,18 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.mjs';
2
+
3
+ /**
4
+ * Merge Sort
5
+ *
6
+ * Divides the array into halves, recursively sorts each half, then merges the
7
+ * sorted halves back together.
8
+ *
9
+ * Time complexity: O(n log n) in all cases
10
+ * Space complexity: O(n)
11
+ *
12
+ * @param arr - The array to sort (a new sorted array is returned)
13
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
14
+ * @returns A new sorted array
15
+ */
16
+ declare function mergeSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
17
+
18
+ export { mergeSort };
@@ -0,0 +1,18 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.js';
2
+
3
+ /**
4
+ * Merge Sort
5
+ *
6
+ * Divides the array into halves, recursively sorts each half, then merges the
7
+ * sorted halves back together.
8
+ *
9
+ * Time complexity: O(n log n) in all cases
10
+ * Space complexity: O(n)
11
+ *
12
+ * @param arr - The array to sort (a new sorted array is returned)
13
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
14
+ * @returns A new sorted array
15
+ */
16
+ declare function mergeSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
17
+
18
+ export { mergeSort };
@@ -0,0 +1 @@
1
+ export{a as mergeSort}from'../chunk-3JE3MTR3.mjs';import'../chunk-J5DRKNXL.mjs';
@@ -0,0 +1 @@
1
+ 'use strict';function y(n,t){let i=d(n),f=d(t);if(i!==f)return i-f;if(typeof n=="number"&&typeof t=="number")return Number.isNaN(n)&&Number.isNaN(t)?0:Number.isNaN(n)?1:Number.isNaN(t)?-1:n-t;if(typeof n=="bigint"&&typeof t=="bigint")return n<t?-1:n>t?1:0;if(typeof n=="boolean"&&typeof t=="boolean")return Number(n)-Number(t);if(n instanceof Date&&t instanceof Date){let e=n.getTime(),r=t.getTime();return Number.isNaN(e)&&Number.isNaN(r)?0:Number.isNaN(e)?1:Number.isNaN(r)?-1:e-r}let o=N(n),u=N(t);return o<u?-1:o>u?1:0}function d(n){return n===void 0?0:n===null?1:typeof n=="boolean"?2:typeof n=="number"?3:typeof n=="bigint"?4:typeof n=="string"?5:n instanceof Date?6:Array.isArray(n)?7:typeof n=="object"?8:typeof n=="symbol"?9:10}function N(n){return n===void 0?"undefined":n===null?"null":typeof n=="symbol"?n.toString():typeof n=="function"?n.name||"anonymous":b(n)}function b(n){let t=new Set,i=new WeakMap,f=1;function o(e){let r=i.get(e);if(r!==void 0)return r;let s=f++;return i.set(e,s),s}function u(e){if(e===null)return "null";if(typeof e!="object")return String(e);let r=o(e);if(t.has(e))return `[Circular#${r}]`;t.add(e);let s;return Array.isArray(e)?s=`[${e.map(u).join(",")}]`:e instanceof Date?s=`Date:${e.toISOString()}`:s=`{${Object.entries(e).sort(([m],[c])=>m<c?-1:m>c?1:0).map(([m,c])=>`${m}:${u(c)}`).join(",")}}`,t.delete(e),s}return u(n)}function T(n,t=y){return p(n,0,n.length-1,t),n}function p(n,t,i,f){if(t<i){let o=k(n,t,i,f);p(n,t,o-1,f),p(n,o+1,i,f);}}function k(n,t,i,f){let o=Math.floor((t+i)/2);f(n[o],n[t])<0&&([n[t],n[o]]=[n[o],n[t]]),f(n[i],n[t])<0&&([n[t],n[i]]=[n[i],n[t]]),f(n[o],n[i])>0&&([n[o],n[i]]=[n[i],n[o]]),[n[o],n[i]]=[n[i],n[o]];let u=n[i],e=t-1;for(let r=t;r<i;r++)f(n[r],u)<=0&&(e++,[n[e],n[r]]=[n[r],n[e]]);return [n[e+1],n[i]]=[n[i],n[e+1]],e+1}exports.quickSort=T;
@@ -0,0 +1,19 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.mjs';
2
+
3
+ /**
4
+ * Quick Sort
5
+ *
6
+ * Selects a pivot element and partitions the array around it so that elements
7
+ * less than the pivot come before it and elements greater come after, then
8
+ * recursively sorts the sub-arrays.
9
+ *
10
+ * Time complexity: O(n log n) average, O(n²) worst case
11
+ * Space complexity: O(log n) average (call stack)
12
+ *
13
+ * @param arr - The array to sort (mutated in place)
14
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
15
+ * @returns The sorted array
16
+ */
17
+ declare function quickSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
18
+
19
+ export { quickSort };
@@ -0,0 +1,19 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.js';
2
+
3
+ /**
4
+ * Quick Sort
5
+ *
6
+ * Selects a pivot element and partitions the array around it so that elements
7
+ * less than the pivot come before it and elements greater come after, then
8
+ * recursively sorts the sub-arrays.
9
+ *
10
+ * Time complexity: O(n log n) average, O(n²) worst case
11
+ * Space complexity: O(log n) average (call stack)
12
+ *
13
+ * @param arr - The array to sort (mutated in place)
14
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
15
+ * @returns The sorted array
16
+ */
17
+ declare function quickSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
18
+
19
+ export { quickSort };
@@ -0,0 +1 @@
1
+ export{a as quickSort}from'../chunk-F7APGQXB.mjs';import'../chunk-J5DRKNXL.mjs';
@@ -0,0 +1 @@
1
+ 'use strict';function d(n,e){let f=p(n),r=p(e);if(f!==r)return f-r;if(typeof n=="number"&&typeof e=="number")return Number.isNaN(n)&&Number.isNaN(e)?0:Number.isNaN(n)?1:Number.isNaN(e)?-1:n-e;if(typeof n=="bigint"&&typeof e=="bigint")return n<e?-1:n>e?1:0;if(typeof n=="boolean"&&typeof e=="boolean")return Number(n)-Number(e);if(n instanceof Date&&e instanceof Date){let t=n.getTime(),u=e.getTime();return Number.isNaN(t)&&Number.isNaN(u)?0:Number.isNaN(t)?1:Number.isNaN(u)?-1:t-u}let o=N(n),i=N(e);return o<i?-1:o>i?1:0}function p(n){return n===void 0?0:n===null?1:typeof n=="boolean"?2:typeof n=="number"?3:typeof n=="bigint"?4:typeof n=="string"?5:n instanceof Date?6:Array.isArray(n)?7:typeof n=="object"?8:typeof n=="symbol"?9:10}function N(n){return n===void 0?"undefined":n===null?"null":typeof n=="symbol"?n.toString():typeof n=="function"?n.name||"anonymous":y(n)}function y(n){let e=new Set,f=new WeakMap,r=1;function o(t){let u=f.get(t);if(u!==void 0)return u;let s=r++;return f.set(t,s),s}function i(t){if(t===null)return "null";if(typeof t!="object")return String(t);let u=o(t);if(e.has(t))return `[Circular#${u}]`;e.add(t);let s;return Array.isArray(t)?s=`[${t.map(i).join(",")}]`:t instanceof Date?s=`Date:${t.toISOString()}`:s=`{${Object.entries(t).sort(([m],[c])=>m<c?-1:m>c?1:0).map(([m,c])=>`${m}:${i(c)}`).join(",")}}`,e.delete(t),s}return i(n)}function b(n,e=d){let f=n.length;for(let r=0;r<f-1;r++){let o=r;for(let i=r+1;i<f;i++)e(n[i],n[o])<0&&(o=i);o!==r&&([n[r],n[o]]=[n[o],n[r]]);}return n}exports.selectionSort=b;
@@ -0,0 +1,19 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.mjs';
2
+
3
+ /**
4
+ * Selection Sort
5
+ *
6
+ * Divides the array into a sorted and an unsorted region, repeatedly selecting
7
+ * the minimum element from the unsorted region and moving it to the end of the
8
+ * sorted region.
9
+ *
10
+ * Time complexity: O(n²) in all cases
11
+ * Space complexity: O(1)
12
+ *
13
+ * @param arr - The array to sort (mutated in place)
14
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
15
+ * @returns The sorted array
16
+ */
17
+ declare function selectionSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
18
+
19
+ export { selectionSort };
@@ -0,0 +1,19 @@
1
+ import { C as CompareFn, a as SortedArray } from '../function-type-BAHbNN5P.js';
2
+
3
+ /**
4
+ * Selection Sort
5
+ *
6
+ * Divides the array into a sorted and an unsorted region, repeatedly selecting
7
+ * the minimum element from the unsorted region and moving it to the end of the
8
+ * sorted region.
9
+ *
10
+ * Time complexity: O(n²) in all cases
11
+ * Space complexity: O(1)
12
+ *
13
+ * @param arr - The array to sort (mutated in place)
14
+ * @param compareFn - Optional comparator; defaults to ascending numeric/lexicographic order
15
+ * @returns The sorted array
16
+ */
17
+ declare function selectionSort<T>(arr: T[], compareFn?: CompareFn<T>): SortedArray<T>;
18
+
19
+ export { selectionSort };
@@ -0,0 +1 @@
1
+ export{a as selectionSort}from'../chunk-KESA4OWP.mjs';import'../chunk-J5DRKNXL.mjs';
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-J5DRKNXL.mjs';function s(e,t=a){if(e.length<=1)return e.slice();let l=Math.floor(e.length/2),o=s(e.slice(0,l),t),r=s(e.slice(l),t);return u(o,r,t)}function u(e,t,l){let o=[],r=0,n=0;for(;r<e.length&&n<t.length;)l(e[r],t[n])<=0?o.push(e[r++]):o.push(t[n++]);for(;r<e.length;)o.push(e[r++]);for(;n<t.length;)o.push(t[n++]);return o}export{s as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-J5DRKNXL.mjs';function p(e,l=a){let r=e.length;for(let t=0;t<r-1;t++){let f=false;for(let o=0;o<r-1-t;o++)l(e[o],e[o+1])>0&&([e[o],e[o+1]]=[e[o+1],e[o]],f=true);if(!f)break}return e}export{p as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-J5DRKNXL.mjs';function i(t,o=a){return T(t,0,t.length-1,o),t}function T(t,o,n,f){if(o<n){let e=S(t,o,n,f);T(t,o,e-1,f),T(t,e+1,n,f);}}function S(t,o,n,f){let e=Math.floor((o+n)/2);f(t[e],t[o])<0&&([t[o],t[e]]=[t[e],t[o]]),f(t[n],t[o])<0&&([t[o],t[n]]=[t[n],t[o]]),f(t[e],t[n])>0&&([t[e],t[n]]=[t[n],t[e]]),[t[e],t[n]]=[t[n],t[e]];let d=t[n],u=o-1;for(let m=o;m<n;m++)f(t[m],d)<=0&&(u++,[t[u],t[m]]=[t[m],t[u]]);return [t[u+1],t[n]]=[t[n],t[u+1]],u+1}export{i as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-J5DRKNXL.mjs';function h(e,i=a){let f=e.length;for(let t=Math.floor(f/2)-1;t>=0;t--)l(e,f,t,i);for(let t=f-1;t>0;t--)[e[0],e[t]]=[e[t],e[0]],l(e,t,0,i);return e}function l(e,i,f,t){let o=f,n=2*f+1,p=2*f+2;n<i&&t(e[n],e[o])>0&&(o=n),p<i&&t(e[p],e[o])>0&&(o=p),o!==f&&([e[f],e[o]]=[e[o],e[f]],l(e,i,o,t));}export{h as a};
@@ -0,0 +1 @@
1
+ function b(n,r){let f=N(n),u=N(r);if(f!==u)return f-u;if(typeof n=="number"&&typeof r=="number")return Number.isNaN(n)&&Number.isNaN(r)?0:Number.isNaN(n)?1:Number.isNaN(r)?-1:n-r;if(typeof n=="bigint"&&typeof r=="bigint")return n<r?-1:n>r?1:0;if(typeof n=="boolean"&&typeof r=="boolean")return Number(n)-Number(r);if(n instanceof Date&&r instanceof Date){let e=n.getTime(),t=r.getTime();return Number.isNaN(e)&&Number.isNaN(t)?0:Number.isNaN(e)?1:Number.isNaN(t)?-1:e-t}let s=y(n),o=y(r);return s<o?-1:s>o?1:0}function N(n){return n===void 0?0:n===null?1:typeof n=="boolean"?2:typeof n=="number"?3:typeof n=="bigint"?4:typeof n=="string"?5:n instanceof Date?6:Array.isArray(n)?7:typeof n=="object"?8:typeof n=="symbol"?9:10}function y(n){return n===void 0?"undefined":n===null?"null":typeof n=="symbol"?n.toString():typeof n=="function"?n.name||"anonymous":p(n)}function p(n){let r=new Set,f=new WeakMap,u=1;function s(e){let t=f.get(e);if(t!==void 0)return t;let i=u++;return f.set(e,i),i}function o(e){if(e===null)return "null";if(typeof e!="object")return String(e);let t=s(e);if(r.has(e))return `[Circular#${t}]`;r.add(e);let i;return Array.isArray(e)?i=`[${e.map(o).join(",")}]`:e instanceof Date?i=`Date:${e.toISOString()}`:i=`{${Object.entries(e).sort(([c],[m])=>c<m?-1:c>m?1:0).map(([c,m])=>`${c}:${o(m)}`).join(",")}}`,r.delete(e),i}return o(n)}export{b as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-J5DRKNXL.mjs';function m(o,i=a){let f=o.length;for(let t=0;t<f-1;t++){let e=t;for(let n=t+1;n<f;n++)i(o[n],o[e])<0&&(e=n);e!==t&&([o[t],o[e]]=[o[e],o[t]]);}return o}export{m as a};
@@ -0,0 +1 @@
1
+ import {a}from'./chunk-J5DRKNXL.mjs';function m(o,i=a){for(let e=1;e<o.length;e++){let r=o[e],t=e-1;for(;t>=0&&i(o[t],r)>0;)o[t+1]=o[t],t--;o[t+1]=r;}return o}export{m as a};
@@ -0,0 +1,5 @@
1
+ type CompareFn<T> = (a: T, b: T) => number;
2
+ type SortedArray<T> = T[];
3
+ type SelectorFn<T, K> = (item: T) => K;
4
+
5
+ export type { CompareFn as C, SelectorFn as S, SortedArray as a };
@@ -0,0 +1,5 @@
1
+ type CompareFn<T> = (a: T, b: T) => number;
2
+ type SortedArray<T> = T[];
3
+ type SelectorFn<T, K> = (item: T) => K;
4
+
5
+ export type { CompareFn as C, SelectorFn as S, SortedArray as a };
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ 'use strict';function u(t,e){let n=y(t),o=y(e);if(n!==o)return n-o;if(typeof t=="number"&&typeof e=="number")return Number.isNaN(t)&&Number.isNaN(e)?0:Number.isNaN(t)?1:Number.isNaN(e)?-1:t-e;if(typeof t=="bigint"&&typeof e=="bigint")return t<e?-1:t>e?1:0;if(typeof t=="boolean"&&typeof e=="boolean")return Number(t)-Number(e);if(t instanceof Date&&e instanceof Date){let f=t.getTime(),m=e.getTime();return Number.isNaN(f)&&Number.isNaN(m)?0:Number.isNaN(f)?1:Number.isNaN(m)?-1:f-m}let r=S(t),i=S(e);return r<i?-1:r>i?1:0}function y(t){return t===void 0?0:t===null?1:typeof t=="boolean"?2:typeof t=="number"?3:typeof t=="bigint"?4:typeof t=="string"?5:t instanceof Date?6:Array.isArray(t)?7:typeof t=="object"?8:typeof t=="symbol"?9:10}function S(t){return t===void 0?"undefined":t===null?"null":typeof t=="symbol"?t.toString():typeof t=="function"?t.name||"anonymous":b(t)}function b(t){let e=new Set,n=new WeakMap,o=1;function r(f){let m=n.get(f);if(m!==void 0)return m;let p=o++;return n.set(f,p),p}function i(f){if(f===null)return "null";if(typeof f!="object")return String(f);let m=r(f);if(e.has(f))return `[Circular#${m}]`;e.add(f);let p;return Array.isArray(f)?p=`[${f.map(i).join(",")}]`:f instanceof Date?p=`Date:${f.toISOString()}`:p=`{${Object.entries(f).sort(([s],[c])=>s<c?-1:s>c?1:0).map(([s,c])=>`${s}:${i(c)}`).join(",")}}`,e.delete(f),p}return i(t)}function C(t,e=u){let n=t.length;for(let o=0;o<n-1;o++){let r=false;for(let i=0;i<n-1-o;i++)e(t[i],t[i+1])>0&&([t[i],t[i+1]]=[t[i+1],t[i]],r=true);if(!r)break}return t}function x(t,e=u){let n=t.length;for(let o=Math.floor(n/2)-1;o>=0;o--)l(t,n,o,e);for(let o=n-1;o>0;o--)[t[0],t[o]]=[t[o],t[0]],l(t,o,0,e);return t}function l(t,e,n,o){let r=n,i=2*n+1,f=2*n+2;i<e&&o(t[i],t[r])>0&&(r=i),f<e&&o(t[f],t[r])>0&&(r=f),r!==n&&([t[n],t[r]]=[t[r],t[n]],l(t,e,r,o));}function N(t,e=u){for(let n=1;n<t.length;n++){let o=t[n],r=n-1;for(;r>=0&&e(t[r],o)>0;)t[r+1]=t[r],r--;t[r+1]=o;}return t}function T(t,e=u){if(t.length<=1)return t.slice();let n=Math.floor(t.length/2),o=T(t.slice(0,n),e),r=T(t.slice(n),e);return A(o,r,e)}function A(t,e,n){let o=[],r=0,i=0;for(;r<t.length&&i<e.length;)n(t[r],e[i])<=0?o.push(t[r++]):o.push(e[i++]);for(;r<t.length;)o.push(t[r++]);for(;i<e.length;)o.push(e[i++]);return o}function g(t,e=u){return d(t,0,t.length-1,e),t}function d(t,e,n,o){if(e<n){let r=k(t,e,n,o);d(t,e,r-1,o),d(t,r+1,n,o);}}function k(t,e,n,o){let r=Math.floor((e+n)/2);o(t[r],t[e])<0&&([t[e],t[r]]=[t[r],t[e]]),o(t[n],t[e])<0&&([t[e],t[n]]=[t[n],t[e]]),o(t[r],t[n])>0&&([t[r],t[n]]=[t[n],t[r]]),[t[r],t[n]]=[t[n],t[r]];let i=t[n],f=e-1;for(let m=e;m<n;m++)o(t[m],i)<=0&&(f++,[t[f],t[m]]=[t[m],t[f]]);return [t[f+1],t[n]]=[t[n],t[f+1]],f+1}function F(t,e=u){let n=t.length;for(let o=0;o<n-1;o++){let r=o;for(let i=o+1;i<n;i++)e(t[i],t[r])<0&&(r=i);r!==o&&([t[o],t[r]]=[t[r],t[o]]);}return t}function j(t,e){let n=e!=null?e:u;return function(o,r){return n(t(o),t(r))}}exports.bubbleSort=C;exports.compareBy=j;exports.defaultCompareFn=u;exports.heapSort=x;exports.insertionSort=N;exports.mergeSort=T;exports.quickSort=g;exports.selectionSort=F;
@@ -0,0 +1,14 @@
1
+ export { bubbleSort } from './base/bubble.mjs';
2
+ export { heapSort } from './base/heap.mjs';
3
+ export { insertionSort } from './base/insertion.mjs';
4
+ export { mergeSort } from './base/merge.mjs';
5
+ export { quickSort } from './base/quick.mjs';
6
+ export { selectionSort } from './base/selection.mjs';
7
+ import { S as SelectorFn, C as CompareFn } from './function-type-BAHbNN5P.mjs';
8
+ export { a as SortedArray } from './function-type-BAHbNN5P.mjs';
9
+
10
+ declare function compareBy<T, K>(selector: SelectorFn<T, K>, compareFn?: CompareFn<K>): CompareFn<T>;
11
+
12
+ declare function defaultCompareFn<T>(a: T, b: T): number;
13
+
14
+ export { CompareFn, SelectorFn, compareBy, defaultCompareFn };
@@ -0,0 +1,14 @@
1
+ export { bubbleSort } from './base/bubble.js';
2
+ export { heapSort } from './base/heap.js';
3
+ export { insertionSort } from './base/insertion.js';
4
+ export { mergeSort } from './base/merge.js';
5
+ export { quickSort } from './base/quick.js';
6
+ export { selectionSort } from './base/selection.js';
7
+ import { S as SelectorFn, C as CompareFn } from './function-type-BAHbNN5P.js';
8
+ export { a as SortedArray } from './function-type-BAHbNN5P.js';
9
+
10
+ declare function compareBy<T, K>(selector: SelectorFn<T, K>, compareFn?: CompareFn<K>): CompareFn<T>;
11
+
12
+ declare function defaultCompareFn<T>(a: T, b: T): number;
13
+
14
+ export { CompareFn, SelectorFn, compareBy, defaultCompareFn };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export{a as bubbleSort}from'./chunk-6OACJ5NV.mjs';export{a as heapSort}from'./chunk-FZMEZVLG.mjs';export{a as insertionSort}from'./chunk-YWVRJOGW.mjs';export{a as mergeSort}from'./chunk-3JE3MTR3.mjs';export{a as quickSort}from'./chunk-F7APGQXB.mjs';export{a as selectionSort}from'./chunk-KESA4OWP.mjs';import {a}from'./chunk-J5DRKNXL.mjs';export{a as defaultCompareFn}from'./chunk-J5DRKNXL.mjs';function f(t,r){let e=r!=null?r:a;return function(m,p){return e(t(m),t(p))}}export{f as compareBy};
@@ -0,0 +1 @@
1
+ 'use strict';
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+
2
+ export { }
File without changes
package/package.json ADDED
@@ -0,0 +1,114 @@
1
+ {
2
+ "name": "exsorted",
3
+ "version": "1.0.0",
4
+ "description": "A TypeScript sorting algorithms library",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./base": {
15
+ "types": "./dist/base/index.d.ts",
16
+ "import": "./dist/base/index.mjs",
17
+ "require": "./dist/base/index.cjs"
18
+ },
19
+ "./bubble": {
20
+ "types": "./dist/base/bubble.d.ts",
21
+ "import": "./dist/base/bubble.mjs",
22
+ "require": "./dist/base/bubble.cjs"
23
+ },
24
+ "./insertion": {
25
+ "types": "./dist/base/insertion.d.ts",
26
+ "import": "./dist/base/insertion.mjs",
27
+ "require": "./dist/base/insertion.cjs"
28
+ },
29
+ "./selection": {
30
+ "types": "./dist/base/selection.d.ts",
31
+ "import": "./dist/base/selection.mjs",
32
+ "require": "./dist/base/selection.cjs"
33
+ },
34
+ "./merge": {
35
+ "types": "./dist/base/merge.d.ts",
36
+ "import": "./dist/base/merge.mjs",
37
+ "require": "./dist/base/merge.cjs"
38
+ },
39
+ "./quick": {
40
+ "types": "./dist/base/quick.d.ts",
41
+ "import": "./dist/base/quick.mjs",
42
+ "require": "./dist/base/quick.cjs"
43
+ },
44
+ "./heap": {
45
+ "types": "./dist/base/heap.d.ts",
46
+ "import": "./dist/base/heap.mjs",
47
+ "require": "./dist/base/heap.cjs"
48
+ },
49
+ "./meme": {
50
+ "types": "./dist/meme/index.d.ts",
51
+ "import": "./dist/meme/index.mjs",
52
+ "require": "./dist/meme/index.cjs"
53
+ }
54
+ },
55
+ "sideEffects": false,
56
+ "files": [
57
+ "dist"
58
+ ],
59
+ "scripts": {
60
+ "build": "tsup --config tsup.config.ts",
61
+ "minify": "tsup --config tsup.config.ts --minify",
62
+ "test": "jest",
63
+ "lint": "oxlint . --deny-warnings",
64
+ "lint:fix": "oxlint . --fix",
65
+ "typecheck": "tsc --noEmit",
66
+ "format": "prettier . --write",
67
+ "format:check": "prettier . --check",
68
+ "prepare": "husky",
69
+ "prepublishOnly": "pnpm run minify"
70
+ },
71
+ "lint-staged": {
72
+ "*.{ts,tsx,js,mjs,cjs,json,md,yml,yaml}": [
73
+ "prettier --write"
74
+ ],
75
+ "*.{ts,tsx,js,mjs,cjs}": [
76
+ "oxlint --fix"
77
+ ]
78
+ },
79
+ "repository": {
80
+ "type": "git",
81
+ "url": "git+https://github.com/Ink01101011/exsorted.git"
82
+ },
83
+ "keywords": [
84
+ "sort",
85
+ "sorting",
86
+ "algorithms",
87
+ "typescript",
88
+ "bubble-sort",
89
+ "merge-sort",
90
+ "quick-sort",
91
+ "heap-sort",
92
+ "insertion-sort",
93
+ "selection-sort"
94
+ ],
95
+ "author": "Ink01101011",
96
+ "license": "MIT",
97
+ "type": "commonjs",
98
+ "bugs": {
99
+ "url": "https://github.com/Ink01101011/exsorted/issues"
100
+ },
101
+ "homepage": "https://github.com/Ink01101011/exsorted#readme",
102
+ "devDependencies": {
103
+ "@types/jest": "^29.5.14",
104
+ "@types/node": "^25.5.0",
105
+ "husky": "^9.1.7",
106
+ "jest": "^29.7.0",
107
+ "lint-staged": "^16.4.0",
108
+ "oxlint": "^1.58.0",
109
+ "prettier": "^3.8.1",
110
+ "ts-jest": "^29.4.8",
111
+ "tsup": "^8.5.1",
112
+ "typescript": "^6.0.2"
113
+ }
114
+ }