@kensio/smartass 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +7 -0
  2. package/dist/assert/array-includes/array-includes.assert.d.ts +10 -0
  3. package/dist/assert/array-includes/array-includes.assert.d.ts.map +1 -0
  4. package/dist/assert/array-includes/array-includes.assert.js +15 -0
  5. package/dist/assert/array-includes/array-includes.assert.js.map +1 -0
  6. package/dist/assert/array-includes-all/array-includes-all.assert.d.ts +9 -0
  7. package/dist/assert/array-includes-all/array-includes-all.assert.d.ts.map +1 -0
  8. package/dist/assert/array-includes-all/array-includes-all.assert.js +15 -0
  9. package/dist/assert/array-includes-all/array-includes-all.assert.js.map +1 -0
  10. package/dist/assert/buffer-equal/buffer-equal.assert.d.ts +8 -0
  11. package/dist/assert/buffer-equal/buffer-equal.assert.d.ts.map +1 -0
  12. package/dist/assert/buffer-equal/buffer-equal.assert.js +18 -0
  13. package/dist/assert/buffer-equal/buffer-equal.assert.js.map +1 -0
  14. package/dist/assert/string-ends-with/string-ends-with.assert.d.ts +5 -0
  15. package/dist/assert/string-ends-with/string-ends-with.assert.d.ts.map +1 -0
  16. package/dist/assert/string-ends-with/string-ends-with.assert.js +12 -0
  17. package/dist/assert/string-ends-with/string-ends-with.assert.js.map +1 -0
  18. package/dist/assert/string-includes/string-includes.assert.d.ts +5 -0
  19. package/dist/assert/string-includes/string-includes.assert.d.ts.map +1 -0
  20. package/dist/assert/string-includes/string-includes.assert.js +12 -0
  21. package/dist/assert/string-includes/string-includes.assert.js.map +1 -0
  22. package/dist/assert/string-starts-with/string-starts-with.assert.d.ts +5 -0
  23. package/dist/assert/string-starts-with/string-starts-with.assert.d.ts.map +1 -0
  24. package/dist/assert/string-starts-with/string-starts-with.assert.js +12 -0
  25. package/dist/assert/string-starts-with/string-starts-with.assert.js.map +1 -0
  26. package/dist/assert/type-typed-array/type-typed-array.assert.d.ts +12 -0
  27. package/dist/assert/type-typed-array/type-typed-array.assert.d.ts.map +1 -0
  28. package/dist/assert/type-typed-array/type-typed-array.assert.js +14 -0
  29. package/dist/assert/type-typed-array/type-typed-array.assert.js.map +1 -0
  30. package/dist/index.d.ts +7 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +7 -0
  33. package/dist/index.js.map +1 -1
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -38,9 +38,12 @@ npm install @kensio/smartass
38
38
 
39
39
  ## Assertion functions
40
40
 
41
+ - [assertArrayIncludes](src/assert/array-includes/array-includes.assert.ts)
42
+ - [assertArrayIncludesAll](src/assert/array-includes-all/array-includes-all.assert.ts)
41
43
  - [assertArrayLength](src/assert/array-length/array-length.assert.ts)
42
44
  - [assertArrayMinLength](src/assert/array-min-length/array-min-length.assert.ts)
43
45
  - [assertArrayNotEmpty](src/assert/array-not-empty/array-not-empty.assert.ts)
46
+ - [assertBufferEqual](src/assert/buffer-equal/buffer-equal.assert.ts)
44
47
  - [assertFalse](src/assert/false/false.assert.ts)
45
48
  - [assertIdentical](src/assert/identical/identical.assert.ts)
46
49
  - [assertInstanceOf](src/assert/instance-of/instance-of.assert.ts)
@@ -48,6 +51,9 @@ npm install @kensio/smartass
48
51
  - [assertNumberBetween](src/assert/number-between/number-between.assert.ts)
49
52
  - [assertNumberToNearest](src/assert/number-to-nearest/number-to-nearest.assert.ts)
50
53
  - [assertOneOf](src/assert/one-of/one-of.assert.ts)
54
+ - [assertStringIncludes](src/assert/string-includes/string-includes.assert.ts)
55
+ - [assertStringEndsWith](src/assert/string-ends-with/string-ends-with.assert.ts)
56
+ - [assertStringStartsWith](src/assert/string-starts-with/string-starts-with.assert.ts)
51
57
  - [assertThrowsError](src/assert/throws-error/throws-error.assert.ts)
52
58
  - [assertThrowsErrorAsync](src/assert/throws-error-async/throws-error-async.assert.ts)
53
59
  - [assertTrue](src/assert/true/true.assert.ts)
@@ -58,3 +64,4 @@ npm install @kensio/smartass
58
64
  - [assertTypeNumeric](src/assert/type-numeric/type-numeric.assert.ts)
59
65
  - [assertTypeObject](src/assert/type-object/type-object.assert.ts)
60
66
  - [assertTypeString](src/assert/type-string/type-string.assert.ts)
67
+ - [assertTypeTypedArray](src/assert/type-typed-array/type-typed-array.assert.ts)
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Assert that an array includes a specific element, with type narrowing.
3
+ * Note that this is an identity match, so objects in an array only fulfill the
4
+ * assertion by being a reference to the same object, rather than equivalent in
5
+ * value to another object reference.
6
+ */
7
+ export declare function assertArrayIncludes<T, const E extends T>(value: readonly T[], element: E, message?: string): asserts value is readonly [T, ...T[]] & {
8
+ includes(searchElement: E): true;
9
+ };
10
+ //# sourceMappingURL=array-includes.assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-includes.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/array-includes/array-includes.assert.ts"],"names":[],"mappings":"AAGA;;;;;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,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG;IACzC,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,IAAI,CAAC;CAClC,CASA"}
@@ -0,0 +1,15 @@
1
+ import { AssertionError } from "../../assertion-error.js";
2
+ import { desc } from "../../describe/describe.js";
3
+ /**
4
+ * Assert that an array includes a specific element, with type narrowing.
5
+ * Note that this is an identity match, so objects in an array only fulfill the
6
+ * assertion by being a reference to the same object, rather than equivalent in
7
+ * value to another object reference.
8
+ */
9
+ export function assertArrayIncludes(value, element, message) {
10
+ if (!value.includes(element)) {
11
+ throw new AssertionError(message ??
12
+ `Expected ${desc(value)} to include ${desc(element)}, but it did not.`, value, [element]);
13
+ }
14
+ }
15
+ //# sourceMappingURL=array-includes.assert.js.map
@@ -0,0 +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;IAIhB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,OAAO,CAAC,mBAAmB,EACxE,KAAK,EACL,CAAC,OAAO,CAAC,CACV,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Assert that an array includes all specified elements, with type narrowing.
3
+ * Elements can appear in any order and do not need to be contiguous.
4
+ * Each required element must be present at least once.
5
+ */
6
+ export declare function assertArrayIncludesAll<T, const E extends readonly T[]>(value: readonly T[], elements: E, message?: string): asserts value is readonly [T, ...T[]] & {
7
+ includes(searchElement: E[number]): true;
8
+ };
9
+ //# sourceMappingURL=array-includes-all.assert.d.ts.map
@@ -0,0 +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":"AAGA;;;;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,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG;IACzC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAC1C,CAWA"}
@@ -0,0 +1,15 @@
1
+ import { AssertionError } from "../../assertion-error.js";
2
+ import { desc, repr } from "../../describe/describe.js";
3
+ /**
4
+ * Assert that an array includes all specified elements, with type narrowing.
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 assertArrayIncludesAll(value, elements, message) {
9
+ const missing = elements.filter((element) => !value.includes(element));
10
+ if (missing.length > 0) {
11
+ throw new AssertionError(message ??
12
+ `Expected ${desc(value)} to include all of ${repr(elements)}, but missing ${repr(missing)}.`, value, elements);
13
+ }
14
+ }
15
+ //# sourceMappingURL=array-includes-all.assert.js.map
@@ -0,0 +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;IAIhB,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAEvE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,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,QAAQ,CACT,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type TypedArray } from "../type-typed-array/type-typed-array.assert.js";
2
+ /**
3
+ * Assert that two buffers (TypedArrays) are equal, comparing element by element.
4
+ * Supports all TypedArray types: Uint8Array, Int8Array, Uint16Array, Int16Array,
5
+ * Uint32Array, Int32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array.
6
+ */
7
+ export declare function assertBufferEqual<T extends TypedArray>(actual: unknown, expected: T, message?: string): asserts actual is T;
8
+ //# sourceMappingURL=buffer-equal.assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer-equal.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/buffer-equal/buffer-equal.assert.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,UAAU,EAChB,MAAM,gDAAgD,CAAC;AAExD;;;;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,CAsBrB"}
@@ -0,0 +1,18 @@
1
+ import { AssertionError } from "../../assertion-error.js";
2
+ import { desc } from "../../describe/describe.js";
3
+ import { assertTypeTypedArray, } from "../type-typed-array/type-typed-array.assert.js";
4
+ /**
5
+ * Assert that two buffers (TypedArrays) are equal, comparing element by element.
6
+ * Supports all TypedArray types: Uint8Array, Int8Array, Uint16Array, Int16Array,
7
+ * Uint32Array, Int32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array.
8
+ */
9
+ export function assertBufferEqual(actual, expected, message) {
10
+ assertTypeTypedArray(actual);
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) {
15
+ throw new AssertionError(message ?? `Expected ${desc(actual)} to equal ${desc(expected)}.`, actual, expected);
16
+ }
17
+ }
18
+ //# sourceMappingURL=buffer-equal.assert.js.map
@@ -0,0 +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;AAClD,OAAO,EACL,oBAAoB,GAErB,MAAM,gDAAgD,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAe,EACf,QAAW,EACX,OAAgB;IAEhB,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAE7B,uDAAuD;IACvD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAC9B,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,UAAU,CAClB,CAAC;IACF,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAChC,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,UAAU,EACnB,QAAQ,CAAC,UAAU,CACpB,CAAC;IAEF,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC;QACvD,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,5 @@
1
+ /**
2
+ * Assert that a string ends with a given suffix, with type narrowing.
3
+ */
4
+ export declare function assertStringEndsWith<const T extends string>(value: string, suffix: T, message?: string): asserts value is `${string}${T}`;
5
+ //# sourceMappingURL=string-ends-with.assert.d.ts.map
@@ -0,0 +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":"AAGA;;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,CASlC"}
@@ -0,0 +1,12 @@
1
+ import { AssertionError } from "../../assertion-error.js";
2
+ import { desc, repr } from "../../describe/describe.js";
3
+ /**
4
+ * Assert that a string ends with a given suffix, with type narrowing.
5
+ */
6
+ export function assertStringEndsWith(value, suffix, message) {
7
+ if (!value.endsWith(suffix)) {
8
+ throw new AssertionError(message ??
9
+ `Expected ${desc(value)} to end with ${repr(suffix)}, but it did not.`, value, `string ending with ${repr(suffix)}`);
10
+ }
11
+ }
12
+ //# sourceMappingURL=string-ends-with.assert.js.map
@@ -0,0 +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;AAExD;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAa,EACb,MAAS,EACT,OAAgB;IAEhB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,mBAAmB,EACxE,KAAK,EACL,sBAAsB,IAAI,CAAC,MAAM,CAAC,EAAE,CACrC,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Assert that a string includes a given substring, with type narrowing.
3
+ */
4
+ export declare function assertStringIncludes<const T extends string>(value: string, substring: T, message?: string): asserts value is `${string}${T}${string}`;
5
+ //# sourceMappingURL=string-includes.assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-includes.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/string-includes/string-includes.assert.ts"],"names":[],"mappings":"AAGA;;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,CAS3C"}
@@ -0,0 +1,12 @@
1
+ import { AssertionError } from "../../assertion-error.js";
2
+ import { desc, repr } from "../../describe/describe.js";
3
+ /**
4
+ * Assert that a string includes a given substring, with type narrowing.
5
+ */
6
+ export function assertStringIncludes(value, substring, message) {
7
+ if (!value.includes(substring)) {
8
+ throw new AssertionError(message ??
9
+ `Expected ${desc(value)} to include ${repr(substring)}, but it did not.`, value, `... ${substring} ...`);
10
+ }
11
+ }
12
+ //# sourceMappingURL=string-includes.assert.js.map
@@ -0,0 +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;AAExD;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAa,EACb,SAAY,EACZ,OAAgB;IAEhB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAC1E,KAAK,EACL,OAAO,SAAS,MAAM,CACvB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Assert that a string starts with a given prefix, with type narrowing.
3
+ */
4
+ export declare function assertStringStartsWith<const T extends string>(value: string, prefix: T, message?: string): asserts value is `${T}${string}`;
5
+ //# sourceMappingURL=string-starts-with.assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-starts-with.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/string-starts-with/string-starts-with.assert.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAC3D,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,MAAM,EAAE,CASlC"}
@@ -0,0 +1,12 @@
1
+ import { AssertionError } from "../../assertion-error.js";
2
+ import { desc, repr } from "../../describe/describe.js";
3
+ /**
4
+ * Assert that a string starts with a given prefix, with type narrowing.
5
+ */
6
+ export function assertStringStartsWith(value, prefix, message) {
7
+ if (!value.startsWith(prefix)) {
8
+ throw new AssertionError(message ??
9
+ `Expected ${desc(value)} to start with ${repr(prefix)}, but it did not.`, value, `string starting with ${repr(prefix)}`);
10
+ }
11
+ }
12
+ //# sourceMappingURL=string-starts-with.assert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-starts-with.assert.js","sourceRoot":"","sources":["../../../src/assert/string-starts-with/string-starts-with.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAExD;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAa,EACb,MAAS,EACT,OAAgB;IAEhB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,cAAc,CACtB,OAAO;YACL,YAAY,IAAI,CAAC,KAAK,CAAC,kBAAkB,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAC1E,KAAK,EACL,wBAAwB,IAAI,CAAC,MAAM,CAAC,EAAE,CACvC,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Union type of all TypedArray types
3
+ */
4
+ export type TypedArray = Uint8Array | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
5
+ /**
6
+ * Assert that a value is a TypedArray, with type-narrowing.
7
+ * Supports all TypedArray types: Uint8Array, Int8Array, Uint16Array,
8
+ * Int16Array, Uint32Array, Int32Array, Float32Array, Float64Array,
9
+ * BigInt64Array, BigUint64Array.
10
+ */
11
+ export declare function assertTypeTypedArray(value: unknown, message?: string): asserts value is TypedArray;
12
+ //# sourceMappingURL=type-typed-array.assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-typed-array.assert.d.ts","sourceRoot":"","sources":["../../../src/assert/type-typed-array/type-typed-array.assert.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,SAAS,GACT,WAAW,GACX,UAAU,GACV,WAAW,GACX,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,cAAc,CAAC;AAEnB;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,OAAO,SAAgD,GACtD,OAAO,CAAC,KAAK,IAAI,UAAU,CAI7B"}
@@ -0,0 +1,14 @@
1
+ import { AssertionError } from "../../assertion-error.js";
2
+ import { desc } from "../../describe/describe.js";
3
+ /**
4
+ * Assert that a value is a TypedArray, with type-narrowing.
5
+ * Supports all TypedArray types: Uint8Array, Int8Array, Uint16Array,
6
+ * Int16Array, Uint32Array, Int32Array, Float32Array, Float64Array,
7
+ * BigInt64Array, BigUint64Array.
8
+ */
9
+ export function assertTypeTypedArray(value, message = `Expected ${desc(value)} to be a TypedArray.`) {
10
+ if (!ArrayBuffer.isView(value)) {
11
+ throw new AssertionError(message, value, "TypedArray");
12
+ }
13
+ }
14
+ //# sourceMappingURL=type-typed-array.assert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-typed-array.assert.js","sourceRoot":"","sources":["../../../src/assert/type-typed-array/type-typed-array.assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAiBlD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAc,EACd,OAAO,GAAG,YAAY,IAAI,CAAC,KAAK,CAAC,sBAAsB;IAEvD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,cAAc,CAAC,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
+ export * from "./assert/array-includes/array-includes.assert.js";
2
+ export * from "./assert/array-includes-all/array-includes-all.assert.js";
1
3
  export * from "./assert/array-length/array-length.assert.js";
2
4
  export * from "./assert/array-min-length/array-min-length.assert.js";
3
5
  export * from "./assert/array-not-empty/array-not-empty.assert.js";
6
+ export * from "./assert/buffer-equal/buffer-equal.assert.js";
4
7
  export * from "./assert/false/false.assert.js";
5
8
  export * from "./assert/identical/identical.assert.js";
6
9
  export * from "./assert/instance-of/instance-of.assert.js";
@@ -8,6 +11,9 @@ export * from "./assert/non-nullable/non-nullable.assert.js";
8
11
  export * from "./assert/number-between/number-between.assert.js";
9
12
  export * from "./assert/number-to-nearest/number-to-nearest.assert.js";
10
13
  export * from "./assert/one-of/one-of.assert.js";
14
+ export * from "./assert/string-includes/string-includes.assert.js";
15
+ export * from "./assert/string-ends-with/string-ends-with.assert.js";
16
+ export * from "./assert/string-starts-with/string-starts-with.assert.js";
11
17
  export * from "./assert/throws-error-async/throws-error-async.assert.js";
12
18
  export * from "./assert/throws-error/throws-error.assert.js";
13
19
  export * from "./assert/true/true.assert.js";
@@ -18,4 +24,5 @@ export * from "./assert/type-number/type-number.assert.js";
18
24
  export * from "./assert/type-numeric/type-numeric.assert.js";
19
25
  export * from "./assert/type-object/type-object.assert.js";
20
26
  export * from "./assert/type-string/type-string.assert.js";
27
+ export * from "./assert/type-typed-array/type-typed-array.assert.js";
21
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8CAA8C,CAAC;AAC7D,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,kDAAkD,CAAC;AACjE,cAAc,wDAAwD,CAAC;AACvE,cAAc,kCAAkC,CAAC;AACjD,cAAc,0DAA0D,CAAC;AACzE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kDAAkD,CAAC;AACjE,cAAc,0DAA0D,CAAC;AACzE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,kDAAkD,CAAC;AACjE,cAAc,wDAAwD,CAAC;AACvE,cAAc,kCAAkC,CAAC;AACjD,cAAc,oDAAoD,CAAC;AACnE,cAAc,sDAAsD,CAAC;AACrE,cAAc,0DAA0D,CAAC;AACzE,cAAc,0DAA0D,CAAC;AACzE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sDAAsD,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
+ export * from "./assert/array-includes/array-includes.assert.js";
2
+ export * from "./assert/array-includes-all/array-includes-all.assert.js";
1
3
  export * from "./assert/array-length/array-length.assert.js";
2
4
  export * from "./assert/array-min-length/array-min-length.assert.js";
3
5
  export * from "./assert/array-not-empty/array-not-empty.assert.js";
6
+ export * from "./assert/buffer-equal/buffer-equal.assert.js";
4
7
  export * from "./assert/false/false.assert.js";
5
8
  export * from "./assert/identical/identical.assert.js";
6
9
  export * from "./assert/instance-of/instance-of.assert.js";
@@ -8,6 +11,9 @@ export * from "./assert/non-nullable/non-nullable.assert.js";
8
11
  export * from "./assert/number-between/number-between.assert.js";
9
12
  export * from "./assert/number-to-nearest/number-to-nearest.assert.js";
10
13
  export * from "./assert/one-of/one-of.assert.js";
14
+ export * from "./assert/string-includes/string-includes.assert.js";
15
+ export * from "./assert/string-ends-with/string-ends-with.assert.js";
16
+ export * from "./assert/string-starts-with/string-starts-with.assert.js";
11
17
  export * from "./assert/throws-error-async/throws-error-async.assert.js";
12
18
  export * from "./assert/throws-error/throws-error.assert.js";
13
19
  export * from "./assert/true/true.assert.js";
@@ -18,4 +24,5 @@ export * from "./assert/type-number/type-number.assert.js";
18
24
  export * from "./assert/type-numeric/type-numeric.assert.js";
19
25
  export * from "./assert/type-object/type-object.assert.js";
20
26
  export * from "./assert/type-string/type-string.assert.js";
27
+ export * from "./assert/type-typed-array/type-typed-array.assert.js";
21
28
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8CAA8C,CAAC;AAC7D,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,kDAAkD,CAAC;AACjE,cAAc,wDAAwD,CAAC;AACvE,cAAc,kCAAkC,CAAC;AACjD,cAAc,0DAA0D,CAAC;AACzE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kDAAkD,CAAC;AACjE,cAAc,0DAA0D,CAAC;AACzE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wCAAwC,CAAC;AACvD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,kDAAkD,CAAC;AACjE,cAAc,wDAAwD,CAAC;AACvE,cAAc,kCAAkC,CAAC;AACjD,cAAc,oDAAoD,CAAC;AACnE,cAAc,sDAAsD,CAAC;AACrE,cAAc,0DAA0D,CAAC;AACzE,cAAc,0DAA0D,CAAC;AACzE,cAAc,8CAA8C,CAAC;AAC7D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sDAAsD,CAAC"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Kensio Software",
5
5
  "repository": "https://github.com/KensioSoftware/smartass",
6
6
  "license": "AGPL-3.0",
7
- "version": "0.1.4",
7
+ "version": "0.1.6",
8
8
  "type": "module",
9
9
  "main": "./dist/index.js",
10
10
  "types": "./dist/index.d.ts",