-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
248 changed files
with
2,143 additions
and
462 deletions.
There are no files selected for viewing
Binary file renamed
BIN
+8.03 KB
...rame-npm-7.21.4-5db83e65be-e5390e6ec1.zip → ...rame-npm-7.22.5-b36f88d6f9-cfe804f518.zip
Binary file not shown.
Binary file renamed
BIN
+9.18 KB
...data-npm-7.22.3-7b67f6cb95-eb001646f4.zip → ...data-npm-7.22.5-282f002362-eb1a47ebf7.zip
Binary file not shown.
Binary file renamed
BIN
+244 KB
...core-npm-7.22.1-4ec1915241-bbe45e791f.zip → ...core-npm-7.22.5-d75e931080-173ae42695.zip
Binary file not shown.
Binary file renamed
BIN
+119 KB
...ator-npm-7.22.3-da14afacf5-ccb6426ca5.zip → ...ator-npm-7.22.5-0e87a1a822-efa64da70c.zip
Binary file not shown.
Binary file renamed
BIN
+21.6 KB
...gets-npm-7.22.1-4f7cfd1a17-a686a01bd3.zip → ...gets-npm-7.22.5-5e6d9af186-a479460615.zip
Binary file not shown.
Binary file renamed
BIN
+4.34 KB
...itor-npm-7.22.1-e00fbc528d-a6b4bb5505.zip → ...itor-npm-7.22.5-7bc52eec61-248532077d.zip
Binary file not shown.
Binary file removed
BIN
-8.7 KB
.yarn/cache/@babel-helper-function-name-npm-7.21.0-a17ce5a05a-d63e63c3e0.zip
Binary file not shown.
Binary file added
BIN
+8.75 KB
.yarn/cache/@babel-helper-function-name-npm-7.22.5-8a1a69b63d-6b1f6ce1b1.zip
Binary file not shown.
Binary file removed
BIN
-2.99 KB
.yarn/cache/@babel-helper-hoist-variables-npm-7.18.6-6eb061f405-fd9c35bb43.zip
Binary file not shown.
Binary file added
BIN
+4.5 KB
.yarn/cache/@babel-helper-hoist-variables-npm-7.22.5-6db3192347-394ca191b4.zip
Binary file not shown.
Binary file removed
BIN
-16 KB
.yarn/cache/@babel-helper-module-imports-npm-7.21.4-e4cd6b4e21-bd330a2eda.zip
Binary file not shown.
Binary file added
BIN
+16 KB
.yarn/cache/@babel-helper-module-imports-npm-7.22.5-399b6063db-9ac2b0404f.zip
Binary file not shown.
Binary file renamed
BIN
+41.9 KB
...orms-npm-7.22.1-bd7615b6f7-dfa084211a.zip → ...orms-npm-7.22.5-c31751930e-8985dc0d97.zip
Binary file not shown.
Binary file removed
BIN
-6.19 KB
.yarn/cache/@babel-helper-plugin-utils-npm-7.21.5-b310faa7aa-6f086e9a84.zip
Binary file not shown.
Binary file added
BIN
+6.18 KB
.yarn/cache/@babel-helper-plugin-utils-npm-7.22.5-192e38e1de-c0fc722707.zip
Binary file not shown.
Binary file removed
BIN
-5.91 KB
.yarn/cache/@babel-helper-simple-access-npm-7.21.5-adbdd3a62b-ad212beaa2.zip
Binary file not shown.
Binary file added
BIN
+5.9 KB
.yarn/cache/@babel-helper-simple-access-npm-7.22.5-0a3f578780-fe9686714c.zip
Binary file not shown.
Binary file removed
BIN
-3.17 KB
.yarn/cache/@babel-helper-split-export-declaration-npm-7.18.6-53ebf8ad4c-c6d3dede53.zip
Binary file not shown.
Binary file added
BIN
+5.14 KB
.yarn/cache/@babel-helper-split-export-declaration-npm-7.22.5-5e708abd3e-d10e05a02f.zip
Binary file not shown.
Binary file removed
BIN
-9.82 KB
.yarn/cache/@babel-helper-string-parser-npm-7.21.5-9fa0e56f04-36c0ded452.zip
Binary file not shown.
Binary file added
BIN
+9.82 KB
.yarn/cache/@babel-helper-string-parser-npm-7.22.5-448ff0e489-836851ca5e.zip
Binary file not shown.
Binary file removed
BIN
-20.8 KB
.yarn/cache/@babel-helper-validator-identifier-npm-7.19.1-d84f19e1dc-0eca5e86a7.zip
Binary file not shown.
Binary file added
BIN
+17.5 KB
.yarn/cache/@babel-helper-validator-identifier-npm-7.22.5-4536624779-7f0f301134.zip
Binary file not shown.
Binary file removed
BIN
-7.08 KB
.yarn/cache/@babel-helper-validator-option-npm-7.21.0-fbe86866e3-8ece4c78ff.zip
Binary file not shown.
Binary file added
BIN
+7.14 KB
.yarn/cache/@babel-helper-validator-option-npm-7.22.5-eaf22b24ab-bbeca8a85e.zip
Binary file not shown.
Binary file renamed
BIN
+149 KB
...pers-npm-7.22.3-0e890dfceb-385289ee8b.zip → ...pers-npm-7.22.5-b98bfa9936-a96e785029.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+833 KB
...rser-npm-7.22.4-32183c89ee-0ca6d3a2d9.zip → ...rser-npm-7.22.5-6f8647af64-470ebba516.zip
Binary file not shown.
Binary file removed
BIN
-3.53 KB
.yarn/cache/@babel-plugin-syntax-jsx-npm-7.21.4-52d55c7a43-bb7309402a.zip
Binary file not shown.
Binary file added
BIN
+3.52 KB
.yarn/cache/@babel-plugin-syntax-jsx-npm-7.22.5-2cbf8e7e68-8829d30c26.zip
Binary file not shown.
Binary file renamed
BIN
+4.54 KB
...ript-npm-7.21.4-bcb1097f7e-a59ce2477b.zip → ...ript-npm-7.22.5-e17157d73d-8ab7718fbb.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+171 KB
...erse-npm-7.22.4-7501c8e8f8-9560ae2209.zip → ...erse-npm-7.22.5-071d471ccd-560931422d.zip
Binary file not shown.
Binary file renamed
BIN
+321 KB
...ypes-npm-7.22.4-7dadf03e9d-ffe36bb4f4.zip → ...ypes-npm-7.22.5-d1e4264bef-c13a9c1dc7.zip
Binary file not shown.
Binary file renamed
BIN
+12.7 KB
...-cli-npm-17.6.3-583c622f77-e5a597ef45.zip → ...-cli-npm-17.6.5-1dd10cbe12-acc57bdb73.zip
Binary file not shown.
Binary file renamed
BIN
+4.39 KB
...onal-npm-17.6.3-dc84eb5c43-2dbe26cfaf.zip → ...onal-npm-17.6.5-ef8d82de49-f2c637a993.zip
Binary file not shown.
Binary file renamed
BIN
+7.35 KB
...ored-npm-17.6.3-570445525b-db664b7e6b.zip → ...ored-npm-17.6.5-eb9c495070-2b7b7f0773.zip
Binary file not shown.
Binary file renamed
BIN
+7.55 KB
...lint-npm-17.6.3-fbda5b486d-f033d25fd3.zip → ...lint-npm-17.6.5-4378eb0cdb-6a6c04a5ec.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+66.2 KB
...ules-npm-17.6.1-50fd353ff2-e00b453e8a.zip → ...ules-npm-17.6.5-8317b1f8b5-7f62c59415.zip
Binary file not shown.
Binary file renamed
BIN
+6.01 KB
...t-js-npm-8.41.0-7597c33d09-af013d70fe.zip → ...t-js-npm-8.42.0-820f8f50f7-750558843a.zip
Binary file not shown.
Binary file added
BIN
+16.5 KB
.yarn/cache/@humanwhocodes-config-array-npm-0.11.10-7b63df9e7f-1b1302e240.zip
Binary file not shown.
Binary file removed
BIN
-18.8 KB
.yarn/cache/@humanwhocodes-config-array-npm-0.11.8-7955bfecc2-0fd6b3c54f.zip
Binary file not shown.
Binary file renamed
BIN
+12.1 KB
...i-git-npm-4.0.4-58b0cf13b7-fd8ad33113.zip → ...i-git-npm-4.1.0-f7322fced9-37efb92659.zip
Binary file not shown.
Binary file removed
BIN
-9.89 KB
.yarn/cache/@npmcli-package-json-npm-3.1.0-ba411bfc47-bcc3a464c6.zip
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-13.2 KB
.yarn/cache/@octokit-auth-token-npm-3.0.3-6fba099166-9b3f569cec.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-399 KB
.yarn/cache/@octokit-openapi-types-npm-17.2.0-e9456595e7-29995e34f9.zip
Binary file not shown.
Binary file added
BIN
+402 KB
.yarn/cache/@octokit-openapi-types-npm-18.0.0-1586e405d6-d487d6c6c1.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+19.3 KB
.yarn/cache/@sinonjs-fake-timers-npm-10.1.0-9e99531b91-f8f7e23a13.zip
Binary file not shown.
Binary file removed
BIN
-19.6 KB
.yarn/cache/@sinonjs-fake-timers-npm-10.2.0-cc1159e8aa-586c76e1dd.zip
Binary file not shown.
Binary file removed
BIN
-29.6 KB
.yarn/cache/@types-babel__traverse-npm-7.20.0-c5a0b2eb9a-030d647a61.zip
Binary file not shown.
Binary file added
BIN
+16.1 KB
.yarn/cache/@types-babel__traverse-npm-7.20.1-e1e93d4b3f-58341e23c6.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+731 KB
...node-npm-20.2.5-0014d2d9ce-38ce7c7e9d.zip → ...node-npm-20.3.1-86012346c0-63a393ab6d.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+735 KB
...ugin-npm-5.59.8-255dbedf93-3e05cd0614.zip → ...gin-npm-5.59.11-2b9cfe03cd-ff03eaa65a.zip
Binary file not shown.
Binary file renamed
BIN
+9.99 KB
...rser-npm-5.59.8-ceb8b0eaa0-bac9f09d85.zip → ...ser-npm-5.59.11-645894e08d-75eb6e6057.zip
Binary file not shown.
Binary file renamed
BIN
+317 KB
...ager-npm-5.59.8-d925c50275-e1e810ee99.zip → ...ger-npm-5.59.11-5d2465827e-f5c4e6d26d.zip
Binary file not shown.
Binary file renamed
BIN
+50.5 KB
...tils-npm-5.59.8-61b85480e4-d9fde31397.zip → ...ils-npm-5.59.11-b04b5ea015-3570ba21af.zip
Binary file not shown.
Binary file renamed
BIN
+42.8 KB
...ypes-npm-5.59.8-aac9636f23-559473d560.zip → ...pes-npm-5.59.11-fec3c5ff28-4bb667571a.zip
Binary file not shown.
Binary file renamed
BIN
+179 KB
...tree-npm-5.59.8-8d25500a8f-d93371cc86.zip → ...ree-npm-5.59.11-451bf9de0d-516a828884.zip
Binary file not shown.
Binary file renamed
BIN
+175 KB
...tils-npm-5.59.8-24495aa535-cbaa057485.zip → ...ils-npm-5.59.11-fc5a1295dc-a61f3e761d.zip
Binary file not shown.
Binary file renamed
BIN
+11 KB
...keys-npm-5.59.8-bd7eb812d7-6bfa7918db.zip → ...eys-npm-5.59.11-2c0f2bc79a-4894ec4b2b.zip
Binary file not shown.
Binary file renamed
BIN
+31 KB
...npm-3.0.0-rc.44-5bc24fcbd1-45b96a06ce.zip → ...npm-3.0.0-rc.45-8e556a569c-10f3b10e2e.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-32.2 KB
.yarn/cache/electron-to-chromium-npm-1.4.413-7e81be06e6-6d702b84e2.zip
Binary file not shown.
Binary file added
BIN
+32.5 KB
.yarn/cache/electron-to-chromium-npm-1.4.430-b477454307-f5350cc693.zip
Binary file not shown.
Binary file renamed
BIN
+754 KB
...lint-npm-8.41.0-0e83e90d27-09979a6f84.zip → ...lint-npm-8.42.0-593c3ddde5-07105397b5.zip
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+35.7 KB
...arser-npm-4.2.2-3696e5f2bb-f0e687927d.zip → ...arser-npm-4.2.4-fc3c8e46cb-d3b4d0c015.zip
Binary file not shown.
Binary file renamed
BIN
+129 KB
...glob-npm-10.2.6-dcc609070c-94c5964bfa.zip → ...glob-npm-10.2.7-25e89f4e5c-555205a746.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+504 KB
...e-gyp-npm-9.3.1-43540bab9c-b860e9976f.zip → ...e-gyp-npm-9.4.0-ebf5f5573e-78b404e2e0.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+58.7 KB
...olve-npm-1.22.2-9d9621a4ae-7e5df75796.zip → ...olve-npm-1.22.3-f7dee15274-fb834b8134.zip
Binary file not shown.
Binary file renamed
BIN
+59.9 KB
...e/resolve-patch-f4c4056507-66cc788f13.zip → ...e/resolve-patch-bb62d3c3c5-ad59734723.zip
Binary file not shown.
Binary file renamed
BIN
+115 KB
...store-npm-1.5.2-b102310995-f54b4f427f.zip → ...store-npm-1.6.0-fc786d3026-55d87e24fc.zip
Binary file not shown.
Binary file renamed
BIN
+19.6 KB
...tslib-npm-2.5.2-3f1b58afbb-4d3c1e238b.zip → ...tslib-npm-2.5.3-7756051e02-88902b309a.zip
Binary file not shown.
Binary file renamed
BIN
+14.5 KB
...uf-js-npm-1.1.6-976a3cf45a-ab4b777251.zip → ...uf-js-npm-1.1.7-045f70823d-089fc0dabe.zip
Binary file not shown.
Binary file renamed
BIN
+6.79 MB
...cript-npm-5.0.4-122f6a883a-82b94da3f4.zip → ...cript-npm-5.1.3-ff9af2aba1-d9d51862d9.zip
Binary file not shown.
Binary file renamed
BIN
+6.8 MB
...ypescript-patch-ecf29fafbd-d26b6ba97b.zip → ...ypescript-patch-b923e81685-32a25b2e12.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Artur Bier | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "@bunt/assert", | ||
"version": "0.1.0", | ||
"keywords": [ | ||
"typescript" | ||
], | ||
"author": { | ||
"name": "Artur Bier", | ||
"email": "izatop@gmail.com" | ||
}, | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"types": "dist/cjs/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/esm/index.d.ts", | ||
"default": "./dist/esm/index.js" | ||
}, | ||
"require": { | ||
"types": "./dist/cjs/index.d.ts", | ||
"default": "./dist/cjs/index.js" | ||
} | ||
} | ||
}, | ||
"files": [ | ||
"dist/", | ||
"LICENSE" | ||
], | ||
"description": "Utils", | ||
"repository": "git@github.com:izatop/bunt.git", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@bunt/is": "^0.1.0", | ||
"@bunt/type": "^0.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {isFunction} from "@bunt/is"; | ||
import {ILogable} from "@bunt/type"; | ||
import {ValidationError} from "./ValidationError.js"; | ||
|
||
export class AssertionError extends ValidationError implements ILogable<Record<any, any>> { | ||
public readonly details?: any; | ||
|
||
constructor(message?: string, details?: unknown | (() => unknown)) { | ||
super(message || "Assertion fails"); | ||
|
||
this.details = isFunction(details) | ||
? details() | ||
: details; | ||
} | ||
|
||
public getLogValue(): Record<any, any> { | ||
return this.details; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class NotFound extends Error {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class PermissionError extends Error {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export class ValidationError extends Error {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {IReadableError} from "./interfaces.js"; | ||
|
||
export const isReadableError = (error: Error): error is IReadableError & Error => { | ||
return "toSafeJSON" in error && "toSafeString" in error; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export * from "./interfaces.js"; | ||
export * from "./PermissionError.js"; | ||
export * from "./ValidationError.js"; | ||
export * from "./AssertionError.js"; | ||
export * from "./NotFound.js"; | ||
export * from "./functions.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface IReadableError { | ||
toSafeString(): string; | ||
|
||
toSafeJSON(): Record<any, any>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {isFunction, isInstanceOf, isString} from "@bunt/is"; | ||
import {AssertionError} from "./Exception/index.js"; | ||
|
||
export type AssertionDetailsAllowType = string | Record<any, any> | null | number; | ||
export type AssertionDetails = (() => AssertionDetailsAllowType) | AssertionDetailsAllowType; | ||
export type AssertionMessage = string | (() => string) | (() => Error); | ||
|
||
function createAssertionError(message?: AssertionMessage, details?: AssertionDetails): Error | AssertionError { | ||
const description = isFunction(message) ? message() : message; | ||
|
||
return isInstanceOf(description, Error) | ||
? description | ||
: new AssertionError(description, details); | ||
} | ||
|
||
export function assert(expr: unknown, message?: AssertionMessage, details?: AssertionDetails): asserts expr { | ||
if (!expr) { | ||
throw createAssertionError(message, details); | ||
} | ||
} | ||
|
||
export function validateTrue(result: true | string, details?: AssertionDetails): void { | ||
if (isString(result)) { | ||
throw createAssertionError(result, details); | ||
} | ||
} | ||
|
||
export function fails(expr: unknown, message?: AssertionMessage, details?: AssertionDetails): void { | ||
if (expr) { | ||
throw createAssertionError(message, details); | ||
} | ||
} | ||
|
||
export function pass<T>(value: unknown, transform: (v: any) => T, validator: (v: any) => boolean, label?: string): T { | ||
assert(value, `${label || "Value"} should be defined`); | ||
|
||
const nextValue = transform(value); | ||
assert( | ||
validator(nextValue), | ||
`This ${label || "value"} "${nextValue}" should pass the validation stage: ${validator.toString()}`, | ||
); | ||
|
||
return nextValue; | ||
} | ||
|
||
export function toError(error: unknown, alt: Error | string = "Unexpected error"): Error { | ||
if (error instanceof Error) { | ||
return error; | ||
} | ||
|
||
if (typeof alt === "string") { | ||
return new Error(alt); | ||
} | ||
|
||
return alt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./Exception/index.js"; | ||
export * from "./assert"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
transform: {"src/.+\\.[jt]s?$": ["ts-jest", {}]}, | ||
moduleNameMapper: { | ||
"^([\\.]+\\/.+)\\/index\\.js": "$1", | ||
"^([\\.]+\\/.+)\\.js": "$1", | ||
}, | ||
rootDir: "src", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {assert} from "../../src"; | ||
|
||
test("assert", () => { | ||
expect(() => assert(false)).toThrow(); | ||
expect(() => assert(true)).not.toThrow(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../../tsconfig.test.json", | ||
"include": [ | ||
"src", | ||
"../src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"extends": "../../tsconfig.lib.json", | ||
"compilerOptions": { | ||
"module": "esnext", | ||
"moduleResolution": "nodenext", | ||
"rootDir": "src", | ||
"outDir": "dist/esm" | ||
}, | ||
"references": [ | ||
{ | ||
"path": "../type" | ||
}, | ||
{ | ||
"path": "../is" | ||
} | ||
], | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": "../../tsconfig.lib.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "dist/cjs" | ||
}, | ||
"references": [ | ||
{ | ||
"path": "../type" | ||
}, | ||
{ | ||
"path": "../is" | ||
} | ||
], | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.