@kensio/smartass 1.6.0 → 1.8.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/dist/assert/array-includes/array-includes.assert.d.ts +2 -3
- package/dist/assert/array-includes/array-includes.assert.d.ts.map +1 -1
- package/dist/assert/array-includes/array-includes.assert.js +4 -2
- package/dist/assert/array-includes/array-includes.assert.js.map +1 -1
- package/dist/assert/array-includes/array-includes.match.d.ts +9 -0
- package/dist/assert/array-includes/array-includes.match.d.ts.map +1 -0
- package/dist/assert/array-includes/array-includes.match.js +9 -0
- package/dist/assert/array-includes/array-includes.match.js.map +1 -0
- package/dist/assert/array-includes-all/array-includes-all.assert.d.ts +2 -3
- package/dist/assert/array-includes-all/array-includes-all.assert.d.ts.map +1 -1
- package/dist/assert/array-includes-all/array-includes-all.assert.js +5 -3
- package/dist/assert/array-includes-all/array-includes-all.assert.js.map +1 -1
- package/dist/assert/array-includes-all/array-includes-all.match.d.ts +14 -0
- package/dist/assert/array-includes-all/array-includes-all.match.d.ts.map +1 -0
- package/dist/assert/array-includes-all/array-includes-all.match.js +20 -0
- package/dist/assert/array-includes-all/array-includes-all.match.js.map +1 -0
- package/dist/assert/array-length/array-length.assert.d.ts +1 -4
- package/dist/assert/array-length/array-length.assert.d.ts.map +1 -1
- package/dist/assert/array-length/array-length.assert.js +4 -2
- package/dist/assert/array-length/array-length.assert.js.map +1 -1
- package/dist/assert/array-length/array-length.match.d.ts +9 -0
- package/dist/assert/array-length/array-length.match.d.ts.map +1 -0
- package/dist/assert/array-length/array-length.match.js +9 -0
- package/dist/assert/array-length/array-length.match.js.map +1 -0
- package/dist/assert/array-min-length/array-min-length.assert.d.ts +2 -1
- package/dist/assert/array-min-length/array-min-length.assert.d.ts.map +1 -1
- package/dist/assert/array-min-length/array-min-length.assert.js +2 -1
- package/dist/assert/array-min-length/array-min-length.assert.js.map +1 -1
- package/dist/assert/array-min-length/array-min-length.match.d.ts +7 -0
- package/dist/assert/array-min-length/array-min-length.match.d.ts.map +1 -0
- package/dist/assert/array-min-length/array-min-length.match.js +9 -0
- package/dist/assert/array-min-length/array-min-length.match.js.map +1 -0
- package/dist/assert/array-not-empty/array-not-empty.assert.d.ts +2 -1
- package/dist/assert/array-not-empty/array-not-empty.assert.d.ts.map +1 -1
- package/dist/assert/array-not-empty/array-not-empty.assert.js +2 -1
- package/dist/assert/array-not-empty/array-not-empty.assert.js.map +1 -1
- package/dist/assert/array-not-empty/array-not-empty.match.d.ts +7 -0
- package/dist/assert/array-not-empty/array-not-empty.match.d.ts.map +1 -0
- package/dist/assert/array-not-empty/array-not-empty.match.js +8 -0
- package/dist/assert/array-not-empty/array-not-empty.match.js.map +1 -0
- package/dist/assert/buffer-equal/buffer-equal.assert.d.ts +1 -1
- package/dist/assert/buffer-equal/buffer-equal.assert.d.ts.map +1 -1
- package/dist/assert/buffer-equal/buffer-equal.assert.js +2 -6
- package/dist/assert/buffer-equal/buffer-equal.assert.js.map +1 -1
- package/dist/assert/buffer-equal/buffer-equal.match.d.ts +7 -0
- package/dist/assert/buffer-equal/buffer-equal.match.d.ts.map +1 -0
- package/dist/assert/buffer-equal/buffer-equal.match.js +20 -0
- package/dist/assert/buffer-equal/buffer-equal.match.js.map +1 -0
- package/dist/assert/instance-of/instance-of.assert.d.ts.map +1 -1
- package/dist/assert/instance-of/instance-of.assert.js +4 -3
- package/dist/assert/instance-of/instance-of.assert.js.map +1 -1
- package/dist/assert/instance-of/instance-of.match.d.ts +6 -0
- package/dist/assert/instance-of/instance-of.match.d.ts.map +1 -0
- package/dist/assert/instance-of/instance-of.match.js +8 -0
- package/dist/assert/instance-of/instance-of.match.js.map +1 -0
- package/dist/assert/non-nullable/non-nullable.match.d.ts +6 -0
- package/dist/assert/non-nullable/non-nullable.match.d.ts.map +1 -0
- package/dist/assert/non-nullable/non-nullable.match.js +8 -0
- package/dist/assert/non-nullable/non-nullable.match.js.map +1 -0
- package/dist/assert/number-between/number-between.assert.d.ts.map +1 -1
- package/dist/assert/number-between/number-between.assert.js +2 -1
- package/dist/assert/number-between/number-between.assert.js.map +1 -1
- package/dist/assert/number-between/number-between.match.d.ts +6 -0
- package/dist/assert/number-between/number-between.match.d.ts.map +1 -0
- package/dist/assert/number-between/number-between.match.js +14 -0
- package/dist/assert/number-between/number-between.match.js.map +1 -0
- package/dist/assert/number-to-nearest/number-to-nearest.assert.d.ts.map +1 -1
- package/dist/assert/number-to-nearest/number-to-nearest.assert.js +4 -8
- package/dist/assert/number-to-nearest/number-to-nearest.assert.js.map +1 -1
- package/dist/assert/number-to-nearest/number-to-nearest.match.d.ts +7 -0
- package/dist/assert/number-to-nearest/number-to-nearest.match.d.ts.map +1 -0
- package/dist/assert/number-to-nearest/number-to-nearest.match.js +18 -0
- package/dist/assert/number-to-nearest/number-to-nearest.match.js.map +1 -0
- package/dist/assert/object-has-property/object-has-property.assert.d.ts +2 -3
- package/dist/assert/object-has-property/object-has-property.assert.d.ts.map +1 -1
- package/dist/assert/object-has-property/object-has-property.assert.js +5 -3
- package/dist/assert/object-has-property/object-has-property.assert.js.map +1 -1
- package/dist/assert/object-has-property/object-has-property.match.d.ts +8 -0
- package/dist/assert/object-has-property/object-has-property.match.d.ts.map +1 -0
- package/dist/assert/object-has-property/object-has-property.match.js +10 -0
- package/dist/assert/object-has-property/object-has-property.match.js.map +1 -0
- package/dist/assert/object-matches/object-matches.assert.d.ts +7 -4
- package/dist/assert/object-matches/object-matches.assert.d.ts.map +1 -1
- package/dist/assert/object-matches/object-matches.assert.js +5 -3
- package/dist/assert/object-matches/object-matches.assert.js.map +1 -1
- package/dist/assert/one-of/one-of.assert.d.ts.map +1 -1
- package/dist/assert/one-of/one-of.assert.js +6 -4
- package/dist/assert/one-of/one-of.assert.js.map +1 -1
- package/dist/assert/one-of/one-of.match.d.ts +6 -0
- package/dist/assert/one-of/one-of.match.d.ts.map +1 -0
- package/dist/assert/one-of/one-of.match.js +9 -0
- package/dist/assert/one-of/one-of.match.js.map +1 -0
- package/dist/assert/string-ends-with/string-ends-with.assert.d.ts.map +1 -1
- package/dist/assert/string-ends-with/string-ends-with.assert.js +4 -2
- package/dist/assert/string-ends-with/string-ends-with.assert.js.map +1 -1
- package/dist/assert/string-ends-with/string-ends-with.match.d.ts +6 -0
- package/dist/assert/string-ends-with/string-ends-with.match.d.ts.map +1 -0
- package/dist/assert/string-ends-with/string-ends-with.match.js +9 -0
- package/dist/assert/string-ends-with/string-ends-with.match.js.map +1 -0
- package/dist/assert/string-includes/string-includes.assert.d.ts.map +1 -1
- package/dist/assert/string-includes/string-includes.assert.js +4 -2
- package/dist/assert/string-includes/string-includes.assert.js.map +1 -1
- package/dist/assert/string-includes/string-includes.match.d.ts +6 -0
- package/dist/assert/string-includes/string-includes.match.d.ts.map +1 -0
- package/dist/assert/string-includes/string-includes.match.js +9 -0
- package/dist/assert/string-includes/string-includes.match.js.map +1 -0
- package/dist/assert/string-length/string-length.assert.d.ts +1 -90
- package/dist/assert/string-length/string-length.assert.d.ts.map +1 -1
- package/dist/assert/string-length/string-length.assert.js +4 -2
- package/dist/assert/string-length/string-length.assert.js.map +1 -1
- package/dist/assert/string-length/string-length.match.d.ts +95 -0
- package/dist/assert/string-length/string-length.match.d.ts.map +1 -0
- package/dist/assert/string-length/string-length.match.js +9 -0
- package/dist/assert/string-length/string-length.match.js.map +1 -0
- package/dist/assert/string-not-includes/string-not-includes.assert.d.ts.map +1 -1
- package/dist/assert/string-not-includes/string-not-includes.assert.js +4 -2
- package/dist/assert/string-not-includes/string-not-includes.assert.js.map +1 -1
- package/dist/assert/string-not-includes/string-not-includes.match.d.ts +6 -0
- package/dist/assert/string-not-includes/string-not-includes.match.d.ts.map +1 -0
- package/dist/assert/string-not-includes/string-not-includes.match.js +9 -0
- package/dist/assert/string-not-includes/string-not-includes.match.js.map +1 -0
- package/dist/compare/object-comparison.d.ts.map +1 -1
- package/dist/compare/object-comparison.js +11 -0
- package/dist/compare/object-comparison.js.map +1 -1
- package/dist/describe/describe.d.ts.map +1 -1
- package/dist/describe/describe.js +8 -1
- package/dist/describe/describe.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/match/match.d.ts +20 -0
- package/dist/match/match.d.ts.map +1 -0
- package/dist/match/match.js +19 -0
- package/dist/match/match.js.map +1 -0
- package/package.json +3 -3
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { type ArrayIncluding } from "./array-includes.match.js";
|
|
1
2
|
/**
|
|
2
3
|
* Assert that an array includes a specific element, with type narrowing.
|
|
3
4
|
* Note that this is an identity match, so objects in an array only fulfill the
|
|
4
5
|
* assertion by being a reference to the same object, rather than equivalent in
|
|
5
6
|
* value to another object reference.
|
|
6
7
|
*/
|
|
7
|
-
export declare function assertArrayIncludes<T, const E extends T>(value: readonly T[], element: E, message?: string): asserts value is
|
|
8
|
-
includes(searchElement: E): true;
|
|
9
|
-
};
|
|
8
|
+
export declare function assertArrayIncludes<T, const E extends T>(value: readonly T[], element: E, message?: string): asserts value is ArrayIncluding<T, E>;
|
|
10
9
|
//# sourceMappingURL=array-includes.assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-includes.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-includes/array-includes.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array-includes.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-includes/array-includes.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhF;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,SAAS,CAAC,EACtD,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,OAAO,EAAE,CAAC,EACV,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAUvC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arrayIncluding } from "./array-includes.match.js";
|
|
1
2
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
3
|
import { desc } from "../../describe/describe.js";
|
|
3
4
|
/**
|
|
@@ -7,9 +8,10 @@ import { desc } from "../../describe/describe.js";
|
|
|
7
8
|
* value to another object reference.
|
|
8
9
|
*/
|
|
9
10
|
export function assertArrayIncludes(value, element, message) {
|
|
10
|
-
|
|
11
|
+
const matcher = arrayIncluding(element);
|
|
12
|
+
if (!matcher.matches(value)) {
|
|
11
13
|
throw new AssertionError(message ??
|
|
12
|
-
`Expected ${desc(value)} to include ${desc(element)}, but it did not.`, value,
|
|
14
|
+
`Expected ${desc(value)} to include ${desc(element)}, but it did not.`, value, matcher.represent());
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
//# sourceMappingURL=array-includes.assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-includes.assert.js","sourceRoot":"","sources":["../../../src/assert/array-includes/array-includes.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAmB,EACnB,OAAU,EACV,OAAgB;
|
|
1
|
+
{"version":3,"file":"array-includes.assert.js","sourceRoot":"","sources":["../../../src/assert/array-includes/array-includes.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAmB,EACnB,OAAU,EACV,OAAgB;IAEhB,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,OAAO,CAAC,mBAAmB,EACxE,KAAK,EACL,OAAO,CAAC,SAAS,EAAE,CACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
export type ArrayIncluding<T, E extends T> = readonly [T, ...T[]] & {
|
|
3
|
+
includes(searchElement: E): true;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Matcher for an array including a specific single element.
|
|
7
|
+
*/
|
|
8
|
+
export declare function arrayIncluding<const E>(element: E): AssertionMatcher<ArrayIncluding<unknown, E>>;
|
|
9
|
+
//# sourceMappingURL=array-includes.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-includes.match.d.ts","sourceRoot":"","sources":["../../../src/assert/array-includes/array-includes.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG5E,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG;IAClE,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,EACpC,OAAO,EAAE,CAAC,GACT,gBAAgB,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAO9C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createMatcher } from "../../match/match.js";
|
|
2
|
+
import { desc, repr } from "../../describe/describe.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for an array including a specific single element.
|
|
5
|
+
*/
|
|
6
|
+
export function arrayIncluding(element) {
|
|
7
|
+
return createMatcher((value) => Array.isArray(value) && value.includes(element), () => `array including ${desc(element)}`, () => `[…,${repr(element)},…]`);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=array-includes.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-includes.match.js","sourceRoot":"","sources":["../../../src/assert/array-includes/array-includes.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAMxD;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAU;IAEV,OAAO,aAAa,CAClB,CAAC,KAAK,EAAuC,EAAE,CAC7C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EACjD,GAAG,EAAE,CAAC,mBAAmB,IAAI,CAAC,OAAO,CAAC,EAAE,EACxC,GAAG,EAAE,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { type ArrayIncludingAll } from "./array-includes-all.match.js";
|
|
1
2
|
/**
|
|
2
3
|
* Assert that an array includes all specified elements, with type narrowing.
|
|
3
4
|
* Elements can appear in any order and do not need to be contiguous.
|
|
4
5
|
* Each required element must be present at least once.
|
|
5
6
|
*/
|
|
6
|
-
export declare function assertArrayIncludesAll<T, const E extends readonly T[]>(value: readonly T[], elements: E, message?: string): asserts value is
|
|
7
|
-
includes(searchElement: E[number]): true;
|
|
8
|
-
};
|
|
7
|
+
export declare function assertArrayIncludesAll<T, const E extends readonly T[]>(value: readonly T[], elements: E, message?: string): asserts value is ArrayIncludingAll<T, E>;
|
|
9
8
|
//# sourceMappingURL=array-includes-all.assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-includes-all.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-includes-all/array-includes-all.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array-includes-all.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-includes-all/array-includes-all.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AAIvC;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,SAAS,SAAS,CAAC,EAAE,EACpE,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,QAAQ,EAAE,CAAC,EACX,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAW1C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arrayIncludingAll, } from "./array-includes-all.match.js";
|
|
1
2
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
3
|
import { desc, repr } from "../../describe/describe.js";
|
|
3
4
|
/**
|
|
@@ -6,10 +7,11 @@ import { desc, repr } from "../../describe/describe.js";
|
|
|
6
7
|
* Each required element must be present at least once.
|
|
7
8
|
*/
|
|
8
9
|
export function assertArrayIncludesAll(value, elements, message) {
|
|
9
|
-
const
|
|
10
|
-
if (
|
|
10
|
+
const matcher = arrayIncludingAll(elements);
|
|
11
|
+
if (!matcher.matches(value)) {
|
|
12
|
+
const missing = elements.filter((element) => !value.includes(element));
|
|
11
13
|
throw new AssertionError(message ??
|
|
12
|
-
`Expected ${desc(value)} to include all of ${repr(elements)}, but missing ${repr(missing)}.`, value,
|
|
14
|
+
`Expected ${desc(value)} to include all of ${repr(elements)}, but missing ${repr(missing)}.`, value, matcher.represent());
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
//# sourceMappingURL=array-includes-all.assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-includes-all.assert.js","sourceRoot":"","sources":["../../../src/assert/array-includes-all/array-includes-all.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAmB,EACnB,QAAW,EACX,OAAgB;
|
|
1
|
+
{"version":3,"file":"array-includes-all.assert.js","sourceRoot":"","sources":["../../../src/assert/array-includes-all/array-includes-all.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAElB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAmB,EACnB,QAAW,EACX,OAAgB;IAEhB,MAAM,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QACvE,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,KAAK,CAAC,sBAAsB,IAAI,CAAC,QAAQ,CAAC,iBAAiB,IAAI,CAAC,OAAO,CAAC,GAAG,EAC9F,KAAK,EACL,OAAO,CAAC,SAAS,EAAE,CACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
export type ArrayIncludingAll<T, E extends readonly T[]> = readonly [
|
|
3
|
+
T,
|
|
4
|
+
...T[]
|
|
5
|
+
] & {
|
|
6
|
+
includes(searchElement: E[number]): true;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Matcher for an array including all specified elements.
|
|
10
|
+
* Elements can appear in any order and do not need to be contiguous.
|
|
11
|
+
* Each required element must be present at least once.
|
|
12
|
+
*/
|
|
13
|
+
export declare function arrayIncludingAll<const E extends readonly unknown[]>(elements: E): AssertionMatcher<ArrayIncludingAll<unknown, E>>;
|
|
14
|
+
//# sourceMappingURL=array-includes-all.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-includes-all.match.d.ts","sourceRoot":"","sources":["../../../src/assert/array-includes-all/array-includes-all.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG5E,MAAM,MAAM,iBAAiB,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,CAAC,EAAE,IAAI,SAAS;IAClE,CAAC;IACD,GAAG,CAAC,EAAE;CACP,GAAG;IACF,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAC1C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAClE,QAAQ,EAAE,CAAC,GACV,gBAAgB,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAQjD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createMatcher } from "../../match/match.js";
|
|
2
|
+
import { desc, repr } from "../../describe/describe.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for an array including all specified elements.
|
|
5
|
+
* Elements can appear in any order and do not need to be contiguous.
|
|
6
|
+
* Each required element must be present at least once.
|
|
7
|
+
*/
|
|
8
|
+
export function arrayIncludingAll(elements) {
|
|
9
|
+
return createMatcher((value) => Array.isArray(value) &&
|
|
10
|
+
elements.every((element) => value.includes(element)), () => `array including all of ${desc(elements)}`, () => `[…,${reprArrayElements(elements)},…]`);
|
|
11
|
+
}
|
|
12
|
+
function reprArrayElements(values) {
|
|
13
|
+
if (values.length <= 5) {
|
|
14
|
+
return values.map((value) => repr(value)).join(",");
|
|
15
|
+
}
|
|
16
|
+
const first = values.slice(0, 3).map((value) => repr(value));
|
|
17
|
+
const last = values.slice(-1).map((value) => repr(value));
|
|
18
|
+
return [...first, "…", ...last].join(",");
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=array-includes-all.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-includes-all.match.js","sourceRoot":"","sources":["../../../src/assert/array-includes-all/array-includes-all.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AASxD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAW;IAEX,OAAO,aAAa,CAClB,CAAC,KAAK,EAA0C,EAAE,CAChD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EACtD,GAAG,EAAE,CAAC,0BAA0B,IAAI,CAAC,QAAQ,CAAC,EAAE,EAChD,GAAG,EAAE,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAC7C,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,MAA0B;IACnD,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAE1D,OAAO,CAAC,GAAG,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ArrayOfLength } from "./array-length.match.js";
|
|
1
2
|
/**
|
|
2
3
|
* Assert that an array has exactly the expected length, with type narrowing.
|
|
3
4
|
* The type narrowing indicates:
|
|
@@ -6,8 +7,4 @@
|
|
|
6
7
|
* - At least 10 elements for >10
|
|
7
8
|
*/
|
|
8
9
|
export declare function assertArrayLength<T, const N extends number>(value: readonly T[] | undefined | null, expectedLength: N, message?: string): asserts value is ArrayOfLength<T, N>;
|
|
9
|
-
type ArrayOfLength<T, N extends number> = N extends 0 ? readonly [] : N extends 1 ? readonly [T] : N extends 2 ? readonly [T, T] : N extends 3 ? readonly [T, T, T] : N extends 4 ? readonly [T, T, T, T] : N extends 5 ? readonly [T, T, T, T, T] : N extends 6 ? readonly [T, T, T, T, T, T] : N extends 7 ? readonly [T, T, T, T, T, T, T] : N extends 8 ? readonly [T, T, T, T, T, T, T, T] : N extends 9 ? readonly [T, T, T, T, T, T, T, T, T] : N extends 10 ? readonly [T, T, T, T, T, T, T, T, T, T] : readonly [T, T, T, T, T, T, T, T, T, T, ...T[]] & {
|
|
10
|
-
length: N;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
13
10
|
//# sourceMappingURL=array-length.assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-length.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-length/array-length.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array-length.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-length/array-length.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAK5E;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,SAAS,MAAM,EACzD,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,GAAG,IAAI,EACtC,cAAc,EAAE,CAAC,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAWtC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arrayOfLength } from "./array-length.match.js";
|
|
1
2
|
import { assertNonNullable } from "../non-nullable/non-nullable.assert.js";
|
|
2
3
|
import { AssertionError } from "../../assertion-error.js";
|
|
3
4
|
import { desc, repr } from "../../describe/describe.js";
|
|
@@ -10,9 +11,10 @@ import { desc, repr } from "../../describe/describe.js";
|
|
|
10
11
|
*/
|
|
11
12
|
export function assertArrayLength(value, expectedLength, message) {
|
|
12
13
|
assertNonNullable(value, message);
|
|
13
|
-
|
|
14
|
+
const matcher = arrayOfLength(expectedLength);
|
|
15
|
+
if (!matcher.matches(value)) {
|
|
14
16
|
throw new AssertionError(message ??
|
|
15
|
-
`Expected ${desc(value)} to have length ${repr(expectedLength)}, but it had length ${repr(value.length)}.`, value,
|
|
17
|
+
`Expected ${desc(value)} to have length ${repr(expectedLength)}, but it had length ${repr(value.length)}.`, value, matcher.represent());
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
//# sourceMappingURL=array-length.assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-length.assert.js","sourceRoot":"","sources":["../../../src/assert/array-length/array-length.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAsC,EACtC,cAAiB,EACjB,OAAgB;IAEhB,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"array-length.assert.js","sourceRoot":"","sources":["../../../src/assert/array-length/array-length.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAsB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAsC,EACtC,cAAiB,EACjB,OAAgB;IAEhB,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;IAC9C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,KAAK,CAAC,mBAAmB,IAAI,CAAC,cAAc,CAAC,uBAAuB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAC5G,KAAK,EACL,OAAO,CAAC,SAAS,EAAE,CACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
export type ArrayOfLength<T, N extends number> = N extends 0 ? readonly [] : N extends 1 ? readonly [T] : N extends 2 ? readonly [T, T] : N extends 3 ? readonly [T, T, T] : N extends 4 ? readonly [T, T, T, T] : N extends 5 ? readonly [T, T, T, T, T] : N extends 6 ? readonly [T, T, T, T, T, T] : N extends 7 ? readonly [T, T, T, T, T, T, T] : N extends 8 ? readonly [T, T, T, T, T, T, T, T] : N extends 9 ? readonly [T, T, T, T, T, T, T, T, T] : N extends 10 ? readonly [T, T, T, T, T, T, T, T, T, T] : readonly [T, T, T, T, T, T, T, T, T, T, ...T[]] & {
|
|
3
|
+
length: N;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Matcher for an array with exactly the expected length.
|
|
7
|
+
*/
|
|
8
|
+
export declare function arrayOfLength<const N extends number>(expectedLength: N): AssertionMatcher<ArrayOfLength<unknown, N>>;
|
|
9
|
+
//# sourceMappingURL=array-length.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-length.match.d.ts","sourceRoot":"","sources":["../../../src/assert/array-length/array-length.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG5E,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,GACxD,SAAS,EAAE,GACX,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,CAAC,GACZ,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GACf,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAClB,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACrB,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACxB,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC3B,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAC9B,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACjC,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACpC,CAAC,SAAS,EAAE,GACV,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACvC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG;IAChD,MAAM,EAAE,CAAC,CAAC;CACX,CAAC;AAE1B;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAClD,cAAc,EAAE,CAAC,GAChB,gBAAgB,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAO7C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createMatcher } from "../../match/match.js";
|
|
2
|
+
import { repr } from "../../describe/describe.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for an array with exactly the expected length.
|
|
5
|
+
*/
|
|
6
|
+
export function arrayOfLength(expectedLength) {
|
|
7
|
+
return createMatcher((value) => Array.isArray(value) && value.length === expectedLength, () => `array of length ${repr(expectedLength)}`, () => `Array(${repr(expectedLength)})`);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=array-length.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-length.match.js","sourceRoot":"","sources":["../../../src/assert/array-length/array-length.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AA4BlD;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,cAAiB;IAEjB,OAAO,aAAa,CAClB,CAAC,KAAK,EAAsC,EAAE,CAC5C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,cAAc,EACzD,GAAG,EAAE,CAAC,mBAAmB,IAAI,CAAC,cAAc,CAAC,EAAE,EAC/C,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,cAAc,CAAC,GAAG,CACvC,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ArrayOfMinLength } from "./array-min-length.match.js";
|
|
1
2
|
/**
|
|
2
3
|
* Assert that an array has at least the expected minimum length, with type narrowing.
|
|
3
4
|
* The type narrowing indicates:
|
|
@@ -5,5 +6,5 @@
|
|
|
5
6
|
* - At least N elements up to 5
|
|
6
7
|
* - At least 5 elements for >5
|
|
7
8
|
*/
|
|
8
|
-
export declare function assertArrayMinLength<T, const N extends number>(value: readonly T[] | undefined | null, minLength: N, message?: string): asserts value is
|
|
9
|
+
export declare function assertArrayMinLength<T, const N extends number>(value: readonly T[] | undefined | null, minLength: N, message?: string): asserts value is ArrayOfMinLength<T, N>;
|
|
9
10
|
//# sourceMappingURL=array-min-length.assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-min-length.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-min-length/array-min-length.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array-min-length.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-min-length/array-min-length.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,6BAA6B,CAAC;AAKrC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,SAAS,MAAM,EAC5D,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,GAAG,IAAI,EACtC,SAAS,EAAE,CAAC,EACZ,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAWzC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { arrayOfMinLength, } from "./array-min-length.match.js";
|
|
1
2
|
import { assertNonNullable } from "../non-nullable/non-nullable.assert.js";
|
|
2
3
|
import { AssertionError } from "../../assertion-error.js";
|
|
3
4
|
import { desc, repr } from "../../describe/describe.js";
|
|
@@ -10,7 +11,7 @@ import { desc, repr } from "../../describe/describe.js";
|
|
|
10
11
|
*/
|
|
11
12
|
export function assertArrayMinLength(value, minLength, message) {
|
|
12
13
|
assertNonNullable(value, message);
|
|
13
|
-
if (
|
|
14
|
+
if (!arrayOfMinLength(minLength).matches(value)) {
|
|
14
15
|
throw new AssertionError(message ??
|
|
15
16
|
`Expected ${desc(value)} to have at least ${repr(minLength)} elements, but it had ${repr(value.length)}.`, value, { minLength });
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-min-length.assert.js","sourceRoot":"","sources":["../../../src/assert/array-min-length/array-min-length.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAsC,EACtC,SAAY,EACZ,OAAgB;
|
|
1
|
+
{"version":3,"file":"array-min-length.assert.js","sourceRoot":"","sources":["../../../src/assert/array-min-length/array-min-length.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAEjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAsC,EACtC,SAAY,EACZ,OAAgB;IAEhB,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAElC,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,KAAK,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,yBAAyB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,EAC3G,KAAK,EACL,EAAE,SAAS,EAAE,CACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
export type ArrayOfMinLength<T, N extends number> = N extends 0 ? readonly T[] : N extends 1 ? readonly [T, ...T[]] : N extends 2 ? readonly [T, T, ...T[]] : N extends 3 ? readonly [T, T, T, ...T[]] : N extends 4 ? readonly [T, T, T, T, ...T[]] : N extends 5 ? readonly [T, T, T, T, T, ...T[]] : readonly [T, T, T, T, T, ...T[]];
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for an array with at least the expected minimum length.
|
|
5
|
+
*/
|
|
6
|
+
export declare function arrayOfMinLength<const N extends number>(minLength: N): AssertionMatcher<ArrayOfMinLength<unknown, N>>;
|
|
7
|
+
//# sourceMappingURL=array-min-length.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-min-length.match.d.ts","sourceRoot":"","sources":["../../../src/assert/array-min-length/array-min-length.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG5E,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,GAC3D,SAAS,CAAC,EAAE,GACZ,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GACpB,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GACvB,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAC1B,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAC7B,CAAC,SAAS,CAAC,GACT,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAChC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAE/C;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACrD,SAAS,EAAE,CAAC,GACX,gBAAgB,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAOhD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createMatcher } from "../../match/match.js";
|
|
2
|
+
import { repr } from "../../describe/describe.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for an array with at least the expected minimum length.
|
|
5
|
+
*/
|
|
6
|
+
export function arrayOfMinLength(minLength) {
|
|
7
|
+
return createMatcher((value) => Array.isArray(value) && value.length >= minLength, () => `array of at least ${repr(minLength)} elements`, () => `Array(>=${repr(minLength)})`);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=array-min-length.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-min-length.match.js","sourceRoot":"","sources":["../../../src/assert/array-min-length/array-min-length.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAyB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAgBlD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAY;IAEZ,OAAO,aAAa,CAClB,CAAC,KAAK,EAAyC,EAAE,CAC/C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS,EACnD,GAAG,EAAE,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,WAAW,EACrD,GAAG,EAAE,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,GAAG,CACpC,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { type NonEmptyArray } from "./array-not-empty.match.js";
|
|
1
2
|
/**
|
|
2
3
|
* Assert that an array has at least one element, with type-narrowing.
|
|
3
4
|
*/
|
|
4
|
-
export declare function assertArrayNotEmpty<T>(value: readonly T[] | undefined | null, message?: string): asserts value is
|
|
5
|
+
export declare function assertArrayNotEmpty<T>(value: readonly T[] | undefined | null, message?: string): asserts value is NonEmptyArray<T>;
|
|
5
6
|
//# sourceMappingURL=array-not-empty.assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-not-empty.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-not-empty/array-not-empty.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array-not-empty.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-not-empty/array-not-empty.assert.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,4BAA4B,CAAC;AAG/E;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,GAAG,IAAI,EACtC,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,CAUnC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { assertNonNullable } from "../non-nullable/non-nullable.assert.js";
|
|
2
|
+
import { nonEmptyArray } from "./array-not-empty.match.js";
|
|
2
3
|
import { AssertionError } from "../../assertion-error.js";
|
|
3
4
|
/**
|
|
4
5
|
* Assert that an array has at least one element, with type-narrowing.
|
|
5
6
|
*/
|
|
6
7
|
export function assertArrayNotEmpty(value, message) {
|
|
7
8
|
assertNonNullable(value, message);
|
|
8
|
-
if (value
|
|
9
|
+
if (!nonEmptyArray().matches(value)) {
|
|
9
10
|
throw new AssertionError(message ?? `Expected array not to be empty, but it was empty.`, value, ["..."]);
|
|
10
11
|
}
|
|
11
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-not-empty.assert.js","sourceRoot":"","sources":["../../../src/assert/array-not-empty/array-not-empty.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAsC,EACtC,OAAgB;IAEhB,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAElC,IAAI,
|
|
1
|
+
{"version":3,"file":"array-not-empty.assert.js","sourceRoot":"","sources":["../../../src/assert/array-not-empty/array-not-empty.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAsB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAsC,EACtC,OAAgB;IAEhB,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAElC,IAAI,CAAC,aAAa,EAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,cAAc,CACtB,OAAO,IAAI,mDAAmD,EAC9D,KAAK,EACL,CAAC,KAAK,CAAC,CACR,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
export type NonEmptyArray<T> = readonly [T, ...T[]];
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for a non-empty array.
|
|
5
|
+
*/
|
|
6
|
+
export declare function nonEmptyArray<T>(): AssertionMatcher<NonEmptyArray<T>>;
|
|
7
|
+
//# sourceMappingURL=array-not-empty.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-not-empty.match.d.ts","sourceRoot":"","sources":["../../../src/assert/array-not-empty/array-not-empty.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAEpD;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,KAAK,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAOrE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createMatcher } from "../../match/match.js";
|
|
2
|
+
/**
|
|
3
|
+
* Matcher for a non-empty array.
|
|
4
|
+
*/
|
|
5
|
+
export function nonEmptyArray() {
|
|
6
|
+
return createMatcher((value) => Array.isArray(value) && value.length > 0, () => `non-empty array`, () => `[...]`);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=array-not-empty.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-not-empty.match.js","sourceRoot":"","sources":["../../../src/assert/array-not-empty/array-not-empty.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI5E;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,aAAa,CAClB,CAAC,KAAK,EAA6B,EAAE,CACnC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAC1C,GAAG,EAAE,CAAC,iBAAiB,EACvB,GAAG,EAAE,CAAC,OAAO,CACd,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TypedArray } from "../type-typed-array/type-typed-array.assert.js";
|
|
2
2
|
/**
|
|
3
3
|
* Assert that two buffers (TypedArrays) are equal, comparing element by element.
|
|
4
4
|
* Supports all TypedArray types: Uint8Array, Int8Array, Uint16Array, Int16Array,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-equal.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/buffer-equal/buffer-equal.assert.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"buffer-equal.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/buffer-equal/buffer-equal.assert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gDAAgD,CAAC;AAGjF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,UAAU,EACpD,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,CAAC,EACX,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,IAAI,CAAC,CAQrB"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
2
|
import { desc } from "../../describe/describe.js";
|
|
3
|
-
import {
|
|
3
|
+
import { bufferEqualTo } from "./buffer-equal.match.js";
|
|
4
4
|
/**
|
|
5
5
|
* Assert that two buffers (TypedArrays) are equal, comparing element by element.
|
|
6
6
|
* Supports all TypedArray types: Uint8Array, Int8Array, Uint16Array, Int16Array,
|
|
7
7
|
* Uint32Array, Int32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array.
|
|
8
8
|
*/
|
|
9
9
|
export function assertBufferEqual(actual, expected, message) {
|
|
10
|
-
|
|
11
|
-
// Convert to Node.js Buffer for fast native comparison
|
|
12
|
-
const actualBuffer = Buffer.from(actual.buffer, actual.byteOffset, actual.byteLength);
|
|
13
|
-
const expectedBuffer = Buffer.from(expected.buffer, expected.byteOffset, expected.byteLength);
|
|
14
|
-
if (Buffer.compare(actualBuffer, expectedBuffer) !== 0) {
|
|
10
|
+
if (!bufferEqualTo(expected).matches(actual)) {
|
|
15
11
|
throw new AssertionError(message ?? `Expected ${desc(actual)} to equal ${desc(expected)}.`, actual, expected);
|
|
16
12
|
}
|
|
17
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-equal.assert.js","sourceRoot":"","sources":["../../../src/assert/buffer-equal/buffer-equal.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"buffer-equal.assert.js","sourceRoot":"","sources":["../../../src/assert/buffer-equal/buffer-equal.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAe,EACf,QAAW,EACX,OAAgB;IAEhB,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,cAAc,CACtB,OAAO,IAAI,YAAY,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,QAAQ,CAAC,GAAG,EACjE,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
import { type TypedArray } from "../type-typed-array/type-typed-array.assert.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for a TypedArray equal to an expected TypedArray, comparing byte by byte.
|
|
5
|
+
*/
|
|
6
|
+
export declare function bufferEqualTo<T extends TypedArray>(expected: T): AssertionMatcher<T>;
|
|
7
|
+
//# sourceMappingURL=buffer-equal.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-equal.match.d.ts","sourceRoot":"","sources":["../../../src/assert/buffer-equal/buffer-equal.match.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAEL,KAAK,UAAU,EAChB,MAAM,gDAAgD,CAAC;AAExD;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,UAAU,EAChD,QAAQ,EAAE,CAAC,GACV,gBAAgB,CAAC,CAAC,CAAC,CAyBrB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { desc, repr } from "../../describe/describe.js";
|
|
2
|
+
import { createMatcher } from "../../match/match.js";
|
|
3
|
+
import { assertTypeTypedArray, } from "../type-typed-array/type-typed-array.assert.js";
|
|
4
|
+
/**
|
|
5
|
+
* Matcher for a TypedArray equal to an expected TypedArray, comparing byte by byte.
|
|
6
|
+
*/
|
|
7
|
+
export function bufferEqualTo(expected) {
|
|
8
|
+
return createMatcher((value) => {
|
|
9
|
+
try {
|
|
10
|
+
assertTypeTypedArray(value);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const actualBuffer = Buffer.from(value.buffer, value.byteOffset, value.byteLength);
|
|
16
|
+
const expectedBuffer = Buffer.from(expected.buffer, expected.byteOffset, expected.byteLength);
|
|
17
|
+
return Buffer.compare(actualBuffer, expectedBuffer) === 0;
|
|
18
|
+
}, () => `buffer equal to ${desc(expected)}`, () => repr(expected));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=buffer-equal.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-equal.match.js","sourceRoot":"","sources":["../../../src/assert/buffer-equal/buffer-equal.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAyB,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACL,oBAAoB,GAErB,MAAM,gDAAgD,CAAC;AAExD;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAW;IAEX,OAAO,aAAa,CAClB,CAAC,KAAK,EAAc,EAAE;QACpB,IAAI,CAAC;YACH,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAC9B,KAAK,CAAC,MAAM,EACZ,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,UAAU,CACjB,CAAC;QACF,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAChC,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,UAAU,EACnB,QAAQ,CAAC,UAAU,CACpB,CAAC;QAEF,OAAO,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC,EACD,GAAG,EAAE,CAAC,mBAAmB,IAAI,CAAC,QAAQ,CAAC,EAAE,EACzC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CACrB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance-of.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/instance-of/instance-of.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instance-of.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/instance-of/instance-of.assert.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,KAAK,EAAE,OAAO,EACd,gBAAgB,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,EACtD,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,CAAC,CASpB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
|
+
import { instanceOf } from "./instance-of.match.js";
|
|
2
3
|
/**
|
|
3
4
|
* Assertion function that checks if a value is an instance of a given class, with type-narrowing.
|
|
4
5
|
*/
|
|
5
6
|
export function assertInstanceOf(value, classConstructor, message) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const matcher = instanceOf(classConstructor);
|
|
8
|
+
if (!matcher.matches(value)) {
|
|
9
|
+
throw new AssertionError(message ?? `Expected value to be ${matcher.describe()}, but it was not.`, value, matcher.represent());
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=instance-of.assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance-of.assert.js","sourceRoot":"","sources":["../../../src/assert/instance-of/instance-of.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"instance-of.assert.js","sourceRoot":"","sources":["../../../src/assert/instance-of/instance-of.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAc,EACd,gBAAsD,EACtD,OAAgB;IAEhB,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO,IAAI,wBAAwB,OAAO,CAAC,QAAQ,EAAE,mBAAmB,EACxE,KAAK,EACL,OAAO,CAAC,SAAS,EAAE,CACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
/**
|
|
3
|
+
* Matcher for a value being an instance of a given class.
|
|
4
|
+
*/
|
|
5
|
+
export declare function instanceOf<T>(classConstructor: abstract new (...args: never[]) => T): AssertionMatcher<T>;
|
|
6
|
+
//# sourceMappingURL=instance-of.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-of.match.d.ts","sourceRoot":"","sources":["../../../src/assert/instance-of/instance-of.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,gBAAgB,EAAE,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,GACrD,gBAAgB,CAAC,CAAC,CAAC,CAMrB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createMatcher } from "../../match/match.js";
|
|
2
|
+
/**
|
|
3
|
+
* Matcher for a value being an instance of a given class.
|
|
4
|
+
*/
|
|
5
|
+
export function instanceOf(classConstructor) {
|
|
6
|
+
return createMatcher((value) => value instanceof classConstructor, () => `instance of ${classConstructor.name}`, () => `${classConstructor.name}()`);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=instance-of.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-of.match.js","sourceRoot":"","sources":["../../../src/assert/instance-of/instance-of.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,MAAM,UAAU,UAAU,CACxB,gBAAsD;IAEtD,OAAO,aAAa,CAClB,CAAC,KAAK,EAAc,EAAE,CAAC,KAAK,YAAY,gBAAgB,EACxD,GAAG,EAAE,CAAC,eAAe,gBAAgB,CAAC,IAAI,EAAE,EAC5C,GAAG,EAAE,CAAC,GAAG,gBAAgB,CAAC,IAAI,IAAI,CACnC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-nullable.match.d.ts","sourceRoot":"","sources":["../../../src/assert/non-nullable/non-nullable.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,KAAK,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAMjE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createMatcher } from "../../match/match.js";
|
|
2
|
+
/**
|
|
3
|
+
* Matcher for a non-nullable value.
|
|
4
|
+
*/
|
|
5
|
+
export function nonNullable() {
|
|
6
|
+
return createMatcher((value) => value !== null && value !== undefined, () => "non-null defined value", () => `NonNullable`);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=non-nullable.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-nullable.match.js","sourceRoot":"","sources":["../../../src/assert/non-nullable/non-nullable.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,aAAa,CAClB,CAAC,KAAK,EAA2B,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EACzE,GAAG,EAAE,CAAC,wBAAwB,EAC9B,GAAG,EAAE,CAAC,aAAa,CACpB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-between.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/number-between/number-between.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"number-between.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/number-between/number-between.assert.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,OAAO,SAAmF,GACzF,OAAO,CAAC,KAAK,IAAI,MAAM,GAAG,MAAM,CASlC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
2
|
import { assertTypeNumeric } from "../type-numeric/type-numeric.assert.js";
|
|
3
3
|
import { desc, repr } from "../../describe/describe.js";
|
|
4
|
+
import { numberBetween } from "./number-between.match.js";
|
|
4
5
|
/**
|
|
5
6
|
* Assert that a numeric value is between min and max inclusive, with
|
|
6
7
|
* type-narrowing.
|
|
7
8
|
*/
|
|
8
9
|
export function assertNumberBetween(value, min, max, message = `Expected ${desc(value)} to be between ${desc(min)} and ${desc(max)} inclusive.`) {
|
|
9
10
|
assertTypeNumeric(value, message);
|
|
10
|
-
if (
|
|
11
|
+
if (!numberBetween(min, max).matches(value)) {
|
|
11
12
|
throw new AssertionError(message, value, `${repr(min)} ≤ ${repr(value)} ≤ ${repr(max)}`);
|
|
12
13
|
}
|
|
13
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-between.assert.js","sourceRoot":"","sources":["../../../src/assert/number-between/number-between.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"number-between.assert.js","sourceRoot":"","sources":["../../../src/assert/number-between/number-between.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAc,EACd,GAAoB,EACpB,GAAoB,EACpB,OAAO,GAAG,YAAY,IAAI,CAAC,KAAK,CAAC,kBAAkB,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,aAAa;IAE1F,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,cAAc,CACtB,OAAO,EACP,KAAK,EACL,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,CAC/C,CAAC;IACJ,CAAC;AACH,CAAC"}
|