@rightcapital/assert 2.1.3-feature-rename-assert-error-to-assertion-error.2367.1.0 → 2.1.3-feature-assert-package-assert-function-value-parameter-type-must-be-boolean.2370.1.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/README.md CHANGED
@@ -113,15 +113,15 @@ try {
113
113
 
114
114
  ## API Summary
115
115
 
116
- | API | Return / Type Behavior | Typical Use Case |
117
- | :------------------------------- | :-------------------------------- | :---------------------------------------------------- |
118
- | `AssertionError` | `class extends Error` | Error thrown on assertion failure |
119
- | `assertExhaustive(value, msg?)` | `never` | Enforce exhaustiveness check in `switch` or `if-else` |
120
- | `assertUnreachable(msg?)` | `never` | Mark logically unreachable code branches |
121
- | `ensure(value, predicate, msg?)` | `S extends T` | Validate and return value with narrowed type |
122
- | `ensureNonNullable(value, msg?)` | `NonNullable<T>` | Validate non-null/undefined and return value |
123
- | `assert(value, msg?)` | `asserts value` | Standard boolean condition assertion |
124
- | `assertNonNullable(value, msg?)` | `asserts value is NonNullable<T>` | Standard non-null/undefined assertion |
116
+ | API / Signature | Description / Typical Use Case |
117
+ | :------------------------------------------------------------------------------------------- | :---------------------------------------------------- |
118
+ | `AssertionError extends Error` | Error thrown on assertion failure |
119
+ | `assertExhaustive(value: never, message?: string): never` | Enforce exhaustiveness check in `switch` or `if-else` |
120
+ | `assertUnreachable(message?: string): never` | Mark logically unreachable code branches |
121
+ | `ensure<T, S extends T>(value: T, predicate: (value: T) => value is S, message?: string): S` | Validate and return value with narrowed type |
122
+ | `ensureNonNullable<T>(value: T, message?: string): NonNullable<T>` | Validate non-null/undefined and return value |
123
+ | `assert(value: boolean, message?: string): asserts value` | Standard boolean condition assertion |
124
+ | `assertNonNullable<T>(value: T, message?: string): asserts value is NonNullable<T>` | Standard non-null/undefined assertion |
125
125
 
126
126
  ## Agent Skills
127
127
 
package/lib/index.d.ts CHANGED
@@ -26,7 +26,7 @@ export declare class AssertionError extends Error {
26
26
  /**
27
27
  * Basic assertion: verifies that a value or expression is `true`, otherwise throws an exception.
28
28
  *
29
- * @param value - The value to assert as truthy
29
+ * @param value - The boolean condition to assert as `true`
30
30
  * @param message - Optional custom error message
31
31
  * @throws {AssertionError} Throws an error if `value` is not `true`.
32
32
  *
@@ -40,7 +40,7 @@ export declare class AssertionError extends Error {
40
40
  * assert(isValid, 'Data validation failed');
41
41
  * ```
42
42
  */
43
- export declare function assert(value: unknown, message?: string): asserts value;
43
+ export declare function assert(value: boolean, message?: string): asserts value;
44
44
  /**
45
45
  * Asserts that a value is not `null` or `undefined`, providing TypeScript type narrowing to `NonNullable<T>`.
46
46
  * Ensures subsequent code can safely access the value.
package/lib/index.js CHANGED
@@ -39,7 +39,7 @@ function throwError(name, value, message) {
39
39
  /**
40
40
  * Basic assertion: verifies that a value or expression is `true`, otherwise throws an exception.
41
41
  *
42
- * @param value - The value to assert as truthy
42
+ * @param value - The boolean condition to assert as `true`
43
43
  * @param message - Optional custom error message
44
44
  * @throws {AssertionError} Throws an error if `value` is not `true`.
45
45
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rightcapital/assert",
3
- "version": "2.1.3-feature-rename-assert-error-to-assertion-error.2367.1.0",
3
+ "version": "2.1.3-feature-assert-package-assert-function-value-parameter-type-must-be-boolean.2370.1.0",
4
4
  "description": "Type-safe assertion utilities for defensive programming.",
5
5
  "author": "RightCapital Ecosystem team <npm-publisher@rightcapital.com>",
6
6
  "keywords": [
@@ -30,15 +30,15 @@ import {
30
30
 
31
31
  ## Quick Reference
32
32
 
33
- | Class / Function | Signature / Return | Use Case |
34
- | -------------------------------- | --------------------------------- | ------------------------------------------------------------------- |
35
- | `AssertionError` | `class extends Error` | Error type thrown when any assertion in this package fails. |
36
- | `assert(value, msg?)` | `asserts value` | Precondition or boolean check (verifies `value === true`). |
37
- | `assertNonNullable(value, msg?)` | `asserts value is NonNullable<T>` | Guard statement against `null` or `undefined`. |
38
- | `ensure(value, predicate, msg?)` | `S extends T` | Inline validation using type guard function `(val: T) => val is S`. |
39
- | `ensureNonNullable(value, msg?)` | `NonNullable<T>` | Inline assignment or method chain for non-null value. |
40
- | `assertExhaustive(value, msg?)` | `value: never` -> `never` | Exhaustiveness check in `switch` `default` case or `if-else` chain. |
41
- | `assertUnreachable(msg?)` | `never` | Mark logically impossible code paths. |
33
+ | API / Signature | Description / Typical Use Case |
34
+ | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
35
+ | `AssertionError extends Error` | Error type thrown when any assertion in this package fails. |
36
+ | `assert(value: boolean, message?: string): asserts value` | Precondition or boolean check (verifies `value === true`). |
37
+ | `assertNonNullable<T>(value: T, message?: string): asserts value is NonNullable<T>` | Guard statement against `null` or `undefined`. |
38
+ | `ensure<T, S extends T>(value: T, predicate: (value: T) => value is S, message?: string): S` | Inline validation using type guard function `(val: T) => val is S`. |
39
+ | `ensureNonNullable<T>(value: T, message?: string): NonNullable<T>` | Inline assignment or method chain for non-null value. |
40
+ | `assertExhaustive(value: never, message?: string): never` | Exhaustiveness check in `switch` `default` case or `if-else` chain. |
41
+ | `assertUnreachable(message?: string): never` | Mark logically impossible code paths. |
42
42
 
43
43
  ## Error Handling with `AssertionError`
44
44
 
package/src/index.ts CHANGED
@@ -39,7 +39,7 @@ function throwError(
39
39
  /**
40
40
  * Basic assertion: verifies that a value or expression is `true`, otherwise throws an exception.
41
41
  *
42
- * @param value - The value to assert as truthy
42
+ * @param value - The boolean condition to assert as `true`
43
43
  * @param message - Optional custom error message
44
44
  * @throws {AssertionError} Throws an error if `value` is not `true`.
45
45
  *
@@ -53,7 +53,7 @@ function throwError(
53
53
  * assert(isValid, 'Data validation failed');
54
54
  * ```
55
55
  */
56
- export function assert(value: unknown, message?: string): asserts value {
56
+ export function assert(value: boolean, message?: string): asserts value {
57
57
  if (value !== true) {
58
58
  throwError('assert', value, message);
59
59
  }