@thi.ng/arrays 2.4.4 → 2.4.6
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.
- package/CHANGELOG.md +1 -1
- package/README.md +7 -10
- package/api.d.ts +2 -2
- package/binary-search.d.ts +10 -11
- package/binary-search.js +10 -11
- package/ends-with.d.ts +6 -5
- package/ends-with.js +6 -5
- package/find.d.ts +4 -3
- package/find.js +4 -3
- package/fuzzy-match.d.ts +6 -4
- package/fuzzy-match.js +6 -4
- package/is-sorted.d.ts +6 -5
- package/is-sorted.js +6 -5
- package/package.json +13 -13
- package/quicksort.d.ts +10 -9
- package/shuffle.d.ts +5 -5
- package/shuffle.js +5 -5
- package/starts-with.d.ts +6 -5
- package/starts-with.js +6 -5
- package/swap.d.ts +8 -8
- package/swap.js +8 -8
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<!-- This file is generated - DO NOT EDIT! -->
|
|
2
2
|
|
|
3
|
-
# 
|
|
3
|
+
# 
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@thi.ng/arrays)
|
|
6
6
|

|
|
7
|
-
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
This project is part of the
|
|
10
10
|
[@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo.
|
|
@@ -20,7 +20,7 @@ This project is part of the
|
|
|
20
20
|
|
|
21
21
|
## About
|
|
22
22
|
|
|
23
|
-
Array / Arraylike utilities
|
|
23
|
+
Array / Arraylike utilities
|
|
24
24
|
|
|
25
25
|
## Status
|
|
26
26
|
|
|
@@ -44,11 +44,8 @@ ES module import:
|
|
|
44
44
|
|
|
45
45
|
For Node.js REPL:
|
|
46
46
|
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
node --experimental-repl-await
|
|
50
|
-
|
|
51
|
-
> const arrays = await import("@thi.ng/arrays");
|
|
47
|
+
```js
|
|
48
|
+
const arrays = await import("@thi.ng/arrays");
|
|
52
49
|
```
|
|
53
50
|
|
|
54
51
|
Package sizes (brotli'd, pre-treeshake): ESM: 2.40 KB
|
|
@@ -122,7 +119,7 @@ bsGT(binarySearch(src, 40), src.length)
|
|
|
122
119
|
|
|
123
120
|
## Authors
|
|
124
121
|
|
|
125
|
-
Karsten Schmidt
|
|
122
|
+
- [Karsten Schmidt](https://thi.ng)
|
|
126
123
|
|
|
127
124
|
If this project contributes to an academic publication, please cite it as:
|
|
128
125
|
|
|
@@ -137,4 +134,4 @@ If this project contributes to an academic publication, please cite it as:
|
|
|
137
134
|
|
|
138
135
|
## License
|
|
139
136
|
|
|
140
|
-
© 2018 - 2022 Karsten Schmidt // Apache
|
|
137
|
+
© 2018 - 2022 Karsten Schmidt // Apache License 2.0
|
package/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Fn3, TypedArray } from "@thi.ng/api";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type AnyArray = any[] | TypedArray;
|
|
3
|
+
export type SwapFn = Fn3<AnyArray, number, number, void>;
|
|
4
4
|
//# sourceMappingURL=api.d.ts.map
|
package/binary-search.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import type { Comparator, Fn, FnN, FnN2 } from "@thi.ng/api";
|
|
2
2
|
/**
|
|
3
|
-
* Returns the supposed index of `x` in pre-sorted array-like collection
|
|
4
|
-
* `buf`.
|
|
3
|
+
* Returns the supposed index of `x` in pre-sorted array-like collection `buf`.
|
|
5
4
|
*
|
|
6
5
|
* @remarks
|
|
7
|
-
* If `x` can't be found, returns `-index-1`, representing the negative
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* If `x` can't be found, returns `-index-1`, representing the negative of the
|
|
7
|
+
* index, were `x` to be inserted into `buf`. E.g if the return value is -3, `x`
|
|
8
|
+
* would appear/insert at index 2.
|
|
10
9
|
*
|
|
11
|
-
* The optional `key` function is used to obtain the actual sort value
|
|
12
|
-
*
|
|
10
|
+
* The optional `key` function is used to obtain the actual sort value of `x`
|
|
11
|
+
* and each array item (default: identity).
|
|
13
12
|
*
|
|
14
13
|
* The optional `cmp` comparator (default:
|
|
15
|
-
*
|
|
16
|
-
* of `x`. The sort order of `buf` MUST be
|
|
17
|
-
* `cmp`.
|
|
14
|
+
* [`compare()`](https://docs.thi.ng/umbrella/compare/functions/compare.html))
|
|
15
|
+
* is then used to identify the index of `x`. The sort order of `buf` MUST be
|
|
16
|
+
* compatible with that of `cmp`.
|
|
18
17
|
*
|
|
19
18
|
* @example
|
|
20
19
|
* ```ts
|
|
@@ -33,7 +32,7 @@ export declare const binarySearch: <A, B>(buf: ArrayLike<A>, x: A, key?: Fn<A, B
|
|
|
33
32
|
/**
|
|
34
33
|
* Similar to {@link binarySearch}, but optimized for numeric arrays and
|
|
35
34
|
* supporting custom comparators (default:
|
|
36
|
-
*
|
|
35
|
+
* [`compareNumAsc()`](https://docs.thi.ng/umbrella/compare/functions/compareNumAsc.html)).
|
|
37
36
|
*
|
|
38
37
|
* @param buf - array
|
|
39
38
|
* @param x - search value
|
package/binary-search.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { compare } from "@thi.ng/compare/compare";
|
|
2
2
|
import { compareNumAsc } from "@thi.ng/compare/numeric";
|
|
3
3
|
/**
|
|
4
|
-
* Returns the supposed index of `x` in pre-sorted array-like collection
|
|
5
|
-
* `buf`.
|
|
4
|
+
* Returns the supposed index of `x` in pre-sorted array-like collection `buf`.
|
|
6
5
|
*
|
|
7
6
|
* @remarks
|
|
8
|
-
* If `x` can't be found, returns `-index-1`, representing the negative
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* If `x` can't be found, returns `-index-1`, representing the negative of the
|
|
8
|
+
* index, were `x` to be inserted into `buf`. E.g if the return value is -3, `x`
|
|
9
|
+
* would appear/insert at index 2.
|
|
11
10
|
*
|
|
12
|
-
* The optional `key` function is used to obtain the actual sort value
|
|
13
|
-
*
|
|
11
|
+
* The optional `key` function is used to obtain the actual sort value of `x`
|
|
12
|
+
* and each array item (default: identity).
|
|
14
13
|
*
|
|
15
14
|
* The optional `cmp` comparator (default:
|
|
16
|
-
*
|
|
17
|
-
* of `x`. The sort order of `buf` MUST be
|
|
18
|
-
* `cmp`.
|
|
15
|
+
* [`compare()`](https://docs.thi.ng/umbrella/compare/functions/compare.html))
|
|
16
|
+
* is then used to identify the index of `x`. The sort order of `buf` MUST be
|
|
17
|
+
* compatible with that of `cmp`.
|
|
19
18
|
*
|
|
20
19
|
* @example
|
|
21
20
|
* ```ts
|
|
@@ -50,7 +49,7 @@ export const binarySearch = (buf, x, key = (x) => x, cmp = compare, low = 0, hig
|
|
|
50
49
|
/**
|
|
51
50
|
* Similar to {@link binarySearch}, but optimized for numeric arrays and
|
|
52
51
|
* supporting custom comparators (default:
|
|
53
|
-
*
|
|
52
|
+
* [`compareNumAsc()`](https://docs.thi.ng/umbrella/compare/functions/compareNumAsc.html)).
|
|
54
53
|
*
|
|
55
54
|
* @param buf - array
|
|
56
55
|
* @param x - search value
|
package/ends-with.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns true if the last items of `buf` are the same items as in
|
|
3
|
-
* `needle`.
|
|
2
|
+
* Returns true if the last items of `buf` are the same items as in `needle`.
|
|
4
3
|
*
|
|
5
4
|
* @remarks
|
|
6
|
-
* This means `buf` should have at least the same length as `needle` for
|
|
7
|
-
*
|
|
5
|
+
* This means `buf` should have at least the same length as `needle` for this to
|
|
6
|
+
* be true.
|
|
8
7
|
*
|
|
9
|
-
* By default, uses
|
|
8
|
+
* By default, uses
|
|
9
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) for
|
|
10
|
+
* equality checking.
|
|
10
11
|
*
|
|
11
12
|
* {@link startsWith}
|
|
12
13
|
*
|
package/ends-with.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { equiv as _eq } from "@thi.ng/equiv";
|
|
2
2
|
/**
|
|
3
|
-
* Returns true if the last items of `buf` are the same items as in
|
|
4
|
-
* `needle`.
|
|
3
|
+
* Returns true if the last items of `buf` are the same items as in `needle`.
|
|
5
4
|
*
|
|
6
5
|
* @remarks
|
|
7
|
-
* This means `buf` should have at least the same length as `needle` for
|
|
8
|
-
*
|
|
6
|
+
* This means `buf` should have at least the same length as `needle` for this to
|
|
7
|
+
* be true.
|
|
9
8
|
*
|
|
10
|
-
* By default, uses
|
|
9
|
+
* By default, uses
|
|
10
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) for
|
|
11
|
+
* equality checking.
|
|
11
12
|
*
|
|
12
13
|
* {@link startsWith}
|
|
13
14
|
*
|
package/find.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Predicate2 } from "@thi.ng/api";
|
|
2
2
|
/**
|
|
3
|
-
* Similar to `Array.find()`, but uses
|
|
3
|
+
* Similar to `Array.find()`, but uses [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) as
|
|
4
4
|
* default predicate.
|
|
5
5
|
*
|
|
6
6
|
* @param buf - array
|
|
@@ -9,8 +9,9 @@ import type { Predicate2 } from "@thi.ng/api";
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const find: <T>(buf: ArrayLike<T>, x: T, equiv?: Predicate2<T>) => T | undefined;
|
|
11
11
|
/**
|
|
12
|
-
* Similar to `Array.findIndex()`, but uses
|
|
13
|
-
* as
|
|
12
|
+
* Similar to `Array.findIndex()`, but uses
|
|
13
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) as
|
|
14
|
+
* default predicate.
|
|
14
15
|
*
|
|
15
16
|
* @param buf - array
|
|
16
17
|
* @param x - search value
|
package/find.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { equiv as _equiv } from "@thi.ng/equiv";
|
|
2
2
|
/**
|
|
3
|
-
* Similar to `Array.find()`, but uses
|
|
3
|
+
* Similar to `Array.find()`, but uses [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) as
|
|
4
4
|
* default predicate.
|
|
5
5
|
*
|
|
6
6
|
* @param buf - array
|
|
@@ -12,8 +12,9 @@ export const find = (buf, x, equiv = _equiv) => {
|
|
|
12
12
|
return i !== -1 ? buf[i] : undefined;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* Similar to `Array.findIndex()`, but uses
|
|
16
|
-
* as
|
|
15
|
+
* Similar to `Array.findIndex()`, but uses
|
|
16
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) as
|
|
17
|
+
* default predicate.
|
|
17
18
|
*
|
|
18
19
|
* @param buf - array
|
|
19
20
|
* @param x - search value
|
package/fuzzy-match.d.ts
CHANGED
|
@@ -5,12 +5,14 @@ import type { Predicate2 } from "@thi.ng/api";
|
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* The optional `equiv` predicate can be used to customize item equality
|
|
8
|
-
* checking. Uses
|
|
8
|
+
* checking. Uses
|
|
9
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) by
|
|
10
|
+
* default.
|
|
9
11
|
*
|
|
10
|
-
* Adapted and generalized from:
|
|
11
|
-
*
|
|
12
|
+
* Adapted and generalized from: https://github.com/bevacqua/fufuzzyzzysearch
|
|
13
|
+
* (MIT licensed)
|
|
12
14
|
*
|
|
13
|
-
*
|
|
15
|
+
* [`filterFuzzy()`](https://docs.thi.ng/umbrella/transducers/functions/filterFuzzy.html)
|
|
14
16
|
*
|
|
15
17
|
* @param domain - array
|
|
16
18
|
* @param query - search value
|
package/fuzzy-match.js
CHANGED
|
@@ -5,12 +5,14 @@ import { equiv as _eq } from "@thi.ng/equiv";
|
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
7
|
* The optional `equiv` predicate can be used to customize item equality
|
|
8
|
-
* checking. Uses
|
|
8
|
+
* checking. Uses
|
|
9
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) by
|
|
10
|
+
* default.
|
|
9
11
|
*
|
|
10
|
-
* Adapted and generalized from:
|
|
11
|
-
*
|
|
12
|
+
* Adapted and generalized from: https://github.com/bevacqua/fufuzzyzzysearch
|
|
13
|
+
* (MIT licensed)
|
|
12
14
|
*
|
|
13
|
-
*
|
|
15
|
+
* [`filterFuzzy()`](https://docs.thi.ng/umbrella/transducers/functions/filterFuzzy.html)
|
|
14
16
|
*
|
|
15
17
|
* @param domain - array
|
|
16
18
|
* @param query - search value
|
package/is-sorted.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { Comparator } from "@thi.ng/api";
|
|
2
2
|
/**
|
|
3
|
-
* Returns true if the given array and its elements in the selected
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Returns true if the given array and its elements in the selected index range
|
|
4
|
+
* (entire array, by default) are in the order defined by the given comparator
|
|
5
|
+
* ([`compare()`](https://docs.thi.ng/umbrella/compare/functions/compare.html)
|
|
6
|
+
* by default).
|
|
6
7
|
*
|
|
7
8
|
* @remarks
|
|
8
|
-
* Always returns true, if effective index range (or array length) has
|
|
9
|
-
*
|
|
9
|
+
* Always returns true, if effective index range (or array length) has less than
|
|
10
|
+
* two elements. No bounds checking.
|
|
10
11
|
*
|
|
11
12
|
* @example
|
|
12
13
|
* ```ts
|
package/is-sorted.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { compare } from "@thi.ng/compare/compare";
|
|
2
2
|
/**
|
|
3
|
-
* Returns true if the given array and its elements in the selected
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Returns true if the given array and its elements in the selected index range
|
|
4
|
+
* (entire array, by default) are in the order defined by the given comparator
|
|
5
|
+
* ([`compare()`](https://docs.thi.ng/umbrella/compare/functions/compare.html)
|
|
6
|
+
* by default).
|
|
6
7
|
*
|
|
7
8
|
* @remarks
|
|
8
|
-
* Always returns true, if effective index range (or array length) has
|
|
9
|
-
*
|
|
9
|
+
* Always returns true, if effective index range (or array length) has less than
|
|
10
|
+
* two elements. No bounds checking.
|
|
10
11
|
*
|
|
11
12
|
* @example
|
|
12
13
|
* ```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/arrays",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.6",
|
|
4
4
|
"description": "Array / Arraylike utilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "https://patreon.com/thing_umbrella"
|
|
22
22
|
}
|
|
23
23
|
],
|
|
24
|
-
"author": "Karsten Schmidt
|
|
24
|
+
"author": "Karsten Schmidt (https://thi.ng)",
|
|
25
25
|
"license": "Apache-2.0",
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "yarn clean && tsc --declaration",
|
|
@@ -34,20 +34,20 @@
|
|
|
34
34
|
"test": "testament test"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@thi.ng/api": "^8.
|
|
38
|
-
"@thi.ng/checks": "^3.3.
|
|
39
|
-
"@thi.ng/compare": "^2.1.
|
|
40
|
-
"@thi.ng/equiv": "^2.1.
|
|
41
|
-
"@thi.ng/errors": "^2.2.
|
|
42
|
-
"@thi.ng/random": "^3.3.
|
|
37
|
+
"@thi.ng/api": "^8.6.1",
|
|
38
|
+
"@thi.ng/checks": "^3.3.5",
|
|
39
|
+
"@thi.ng/compare": "^2.1.20",
|
|
40
|
+
"@thi.ng/equiv": "^2.1.15",
|
|
41
|
+
"@thi.ng/errors": "^2.2.6",
|
|
42
|
+
"@thi.ng/random": "^3.3.19"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@microsoft/api-extractor": "^7.33.
|
|
46
|
-
"@thi.ng/testament": "^0.3.
|
|
45
|
+
"@microsoft/api-extractor": "^7.33.7",
|
|
46
|
+
"@thi.ng/testament": "^0.3.7",
|
|
47
47
|
"rimraf": "^3.0.2",
|
|
48
48
|
"tools": "^0.0.1",
|
|
49
|
-
"typedoc": "^0.23.
|
|
50
|
-
"typescript": "^4.
|
|
49
|
+
"typedoc": "^0.23.22",
|
|
50
|
+
"typescript": "^4.9.4"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"aos",
|
|
@@ -153,5 +153,5 @@
|
|
|
153
153
|
"thi.ng": {
|
|
154
154
|
"year": 2018
|
|
155
155
|
},
|
|
156
|
-
"gitHead": "
|
|
156
|
+
"gitHead": "7b2af448da8a63fb21704a79cc4cdf1f3d7d7a64\n"
|
|
157
157
|
}
|
package/quicksort.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { Comparator, Fn3, TypedArray } from "@thi.ng/api";
|
|
2
2
|
/**
|
|
3
|
-
* In-place quicksort implementation with optional comparator & index
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* In-place quicksort implementation with optional comparator & index based swap
|
|
4
|
+
* function, useful for sorting multiple related arrays in parallel, based on a
|
|
5
|
+
* single sort criteria.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* Supports sorting of sub-ranges only, via optionally given
|
|
9
|
-
*
|
|
8
|
+
* Supports sorting of sub-ranges only, via optionally given `start`/`end`
|
|
9
|
+
* indices (both inclusive).
|
|
10
10
|
*
|
|
11
|
-
* Uses Hoare partitioning scheme.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Uses Hoare partitioning scheme.
|
|
12
|
+
* [`compare()`](https://docs.thi.ng/umbrella/compare/functions/compare.html) is
|
|
13
|
+
* used as default comparator and {@link swap} from this package as default swap
|
|
14
|
+
* function. Also see {@link multiSwap}.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
+
* - https://en.wikipedia.org/wiki/Quicksort#Hoare_partition_scheme
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* ```ts
|
package/shuffle.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import type { TypedArray } from "@thi.ng/api";
|
|
|
2
2
|
import type { IRandom } from "@thi.ng/random";
|
|
3
3
|
import type { AnyArray } from "./api.js";
|
|
4
4
|
/**
|
|
5
|
-
* Shuffles the items in the given index range of array `buf` using
|
|
6
|
-
*
|
|
5
|
+
* Shuffles the items in the given index range of array `buf` using Fisher-yates
|
|
6
|
+
* and optional `rnd` PRNG.
|
|
7
7
|
*
|
|
8
8
|
* @remarks
|
|
9
|
-
* If neither `start` / `end` are given, the entire array will be
|
|
10
|
-
*
|
|
9
|
+
* If neither `start` / `end` are given, the entire array will be shuffled.
|
|
10
|
+
* Mutates original array.
|
|
11
11
|
*
|
|
12
|
-
* See
|
|
12
|
+
* See [`IRandom`](https://docs.thi.ng/umbrella/random/interfaces/IRandom.html)
|
|
13
13
|
*
|
|
14
14
|
* @param buf - array
|
|
15
15
|
* @param n - num items
|
package/shuffle.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { assert } from "@thi.ng/errors/assert";
|
|
2
2
|
import { SYSTEM } from "@thi.ng/random/system";
|
|
3
3
|
/**
|
|
4
|
-
* Shuffles the items in the given index range of array `buf` using
|
|
5
|
-
*
|
|
4
|
+
* Shuffles the items in the given index range of array `buf` using Fisher-yates
|
|
5
|
+
* and optional `rnd` PRNG.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
* If neither `start` / `end` are given, the entire array will be
|
|
9
|
-
*
|
|
8
|
+
* If neither `start` / `end` are given, the entire array will be shuffled.
|
|
9
|
+
* Mutates original array.
|
|
10
10
|
*
|
|
11
|
-
* See
|
|
11
|
+
* See [`IRandom`](https://docs.thi.ng/umbrella/random/interfaces/IRandom.html)
|
|
12
12
|
*
|
|
13
13
|
* @param buf - array
|
|
14
14
|
* @param n - num items
|
package/starts-with.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Returns true if the first items of `buf` are the same items as in
|
|
3
|
-
* `needle`.
|
|
2
|
+
* Returns true if the first items of `buf` are the same items as in `needle`.
|
|
4
3
|
*
|
|
5
4
|
* @remarks
|
|
6
|
-
* This means `buf` should have at least the same length as `needle` for
|
|
7
|
-
*
|
|
5
|
+
* This means `buf` should have at least the same length as `needle` for this to
|
|
6
|
+
* be true.
|
|
8
7
|
*
|
|
9
|
-
* By default, uses
|
|
8
|
+
* By default, uses
|
|
9
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) for
|
|
10
|
+
* equality checking.
|
|
10
11
|
*
|
|
11
12
|
* {@link endsWith}
|
|
12
13
|
*
|
package/starts-with.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { equiv as _eq } from "@thi.ng/equiv";
|
|
2
2
|
/**
|
|
3
|
-
* Returns true if the first items of `buf` are the same items as in
|
|
4
|
-
* `needle`.
|
|
3
|
+
* Returns true if the first items of `buf` are the same items as in `needle`.
|
|
5
4
|
*
|
|
6
5
|
* @remarks
|
|
7
|
-
* This means `buf` should have at least the same length as `needle` for
|
|
8
|
-
*
|
|
6
|
+
* This means `buf` should have at least the same length as `needle` for this to
|
|
7
|
+
* be true.
|
|
9
8
|
*
|
|
10
|
-
* By default, uses
|
|
9
|
+
* By default, uses
|
|
10
|
+
* [`equiv()`](https://docs.thi.ng/umbrella/equiv/functions/equiv.html) for
|
|
11
|
+
* equality checking.
|
|
11
12
|
*
|
|
12
13
|
* {@link endsWith}
|
|
13
14
|
*
|
package/swap.d.ts
CHANGED
|
@@ -8,17 +8,17 @@ import type { AnyArray, SwapFn } from "./api.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare const swap: (arr: AnyArray, x: number, y: number) => void;
|
|
10
10
|
/**
|
|
11
|
-
* Higher-order version of {@link swap} for swapping elements in
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Higher-order version of {@link swap} for swapping elements in multiple arrays
|
|
12
|
+
* at once and hence useful for sorting multiple arrays based on a single
|
|
13
|
+
* criteria.
|
|
14
14
|
*
|
|
15
15
|
* @remarks
|
|
16
|
-
* The returned function takes the same args as `swap`, and when called
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* The returned function takes the same args as `swap`, and when called swaps 2
|
|
17
|
+
* elements in the array given to that function AND in the arrays given to
|
|
18
|
+
* {@link multiSwap} itself. Provides fast routes for up to 3 extra arrays, then
|
|
19
|
+
* falls back to a loop-based approach.
|
|
20
20
|
*
|
|
21
|
-
* {@link
|
|
21
|
+
* {@link quickSort}
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```ts
|
package/swap.js
CHANGED
|
@@ -11,17 +11,17 @@ export const swap = (arr, x, y) => {
|
|
|
11
11
|
arr[y] = t;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
|
-
* Higher-order version of {@link swap} for swapping elements in
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* Higher-order version of {@link swap} for swapping elements in multiple arrays
|
|
15
|
+
* at once and hence useful for sorting multiple arrays based on a single
|
|
16
|
+
* criteria.
|
|
17
17
|
*
|
|
18
18
|
* @remarks
|
|
19
|
-
* The returned function takes the same args as `swap`, and when called
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* The returned function takes the same args as `swap`, and when called swaps 2
|
|
20
|
+
* elements in the array given to that function AND in the arrays given to
|
|
21
|
+
* {@link multiSwap} itself. Provides fast routes for up to 3 extra arrays, then
|
|
22
|
+
* falls back to a loop-based approach.
|
|
23
23
|
*
|
|
24
|
-
* {@link
|
|
24
|
+
* {@link quickSort}
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
27
27
|
* ```ts
|