assertron 11.0.3 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,6 +34,7 @@ rush add -p assertron
34
34
 
35
35
  - `assertron.false(value)`: asserts the provided value is false.
36
36
  - `assertron.falsy(value)`: asserts the provided value is falsy.
37
+ - `assertron.isInstanceof(value, ClassType)`: asserts `value instanceof ClassType`.
37
38
  - `assertron.pathEqual(actual, expected)`: asserts the two paths are equal regardless of operating system differences.
38
39
  - `assertron.rejects(promise)`: asserts the promise rejects.
39
40
  - `assertron.repeat(fn, times)`: repeat the specified function n times and return the last result.\
@@ -1,21 +1,21 @@
1
- import { falsy } from './falsy.js';
2
- import { pathEqual } from './pathEqual.js';
3
- import { rejects } from './rejects.js';
4
- import { repeat } from './repeat.js';
5
- import { resolves } from './resolves.js';
6
- import { satisfies } from './satisfies.js';
7
- import { throws } from './throws.js';
8
- import { truthy } from './truthy.js';
9
- export declare const assertron: {
10
- false(value: any): void;
11
- falsy: typeof falsy;
12
- pathEqual: typeof pathEqual;
13
- rejects: typeof rejects;
14
- repeat: typeof repeat;
15
- resolves: typeof resolves;
16
- satisfies: typeof satisfies;
17
- throws: typeof throws;
18
- true(value: any): void;
19
- truthy: typeof truthy;
1
+ import type { AnyConstructor } from 'type-plus';
2
+ import type { ErrorConstructor, ErrorValidator } from '../types.js';
3
+ import { SatisfyExpectation } from './satisfies.js';
4
+ export declare type Assertron = {
5
+ false(value: unknown): asserts value is false;
6
+ falsy(value: any): asserts value is false | 0 | '' | null | undefined;
7
+ isInstanceof<T extends AnyConstructor>(value: unknown, type: T): asserts value is InstanceType<T>;
8
+ pathEqual(actual: string, expected: string): void;
9
+ rejects<R = any>(promise: Promise<any>): Promise<R>;
10
+ repeat<R>(fn: () => R | (() => Promise<R>), times: number): ReturnType<typeof fn> extends Promise<R> ? Promise<R> : R;
11
+ resolves(promise: Promise<any>): Promise<void>;
12
+ satisfies<Actual, Expected extends Actual>(actual: Actual, expected: SatisfyExpectation<Expected>): void;
13
+ throws<E extends Error>(value: PromiseLike<any>, error?: ErrorValidator | ErrorConstructor<E>): Promise<E>;
14
+ throws<E extends Error>(value: (...args: any[]) => never, error?: ErrorValidator | ErrorConstructor<E>): E;
15
+ throws<E extends Error, R = any>(value: (...args: any[]) => R, error?: ErrorValidator | ErrorConstructor<E>): R extends Promise<any> ? Promise<E> : E;
16
+ throws<T, R = any>(value: (...args: any[]) => R, validator?: ErrorValidator): R extends Promise<any> ? Promise<T> : T;
17
+ true(value: any): asserts value is true;
18
+ truthy(value: unknown): void;
20
19
  };
20
+ export declare const assertron: Assertron;
21
21
  //# sourceMappingURL=assertron.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assertron.d.ts","sourceRoot":"","sources":["../../ts/assertron/assertron.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,eAAO,MAAM,SAAS;iBACP,GAAG;;;;;;;;gBAWJ,GAAG;;CAKhB,CAAA"}
1
+ {"version":3,"file":"assertron.d.ts","sourceRoot":"","sources":["../../ts/assertron/assertron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAQnE,OAAO,EAAa,kB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,CAAC,CAAC,CAAC;IAC3G,MAAM,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,EAAE,KAAK,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3G,MAAM,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACtJ,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,EAAE,cAAc,GAAG,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACtH,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,SAkBvB,CAAA"}
@@ -4,6 +4,7 @@ exports.assertron = void 0;
4
4
  const errors_js_1 = require("../errors.js");
5
5
  const index_js_1 = require("../utils/index.js");
6
6
  const falsy_js_1 = require("./falsy.js");
7
+ const isInstanceof_js_1 = require("./isInstanceof.js");
7
8
  const pathEqual_js_1 = require("./pathEqual.js");
8
9
  const rejects_js_1 = require("./rejects.js");
9
10
  const repeat_js_1 = require("./repeat.js");
@@ -17,6 +18,7 @@ exports.assertron = {
17
18
  throw new errors_js_1.AssertionError((0, index_js_1.notEqualMessage)(value, false), { ssf: exports.assertron.false });
18
19
  },
19
20
  falsy: falsy_js_1.falsy,
21
+ isInstanceof: isInstanceof_js_1.isInstanceof,
20
22
  pathEqual: pathEqual_js_1.pathEqual,
21
23
  rejects: rejects_js_1.rejects,
22
24
  repeat: repeat_js_1.repeat,
@@ -1 +1 @@
1
- {"version":3,"file":"assertron.js","sourceRoot":"","sources":["../../ts/assertron/assertron.ts"],"names":[],"mappings":";;;AAAA,4CAA6C;AAC7C,gDAAmD;AACnD,yCAAkC;AAClC,iDAA0C;AAC1C,6CAAsC;AACtC,2CAAoC;AACpC,+CAAwC;AACxC,iDAA0C;AAC1C,2CAAoC;AACpC,2CAAoC;AAEvB,QAAA,SAAS,GAAG;IACvB,KAAK,CAAC,KAAU;QACd,IAAI,KAAK,KAAK,KAAK;YACjB,MAAM,IAAI,0BAAc,CAAC,IAAA,0BAAe,EAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,iBAAS,CAAC,KAAK,EAAE,CAAC,CAAA;IACrF,CAAC;IACD,KAAK,EAAL,gBAAK;IACL,SAAS,EAAT,wBAAS;IACT,OAAO,EAAP,oBAAO;IACP,MAAM,EAAN,kBAAM;IACN,QAAQ,EAAR,sBAAQ;IACR,SAAS,EAAT,wBAAS;IACT,MAAM,EAAN,kBAAM;IACN,IAAI,CAAC,KAAU;QACb,IAAI,KAAK,KAAK,IAAI;YAChB,MAAM,IAAI,0BAAc,CAAC,IAAA,0BAAe,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,iBAAS,CAAC,IAAI,EAAE,CAAC,CAAA;IACnF,CAAC;IACD,MAAM,EAAN,kBAAM;CACP,CAAA"}
1
+ {"version":3,"file":"assertron.js","sourceRoot":"","sources":["../../ts/assertron/assertron.ts"],"names":[],"mappings":";;;AACA,4CAA6C;AAE7C,gDAAmD;AACnD,yCAAkC;AAClC,uDAAgD;AAChD,iDAA0C;AAC1C,6CAAsC;AACtC,2CAAoC;AACpC,+CAAwC;AACxC,iDAA8D;AAC9D,2CAAoC;AACpC,2CAAoC;AAmBvB,QAAA,SAAS,GAAc;IAClC,KAAK,CAAC,KAAU;QACd,IAAI,KAAK,KAAK,KAAK;YACjB,MAAM,IAAI,0BAAc,CAAC,IAAA,0BAAe,EAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,iBAAS,CAAC,KAAK,EAAE,CAAC,CAAA;IACrF,CAAC;IACD,KAAK,EAAL,gBAAK;IACL,YAAY,EAAZ,8BAAY;IACZ,SAAS,EAAT,wBAAS;IACT,OAAO,EAAP,oBAAO;IACP,MAAM,EAAN,kBAAM;IACN,QAAQ,EAAR,sBAAQ;IACR,SAAS,EAAT,wBAAS;IACT,MAAM,EAAN,kBAAM;IACN,IAAI,CAAC,KAAU;QACb,IAAI,KAAK,KAAK,IAAI;YAChB,MAAM,IAAI,0BAAc,CAAC,IAAA,0BAAe,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,iBAAS,CAAC,IAAI,EAAE,CAAC,CAAA;IACnF,CAAC;IACD,MAAM,EAAN,kBAAM;CACP,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { AnyConstructor } from 'type-plus';
2
+ export declare function isInstanceof<T extends AnyConstructor>(value: unknown, type: T): asserts value is InstanceType<T>;
3
+ //# sourceMappingURL=isInstanceof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isInstanceof.d.ts","sourceRoot":"","sources":["../../ts/assertron/isInstanceof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAG/C,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC,CAAC,CAAC,CAIhH"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isInstanceof = void 0;
4
+ const errors_js_1 = require("../errors.js");
5
+ function isInstanceof(value, type) {
6
+ if (value instanceof type)
7
+ return;
8
+ throw new errors_js_1.AssertionError(`Expected ${value} to be an instance of ${type.name}`, { ssf: isInstanceof });
9
+ }
10
+ exports.isInstanceof = isInstanceof;
11
+ //# sourceMappingURL=isInstanceof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isInstanceof.js","sourceRoot":"","sources":["../../ts/assertron/isInstanceof.ts"],"names":[],"mappings":";;;AACA,4CAA6C;AAE7C,SAAgB,YAAY,CAA2B,KAAc,EAAE,IAAO;IAC5E,IAAI,KAAK,YAAY,IAAI;QAAE,OAAM;IAEjC,MAAM,IAAI,0BAAc,CAAC,YAAY,KAAK,yBAAyB,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAA;AACxG,CAAC;AAJD,oCAIC"}
@@ -1,2 +1,2 @@
1
- export declare function truthy(value: any): void;
1
+ export declare function truthy(value: unknown): void;
2
2
  //# sourceMappingURL=truthy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"truthy.d.ts","sourceRoot":"","sources":["../../ts/assertron/truthy.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,QAKhC"}
1
+ {"version":3,"file":"truthy.d.ts","sourceRoot":"","sources":["../../ts/assertron/truthy.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,QAKpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"truthy.js","sourceRoot":"","sources":["../../ts/assertron/truthy.ts"],"names":[],"mappings":";;;AAAA,4CAA6C;AAE7C,SAAgB,MAAM,CAAC,KAAU;IAC/B,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,0BAAc,CAClC,6CAA6C,KAAK,EAAE,EACpD,EAAE,GAAG,EAAE,MAAM,EAAE,CAChB,CAAA;AACH,CAAC;AALD,wBAKC"}
1
+ {"version":3,"file":"truthy.js","sourceRoot":"","sources":["../../ts/assertron/truthy.ts"],"names":[],"mappings":";;;AAAA,4CAA6C;AAE7C,SAAgB,MAAM,CAAC,KAAc;IACnC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,0BAAc,CAClC,6CAA6C,KAAK,EAAE,EACpD,EAAE,GAAG,EAAE,MAAM,EAAE,CAChB,CAAA;AACH,CAAC;AALD,wBAKC"}
@@ -1,21 +1,21 @@
1
- import { falsy } from './falsy.js';
2
- import { pathEqual } from './pathEqual.js';
3
- import { rejects } from './rejects.js';
4
- import { repeat } from './repeat.js';
5
- import { resolves } from './resolves.js';
6
- import { satisfies } from './satisfies.js';
7
- import { throws } from './throws.js';
8
- import { truthy } from './truthy.js';
9
- export declare const assertron: {
10
- false(value: any): void;
11
- falsy: typeof falsy;
12
- pathEqual: typeof pathEqual;
13
- rejects: typeof rejects;
14
- repeat: typeof repeat;
15
- resolves: typeof resolves;
16
- satisfies: typeof satisfies;
17
- throws: typeof throws;
18
- true(value: any): void;
19
- truthy: typeof truthy;
1
+ import type { AnyConstructor } from 'type-plus';
2
+ import type { ErrorConstructor, ErrorValidator } from '../types.js';
3
+ import { SatisfyExpectation } from './satisfies.js';
4
+ export declare type Assertron = {
5
+ false(value: unknown): asserts value is false;
6
+ falsy(value: any): asserts value is false | 0 | '' | null | undefined;
7
+ isInstanceof<T extends AnyConstructor>(value: unknown, type: T): asserts value is InstanceType<T>;
8
+ pathEqual(actual: string, expected: string): void;
9
+ rejects<R = any>(promise: Promise<any>): Promise<R>;
10
+ repeat<R>(fn: () => R | (() => Promise<R>), times: number): ReturnType<typeof fn> extends Promise<R> ? Promise<R> : R;
11
+ resolves(promise: Promise<any>): Promise<void>;
12
+ satisfies<Actual, Expected extends Actual>(actual: Actual, expected: SatisfyExpectation<Expected>): void;
13
+ throws<E extends Error>(value: PromiseLike<any>, error?: ErrorValidator | ErrorConstructor<E>): Promise<E>;
14
+ throws<E extends Error>(value: (...args: any[]) => never, error?: ErrorValidator | ErrorConstructor<E>): E;
15
+ throws<E extends Error, R = any>(value: (...args: any[]) => R, error?: ErrorValidator | ErrorConstructor<E>): R extends Promise<any> ? Promise<E> : E;
16
+ throws<T, R = any>(value: (...args: any[]) => R, validator?: ErrorValidator): R extends Promise<any> ? Promise<T> : T;
17
+ true(value: any): asserts value is true;
18
+ truthy(value: unknown): void;
20
19
  };
20
+ export declare const assertron: Assertron;
21
21
  //# sourceMappingURL=assertron.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assertron.d.ts","sourceRoot":"","sources":["../../ts/assertron/assertron.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,eAAO,MAAM,SAAS;iBACP,GAAG;;;;;;;;gBAWJ,GAAG;;CAKhB,CAAA"}
1
+ {"version":3,"file":"assertron.d.ts","sourceRoot":"","sources":["../../ts/assertron/assertron.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAQnE,OAAO,EAAa,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAI9D,oBAAY,SAAS,GAAG;IACtB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,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AK,EAAE,KAAK,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC3G,MAAM,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACtJ,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,EAAE,cAAc,GAAG,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACtH,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,SAAS,EAAE,SAkBvB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { AssertionError } from '../errors.js';
2
2
  import { notEqualMessage } from '../utils/index.js';
3
3
  import { falsy } from './falsy.js';
4
+ import { isInstanceof } from './isInstanceof.js';
4
5
  import { pathEqual } from './pathEqual.js';
5
6
  import { rejects } from './rejects.js';
6
7
  import { repeat } from './repeat.js';
@@ -14,6 +15,7 @@ export const assertron = {
14
15
  throw new AssertionError(notEqualMessage(value, false), { ssf: assertron.false });
15
16
  },
16
17
  falsy,
18
+ isInstanceof,
17
19
  pathEqual,
18
20
  rejects,
19
21
  repeat,
@@ -1 +1 @@
1
- {"version":3,"file":"assertron.js","sourceRoot":"","sources":["../../ts/assertron/assertron.ts"],"names":[],"mappings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AA;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,SAAS,EAAsB,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAmBpC,MAAM,CAAC,MAAM,SAAS,GAAc;IAClC,KAAK,CAAC,KAAU;QACd,IAAI,KAAK,KAAK,KAAK;YACjB,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAA;IACrF,CAAC;IACD,KAAK;IACL,YAAY;IACZ,SAAS;IACT,OAAO;IACP,MAAM;IACN,QAAQ;IACR,SAAS;IACT,MAAM;IACN,IAAI,CAAC,KAAU;QACb,IAAI,KAAK,KAAK,IAAI;YAChB,MAAM,IAAI,cAAc,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC,CAAA;IACnF,CAAC;IACD,MAAM;CACP,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { AnyConstructor } from 'type-plus';
2
+ export declare function isInstanceof<T extends AnyConstructor>(value: unknown, type: T): asserts value is InstanceType<T>;
3
+ //# sourceMappingURL=isInstanceof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isInstanceof.d.ts","sourceRoot":"","sources":["../../ts/assertron/isInstanceof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAG/C,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC,CAAC,CAAC,CAIhH"}
@@ -0,0 +1,7 @@
1
+ import { AssertionError } from '../errors.js';
2
+ export function isInstanceof(value, type) {
3
+ if (value instanceof type)
4
+ return;
5
+ throw new AssertionError(`Expected ${value} to be an instance of ${type.name}`, { ssf: isInstanceof });
6
+ }
7
+ //# sourceMappingURL=isInstanceof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isInstanceof.js","sourceRoot":"","sources":["../../ts/assertron/isInstanceof.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,UAAU,YAAY,CAA2B,KAAc,EAAE,IAAO;IAC5E,IAAI,KAAK,YAAY,IAAI;QAAE,OAAM;IAEjC,MAAM,IAAI,cAAc,CAAC,YAAY,KAAK,yBAAyB,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAA;AACxG,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare function truthy(value: any): void;
1
+ export declare function truthy(value: unknown): void;
2
2
  //# sourceMappingURL=truthy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"truthy.d.ts","sourceRoot":"","sources":["../../ts/assertron/truthy.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,QAKhC"}
1
+ {"version":3,"file":"truthy.d.ts","sourceRoot":"","sources":["../../ts/assertron/truthy.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,QAKpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"truthy.js","sourceRoot":"","sources":["../../ts/assertron/truthy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,UAAU,MAAM,CAAC,KAAU;IAC/B,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,cAAc,CAClC,6CAA6C,KAAK,EAAE,EACpD,EAAE,GAAG,EAAE,MAAM,EAAE,CAChB,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"truthy.js","sourceRoot":"","sources":["../../ts/assertron/truthy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,cAAc,CAClC,6CAA6C,KAAK,EAAE,EACpD,EAAE,GAAG,EAAE,MAAM,EAAE,CAChB,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assertron",
3
- "version": "11.0.3",
3
+ "version": "11.1.0",
4
4
  "description": "A supplementary assertion library",
5
5
  "homepage": "https://github.com/unional/assertron",
6
6
  "bugs": {
@@ -89,13 +89,13 @@
89
89
  "npm-run-all": "^4.1.5",
90
90
  "pinst": "^3.0.0",
91
91
  "rimraf": "^3.0.2",
92
- "semantic-release": "^19.0.3",
92
+ "semantic-release": "^20.0.2",
93
93
  "size-limit": "^8.0.0",
94
94
  "ts-jest": "^29.0.0",
95
95
  "tslib": "^2.4.0",
96
96
  "typescript": "^4.7.3"
97
97
  },
98
- "packageManager": "yarn@3.3.0",
98
+ "packageManager": "yarn@3.3.1",
99
99
  "size-limit": [
100
100
  {
101
101
  "path": "./cjs/index.js",
@@ -1,20 +1,41 @@
1
+ import type { AnyConstructor } from 'type-plus'
1
2
  import { AssertionError } from '../errors.js'
3
+ import type { ErrorConstructor, ErrorValidator } from '../types.js'
2
4
  import { notEqualMessage } from '../utils/index.js'
3
5
  import { falsy } from './falsy.js'
6
+ import { isInstanceof } from './isInstanceof.js'
4
7
  import { pathEqual } from './pathEqual.js'
5
8
  import { rejects } from './rejects.js'
6
9
  import { repeat } from './repeat.js'
7
10
  import { resolves } from './resolves.js'
8
- import { satisfies } from './satisfies.js'
11
+ import { satisfies, SatisfyExpectation } from './satisfies.js'
9
12
  import { throws } from './throws.js'
10
13
  import { truthy } from './truthy.js'
11
14
 
12
- export const assertron = {
15
+ export type Assertron = {
16
+ false(value: unknown): asserts value is false,
17
+ falsy(value: any): asserts value is false | 0 | '' | null | undefined,
18
+ isInstanceof<T extends AnyConstructor>(value: unknown, type: T): asserts value is InstanceType<T>,
19
+ pathEqual(actual: string, expected: string): void,
20
+ rejects<R = any>(promise: Promise<any>): Promise<R>,
21
+ repeat<R>(fn: () => R | (() => Promise<R>), times: number): ReturnType<typeof fn> extends Promise<R> ? Promise<R> : R,
22
+ resolves(promise: Promise<any>): Promise<void>,
23
+ satisfies<Actual, Expected extends Actual>(actual: Actual, expected: SatisfyExpectation<Expected>): void,
24
+ throws<E extends Error>(value: PromiseLike<any>, error?: ErrorValidator | ErrorConstructor<E>): Promise<E>,
25
+ throws<E extends Error>(value: (...args: any[]) => never, error?: ErrorValidator | ErrorConstructor<E>): E,
26
+ throws<E extends Error, R = any>(value: (...args: any[]) => R, error?: ErrorValidator | ErrorConstructor<E>): R extends Promise<any> ? Promise<E> : E,
27
+ throws<T, R = any>(value: (...args: any[]) => R, validator?: ErrorValidator): R extends Promise<any> ? Promise<T> : T,
28
+ true(value: any): asserts value is true,
29
+ truthy(value: unknown): void
30
+ }
31
+
32
+ export const assertron: Assertron = {
13
33
  false(value: any) {
14
34
  if (value !== false)
15
35
  throw new AssertionError(notEqualMessage(value, false), { ssf: assertron.false })
16
36
  },
17
37
  falsy,
38
+ isInstanceof,
18
39
  pathEqual,
19
40
  rejects,
20
41
  repeat,
@@ -0,0 +1,8 @@
1
+ import type { AnyConstructor } from 'type-plus'
2
+ import { AssertionError } from '../errors.js'
3
+
4
+ export function isInstanceof<T extends AnyConstructor>(value: unknown, type: T): asserts value is InstanceType<T> {
5
+ if (value instanceof type) return
6
+
7
+ throw new AssertionError(`Expected ${value} to be an instance of ${type.name}`, { ssf: isInstanceof })
8
+ }
@@ -1,6 +1,6 @@
1
1
  import { AssertionError } from '../errors.js'
2
2
 
3
- export function truthy(value: any) {
3
+ export function truthy(value: unknown) {
4
4
  if (!value) throw new AssertionError(
5
5
  `Expected value to be truthy, but received ${value}`,
6
6
  { ssf: truthy }