@kensio/smartass 1.5.0 → 1.7.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 +1 -0
- 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 +7 -0
- package/dist/assert/object-has-property/object-has-property.assert.d.ts.map +1 -0
- package/dist/assert/object-has-property/object-has-property.assert.js +14 -0
- package/dist/assert/object-has-property/object-has-property.assert.js.map +1 -0
- 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 +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -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 +1 -1
|
@@ -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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
/**
|
|
3
|
+
* Matcher for a numeric value between min and max inclusive.
|
|
4
|
+
*/
|
|
5
|
+
export declare function numberBetween(min: number | bigint, max: number | bigint): AssertionMatcher<number | bigint>;
|
|
6
|
+
//# sourceMappingURL=number-between.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-between.match.d.ts","sourceRoot":"","sources":["../../../src/assert/number-between/number-between.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAG5E;;GAEG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,GAAG,EAAE,MAAM,GAAG,MAAM,GACnB,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,CAWnC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createMatcher } from "../../match/match.js";
|
|
2
|
+
import { desc, repr } from "../../describe/describe.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for a numeric value between min and max inclusive.
|
|
5
|
+
*/
|
|
6
|
+
export function numberBetween(min, max) {
|
|
7
|
+
return createMatcher((value) => {
|
|
8
|
+
if (typeof value !== "number" && typeof value !== "bigint") {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
return value >= min && value <= max;
|
|
12
|
+
}, () => `number between ${desc(min)} and ${desc(max)} inclusive`, () => `${repr(min)}<>${repr(max)}`);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=number-between.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-between.match.js","sourceRoot":"","sources":["../../../src/assert/number-between/number-between.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAoB,EACpB,GAAoB;IAEpB,OAAO,aAAa,CAClB,CAAC,KAAK,EAA4B,EAAE;QAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC3D,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,CAAC;IACtC,CAAC,EACD,GAAG,EAAE,CAAC,kBAAkB,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,YAAY,EAC9D,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CACnC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-to-nearest.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"number-to-nearest.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.assert.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,MAAM,CAYzB"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
2
|
import { repr } from "../../describe/describe.js";
|
|
3
3
|
import { assertTypeNumber } from "../type-number/type-number.assert.js";
|
|
4
|
+
import { numberToNearest } from "./number-to-nearest.match.js";
|
|
4
5
|
/**
|
|
5
6
|
* Assert that a numeric value, when rounded to the nearest given increment,
|
|
6
7
|
* equals the expected value.
|
|
7
8
|
*/
|
|
8
9
|
export function assertNumberToNearest(value, toNearest, expected, message) {
|
|
9
10
|
assertTypeNumber(value);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const decimalPlaces = parts[1]?.length ?? 0;
|
|
14
|
-
const rounded = Number(rawRounded.toFixed(decimalPlaces));
|
|
15
|
-
if (rounded !== expected) {
|
|
16
|
-
throw new AssertionError(message ??
|
|
17
|
-
`Expected to equal ${repr(expected)} to nearest ${repr(toNearest)}, got ${repr(value)} rounding to ${repr(rounded)}.`, value, `${repr(expected)} (to nearest ${repr(toNearest)})`);
|
|
11
|
+
const matcher = numberToNearest(toNearest, expected);
|
|
12
|
+
if (!matcher.matches(value)) {
|
|
13
|
+
throw new AssertionError(message ?? `Expected ${repr(value)} to ${matcher.describe()}.`, value, matcher.represent());
|
|
18
14
|
}
|
|
19
15
|
}
|
|
20
16
|
//# sourceMappingURL=number-to-nearest.assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-to-nearest.assert.js","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"number-to-nearest.assert.js","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CACnC,KAAc,EACd,SAAiB,EACjB,QAAgB,EAChB,OAAgB;IAEhB,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAExB,MAAM,OAAO,GAAG,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAErD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO,IAAI,YAAY,IAAI,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,QAAQ,EAAE,GAAG,EAC9D,KAAK,EACL,OAAO,CAAC,SAAS,EAAE,CACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
/**
|
|
3
|
+
* Matcher for a number that, when rounded to the nearest given increment,
|
|
4
|
+
* equals the expected value.
|
|
5
|
+
*/
|
|
6
|
+
export declare function numberToNearest(toNearest: number, expected: number): AssertionMatcher<number>;
|
|
7
|
+
//# sourceMappingURL=number-to-nearest.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-to-nearest.match.d.ts","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.match.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,gBAAgB,CAAC,MAAM,CAAC,CAQ1B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { repr } from "../../describe/describe.js";
|
|
2
|
+
import { createMatcher } from "../../match/match.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for a number that, when rounded to the nearest given increment,
|
|
5
|
+
* equals the expected value.
|
|
6
|
+
*/
|
|
7
|
+
export function numberToNearest(toNearest, expected) {
|
|
8
|
+
return createMatcher((value) => typeof value === "number" &&
|
|
9
|
+
roundToNearest(value, toNearest) === expected, () => `equal ${repr(expected)} to nearest ${repr(toNearest)}`, () => `≈₍${repr(toNearest)}₎${repr(expected)}`);
|
|
10
|
+
}
|
|
11
|
+
function roundToNearest(value, toNearest) {
|
|
12
|
+
const rawRounded = Math.round(value / toNearest) * toNearest;
|
|
13
|
+
// Determine decimal places in toNearest to avoid floating point errors
|
|
14
|
+
const parts = toNearest.toString().split(".");
|
|
15
|
+
const decimalPlaces = parts[1]?.length ?? 0;
|
|
16
|
+
return Number(rawRounded.toFixed(decimalPlaces));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=number-to-nearest.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-to-nearest.match.js","sourceRoot":"","sources":["../../../src/assert/number-to-nearest/number-to-nearest.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAiB,EACjB,QAAgB;IAEhB,OAAO,aAAa,CAClB,CAAC,KAAK,EAAmB,EAAE,CACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,QAAQ,EAC/C,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,EAAE,EAC7D,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAC/C,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,SAAiB;IACtD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IAE7D,uEAAuE;IACvE,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CAAC;IAE5C,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ObjectWithProperty } from "./object-has-property.match.js";
|
|
2
|
+
/**
|
|
3
|
+
* Assert that an object has a certain named property.
|
|
4
|
+
* The property only has to exist on the object, but could be undefined.
|
|
5
|
+
*/
|
|
6
|
+
export declare function assertObjectHasProperty<T extends object, K extends PropertyKey>(value: T, key: K, message?: string): asserts value is T & ObjectWithProperty<K>;
|
|
7
|
+
//# sourceMappingURL=object-has-property.assert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-has-property.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.assert.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,CAAC,SAAS,MAAM,EAChB,CAAC,SAAS,WAAW,EAErB,KAAK,EAAE,CAAC,EACR,GAAG,EAAE,CAAC,EACN,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAU5C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AssertionError } from "../../assertion-error.js";
|
|
2
|
+
import { desc } from "../../describe/describe.js";
|
|
3
|
+
import { objectWithProperty, } from "./object-has-property.match.js";
|
|
4
|
+
/**
|
|
5
|
+
* Assert that an object has a certain named property.
|
|
6
|
+
* The property only has to exist on the object, but could be undefined.
|
|
7
|
+
*/
|
|
8
|
+
export function assertObjectHasProperty(value, key, message) {
|
|
9
|
+
const matcher = objectWithProperty(key);
|
|
10
|
+
if (!matcher.matches(value)) {
|
|
11
|
+
throw new AssertionError(message ?? `Expected ${desc(value)} to be ${matcher.describe()}.`, value, matcher.represent());
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=object-has-property.assert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-has-property.assert.js","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EACL,kBAAkB,GAEnB,MAAM,gCAAgC,CAAC;AAExC;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAIrC,KAAQ,EACR,GAAM,EACN,OAAgB;IAEhB,MAAM,OAAO,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAExC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO,IAAI,YAAY,IAAI,CAAC,KAAK,CAAC,UAAU,OAAO,CAAC,QAAQ,EAAE,GAAG,EACjE,KAAK,EACL,OAAO,CAAC,SAAS,EAAE,CACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type AssertionMatcher } from "../../match/match.js";
|
|
2
|
+
export type ObjectWithProperty<K extends PropertyKey> = object & Record<K, unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for an object with a certain named property.
|
|
5
|
+
* The property only has to exist on the object, but could be undefined.
|
|
6
|
+
*/
|
|
7
|
+
export declare function objectWithProperty<K extends PropertyKey>(key: K): AssertionMatcher<ObjectWithProperty<K>>;
|
|
8
|
+
//# sourceMappingURL=object-has-property.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-has-property.match.d.ts","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.match.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,WAAW,IAAI,MAAM,GAC5D,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAErB;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,WAAW,EACtD,GAAG,EAAE,CAAC,GACL,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAOzC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { desc, repr } from "../../describe/describe.js";
|
|
2
|
+
import { createMatcher } from "../../match/match.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for an object with a certain named property.
|
|
5
|
+
* The property only has to exist on the object, but could be undefined.
|
|
6
|
+
*/
|
|
7
|
+
export function objectWithProperty(key) {
|
|
8
|
+
return createMatcher((value) => typeof value === "object" && value !== null && key in value, () => `object with property ${desc(key)}`, () => `{${repr(key)}}`);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=object-has-property.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-has-property.match.js","sourceRoot":"","sources":["../../../src/assert/object-has-property/object-has-property.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAK5E;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAM;IAEN,OAAO,aAAa,CAClB,CAAC,KAAK,EAAkC,EAAE,CACxC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,EAC7D,GAAG,EAAE,CAAC,wBAAwB,IAAI,CAAC,GAAG,CAAC,EAAE,EACzC,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CACvB,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { AssertionMatcher } from "../../match/match.js";
|
|
1
2
|
type FunctionLike = (...arguments_: never[]) => unknown;
|
|
2
3
|
type ObjectMatchLeaf = FunctionLike | Date | RegExp | Map<unknown, unknown> | Set<unknown> | WeakMap<object, unknown> | WeakSet<object> | Promise<unknown>;
|
|
3
|
-
type DeepObjectMatch<T> = T extends ObjectMatchLeaf ? T : T extends readonly unknown[] ? {
|
|
4
|
+
type DeepObjectMatch<T> = T extends AssertionMatcher<infer TMatched> ? TMatched : T extends ObjectMatchLeaf ? T : T extends readonly unknown[] ? {
|
|
4
5
|
readonly [K in keyof T]: DeepObjectMatch<T[K]>;
|
|
5
6
|
} : T extends object ? {
|
|
6
7
|
[K in keyof T]: DeepObjectMatch<T[K]>;
|
|
@@ -9,9 +10,11 @@ type DeepObjectMatch<T> = T extends ObjectMatchLeaf ? T : T extends readonly unk
|
|
|
9
10
|
* Assert that an object matches a partial deep object structure, with
|
|
10
11
|
* type-narrowing.
|
|
11
12
|
*
|
|
12
|
-
* Plain objects are matched partially and recursively.
|
|
13
|
-
* length and by recursively matching each element in
|
|
14
|
-
*
|
|
13
|
+
* Plain objects are matched partially and recursively.
|
|
14
|
+
* Arrays are matched by length and by recursively matching each element in
|
|
15
|
+
* order.
|
|
16
|
+
* Matcher values are evaluated with their matcher predicate.
|
|
17
|
+
* Primitive values and non-plain objects are compared using Object.is.
|
|
15
18
|
*/
|
|
16
19
|
export declare function assertObjectMatches<TActual, const TExpected extends Record<PropertyKey, unknown>>(actual: TActual, expected: TExpected, message?: string): asserts actual is TActual & DeepObjectMatch<TExpected>;
|
|
17
20
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-matches.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/object-matches/object-matches.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"object-matches.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/object-matches/object-matches.assert.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,KAAK,YAAY,GAAG,CAAC,GAAG,UAAU,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC;AAExD,KAAK,eAAe,GAChB,YAAY,GACZ,IAAI,GACJ,MAAM,GACN,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,GACrB,GAAG,CAAC,OAAO,CAAC,GACZ,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GACxB,OAAO,CAAC,MAAM,CAAC,GACf,OAAO,CAAC,OAAO,CAAC,CAAC;AAErB,KAAK,eAAe,CAAC,CAAC,IACpB,CAAC,SAAS,gBAAgB,CAAC,MAAM,QAAQ,CAAC,GACtC,QAAQ,GACR,CAAC,SAAS,eAAe,GACvB,CAAC,GACD,CAAC,SAAS,SAAS,OAAO,EAAE,GAC1B;IAAE,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAClD,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACzC,CAAC,CAAC;AAEd;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EACP,KAAK,CAAC,SAAS,SAAS,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EAEpD,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,SAAS,EACnB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,IAAI,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,CAcxD"}
|
|
@@ -5,9 +5,11 @@ import { findObjectComparisonMismatch } from "../../compare/object-comparison.js
|
|
|
5
5
|
* Assert that an object matches a partial deep object structure, with
|
|
6
6
|
* type-narrowing.
|
|
7
7
|
*
|
|
8
|
-
* Plain objects are matched partially and recursively.
|
|
9
|
-
* length and by recursively matching each element in
|
|
10
|
-
*
|
|
8
|
+
* Plain objects are matched partially and recursively.
|
|
9
|
+
* Arrays are matched by length and by recursively matching each element in
|
|
10
|
+
* order.
|
|
11
|
+
* Matcher values are evaluated with their matcher predicate.
|
|
12
|
+
* Primitive values and non-plain objects are compared using Object.is.
|
|
11
13
|
*/
|
|
12
14
|
export function assertObjectMatches(actual, expected, message) {
|
|
13
15
|
const mismatch = findObjectComparisonMismatch(actual, expected, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-matches.assert.js","sourceRoot":"","sources":["../../../src/assert/object-matches/object-matches.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"object-matches.assert.js","sourceRoot":"","sources":["../../../src/assert/object-matches/object-matches.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AA0BlF;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAIjC,MAAe,EACf,QAAmB,EACnB,OAAgB;IAEhB,MAAM,QAAQ,GAAG,4BAA4B,CAAC,MAAM,EAAE,QAAQ,EAAE;QAC9D,eAAe,EAAE,KAAK;QACtB,sBAAsB,EAAE,KAAK;KAC9B,CAAC,CAAC;IAEH,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,CAAC,QAAQ,CAAC,iBAAiB,QAAQ,CAAC,IAAI,cAAc,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EACzJ,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-of.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"one-of.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.assert.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,OAAO,EAAE,EACnE,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,QAAQ,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC,MAAM,CAAC,CASnC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
|
-
import { desc
|
|
2
|
+
import { desc } from "../../describe/describe.js";
|
|
3
|
+
import { oneOf } from "./one-of.match.js";
|
|
3
4
|
/**
|
|
4
5
|
* Assert that a value is one of a set of expected values, with type-narrowing.
|
|
5
6
|
*/
|
|
6
|
-
export function assertOneOf(value, allowed, message
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
export function assertOneOf(value, allowed, message) {
|
|
8
|
+
const matcher = oneOf(allowed);
|
|
9
|
+
if (!matcher.matches(value)) {
|
|
10
|
+
throw new AssertionError(message ?? `Expected ${desc(value)} to be ${matcher.describe()}.`, value, matcher.represent());
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
//# sourceMappingURL=one-of.assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one-of.assert.js","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"one-of.assert.js","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C;;GAEG;AACH,MAAM,UAAU,WAAW,CACzB,KAAc,EACd,OAAiB,EACjB,OAAgB;IAEhB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO,IAAI,YAAY,IAAI,CAAC,KAAK,CAAC,UAAU,OAAO,CAAC,QAAQ,EAAE,GAAG,EACjE,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 that is one of a set of expected values.
|
|
4
|
+
*/
|
|
5
|
+
export declare function oneOf<const TAllowed extends readonly unknown[]>(allowed: TAllowed): AssertionMatcher<TAllowed[number]>;
|
|
6
|
+
//# sourceMappingURL=one-of.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-of.match.d.ts","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.match.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,CAAC,QAAQ,SAAS,SAAS,OAAO,EAAE,EAC7D,OAAO,EAAE,QAAQ,GAChB,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAMpC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { repr } from "../../describe/describe.js";
|
|
2
|
+
import { createMatcher } from "../../match/match.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for a value that is one of a set of expected values.
|
|
5
|
+
*/
|
|
6
|
+
export function oneOf(allowed) {
|
|
7
|
+
return createMatcher((value) => allowed.includes(value), () => `one of ${repr(allowed)}`, () => allowed.map((i) => repr(i)).join("|"));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=one-of.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-of.match.js","sourceRoot":"","sources":["../../../src/assert/one-of/one-of.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,MAAM,UAAU,KAAK,CACnB,OAAiB;IAEjB,OAAO,aAAa,CAClB,CAAC,KAAK,EAA6B,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAc,CAAC,EACtE,GAAG,EAAE,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,EAAE,EAC/B,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAC5C,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-ends-with.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/string-ends-with/string-ends-with.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"string-ends-with.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/string-ends-with/string-ends-with.assert.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACzD,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,GAAG,MAAM,GAAG,CAAC,EAAE,CAUlC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
2
|
import { desc, repr } from "../../describe/describe.js";
|
|
3
|
+
import { stringEndingWith } from "./string-ends-with.match.js";
|
|
3
4
|
/**
|
|
4
5
|
* Assert that a string ends with a given suffix, with type narrowing.
|
|
5
6
|
*/
|
|
6
7
|
export function assertStringEndsWith(value, suffix, message) {
|
|
7
|
-
|
|
8
|
+
const matcher = stringEndingWith(suffix);
|
|
9
|
+
if (!matcher.matches(value)) {
|
|
8
10
|
throw new AssertionError(message ??
|
|
9
|
-
`Expected ${desc(value)} to end with ${repr(suffix)}, but it did not.`, value,
|
|
11
|
+
`Expected ${desc(value)} to end with ${repr(suffix)}, but it did not.`, value, matcher.represent());
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
//# sourceMappingURL=string-ends-with.assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-ends-with.assert.js","sourceRoot":"","sources":["../../../src/assert/string-ends-with/string-ends-with.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"string-ends-with.assert.js","sourceRoot":"","sources":["../../../src/assert/string-ends-with/string-ends-with.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAa,EACb,MAAS,EACT,OAAgB;IAEhB,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,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 string that ends with a given suffix.
|
|
4
|
+
*/
|
|
5
|
+
export declare function stringEndingWith<const T extends string>(suffix: T): AssertionMatcher<`${string}${T}`>;
|
|
6
|
+
//# sourceMappingURL=string-ends-with.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-ends-with.match.d.ts","sourceRoot":"","sources":["../../../src/assert/string-ends-with/string-ends-with.match.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACrD,MAAM,EAAE,CAAC,GACR,gBAAgB,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,CAOnC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { repr } from "../../describe/describe.js";
|
|
2
|
+
import { createMatcher } from "../../match/match.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for a string that ends with a given suffix.
|
|
5
|
+
*/
|
|
6
|
+
export function stringEndingWith(suffix) {
|
|
7
|
+
return createMatcher((value) => typeof value === "string" && value.endsWith(suffix), () => `string ending with ${repr(suffix)}`, () => `"*${suffix}"`);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=string-ends-with.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-ends-with.match.js","sourceRoot":"","sources":["../../../src/assert/string-ends-with/string-ends-with.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAS;IAET,OAAO,aAAa,CAClB,CAAC,KAAK,EAA4B,EAAE,CAClC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EACrD,GAAG,EAAE,CAAC,sBAAsB,IAAI,CAAC,MAAM,CAAC,EAAE,EAC1C,GAAG,EAAE,CAAC,KAAK,MAAM,GAAG,CACrB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-includes.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/string-includes/string-includes.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"string-includes.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/string-includes/string-includes.assert.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACzD,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,CAAC,EACZ,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,GAAG,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,CAW3C"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
2
|
import { desc, repr } from "../../describe/describe.js";
|
|
3
|
+
import { stringIncluding } from "./string-includes.match.js";
|
|
3
4
|
/**
|
|
4
5
|
* Assert that a string includes a given substring, with type narrowing.
|
|
5
6
|
*/
|
|
6
7
|
export function assertStringIncludes(value, substring, message) {
|
|
7
|
-
|
|
8
|
+
const matcher = stringIncluding(substring);
|
|
9
|
+
if (!matcher.matches(value)) {
|
|
8
10
|
throw new AssertionError(message ??
|
|
9
|
-
`Expected ${desc(value)} to include ${repr(substring)}, but it did not.`, value,
|
|
11
|
+
`Expected ${desc(value)} to include ${repr(substring)}, but it did not.`, value, matcher.represent());
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
//# sourceMappingURL=string-includes.assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-includes.assert.js","sourceRoot":"","sources":["../../../src/assert/string-includes/string-includes.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"string-includes.assert.js","sourceRoot":"","sources":["../../../src/assert/string-includes/string-includes.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAa,EACb,SAAY,EACZ,OAAgB;IAEhB,MAAM,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAE3C,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,SAAS,CAAC,mBAAmB,EAC1E,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 string that includes a given substring.
|
|
4
|
+
*/
|
|
5
|
+
export declare function stringIncluding<const T extends string>(substring: T): AssertionMatcher<`${string}${T}${string}`>;
|
|
6
|
+
//# sourceMappingURL=string-includes.match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-includes.match.d.ts","sourceRoot":"","sources":["../../../src/assert/string-includes/string-includes.match.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACpD,SAAS,EAAE,CAAC,GACX,gBAAgB,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,MAAM,EAAE,CAAC,CAO5C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { repr } from "../../describe/describe.js";
|
|
2
|
+
import { createMatcher } from "../../match/match.js";
|
|
3
|
+
/**
|
|
4
|
+
* Matcher for a string that includes a given substring.
|
|
5
|
+
*/
|
|
6
|
+
export function stringIncluding(substring) {
|
|
7
|
+
return createMatcher((value) => typeof value === "string" && value.includes(substring), () => `string including ${repr(substring)}`, () => `"…${substring}…"`);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=string-includes.match.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string-includes.match.js","sourceRoot":"","sources":["../../../src/assert/string-includes/string-includes.match.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAyB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE5E;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAY;IAEZ,OAAO,aAAa,CAClB,CAAC,KAAK,EAAqC,EAAE,CAC3C,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EACxD,GAAG,EAAE,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,EAAE,EAC3C,GAAG,EAAE,CAAC,KAAK,SAAS,IAAI,CACzB,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type StringOfLength } from "./string-length.match.js";
|
|
1
2
|
/**
|
|
2
3
|
* Assert that a string has exactly the expected length, with type narrowing.
|
|
3
4
|
*
|
|
@@ -11,94 +12,4 @@
|
|
|
11
12
|
* not Unicode grapheme clusters.
|
|
12
13
|
*/
|
|
13
14
|
export declare function assertStringLength<const N extends number>(value: string, expectedLength: N, message?: string): asserts value is StringOfLength<N>;
|
|
14
|
-
type StringOfLength<N extends number> = N extends 0 ? "" : N extends 1 ? string & {
|
|
15
|
-
length: 1;
|
|
16
|
-
0: string;
|
|
17
|
-
} : N extends 2 ? string & {
|
|
18
|
-
length: 2;
|
|
19
|
-
0: string;
|
|
20
|
-
1: string;
|
|
21
|
-
} : N extends 3 ? string & {
|
|
22
|
-
length: 3;
|
|
23
|
-
0: string;
|
|
24
|
-
1: string;
|
|
25
|
-
2: string;
|
|
26
|
-
} : N extends 4 ? string & {
|
|
27
|
-
length: 4;
|
|
28
|
-
0: string;
|
|
29
|
-
1: string;
|
|
30
|
-
2: string;
|
|
31
|
-
3: string;
|
|
32
|
-
} : N extends 5 ? string & {
|
|
33
|
-
length: 5;
|
|
34
|
-
0: string;
|
|
35
|
-
1: string;
|
|
36
|
-
2: string;
|
|
37
|
-
3: string;
|
|
38
|
-
4: string;
|
|
39
|
-
} : N extends 6 ? string & {
|
|
40
|
-
length: 6;
|
|
41
|
-
0: string;
|
|
42
|
-
1: string;
|
|
43
|
-
2: string;
|
|
44
|
-
3: string;
|
|
45
|
-
4: string;
|
|
46
|
-
5: string;
|
|
47
|
-
} : N extends 7 ? string & {
|
|
48
|
-
length: 7;
|
|
49
|
-
0: string;
|
|
50
|
-
1: string;
|
|
51
|
-
2: string;
|
|
52
|
-
3: string;
|
|
53
|
-
4: string;
|
|
54
|
-
5: string;
|
|
55
|
-
6: string;
|
|
56
|
-
} : N extends 8 ? string & {
|
|
57
|
-
length: 8;
|
|
58
|
-
0: string;
|
|
59
|
-
1: string;
|
|
60
|
-
2: string;
|
|
61
|
-
3: string;
|
|
62
|
-
4: string;
|
|
63
|
-
5: string;
|
|
64
|
-
6: string;
|
|
65
|
-
7: string;
|
|
66
|
-
} : N extends 9 ? string & {
|
|
67
|
-
length: 9;
|
|
68
|
-
0: string;
|
|
69
|
-
1: string;
|
|
70
|
-
2: string;
|
|
71
|
-
3: string;
|
|
72
|
-
4: string;
|
|
73
|
-
5: string;
|
|
74
|
-
6: string;
|
|
75
|
-
7: string;
|
|
76
|
-
8: string;
|
|
77
|
-
} : N extends 10 ? string & {
|
|
78
|
-
length: 10;
|
|
79
|
-
0: string;
|
|
80
|
-
1: string;
|
|
81
|
-
2: string;
|
|
82
|
-
3: string;
|
|
83
|
-
4: string;
|
|
84
|
-
5: string;
|
|
85
|
-
6: string;
|
|
86
|
-
7: string;
|
|
87
|
-
8: string;
|
|
88
|
-
9: string;
|
|
89
|
-
} : string & {
|
|
90
|
-
length: N;
|
|
91
|
-
0: string;
|
|
92
|
-
1: string;
|
|
93
|
-
2: string;
|
|
94
|
-
3: string;
|
|
95
|
-
4: string;
|
|
96
|
-
5: string;
|
|
97
|
-
6: string;
|
|
98
|
-
7: string;
|
|
99
|
-
8: string;
|
|
100
|
-
9: string;
|
|
101
|
-
10: string;
|
|
102
|
-
};
|
|
103
|
-
export {};
|
|
104
15
|
//# sourceMappingURL=string-length.assert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-length.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/string-length/string-length.assert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"string-length.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/string-length/string-length.assert.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/E;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EACvD,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,CAAC,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,cAAc,CAAC,CAAC,CAAC,CAUpC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AssertionError } from "../../assertion-error.js";
|
|
2
2
|
import { desc, repr } from "../../describe/describe.js";
|
|
3
|
+
import { stringOfLength } from "./string-length.match.js";
|
|
3
4
|
/**
|
|
4
5
|
* Assert that a string has exactly the expected length, with type narrowing.
|
|
5
6
|
*
|
|
@@ -13,9 +14,10 @@ import { desc, repr } from "../../describe/describe.js";
|
|
|
13
14
|
* not Unicode grapheme clusters.
|
|
14
15
|
*/
|
|
15
16
|
export function assertStringLength(value, expectedLength, message) {
|
|
16
|
-
|
|
17
|
+
const matcher = stringOfLength(expectedLength);
|
|
18
|
+
if (!matcher.matches(value)) {
|
|
17
19
|
throw new AssertionError(message ??
|
|
18
|
-
`Expected ${desc(value)} to have length ${repr(expectedLength)}, but it had length ${repr(value.length)}.`, value,
|
|
20
|
+
`Expected ${desc(value)} to have length ${repr(expectedLength)}, but it had length ${repr(value.length)}.`, value, matcher.represent());
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=string-length.assert.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-length.assert.js","sourceRoot":"","sources":["../../../src/assert/string-length/string-length.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"string-length.assert.js","sourceRoot":"","sources":["../../../src/assert/string-length/string-length.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAuB,MAAM,0BAA0B,CAAC;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAa,EACb,cAAiB,EACjB,OAAgB;IAEhB,MAAM,OAAO,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;IAC/C,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"}
|