@oliversalzburg/js-utils 0.0.17 → 0.0.19-dev.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/array.d.ts +39 -0
- package/{lib/array.js → array.js} +12 -13
- package/array.js.map +1 -0
- package/async.d.ts +28 -0
- package/{lib/async.js → async.js} +16 -10
- package/async.js.map +1 -0
- package/async.test.js +28 -0
- package/async.test.js.map +1 -0
- package/core.d.ts +36 -0
- package/core.js +3 -0
- package/core.js.map +1 -0
- package/{lib/dom → dom}/core.d.ts +8 -8
- package/{lib/dom → dom}/core.js +8 -8
- package/{lib/error-serializer.d.ts → error-serializer.d.ts} +5 -5
- package/{lib/error-serializer.js → error-serializer.js} +5 -5
- package/{lib/errors → errors}/AbstractError.d.ts +5 -5
- package/{lib/errors → errors}/AbstractError.js +5 -5
- package/{lib/errors → errors}/InternalError.d.ts +3 -3
- package/{lib/errors → errors}/InternalError.js +3 -3
- package/{lib/errors → errors}/InvalidArgumentError.d.ts +2 -2
- package/{lib/errors → errors}/InvalidArgumentError.js +2 -2
- package/{lib/errors → errors}/InvalidOperationError.d.ts +2 -2
- package/{lib/errors → errors}/InvalidOperationError.js +2 -2
- package/{lib/errors → errors}/NotImplementedError.d.ts +2 -2
- package/{lib/errors → errors}/NotImplementedError.js +2 -2
- package/{lib/errors → errors}/PermissionViolationError.d.ts +2 -2
- package/{lib/errors → errors}/PermissionViolationError.js +2 -2
- package/{lib/errors → errors}/ResourceConflictError.d.ts +2 -2
- package/{lib/errors → errors}/ResourceConflictError.js +2 -2
- package/{lib/errors → errors}/UnknownError.d.ts +2 -2
- package/{lib/errors → errors}/UnknownError.js +2 -2
- package/{lib/graphics → graphics}/canvas-sandbox.d.ts +13 -13
- package/{lib/graphics → graphics}/canvas-sandbox.js +9 -9
- package/{lib/graphics → graphics}/canvas.d.ts +30 -30
- package/{lib/graphics → graphics}/canvas.js +30 -30
- package/{lib/graphics → graphics}/core.d.ts +23 -23
- package/{lib/graphics → graphics}/core.js +23 -24
- package/{lib/graphics → graphics}/core.js.map +1 -1
- package/{lib/graphics → graphics}/render-loop.d.ts +3 -3
- package/{lib/graphics → graphics}/render-loop.js +3 -3
- package/{lib/math → math}/core.d.ts +19 -10
- package/{lib/math → math}/core.js +21 -10
- package/{lib/math → math}/core.js.map +1 -1
- package/{lib/math → math}/euler.d.ts +4 -4
- package/{lib/math → math}/euler.js +4 -4
- package/{lib/math → math}/matrix3.d.ts +34 -34
- package/{lib/math → math}/matrix3.js +34 -34
- package/{lib/math → math}/quaternion.d.ts +25 -25
- package/{lib/math → math}/quaternion.js +25 -25
- package/{lib/math → math}/transformation.d.ts +3 -3
- package/{lib/math → math}/transformation.js +3 -3
- package/{lib/math → math}/vector2.d.ts +40 -40
- package/{lib/math → math}/vector2.js +40 -40
- package/{lib/math → math}/vector3.d.ts +66 -66
- package/{lib/math → math}/vector3.js +66 -66
- package/{lib/math → math}/vector4.d.ts +38 -38
- package/{lib/math → math}/vector4.js +38 -38
- package/{lib/nil.d.ts → nil.d.ts} +15 -8
- package/{lib/nil.js → nil.js} +18 -8
- package/{lib/nil.js.map → nil.js.map} +1 -1
- package/package.json +21 -22
- package/{lib/random.d.ts → random.d.ts} +11 -17
- package/{lib/random.js → random.js} +11 -17
- package/random.js.map +1 -0
- package/{lib/sleep.d.ts → sleep.d.ts} +1 -1
- package/{lib/sleep.js → sleep.js} +1 -1
- package/{lib/string-formatter.d.ts → string-formatter.d.ts} +8 -4
- package/{lib/string-formatter.js → string-formatter.js} +8 -4
- package/string-formatter.js.map +1 -0
- package/string-formatter.test.d.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/LICENSES.md +0 -17
- package/_site/assets/highlight.css +0 -141
- package/_site/assets/main.js +0 -59
- package/_site/assets/navigation.js +0 -1
- package/_site/assets/search.js +0 -1
- package/_site/assets/style.css +0 -1383
- package/_site/classes/AbstractError.html +0 -67
- package/_site/classes/Canvas.html +0 -106
- package/_site/classes/CanvasSandbox.html +0 -91
- package/_site/classes/Euler.html +0 -217
- package/_site/classes/InternalError.html +0 -71
- package/_site/classes/InvalidArgumentError.html +0 -67
- package/_site/classes/InvalidOperationError.html +0 -67
- package/_site/classes/Matrix3.html +0 -167
- package/_site/classes/NotImplementedError.html +0 -66
- package/_site/classes/PermissionViolationError.html +0 -67
- package/_site/classes/Quaternion.html +0 -211
- package/_site/classes/Random.html +0 -90
- package/_site/classes/RenderLoop.html +0 -85
- package/_site/classes/ResourceConflictError.html +0 -66
- package/_site/classes/Transformation.html +0 -52
- package/_site/classes/UnexpectedNilError.html +0 -54
- package/_site/classes/UnknownError.html +0 -70
- package/_site/classes/Vector2.html +0 -159
- package/_site/classes/Vector3.html +0 -214
- package/_site/classes/Vector4.html +0 -156
- package/_site/functions/addVector2.html +0 -44
- package/_site/functions/addVector3.html +0 -44
- package/_site/functions/blend.html +0 -47
- package/_site/functions/blendAdditive.html +0 -47
- package/_site/functions/blendSubtractive.html +0 -47
- package/_site/functions/clamp.html +0 -45
- package/_site/functions/coalesceOnRejection.html +0 -51
- package/_site/functions/cosDeg.html +0 -43
- package/_site/functions/crossVector3.html +0 -44
- package/_site/functions/deg2rad.html +0 -43
- package/_site/functions/difference.html +0 -46
- package/_site/functions/distance.html +0 -46
- package/_site/functions/dotVector3.html +0 -44
- package/_site/functions/errorToJSON.html +0 -43
- package/_site/functions/errorToRecord.html +0 -43
- package/_site/functions/errorToSimpleSerializable.html +0 -43
- package/_site/functions/filterType.html +0 -46
- package/_site/functions/formatString.html +0 -46
- package/_site/functions/formatStringTemplate.html +0 -46
- package/_site/functions/fromRGB.html +0 -46
- package/_site/functions/fromRGBA.html +0 -46
- package/_site/functions/getA.html +0 -43
- package/_site/functions/getB.html +0 -43
- package/_site/functions/getDocumentElementTypeById.html +0 -46
- package/_site/functions/getDocumentElementTypeByIdStrict.html +0 -48
- package/_site/functions/getG.html +0 -43
- package/_site/functions/getR.html +0 -43
- package/_site/functions/intersect.html +0 -47
- package/_site/functions/is.html +0 -46
- package/_site/functions/isError.html +0 -43
- package/_site/functions/isInteger.html +0 -43
- package/_site/functions/isNil.html +0 -44
- package/_site/functions/isqrt.html +0 -43
- package/_site/functions/multiplyVector2.html +0 -44
- package/_site/functions/multiplyVector3.html +0 -44
- package/_site/functions/mustExist.html +0 -45
- package/_site/functions/nextPalette.html +0 -42
- package/_site/functions/prepareAsyncContext.html +0 -46
- package/_site/functions/putPixel32.html +0 -53
- package/_site/functions/putPixel32Add.html +0 -53
- package/_site/functions/putPixel32Sub.html +0 -53
- package/_site/functions/putSubPixel32.html +0 -47
- package/_site/functions/rad2deg.html +0 -43
- package/_site/functions/randomRange.html +0 -45
- package/_site/functions/safeRGBComponent.html +0 -43
- package/_site/functions/seedFromString.html +0 -44
- package/_site/functions/shuffleArray.html +0 -44
- package/_site/functions/sinDeg.html +0 -43
- package/_site/functions/sleep.html +0 -43
- package/_site/functions/somecolor.html +0 -43
- package/_site/functions/subtractVector2.html +0 -44
- package/_site/functions/subtractVector3.html +0 -44
- package/_site/functions/toGrayScale.html +0 -43
- package/_site/functions/unknownToError.html +0 -45
- package/_site/index.html +0 -44
- package/_site/interfaces/CanvasOptions.html +0 -44
- package/_site/interfaces/CanvasSandboxApplication.html +0 -60
- package/_site/interfaces/CanvasSandboxExpectedOptions.html +0 -48
- package/_site/interfaces/CanvasSandboxOptions.html +0 -45
- package/_site/interfaces/RenderLoopOptions.html +0 -46
- package/_site/modules.html +0 -134
- package/_site/types/AnyAsyncFunction.html +0 -41
- package/_site/types/AnyConstructor.html +0 -41
- package/_site/types/AnyFunction.html +0 -41
- package/_site/types/ConstructorOf.html +0 -41
- package/_site/types/FunctionReturning.html +0 -41
- package/_site/types/Maybe.html +0 -41
- package/_site/types/Mixin.html +0 -42
- package/_site/types/Nil.html +0 -42
- package/_site/types/RenderLoopCallback.html +0 -41
- package/_site/types/SerializedError.html +0 -41
- package/_site/variables/CANVAS_SANDBOX_DEFAULT_CSS.html +0 -41
- package/_site/variables/MS_PER_FRAME_60FPS.html +0 -42
- package/_site/variables/PALETTES.html +0 -41
- package/_site/variables/TWO_PI.html +0 -41
- package/_site/variables/random-1.html +0 -41
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/bundle.js +0 -30
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -16
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/spa.css +0 -298
- package/coverage/string-formatter.ts.html +0 -187
- package/coverage/tmp/coverage-4186-1699218521999-0.json +0 -1
- package/coverage/tmp/coverage-4196-1699218521967-0.json +0 -1
- package/docs/assets/favicon.ico +0 -0
- package/lib/array.d.ts +0 -40
- package/lib/array.js.map +0 -1
- package/lib/async.d.ts +0 -27
- package/lib/async.js.map +0 -1
- package/lib/core.d.ts +0 -33
- package/lib/core.js +0 -12
- package/lib/core.js.map +0 -1
- package/lib/random.js.map +0 -1
- package/lib/string-formatter.js.map +0 -1
- package/mkdocs.yml +0 -52
- /package/{lib/error-serializer.test.d.ts → async.test.d.ts} +0 -0
- /package/{lib/dom → dom}/core.js.map +0 -0
- /package/{lib/dom → dom}/index.d.ts +0 -0
- /package/{lib/dom → dom}/index.js +0 -0
- /package/{lib/dom → dom}/index.js.map +0 -0
- /package/{lib/error-serializer.js.map → error-serializer.js.map} +0 -0
- /package/{lib/string-formatter.test.d.ts → error-serializer.test.d.ts} +0 -0
- /package/{lib/error-serializer.test.js → error-serializer.test.js} +0 -0
- /package/{lib/error-serializer.test.js.map → error-serializer.test.js.map} +0 -0
- /package/{lib/errors → errors}/AbstractError.js.map +0 -0
- /package/{lib/errors → errors}/InternalError.js.map +0 -0
- /package/{lib/errors → errors}/InvalidArgumentError.js.map +0 -0
- /package/{lib/errors → errors}/InvalidOperationError.js.map +0 -0
- /package/{lib/errors → errors}/NotImplementedError.js.map +0 -0
- /package/{lib/errors → errors}/PermissionViolationError.js.map +0 -0
- /package/{lib/errors → errors}/ResourceConflictError.js.map +0 -0
- /package/{lib/errors → errors}/UnknownError.js.map +0 -0
- /package/{lib/errors → errors}/index.d.ts +0 -0
- /package/{lib/errors → errors}/index.js +0 -0
- /package/{lib/errors → errors}/index.js.map +0 -0
- /package/{lib/graphics → graphics}/canvas-sandbox.js.map +0 -0
- /package/{lib/graphics → graphics}/canvas.js.map +0 -0
- /package/{lib/graphics → graphics}/index.d.ts +0 -0
- /package/{lib/graphics → graphics}/index.js +0 -0
- /package/{lib/graphics → graphics}/index.js.map +0 -0
- /package/{lib/graphics → graphics}/render-loop.js.map +0 -0
- /package/{lib/index.d.ts → index.d.ts} +0 -0
- /package/{lib/index.js → index.js} +0 -0
- /package/{lib/index.js.map → index.js.map} +0 -0
- /package/{lib/math → math}/euler.js.map +0 -0
- /package/{lib/math → math}/index.d.ts +0 -0
- /package/{lib/math → math}/index.js +0 -0
- /package/{lib/math → math}/index.js.map +0 -0
- /package/{lib/math → math}/matrix3.js.map +0 -0
- /package/{lib/math → math}/quaternion.js.map +0 -0
- /package/{lib/math → math}/transformation.js.map +0 -0
- /package/{lib/math → math}/vector2.js.map +0 -0
- /package/{lib/math → math}/vector3.js.map +0 -0
- /package/{lib/math → math}/vector4.js.map +0 -0
- /package/{lib/sleep.js.map → sleep.js.map} +0 -0
- /package/{lib/string-formatter.test.js → string-formatter.test.js} +0 -0
- /package/{lib/string-formatter.test.js.map → string-formatter.test.js.map} +0 -0
package/array.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ConstructorOf } from "./core.js";
|
|
2
|
+
/**
|
|
3
|
+
* Places the items in the array in random order.
|
|
4
|
+
* @param array - The array to shuffle.
|
|
5
|
+
* @typeParam TElements - The type of the elements in the array.
|
|
6
|
+
* @returns The passed array in random order.
|
|
7
|
+
* @group Array
|
|
8
|
+
*/
|
|
9
|
+
export declare const shuffleArray: <TElements>(array: TElements[]) => TElements[];
|
|
10
|
+
/**
|
|
11
|
+
* Returns an array that holds all items that appear in both
|
|
12
|
+
* passed arrays.
|
|
13
|
+
* @param a - The first array.
|
|
14
|
+
* @param b - The second array.
|
|
15
|
+
* @typeParam TElements - The type of the elements in the array.
|
|
16
|
+
* @returns A new array which holds the items that appear in
|
|
17
|
+
* both passed arrays.
|
|
18
|
+
* @group Array
|
|
19
|
+
*/
|
|
20
|
+
export declare const intersect: <TElements>(a: TElements[], b: TElements[]) => TElements[];
|
|
21
|
+
/**
|
|
22
|
+
* Returns an array that holds all items that only appear in `a`.
|
|
23
|
+
* @param a - The first array.
|
|
24
|
+
* @param b - The second array.
|
|
25
|
+
* @typeParam TElements - The type of the elements in the array.
|
|
26
|
+
* @returns A new array which holds the items that ony appear in `a`.
|
|
27
|
+
* @group Array
|
|
28
|
+
*/
|
|
29
|
+
export declare const difference: <TElements>(a: TElements[], b: TElements[]) => TElements[];
|
|
30
|
+
/**
|
|
31
|
+
* From an array with unknown contents, retrieve all the elements
|
|
32
|
+
* that are of a certain type and return them as a new array.
|
|
33
|
+
* @param array - The array to filter.
|
|
34
|
+
* @param InstanceType - The type to search for.
|
|
35
|
+
* @typeParam TElements - The type of the elements in the array.
|
|
36
|
+
* @returns A new array with the filtered items.
|
|
37
|
+
* @group Array
|
|
38
|
+
*/
|
|
39
|
+
export declare const filterType: <TElements>(array: Array<unknown>, InstanceType: ConstructorOf<TElements>) => TElements[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { is } from "./nil.js";
|
|
2
2
|
/**
|
|
3
3
|
* Places the items in the array in random order.
|
|
4
|
-
* @param array The array to shuffle.
|
|
5
|
-
* @
|
|
4
|
+
* @param array - The array to shuffle.
|
|
5
|
+
* @typeParam TElements - The type of the elements in the array.
|
|
6
6
|
* @returns The passed array in random order.
|
|
7
7
|
* @group Array
|
|
8
8
|
*/
|
|
@@ -18,9 +18,9 @@ export const shuffleArray = (array) => {
|
|
|
18
18
|
/**
|
|
19
19
|
* Returns an array that holds all items that appear in both
|
|
20
20
|
* passed arrays.
|
|
21
|
-
* @param a The first array.
|
|
22
|
-
* @param b The second array.
|
|
23
|
-
* @
|
|
21
|
+
* @param a - The first array.
|
|
22
|
+
* @param b - The second array.
|
|
23
|
+
* @typeParam TElements - The type of the elements in the array.
|
|
24
24
|
* @returns A new array which holds the items that appear in
|
|
25
25
|
* both passed arrays.
|
|
26
26
|
* @group Array
|
|
@@ -30,11 +30,10 @@ export const intersect = (a, b) => {
|
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Returns an array that holds all items that only appear in `a`.
|
|
33
|
-
* @param a The first array.
|
|
34
|
-
* @param b The second array.
|
|
35
|
-
* @
|
|
36
|
-
* @returns A new array which holds the items that ony appear
|
|
37
|
-
* in `a`.
|
|
33
|
+
* @param a - The first array.
|
|
34
|
+
* @param b - The second array.
|
|
35
|
+
* @typeParam TElements - The type of the elements in the array.
|
|
36
|
+
* @returns A new array which holds the items that ony appear in `a`.
|
|
38
37
|
* @group Array
|
|
39
38
|
*/
|
|
40
39
|
export const difference = (a, b) => {
|
|
@@ -43,9 +42,9 @@ export const difference = (a, b) => {
|
|
|
43
42
|
/**
|
|
44
43
|
* From an array with unknown contents, retrieve all the elements
|
|
45
44
|
* that are of a certain type and return them as a new array.
|
|
46
|
-
* @param array The array to filter.
|
|
47
|
-
* @param InstanceType The type to search for.
|
|
48
|
-
* @
|
|
45
|
+
* @param array - The array to filter.
|
|
46
|
+
* @param InstanceType - The type to search for.
|
|
47
|
+
* @typeParam TElements - The type of the elements in the array.
|
|
49
48
|
* @returns A new array with the filtered items.
|
|
50
49
|
* @group Array
|
|
51
50
|
*/
|
package/array.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../source/array.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAY,KAAuB,EAAE,EAAE;IACjE,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE;QACrD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5D,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;QAClC,KAAK,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;KAC3B;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAY,CAAmB,EAAE,CAAmB,EAAE,EAAE;IAC/E,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAY,CAAmB,EAAE,CAAmB,EAAE,EAAE;IAChF,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAAqB,EACrB,YAAsC,EACtC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAqB,CAAC"}
|
package/async.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AnyAsyncFunction, AnyFunctionReturning, ConstructorOf } from "./core.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps the given asynchronous function in a new function that will ignore any outcome of
|
|
4
|
+
* the context as it resolves.
|
|
5
|
+
*
|
|
6
|
+
* This can be useful when providing asynchonous event handler to `.addEventlistener()`,
|
|
7
|
+
* which only expects synchronous functions.
|
|
8
|
+
* @param context - The asynchronous function to exectute.
|
|
9
|
+
* @typeParam TArguments - The type of the arguments that your function expects.
|
|
10
|
+
* @returns A function returning nothing.
|
|
11
|
+
* @group Async
|
|
12
|
+
*/
|
|
13
|
+
export declare const prepareAsyncContext: <TArguments extends unknown[]>(context: AnyAsyncFunction) => (...args: TArguments) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Executes an asynchronous function and resolves with an alternative result
|
|
16
|
+
* in case the function failed.
|
|
17
|
+
* @param executable - The asynchronous function to execute.
|
|
18
|
+
* @param to - The result we want to return when the function errors.
|
|
19
|
+
* @param filter - An {@linkcode !Error} subclass. If defined, only errors of
|
|
20
|
+
* this type will be coalesced.
|
|
21
|
+
* @typeParam TExecutableReturn - The return type of the function.
|
|
22
|
+
* @typeParam TCoalesce - The type of the object to coalesce to.
|
|
23
|
+
* @typeParam TFilter - The type of the error filter.
|
|
24
|
+
* @returns Whatever the function resolved to, or the provided replacement,
|
|
25
|
+
* in case the function failed.
|
|
26
|
+
* @group Async
|
|
27
|
+
*/
|
|
28
|
+
export declare const coalesceOnRejection: <TExecutableReturn, TCoalesce, TFilter extends ConstructorOf<Error>>(executable: AnyFunctionReturning<TExecutableReturn | Promise<TExecutableReturn>>, to: TCoalesce, filter?: TFilter | undefined) => Promise<TExecutableReturn | TCoalesce>;
|
|
@@ -4,27 +4,33 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This can be useful when providing asynchonous event handler to `.addEventlistener()`,
|
|
6
6
|
* which only expects synchronous functions.
|
|
7
|
-
* @param context The asynchronous function to exectute.
|
|
7
|
+
* @param context - The asynchronous function to exectute.
|
|
8
|
+
* @typeParam TArguments - The type of the arguments that your function expects.
|
|
8
9
|
* @returns A function returning nothing.
|
|
9
10
|
* @group Async
|
|
10
11
|
*/
|
|
11
12
|
export const prepareAsyncContext = (context) => {
|
|
12
|
-
return (
|
|
13
|
-
|
|
13
|
+
return (
|
|
14
|
+
/**
|
|
15
|
+
* The arguments that our new function was called with.
|
|
16
|
+
*/
|
|
17
|
+
...args) => {
|
|
18
|
+
void context(...args)
|
|
14
19
|
.then(() => undefined)
|
|
15
|
-
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
.catch(console.error);
|
|
16
22
|
};
|
|
17
23
|
};
|
|
18
24
|
/**
|
|
19
25
|
* Executes an asynchronous function and resolves with an alternative result
|
|
20
26
|
* in case the function failed.
|
|
21
|
-
* @param executable The asynchronous function to execute.
|
|
22
|
-
* @param to The result we want to return when the function errors.
|
|
23
|
-
* @param filter An {@linkcode !Error} subclass. If defined, only errors of
|
|
27
|
+
* @param executable - The asynchronous function to execute.
|
|
28
|
+
* @param to - The result we want to return when the function errors.
|
|
29
|
+
* @param filter - An {@linkcode !Error} subclass. If defined, only errors of
|
|
24
30
|
* this type will be coalesced.
|
|
25
|
-
* @
|
|
26
|
-
* @
|
|
27
|
-
* @
|
|
31
|
+
* @typeParam TExecutableReturn - The return type of the function.
|
|
32
|
+
* @typeParam TCoalesce - The type of the object to coalesce to.
|
|
33
|
+
* @typeParam TFilter - The type of the error filter.
|
|
28
34
|
* @returns Whatever the function resolved to, or the provided replacement,
|
|
29
35
|
* in case the function failed.
|
|
30
36
|
* @group Async
|
package/async.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.js","sourceRoot":"","sources":["../source/async.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,OAAyB,EACzB,EAAE;IACF,OAAO;IACL;;OAEG;IACH,GAAG,IAAgB,EACnB,EAAE;QACF,KAAK,OAAO,CAAC,GAAG,IAAI,CAAC;aAClB,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;YACtB,sCAAsC;aACrC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAKtC,UAAgF,EAChF,EAAa,EACb,MAAgB,EAChB,EAAE;IACF,IAAI;QACF,OAAO,MAAM,UAAU,EAAE,CAAC;KAC3B;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,YAAY,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE;YAChE,OAAO,EAAE,CAAC;SACX;QACD,MAAM,KAAK,CAAC;KACb;AACH,CAAC,CAAC"}
|
package/async.test.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* eslint-disable no-unused-expressions */
|
|
2
|
+
import { expect } from "chai";
|
|
3
|
+
import { it } from "mocha";
|
|
4
|
+
import { prepareAsyncContext } from "./async.js";
|
|
5
|
+
import { sleep } from "./sleep.js";
|
|
6
|
+
it("executes trivial callback", async () => {
|
|
7
|
+
let executed = false;
|
|
8
|
+
const callback = prepareAsyncContext(async () => {
|
|
9
|
+
await sleep(1);
|
|
10
|
+
executed = true;
|
|
11
|
+
});
|
|
12
|
+
callback();
|
|
13
|
+
await sleep(100);
|
|
14
|
+
expect(executed).to.be.true;
|
|
15
|
+
});
|
|
16
|
+
it("passes parameters to callback", async () => {
|
|
17
|
+
let executed = false;
|
|
18
|
+
const callback = prepareAsyncContext(async (event, eventId) => {
|
|
19
|
+
expect(event.name).to.equal("call");
|
|
20
|
+
expect(eventId).to.equal(42);
|
|
21
|
+
await sleep(1);
|
|
22
|
+
executed = true;
|
|
23
|
+
});
|
|
24
|
+
callback({ name: "call" }, 42);
|
|
25
|
+
await sleep(100);
|
|
26
|
+
expect(executed).to.be.true;
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=async.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.test.js","sourceRoot":"","sources":["../source/async.test.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;IACzC,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,MAAM,QAAQ,GAAG,mBAAmB,CAAC,KAAK,IAAI,EAAE;QAC9C,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;QACf,QAAQ,GAAG,IAAI,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,QAAQ,EAAE,CAAC;IAEX,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjB,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;IAC7C,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,MAAM,QAAQ,GAAG,mBAAmB,CAAC,KAAK,EAAE,KAA6B,EAAE,OAAe,EAAE,EAAE;QAC5F,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACpC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAE7B,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;QACf,QAAQ,GAAG,IAAI,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAE/B,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjB,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;AAC9B,CAAC,CAAC,CAAC"}
|
package/core.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes a function that is a constructor for something.
|
|
3
|
+
* @typeParam TConstructed - The type this is a constructor for.
|
|
4
|
+
*/
|
|
5
|
+
export type ConstructorOf<TConstructed> = new (...args: Array<any>) => TConstructed;
|
|
6
|
+
/**
|
|
7
|
+
* Describes any function.
|
|
8
|
+
*/
|
|
9
|
+
export type AnyFunction = (...args: Array<any>) => any;
|
|
10
|
+
/**
|
|
11
|
+
* Describes any asynchronous function.
|
|
12
|
+
*/
|
|
13
|
+
export type AnyAsyncFunction = (...args: Array<any>) => Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Any constructor
|
|
16
|
+
*/
|
|
17
|
+
export type AnyConstructor = new (...args: Array<any>) => any;
|
|
18
|
+
/**
|
|
19
|
+
* Describes a function returning an instance of a given type.
|
|
20
|
+
* @typeParam TReturned - The type of the item returned by the function.
|
|
21
|
+
*/
|
|
22
|
+
export type AnyFunctionReturning<TReturned = any> = (...args: Array<any>) => TReturned;
|
|
23
|
+
/**
|
|
24
|
+
* Describes an async function returning an instance of a given type.
|
|
25
|
+
* @typeParam TReturned - The type of the item returned by the function.
|
|
26
|
+
*/
|
|
27
|
+
export type AnyAsyncFunctionReturning<TReturned = any> = (...args: Array<any>) => TReturned;
|
|
28
|
+
/**
|
|
29
|
+
* Describes a class "mixin", which is a function that returns a dynamically
|
|
30
|
+
* constructed class, based on the passed parameters.
|
|
31
|
+
*
|
|
32
|
+
* **Hint**: Don't use mixins.
|
|
33
|
+
* @typeParam TTarget - The type of the classed this mixin is being
|
|
34
|
+
* mixed in with.
|
|
35
|
+
*/
|
|
36
|
+
export type Mixin<TTarget extends AnyFunctionReturning> = InstanceType<ReturnType<TTarget>>;
|
package/core.js
ADDED
package/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../source/core.ts"],"names":[],"mappings":"AAAA,uDAAuD"}
|
|
@@ -3,21 +3,21 @@ import { ConstructorOf } from "../core.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves an element from the document and returns it if it is
|
|
5
5
|
* non-null and has the expected type. Otherwise an error is thrown.
|
|
6
|
-
* @param document The document from which to look up the element.
|
|
7
|
-
* @param id The ID of the element.
|
|
8
|
-
* @param Type The type you expect the element to have.
|
|
6
|
+
* @param document - The document from which to look up the element.
|
|
7
|
+
* @param id - The ID of the element.
|
|
8
|
+
* @param Type - The type you expect the element to have.
|
|
9
9
|
* @returns The requested element, if it has the expected type.
|
|
10
|
-
* @throws {InvalidOperationError} When the document element has an unexpected type.
|
|
11
|
-
* @throws {UnexpectedNilError} When the the document element is `null`.
|
|
10
|
+
* @throws {@linkcode InvalidOperationError} When the document element has an unexpected type.
|
|
11
|
+
* @throws {@linkcode UnexpectedNilError} When the the document element is `null`.
|
|
12
12
|
* @group DOM
|
|
13
13
|
*/
|
|
14
14
|
export declare const getDocumentElementTypeByIdStrict: <T extends HTMLElement>(document: Document, id: string, Type: ConstructorOf<T>) => T;
|
|
15
15
|
/**
|
|
16
16
|
* Retrieves an element from the document and returns it if it has the
|
|
17
17
|
* expected type.
|
|
18
|
-
* @param document The document from which to look up the element.
|
|
19
|
-
* @param id The ID of the element.
|
|
20
|
-
* @param Type The type you expect the element to have.
|
|
18
|
+
* @param document - The document from which to look up the element.
|
|
19
|
+
* @param id - The ID of the element.
|
|
20
|
+
* @param Type - The type you expect the element to have.
|
|
21
21
|
* @returns The requested element, if it has the expected type; `null` otherwise.
|
|
22
22
|
* @group DOM
|
|
23
23
|
*/
|
package/{lib/dom → dom}/core.js
RENAMED
|
@@ -3,12 +3,12 @@ import { UnexpectedNilError } from "../nil.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves an element from the document and returns it if it is
|
|
5
5
|
* non-null and has the expected type. Otherwise an error is thrown.
|
|
6
|
-
* @param document The document from which to look up the element.
|
|
7
|
-
* @param id The ID of the element.
|
|
8
|
-
* @param Type The type you expect the element to have.
|
|
6
|
+
* @param document - The document from which to look up the element.
|
|
7
|
+
* @param id - The ID of the element.
|
|
8
|
+
* @param Type - The type you expect the element to have.
|
|
9
9
|
* @returns The requested element, if it has the expected type.
|
|
10
|
-
* @throws {InvalidOperationError} When the document element has an unexpected type.
|
|
11
|
-
* @throws {UnexpectedNilError} When the the document element is `null`.
|
|
10
|
+
* @throws {@linkcode InvalidOperationError} When the document element has an unexpected type.
|
|
11
|
+
* @throws {@linkcode UnexpectedNilError} When the the document element is `null`.
|
|
12
12
|
* @group DOM
|
|
13
13
|
*/
|
|
14
14
|
export const getDocumentElementTypeByIdStrict = (document, id, Type) => {
|
|
@@ -24,9 +24,9 @@ export const getDocumentElementTypeByIdStrict = (document, id, Type) => {
|
|
|
24
24
|
/**
|
|
25
25
|
* Retrieves an element from the document and returns it if it has the
|
|
26
26
|
* expected type.
|
|
27
|
-
* @param document The document from which to look up the element.
|
|
28
|
-
* @param id The ID of the element.
|
|
29
|
-
* @param Type The type you expect the element to have.
|
|
27
|
+
* @param document - The document from which to look up the element.
|
|
28
|
+
* @param id - The ID of the element.
|
|
29
|
+
* @param Type - The type you expect the element to have.
|
|
30
30
|
* @returns The requested element, if it has the expected type; `null` otherwise.
|
|
31
31
|
* @group DOM
|
|
32
32
|
*/
|
|
@@ -6,7 +6,7 @@ import { AbstractError } from "./errors/AbstractError.js";
|
|
|
6
6
|
export type SerializedError = Record<string, Record<string, string> | string | undefined>;
|
|
7
7
|
/**
|
|
8
8
|
* Determine if the given unknown subject is an {@linkcode !Error} instance.
|
|
9
|
-
* @param subject The object to inspect.
|
|
9
|
+
* @param subject - The object to inspect.
|
|
10
10
|
* @returns `true` if the subject is an {@linkcode !Error}, `false` otherwise.
|
|
11
11
|
* @group Errors
|
|
12
12
|
*/
|
|
@@ -15,28 +15,28 @@ export declare const isError: (subject: unknown) => subject is Error;
|
|
|
15
15
|
* Returns an {@linkcode AbstractError} that best represents the passed subject.
|
|
16
16
|
* If the passed subject is already an {@linkcode AbstractError}, it is returned as-is.
|
|
17
17
|
* Otherwise, it will be converted into an appropriate error type.
|
|
18
|
-
* @param subject The subject to inspect
|
|
18
|
+
* @param subject - The subject to inspect
|
|
19
19
|
* @returns An {@linkcode AbstractError} instance.
|
|
20
20
|
* @group Errors
|
|
21
21
|
*/
|
|
22
22
|
export declare const unknownToError: (subject: unknown) => AbstractError;
|
|
23
23
|
/**
|
|
24
24
|
* Serializes an error into a JSON string.
|
|
25
|
-
* @param error The error to stringify.
|
|
25
|
+
* @param error - The error to stringify.
|
|
26
26
|
* @returns A JSON string representing the error.
|
|
27
27
|
* @group Errors
|
|
28
28
|
*/
|
|
29
29
|
export declare const errorToJSON: (error: Error) => string;
|
|
30
30
|
/**
|
|
31
31
|
* Converts an error into a regular hash.
|
|
32
|
-
* @param error The error to convert.
|
|
32
|
+
* @param error - The error to convert.
|
|
33
33
|
* @returns A new object that contains all the properties of the error.
|
|
34
34
|
* @group Errors
|
|
35
35
|
*/
|
|
36
36
|
export declare const errorToRecord: (error: Error) => Record<string, unknown>;
|
|
37
37
|
/**
|
|
38
38
|
* Serializes an error into a simpler shape.
|
|
39
|
-
* @param error The error to serialize.
|
|
39
|
+
* @param error - The error to serialize.
|
|
40
40
|
* @returns A simple representation of the error.
|
|
41
41
|
* @group Errors
|
|
42
42
|
*/
|
|
@@ -3,7 +3,7 @@ import { InternalError } from "./errors/InternalError.js";
|
|
|
3
3
|
import { UnknownError } from "./errors/UnknownError.js";
|
|
4
4
|
/**
|
|
5
5
|
* Determine if the given unknown subject is an {@linkcode !Error} instance.
|
|
6
|
-
* @param subject The object to inspect.
|
|
6
|
+
* @param subject - The object to inspect.
|
|
7
7
|
* @returns `true` if the subject is an {@linkcode !Error}, `false` otherwise.
|
|
8
8
|
* @group Errors
|
|
9
9
|
*/
|
|
@@ -14,7 +14,7 @@ export const isError = (subject) => {
|
|
|
14
14
|
* Returns an {@linkcode AbstractError} that best represents the passed subject.
|
|
15
15
|
* If the passed subject is already an {@linkcode AbstractError}, it is returned as-is.
|
|
16
16
|
* Otherwise, it will be converted into an appropriate error type.
|
|
17
|
-
* @param subject The subject to inspect
|
|
17
|
+
* @param subject - The subject to inspect
|
|
18
18
|
* @returns An {@linkcode AbstractError} instance.
|
|
19
19
|
* @group Errors
|
|
20
20
|
*/
|
|
@@ -29,7 +29,7 @@ export const unknownToError = (subject) => {
|
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* Serializes an error into a JSON string.
|
|
32
|
-
* @param error The error to stringify.
|
|
32
|
+
* @param error - The error to stringify.
|
|
33
33
|
* @returns A JSON string representing the error.
|
|
34
34
|
* @group Errors
|
|
35
35
|
*/
|
|
@@ -38,7 +38,7 @@ export const errorToJSON = (error) => {
|
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
40
|
* Converts an error into a regular hash.
|
|
41
|
-
* @param error The error to convert.
|
|
41
|
+
* @param error - The error to convert.
|
|
42
42
|
* @returns A new object that contains all the properties of the error.
|
|
43
43
|
* @group Errors
|
|
44
44
|
*/
|
|
@@ -51,7 +51,7 @@ export const errorToRecord = (error) => {
|
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
53
|
* Serializes an error into a simpler shape.
|
|
54
|
-
* @param error The error to serialize.
|
|
54
|
+
* @param error - The error to serialize.
|
|
55
55
|
* @returns A simple representation of the error.
|
|
56
56
|
* @group Errors
|
|
57
57
|
*/
|
|
@@ -13,15 +13,15 @@ export declare class AbstractError extends Error {
|
|
|
13
13
|
code: string;
|
|
14
14
|
/**
|
|
15
15
|
* Constructs a new {@linkcode AbstractError}.
|
|
16
|
-
* @param code The main identification code for the error.
|
|
17
|
-
* @param message The main error message.
|
|
18
|
-
* @param status The HTTP status code to return.
|
|
16
|
+
* @param code - The main identification code for the error.
|
|
17
|
+
* @param message - The main error message.
|
|
18
|
+
* @param status - The HTTP status code to return.
|
|
19
19
|
*/
|
|
20
20
|
constructor(code: string, message: string, status: number);
|
|
21
21
|
/**
|
|
22
22
|
* Checks if an object is an instance of {@linkcode AbstractError}, or one of its subclasses.
|
|
23
|
-
* @param error The object to check.
|
|
24
|
-
* @param allowForeignModule Only check for similar looking error codes.
|
|
23
|
+
* @param error - The object to check.
|
|
24
|
+
* @param allowForeignModule - Only check for similar looking error codes.
|
|
25
25
|
* You're going to want to use this if you're dealing with a setup where
|
|
26
26
|
* multiple versions of js-utils are loaded.
|
|
27
27
|
* @returns `true` if the object is an {@linkcode AbstractError}, `false` otherwise.
|
|
@@ -13,9 +13,9 @@ export class AbstractError extends Error {
|
|
|
13
13
|
code;
|
|
14
14
|
/**
|
|
15
15
|
* Constructs a new {@linkcode AbstractError}.
|
|
16
|
-
* @param code The main identification code for the error.
|
|
17
|
-
* @param message The main error message.
|
|
18
|
-
* @param status The HTTP status code to return.
|
|
16
|
+
* @param code - The main identification code for the error.
|
|
17
|
+
* @param message - The main error message.
|
|
18
|
+
* @param status - The HTTP status code to return.
|
|
19
19
|
*/
|
|
20
20
|
constructor(code, message, status) {
|
|
21
21
|
super(message);
|
|
@@ -30,8 +30,8 @@ export class AbstractError extends Error {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Checks if an object is an instance of {@linkcode AbstractError}, or one of its subclasses.
|
|
33
|
-
* @param error The object to check.
|
|
34
|
-
* @param allowForeignModule Only check for similar looking error codes.
|
|
33
|
+
* @param error - The object to check.
|
|
34
|
+
* @param allowForeignModule - Only check for similar looking error codes.
|
|
35
35
|
* You're going to want to use this if you're dealing with a setup where
|
|
36
36
|
* multiple versions of js-utils are loaded.
|
|
37
37
|
* @returns `true` if the object is an {@linkcode AbstractError}, `false` otherwise.
|
|
@@ -7,13 +7,13 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
7
7
|
export declare class InternalError extends AbstractError {
|
|
8
8
|
/**
|
|
9
9
|
* Constructs a new {@linkcode InternalError}.
|
|
10
|
-
* @param message The main error message.
|
|
11
|
-
* @param status The HTTP status code to return.
|
|
10
|
+
* @param message - The main error message.
|
|
11
|
+
* @param status - The HTTP status code to return.
|
|
12
12
|
*/
|
|
13
13
|
constructor(message: string, status?: number);
|
|
14
14
|
/**
|
|
15
15
|
* Converts an error into an {@linkcode InternalError}.
|
|
16
|
-
* @param error The error to convert.
|
|
16
|
+
* @param error - The error to convert.
|
|
17
17
|
* @returns An {@linkcode InternalError} that represents the given error.
|
|
18
18
|
*/
|
|
19
19
|
static fromError(error: Error): InternalError;
|
|
@@ -7,8 +7,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
7
7
|
export class InternalError extends AbstractError {
|
|
8
8
|
/**
|
|
9
9
|
* Constructs a new {@linkcode InternalError}.
|
|
10
|
-
* @param message The main error message.
|
|
11
|
-
* @param status The HTTP status code to return.
|
|
10
|
+
* @param message - The main error message.
|
|
11
|
+
* @param status - The HTTP status code to return.
|
|
12
12
|
*/
|
|
13
13
|
constructor(message, status = 500) {
|
|
14
14
|
super("ERR_OS_INTERNAL", message, status);
|
|
@@ -21,7 +21,7 @@ export class InternalError extends AbstractError {
|
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Converts an error into an {@linkcode InternalError}.
|
|
24
|
-
* @param error The error to convert.
|
|
24
|
+
* @param error - The error to convert.
|
|
25
25
|
* @returns An {@linkcode InternalError} that represents the given error.
|
|
26
26
|
*/
|
|
27
27
|
static fromError(error) {
|
|
@@ -7,8 +7,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
7
7
|
export declare class InvalidArgumentError extends AbstractError {
|
|
8
8
|
/**
|
|
9
9
|
* Constructs a new {@linkcode InvalidArgumentError}.
|
|
10
|
-
* @param message The main error message.
|
|
11
|
-
* @param status The HTTP status code to return.
|
|
10
|
+
* @param message - The main error message.
|
|
11
|
+
* @param status - The HTTP status code to return.
|
|
12
12
|
*/
|
|
13
13
|
constructor(message: string, status?: number);
|
|
14
14
|
}
|
|
@@ -7,8 +7,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
7
7
|
export class InvalidArgumentError extends AbstractError {
|
|
8
8
|
/**
|
|
9
9
|
* Constructs a new {@linkcode InvalidArgumentError}.
|
|
10
|
-
* @param message The main error message.
|
|
11
|
-
* @param status The HTTP status code to return.
|
|
10
|
+
* @param message - The main error message.
|
|
11
|
+
* @param status - The HTTP status code to return.
|
|
12
12
|
*/
|
|
13
13
|
constructor(message, status = 400) {
|
|
14
14
|
super("ERR_OS_INVALID_ARGUMENT", message, status);
|
|
@@ -7,8 +7,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
7
7
|
export declare class InvalidOperationError extends AbstractError {
|
|
8
8
|
/**
|
|
9
9
|
* Constructs a new {@linkcode InvalidOperationError}.
|
|
10
|
-
* @param message The main error message.
|
|
11
|
-
* @param status The HTTP status code to return.
|
|
10
|
+
* @param message - The main error message.
|
|
11
|
+
* @param status - The HTTP status code to return.
|
|
12
12
|
*/
|
|
13
13
|
constructor(message: string, status?: number);
|
|
14
14
|
}
|
|
@@ -7,8 +7,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
7
7
|
export class InvalidOperationError extends AbstractError {
|
|
8
8
|
/**
|
|
9
9
|
* Constructs a new {@linkcode InvalidOperationError}.
|
|
10
|
-
* @param message The main error message.
|
|
11
|
-
* @param status The HTTP status code to return.
|
|
10
|
+
* @param message - The main error message.
|
|
11
|
+
* @param status - The HTTP status code to return.
|
|
12
12
|
*/
|
|
13
13
|
constructor(message, status = 400) {
|
|
14
14
|
super("ERR_OS_INVALID_OPERATION", message, status);
|
|
@@ -6,8 +6,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
6
6
|
export declare class NotImplementedError extends AbstractError {
|
|
7
7
|
/**
|
|
8
8
|
* Constructs a new {@linkcode NotImplementedError}.
|
|
9
|
-
* @param message The main error message.
|
|
10
|
-
* @param status The HTTP status code to return.
|
|
9
|
+
* @param message - The main error message.
|
|
10
|
+
* @param status - The HTTP status code to return.
|
|
11
11
|
*/
|
|
12
12
|
constructor(message: string, status?: number);
|
|
13
13
|
}
|
|
@@ -6,8 +6,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
6
6
|
export class NotImplementedError extends AbstractError {
|
|
7
7
|
/**
|
|
8
8
|
* Constructs a new {@linkcode NotImplementedError}.
|
|
9
|
-
* @param message The main error message.
|
|
10
|
-
* @param status The HTTP status code to return.
|
|
9
|
+
* @param message - The main error message.
|
|
10
|
+
* @param status - The HTTP status code to return.
|
|
11
11
|
*/
|
|
12
12
|
constructor(message, status = 501) {
|
|
13
13
|
super("ERR_OS_NOT_IMPLEMENTED", message, status);
|
|
@@ -7,8 +7,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
7
7
|
export declare class PermissionViolationError extends AbstractError {
|
|
8
8
|
/**
|
|
9
9
|
* Constructs a new {@linkcode PermissionViolationError}.
|
|
10
|
-
* @param message The main error message.
|
|
11
|
-
* @param status The HTTP status code to return.
|
|
10
|
+
* @param message - The main error message.
|
|
11
|
+
* @param status - The HTTP status code to return.
|
|
12
12
|
*/
|
|
13
13
|
constructor(message: string, status?: number);
|
|
14
14
|
}
|
|
@@ -7,8 +7,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
7
7
|
export class PermissionViolationError extends AbstractError {
|
|
8
8
|
/**
|
|
9
9
|
* Constructs a new {@linkcode PermissionViolationError}.
|
|
10
|
-
* @param message The main error message.
|
|
11
|
-
* @param status The HTTP status code to return.
|
|
10
|
+
* @param message - The main error message.
|
|
11
|
+
* @param status - The HTTP status code to return.
|
|
12
12
|
*/
|
|
13
13
|
constructor(message, status = 403) {
|
|
14
14
|
super("ERR_OS_PERMISSION_VIOLATION", message, status);
|
|
@@ -6,8 +6,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
6
6
|
export declare class ResourceConflictError extends AbstractError {
|
|
7
7
|
/**
|
|
8
8
|
* Constructs a new {@linkcode ResourceConflictError}.
|
|
9
|
-
* @param message The main error message.
|
|
10
|
-
* @param status The HTTP status code to return.
|
|
9
|
+
* @param message - The main error message.
|
|
10
|
+
* @param status - The HTTP status code to return.
|
|
11
11
|
*/
|
|
12
12
|
constructor(message: string, status?: number);
|
|
13
13
|
}
|
|
@@ -6,8 +6,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
6
6
|
export class ResourceConflictError extends AbstractError {
|
|
7
7
|
/**
|
|
8
8
|
* Constructs a new {@linkcode ResourceConflictError}.
|
|
9
|
-
* @param message The main error message.
|
|
10
|
-
* @param status The HTTP status code to return.
|
|
9
|
+
* @param message - The main error message.
|
|
10
|
+
* @param status - The HTTP status code to return.
|
|
11
11
|
*/
|
|
12
12
|
constructor(message, status = 409) {
|
|
13
13
|
super("ERR_OS_RESOURCE_CONFLICT", message, status);
|
|
@@ -10,8 +10,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
10
10
|
export declare class UnknownError extends AbstractError {
|
|
11
11
|
/**
|
|
12
12
|
* Constructs a new {@linkcode UnknownError}.
|
|
13
|
-
* @param message The main error message.
|
|
14
|
-
* @param status The HTTP status code to return.
|
|
13
|
+
* @param message - The main error message.
|
|
14
|
+
* @param status - The HTTP status code to return.
|
|
15
15
|
*/
|
|
16
16
|
constructor(message: string, status?: number);
|
|
17
17
|
}
|
|
@@ -10,8 +10,8 @@ import { AbstractError } from "./AbstractError.js";
|
|
|
10
10
|
export class UnknownError extends AbstractError {
|
|
11
11
|
/**
|
|
12
12
|
* Constructs a new {@linkcode UnknownError}.
|
|
13
|
-
* @param message The main error message.
|
|
14
|
-
* @param status The HTTP status code to return.
|
|
13
|
+
* @param message - The main error message.
|
|
14
|
+
* @param status - The HTTP status code to return.
|
|
15
15
|
*/
|
|
16
16
|
constructor(message, status = 500) {
|
|
17
17
|
super("ERR_OS_UNKNOWN", message, status);
|