@thi.ng/arrays 2.4.5 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2022-12-16T12:52:25Z
3
+ - **Last updated**: 2022-12-20T16:33:11Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -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
- * of the index, were `x` to be inserted into `buf`. E.g if the return
9
- * value is -3, `x` would appear/insert at index 2.
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
- * of `x` and each array item (default: identity).
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
- * {@link @thi.ng/compare#compare}) is then used to identify the index
16
- * of `x`. The sort order of `buf` MUST be compatible with that of
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
- * {@link @thi.ng/compare#compareNumAsc}).
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
- * of the index, were `x` to be inserted into `buf`. E.g if the return
10
- * value is -3, `x` would appear/insert at index 2.
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
- * of `x` and each array item (default: identity).
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
- * {@link @thi.ng/compare#compare}) is then used to identify the index
17
- * of `x`. The sort order of `buf` MUST be compatible with that of
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
- * {@link @thi.ng/compare#compareNumAsc}).
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
- * this to be true.
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 {@link @thi.ng/equiv#equiv} for equality checking.
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
- * this to be true.
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 {@link @thi.ng/equiv#equiv} for equality checking.
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 {@link @thi.ng/equiv#equiv} as
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 {@link @thi.ng/equiv#equiv}
13
- * as default predicate.
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 {@link @thi.ng/equiv#equiv} as
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 {@link @thi.ng/equiv#equiv}
16
- * as default predicate.
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 {@link @thi.ng/equiv#equiv} by default.
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
- * {@link https://github.com/bevacqua/fufuzzyzzysearch} (MIT)
12
+ * Adapted and generalized from: https://github.com/bevacqua/fufuzzyzzysearch
13
+ * (MIT licensed)
12
14
  *
13
- * {@link @thi.ng/transducers#(filterFuzzy:1)}
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 {@link @thi.ng/equiv#equiv} by default.
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
- * {@link https://github.com/bevacqua/fufuzzyzzysearch} (MIT)
12
+ * Adapted and generalized from: https://github.com/bevacqua/fufuzzyzzysearch
13
+ * (MIT licensed)
12
14
  *
13
- * {@link @thi.ng/transducers#(filterFuzzy:1)}
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
- * index range (entire array, by default) are in the order defined by
5
- * the given comparator ({@link @thi.ng/compare#compare} by default).
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
- * less than two elements. No bounds checking.
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
- * index range (entire array, by default) are in the order defined by
5
- * the given comparator ({@link @thi.ng/compare#compare} by default).
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
- * less than two elements. No bounds checking.
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.5",
3
+ "version": "2.4.6",
4
4
  "description": "Array / Arraylike utilities",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,12 +34,12 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.6.0",
37
+ "@thi.ng/api": "^8.6.1",
38
38
  "@thi.ng/checks": "^3.3.5",
39
- "@thi.ng/compare": "^2.1.19",
39
+ "@thi.ng/compare": "^2.1.20",
40
40
  "@thi.ng/equiv": "^2.1.15",
41
41
  "@thi.ng/errors": "^2.2.6",
42
- "@thi.ng/random": "^3.3.18"
42
+ "@thi.ng/random": "^3.3.19"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@microsoft/api-extractor": "^7.33.7",
@@ -153,5 +153,5 @@
153
153
  "thi.ng": {
154
154
  "year": 2018
155
155
  },
156
- "gitHead": "f445a9cc8022bcdebbf6ff91fd66ced016d72f01\n"
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
- * based swap function, useful for sorting multiple related arrays in
5
- * parallel, based on a single sort criteria.
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
- * `start`/`end` indices (both inclusive).
8
+ * Supports sorting of sub-ranges only, via optionally given `start`/`end`
9
+ * indices (both inclusive).
10
10
  *
11
- * Uses Hoare partitioning scheme. {@link @thi.ng/compare#compare} is
12
- * used as default comparator and {@link swap} from this package as
13
- * default swap function. Also see {@link multiSwap}.
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
- * {@link https://en.wikipedia.org/wiki/Quicksort#Hoare_partition_scheme}
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
- * Fisher-yates and optional `rnd` PRNG.
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
- * shuffled. Mutates original array.
9
+ * If neither `start` / `end` are given, the entire array will be shuffled.
10
+ * Mutates original array.
11
11
  *
12
- * See {@link @thi.ng/random#IRandom}
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
- * Fisher-yates and optional `rnd` PRNG.
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
- * shuffled. Mutates original array.
8
+ * If neither `start` / `end` are given, the entire array will be shuffled.
9
+ * Mutates original array.
10
10
  *
11
- * See {@link @thi.ng/random#IRandom}
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
- * this to be true.
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 {@link @thi.ng/equiv#equiv} for equality checking.
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
- * this to be true.
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 {@link @thi.ng/equiv#equiv} for equality checking.
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
- * multiple arrays at once and hence useful for sorting multiple arrays
13
- * based on a single criteria.
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
- * swaps 2 elements in the array given to that function AND in the
18
- * arrays given to {@link multiSwap} itself. Provides fast routes for up to 3
19
- * extra arrays, then falls back to a loop-based approach.
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 (quickSort:1)}
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
- * multiple arrays at once and hence useful for sorting multiple arrays
16
- * based on a single criteria.
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
- * swaps 2 elements in the array given to that function AND in the
21
- * arrays given to {@link multiSwap} itself. Provides fast routes for up to 3
22
- * extra arrays, then falls back to a loop-based approach.
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 (quickSort:1)}
24
+ * {@link quickSort}
25
25
  *
26
26
  * @example
27
27
  * ```ts