@openstax/ts-utils 1.1.36 → 1.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/assertions.d.ts +1 -0
- package/dist/cjs/assertions.js +13 -1
- package/dist/cjs/services/authProvider/index.d.ts +1 -0
- package/dist/cjs/tsconfig.without-specs.cjs.tsbuildinfo +1 -1
- package/dist/esm/assertions.d.ts +1 -0
- package/dist/esm/assertions.js +11 -0
- package/dist/esm/services/authProvider/index.d.ts +1 -0
- package/dist/esm/tsconfig.without-specs.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/esm/assertions.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare type AssertionFailed = string | Error | (() => never) | undefined;
|
|
2
2
|
export declare const assertTrue: <X>(x: X, failed?: AssertionFailed) => X & true;
|
|
3
|
+
export declare const assertFalse: <X>(x: X, failed?: AssertionFailed) => X & false;
|
|
3
4
|
export declare const assertDefined: <X>(x: X, failed?: AssertionFailed) => Exclude<X, undefined>;
|
|
4
5
|
export declare const assertString: <X>(x: X, failed?: AssertionFailed) => string;
|
|
5
6
|
export declare const assertNotNaN: <T>(thing: T, failed?: AssertionFailed) => T;
|
package/dist/esm/assertions.js
CHANGED
|
@@ -21,6 +21,17 @@ export const assertTrue = (x, failed) => {
|
|
|
21
21
|
}
|
|
22
22
|
return x;
|
|
23
23
|
};
|
|
24
|
+
/*
|
|
25
|
+
* see note above about the failure case in the second argument
|
|
26
|
+
*
|
|
27
|
+
* const definitelyFalse = assertFalse(randomThing);
|
|
28
|
+
*/
|
|
29
|
+
export const assertFalse = (x, failed) => {
|
|
30
|
+
if (typeof x !== 'boolean' || x !== false) {
|
|
31
|
+
return doThrow(failed);
|
|
32
|
+
}
|
|
33
|
+
return x;
|
|
34
|
+
};
|
|
24
35
|
/*
|
|
25
36
|
* see note above about the failure case in the second argument
|
|
26
37
|
*
|