@williamthorsen/toolbelt.arrays 5.0.0 → 6.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 6.0.0 — 2026-08-21
6
+
7
+ ### Features
8
+
9
+ - 🚨 **Breaking:** Correct the nullish guards' narrowing and rename `isNullable` (#206)
10
+
11
+ Fixes an issue where `isNullable` in `@williamthorsen/toolbelt.guards` narrowed both of its branches backwards: A value it confirmed to be null or undefined was typed as non-nullish, so dereferencing it inside the check compiled and then threw. It is now named `isNullish`, after the type it narrows to.
12
+
13
+ Separately, `isNonNullable` and `assertIsNonNullable` let an explicit type argument exclude `null` from the false branch while `null` still reached it at runtime. Both now take the value at its own type.
14
+
15
+ Migration: `isNullable` no longer exists, and `isNullish` narrows in the opposite direction, so a call site written against the old behavior now fails to compile. On `isNonNullable` and `assertIsNonNullable`, an explicit type argument narrower than the value's own type is now a compile error; inference-driven narrowing is unchanged, as is `filter(isNonNullable)`.
16
+
17
+ ## 5.0.1 — 2026-08-16
18
+
19
+ ### Tests
20
+
21
+ - Drop expect-type in favor of expectTypeOf (#175)
22
+
23
+ Replaces all imports of `expectTypeOf` from `expect-type` with the same import from `vitest`. Previously there had been imports from both libraries. `expect-type` is removed as a dependency.
24
+
5
25
  ## 5.0.0 — 2026-08-15
6
26
 
7
27
  ### Features
package/README.md CHANGED
@@ -3,23 +3,17 @@
3
3
  Array utilities.
4
4
 
5
5
  <!-- section:release-notes -->
6
- ## Release notes — v5.0.0 (2026-08-15)
6
+ ## Release notes — v6.0.0 (2026-08-21)
7
7
 
8
8
  ### Features
9
9
 
10
- - 🚨 **Breaking:** Fix unsound narrowing in `getAtIndexOrThrow` and rename it to `getItemAtIndexOrThrow` (#152)
10
+ - 🚨 **Breaking:** Correct the nullish guards' narrowing and rename `isNullable` (#206)
11
11
 
12
- Fixes an issue where `getAtIndexOrThrow` could falsely treat an `undefined` return value as satisfying a return type that excluded `undefined`. The function now throws a `RangeError` if the array holds no item at the index and a `TypeError` if the index is not a safe integer. `undefined` is a valid return value if the input array's type allows `undefined` elements. The function is renamed `getItemAtIndexOrThrow`.
12
+ Fixes an issue where `isNullable` in `@williamthorsen/toolbelt.guards` narrowed both of its branches backwards: A value it confirmed to be null or undefined was typed as non-nullish, so dereferencing it inside the check compiled and then threw. It is now named `isNullish`, after the type it narrows to.
13
13
 
14
- Separately, `findOrThrow` now decides a match by its predicate rather than by the value it found, so an element is not treated as not found merely because it is falsy. Its return type is now `T` rather than `NonNullable<T>`.
14
+ Separately, `isNonNullable` and `assertIsNonNullable` let an explicit type argument exclude `null` from the false branch while `null` still reached it at runtime. Both now take the value at its own type.
15
15
 
16
- Migration: Consumers of `@williamthorsen/toolbelt.arrays/candidate` import `getItemAtIndexOrThrow` in place of `getAtIndexOrThrow`.
17
-
18
- - 🚨 **Breaking:** Rename `findOrThrow` to `findItemOrThrow` and document it (#153)
19
-
20
- Renames `findOrThrow` to `findItemOrThrow` in `@williamthorsen/toolbelt.arrays` for consistency with repo naming conventions.
21
-
22
- Migration: Consumers import `findItemOrThrow` from `@williamthorsen/toolbelt.arrays/candidate`. The signature and behavior are unchanged.
16
+ Migration: `isNullable` no longer exists, and `isNullish` narrows in the opposite direction, so a call site written against the old behavior now fails to compile. On `isNonNullable` and `assertIsNonNullable`, an explicit type argument narrower than the value's own type is now a compile error; inference-driven narrowing is unchanged, as is `filter(isNonNullable)`.
23
17
  <!-- /section:release-notes -->
24
18
 
25
19
  ## Installation
@@ -1,3 +1,4 @@
1
+ import { isNullish } from '@williamthorsen/toolbelt.guards';
1
2
  export function makeNullishCompare(compare, options = {}) {
2
3
  return function compareWithNullishHandling(a, b) {
3
4
  return nullishCompare(compare, a, b, options);
@@ -15,6 +16,3 @@ export function nullishCompare(compare, a, b, options = {}) {
15
16
  }
16
17
  return compare(a, b) || 0;
17
18
  }
18
- function isNullish(value) {
19
- return value === null || value === undefined;
20
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@williamthorsen/toolbelt.arrays",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "description": "Array utilities",
5
5
  "keywords": [
6
6
  "array",
@@ -44,8 +44,8 @@
44
44
  "CHANGELOG.md"
45
45
  ],
46
46
  "dependencies": {
47
- "@williamthorsen/toolbelt.numbers": "6.0.1",
48
- "@williamthorsen/toolbelt.guards": "3.1.10"
47
+ "@williamthorsen/toolbelt.guards": "4.0.0",
48
+ "@williamthorsen/toolbelt.numbers": "7.0.0"
49
49
  },
50
50
  "engines": {
51
51
  "node": ">=24.0.0"