@oliversalzburg/js-utils 0.0.7 → 0.0.9
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/LICENSES.md +17 -0
- package/_site/assets/highlight.css +57 -0
- package/_site/assets/main.js +59 -0
- package/_site/assets/navigation.js +1 -0
- package/_site/assets/search.js +1 -0
- package/_site/assets/style.css +1383 -0
- package/_site/classes/AbstractError.html +28 -0
- package/_site/classes/Canvas.html +44 -0
- package/_site/classes/InternalError.html +32 -0
- package/_site/classes/InvalidArgumentError.html +28 -0
- package/_site/classes/InvalidOperationError.html +28 -0
- package/_site/classes/NotImplementedError.html +27 -0
- package/_site/classes/PermissionViolationError.html +28 -0
- package/_site/classes/Random.html +43 -0
- package/_site/classes/RenderLoop.html +30 -0
- package/_site/classes/ResourceConflictError.html +27 -0
- package/_site/classes/UnexpectedNilError.html +15 -0
- package/_site/classes/UnknownError.html +31 -0
- package/_site/classes/Vector2.html +113 -0
- package/_site/classes/Vector3.html +28 -0
- package/_site/functions/addVector2.html +5 -0
- package/_site/functions/blend.html +8 -0
- package/_site/functions/blendAdditive.html +8 -0
- package/_site/functions/blendSubtractive.html +8 -0
- package/_site/functions/cosDeg.html +4 -0
- package/_site/functions/deg2rad.html +4 -0
- package/_site/functions/difference.html +7 -0
- package/_site/functions/distance.html +7 -0
- package/_site/functions/errorToJSON.html +4 -0
- package/_site/functions/errorToRecord.html +4 -0
- package/_site/functions/errorToSimpleSerializable.html +4 -0
- package/_site/functions/filterType.html +7 -0
- package/_site/functions/formatString.html +7 -0
- package/_site/functions/formatStringTemplate.html +7 -0
- package/_site/functions/fromRGB.html +7 -0
- package/_site/functions/fromRGBA.html +7 -0
- package/_site/functions/getA.html +4 -0
- package/_site/functions/getB.html +4 -0
- package/_site/functions/getDocumentElementTypeById.html +9 -0
- package/_site/functions/getG.html +4 -0
- package/_site/functions/getR.html +4 -0
- package/_site/functions/intersect.html +8 -0
- package/_site/functions/is.html +7 -0
- package/_site/functions/isError.html +4 -0
- package/_site/functions/isInteger.html +4 -0
- package/_site/functions/isNil.html +5 -0
- package/_site/functions/isqrt.html +4 -0
- package/_site/functions/multiplyVector2.html +5 -0
- package/_site/functions/mustExist.html +6 -0
- package/_site/functions/nextPalette.html +2 -0
- package/_site/functions/putPixel32.html +7 -0
- package/_site/functions/putPixel32Add.html +7 -0
- package/_site/functions/putPixel32Sub.html +7 -0
- package/_site/functions/putSubPixel32.html +8 -0
- package/_site/functions/rad2deg.html +4 -0
- package/_site/functions/randomRange.html +6 -0
- package/_site/functions/safeRGBComponent.html +4 -0
- package/_site/functions/seedFromString.html +5 -0
- package/_site/functions/shuffleArray.html +5 -0
- package/_site/functions/sinDeg.html +4 -0
- package/_site/functions/sleep.html +4 -0
- package/_site/functions/somecolor.html +4 -0
- package/_site/functions/subtractVector2.html +5 -0
- package/_site/functions/toGrayScale.html +4 -0
- package/_site/functions/unknownToError.html +6 -0
- package/_site/index.html +1 -0
- package/_site/modules.html +72 -0
- package/_site/types/AnyConstructor.html +2 -0
- package/_site/types/AnyFunction.html +2 -0
- package/_site/types/ConstructorOf.html +2 -0
- package/_site/types/FunctionReturning.html +2 -0
- package/_site/types/Maybe.html +2 -0
- package/_site/types/Mixin.html +3 -0
- package/_site/types/Nil.html +3 -0
- package/_site/types/RenderLoopCallback.html +2 -0
- package/_site/types/SerializedError.html +2 -0
- package/_site/variables/PALETTES.html +2 -0
- package/_site/variables/TWO_PI.html +2 -0
- package/_site/variables/random-1.html +2 -0
- package/lib/array.d.ts +8 -0
- package/lib/array.js +8 -0
- package/lib/array.js.map +1 -1
- package/lib/dom/core.d.ts +13 -0
- package/lib/dom/core.js +24 -0
- package/lib/dom/core.js.map +1 -0
- package/lib/dom/index.d.ts +1 -0
- package/lib/dom/index.js +2 -0
- package/lib/dom/index.js.map +1 -0
- package/lib/error-serializer.d.ts +12 -6
- package/lib/error-serializer.js +11 -7
- package/lib/error-serializer.js.map +1 -1
- package/lib/error-serializer.test.d.ts +1 -0
- package/lib/error-serializer.test.js +117 -0
- package/lib/error-serializer.test.js.map +1 -0
- package/lib/errors/AbstractError.d.ts +4 -16
- package/lib/errors/AbstractError.js +4 -16
- package/lib/errors/AbstractError.js.map +1 -1
- package/lib/errors/InternalError.d.ts +6 -5
- package/lib/errors/InternalError.js +6 -7
- package/lib/errors/InternalError.js.map +1 -1
- package/lib/errors/InvalidArgumentError.d.ts +2 -1
- package/lib/errors/InvalidArgumentError.js +2 -1
- package/lib/errors/InvalidArgumentError.js.map +1 -1
- package/lib/errors/InvalidOperationError.d.ts +2 -1
- package/lib/errors/InvalidOperationError.js +2 -1
- package/lib/errors/InvalidOperationError.js.map +1 -1
- package/lib/errors/NotImplementedError.d.ts +2 -1
- package/lib/errors/NotImplementedError.js +2 -1
- package/lib/errors/NotImplementedError.js.map +1 -1
- package/lib/errors/PermissionViolationError.d.ts +2 -1
- package/lib/errors/PermissionViolationError.js +2 -1
- package/lib/errors/PermissionViolationError.js.map +1 -1
- package/lib/errors/ResourceConflictError.d.ts +2 -1
- package/lib/errors/ResourceConflictError.js +2 -1
- package/lib/errors/ResourceConflictError.js.map +1 -1
- package/lib/errors/UnknownError.d.ts +6 -5
- package/lib/errors/UnknownError.js +6 -5
- package/lib/errors/UnknownError.js.map +1 -1
- package/lib/graphics/canvas.d.ts +55 -19
- package/lib/graphics/canvas.js +66 -18
- package/lib/graphics/canvas.js.map +1 -1
- package/lib/graphics/core.d.ts +18 -0
- package/lib/graphics/core.js +18 -0
- package/lib/graphics/core.js.map +1 -1
- package/lib/graphics/render-loop.d.ts +25 -4
- package/lib/graphics/render-loop.js +19 -2
- package/lib/graphics/render-loop.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/math/core.d.ts +12 -1
- package/lib/math/core.js +13 -2
- package/lib/math/core.js.map +1 -1
- package/lib/math/index.d.ts +2 -0
- package/lib/math/index.js +2 -0
- package/lib/math/index.js.map +1 -1
- package/lib/math/vector.d.ts +2 -33
- package/lib/math/vector.js +2 -41
- package/lib/math/vector.js.map +1 -1
- package/lib/math/vector2.d.ts +195 -0
- package/lib/math/vector2.js +299 -0
- package/lib/math/vector2.js.map +1 -0
- package/lib/math/vector3.d.ts +46 -0
- package/lib/math/vector3.js +59 -0
- package/lib/math/vector3.js.map +1 -0
- package/lib/nil.d.ts +1 -0
- package/lib/nil.js +1 -0
- package/lib/nil.js.map +1 -1
- package/lib/random.d.ts +40 -4
- package/lib/random.js +175 -14
- package/lib/random.js.map +1 -1
- package/lib/string-formatter.d.ts +2 -0
- package/lib/string-formatter.js +2 -0
- package/lib/string-formatter.js.map +1 -1
- package/package.json +10 -10
- package/docs/README.md +0 -3
- package/docs/classes/AbstractError.md +0 -271
- package/docs/classes/Canvas.md +0 -177
- package/docs/classes/InternalError.md +0 -301
- package/docs/classes/InvalidArgumentError.md +0 -277
- package/docs/classes/InvalidOperationError.md +0 -277
- package/docs/classes/NotImplementedError.md +0 -276
- package/docs/classes/PermissionViolationError.md +0 -277
- package/docs/classes/Random.md +0 -109
- package/docs/classes/RenderLoop.md +0 -49
- package/docs/classes/ResourceConflictError.md +0 -276
- package/docs/classes/UnexpectedNilError.md +0 -169
- package/docs/classes/UnknownError.md +0 -280
- package/docs/classes/Vector2.md +0 -79
- package/docs/classes/Vector3.md +0 -106
- package/docs/modules.md +0 -1313
- package/typedoc.json +0 -8
package/docs/modules.md
DELETED
|
@@ -1,1313 +0,0 @@
|
|
|
1
|
-
[@oliversalzburg/js-utils](README.md) / Exports
|
|
2
|
-
|
|
3
|
-
# @oliversalzburg/js-utils
|
|
4
|
-
|
|
5
|
-
## Classes
|
|
6
|
-
|
|
7
|
-
- [AbstractError](classes/AbstractError.md)
|
|
8
|
-
- [Canvas](classes/Canvas.md)
|
|
9
|
-
- [InternalError](classes/InternalError.md)
|
|
10
|
-
- [InvalidArgumentError](classes/InvalidArgumentError.md)
|
|
11
|
-
- [InvalidOperationError](classes/InvalidOperationError.md)
|
|
12
|
-
- [NotImplementedError](classes/NotImplementedError.md)
|
|
13
|
-
- [PermissionViolationError](classes/PermissionViolationError.md)
|
|
14
|
-
- [Random](classes/Random.md)
|
|
15
|
-
- [RenderLoop](classes/RenderLoop.md)
|
|
16
|
-
- [ResourceConflictError](classes/ResourceConflictError.md)
|
|
17
|
-
- [UnexpectedNilError](classes/UnexpectedNilError.md)
|
|
18
|
-
- [UnknownError](classes/UnknownError.md)
|
|
19
|
-
- [Vector2](classes/Vector2.md)
|
|
20
|
-
- [Vector3](classes/Vector3.md)
|
|
21
|
-
|
|
22
|
-
## Type Aliases
|
|
23
|
-
|
|
24
|
-
### AnyConstructor
|
|
25
|
-
|
|
26
|
-
Ƭ **AnyConstructor**: (...`args`: `any`[]) => `any`
|
|
27
|
-
|
|
28
|
-
#### Type declaration
|
|
29
|
-
|
|
30
|
-
• (`...args`): `any`
|
|
31
|
-
|
|
32
|
-
Any constructor
|
|
33
|
-
|
|
34
|
-
##### Parameters
|
|
35
|
-
|
|
36
|
-
| Name | Type |
|
|
37
|
-
| :-------- | :------ |
|
|
38
|
-
| `...args` | `any`[] |
|
|
39
|
-
|
|
40
|
-
##### Returns
|
|
41
|
-
|
|
42
|
-
`any`
|
|
43
|
-
|
|
44
|
-
#### Defined in
|
|
45
|
-
|
|
46
|
-
[core.ts:16](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/core.ts#L16)
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
### AnyFunction
|
|
51
|
-
|
|
52
|
-
Ƭ **AnyFunction**: (...`args`: `any`[]) => `any`
|
|
53
|
-
|
|
54
|
-
#### Type declaration
|
|
55
|
-
|
|
56
|
-
▸ (`...args`): `any`
|
|
57
|
-
|
|
58
|
-
Describes literally any function.
|
|
59
|
-
|
|
60
|
-
##### Parameters
|
|
61
|
-
|
|
62
|
-
| Name | Type |
|
|
63
|
-
| :-------- | :------ |
|
|
64
|
-
| `...args` | `any`[] |
|
|
65
|
-
|
|
66
|
-
##### Returns
|
|
67
|
-
|
|
68
|
-
`any`
|
|
69
|
-
|
|
70
|
-
#### Defined in
|
|
71
|
-
|
|
72
|
-
[core.ts:11](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/core.ts#L11)
|
|
73
|
-
|
|
74
|
-
---
|
|
75
|
-
|
|
76
|
-
### ConstructorOf
|
|
77
|
-
|
|
78
|
-
Ƭ **ConstructorOf**\<`T`\>: (...`args`: `any`[]) => `T`
|
|
79
|
-
|
|
80
|
-
#### Type parameters
|
|
81
|
-
|
|
82
|
-
| Name | Type |
|
|
83
|
-
| :--- | :------------------------------ |
|
|
84
|
-
| `T` | `Record`\<`string`, `unknown`\> |
|
|
85
|
-
|
|
86
|
-
#### Type declaration
|
|
87
|
-
|
|
88
|
-
• (`...args`): `T`
|
|
89
|
-
|
|
90
|
-
Describes a function that is a constructor for T.
|
|
91
|
-
|
|
92
|
-
##### Parameters
|
|
93
|
-
|
|
94
|
-
| Name | Type |
|
|
95
|
-
| :-------- | :------ |
|
|
96
|
-
| `...args` | `any`[] |
|
|
97
|
-
|
|
98
|
-
##### Returns
|
|
99
|
-
|
|
100
|
-
`T`
|
|
101
|
-
|
|
102
|
-
#### Defined in
|
|
103
|
-
|
|
104
|
-
[core.ts:6](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/core.ts#L6)
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
### FunctionReturning
|
|
109
|
-
|
|
110
|
-
Ƭ **FunctionReturning**\<`T`\>: (...`args`: `any`[]) => `T`
|
|
111
|
-
|
|
112
|
-
#### Type parameters
|
|
113
|
-
|
|
114
|
-
| Name | Type |
|
|
115
|
-
| :--- | :---- |
|
|
116
|
-
| `T` | `any` |
|
|
117
|
-
|
|
118
|
-
#### Type declaration
|
|
119
|
-
|
|
120
|
-
▸ (`...args`): `T`
|
|
121
|
-
|
|
122
|
-
Describes a function returning an instance of T.
|
|
123
|
-
|
|
124
|
-
##### Parameters
|
|
125
|
-
|
|
126
|
-
| Name | Type |
|
|
127
|
-
| :-------- | :------ |
|
|
128
|
-
| `...args` | `any`[] |
|
|
129
|
-
|
|
130
|
-
##### Returns
|
|
131
|
-
|
|
132
|
-
`T`
|
|
133
|
-
|
|
134
|
-
#### Defined in
|
|
135
|
-
|
|
136
|
-
[core.ts:21](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/core.ts#L21)
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
### Maybe
|
|
141
|
-
|
|
142
|
-
Ƭ **Maybe**\<`T`\>: `T` \| [`Nil`](modules.md#nil)
|
|
143
|
-
|
|
144
|
-
A type that could be either what you want, or `Nil`.
|
|
145
|
-
|
|
146
|
-
#### Type parameters
|
|
147
|
-
|
|
148
|
-
| Name |
|
|
149
|
-
| :--- |
|
|
150
|
-
| `T` |
|
|
151
|
-
|
|
152
|
-
#### Defined in
|
|
153
|
-
|
|
154
|
-
[nil.ts:12](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/nil.ts#L12)
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
### Mixin
|
|
159
|
-
|
|
160
|
-
Ƭ **Mixin**\<`T`\>: `InstanceType`\<`ReturnType`\<`T`\>\>
|
|
161
|
-
|
|
162
|
-
Describes a class "mixin", which is a function that returns a dynamically
|
|
163
|
-
constructed class, based on the passed parameters.
|
|
164
|
-
|
|
165
|
-
#### Type parameters
|
|
166
|
-
|
|
167
|
-
| Name | Type |
|
|
168
|
-
| :--- | :---------------------------------------------------------- |
|
|
169
|
-
| `T` | extends [`FunctionReturning`](modules.md#functionreturning) |
|
|
170
|
-
|
|
171
|
-
#### Defined in
|
|
172
|
-
|
|
173
|
-
[core.ts:27](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/core.ts#L27)
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
### Nil
|
|
178
|
-
|
|
179
|
-
Ƭ **Nil**: `null` \| `undefined`
|
|
180
|
-
|
|
181
|
-
When you want to normalize away `null` | `undefined`, or deal
|
|
182
|
-
with either type through a consistent interface.
|
|
183
|
-
|
|
184
|
-
#### Defined in
|
|
185
|
-
|
|
186
|
-
[nil.ts:7](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/nil.ts#L7)
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
### SerializedError
|
|
191
|
-
|
|
192
|
-
Ƭ **SerializedError**: `Record`\<`string`, `Record`\<`string`, `string`\> \| `string` \| `undefined`\>
|
|
193
|
-
|
|
194
|
-
The shape of an `Error` instance, after it has been serialized into a simple hash.
|
|
195
|
-
|
|
196
|
-
#### Defined in
|
|
197
|
-
|
|
198
|
-
[error-serializer.ts:9](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/error-serializer.ts#L9)
|
|
199
|
-
|
|
200
|
-
## Variables
|
|
201
|
-
|
|
202
|
-
### PALETTES
|
|
203
|
-
|
|
204
|
-
• `Const` **PALETTES**: `number`[][]
|
|
205
|
-
|
|
206
|
-
#### Defined in
|
|
207
|
-
|
|
208
|
-
[graphics/core.ts:5](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L5)
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
### TWO_PI
|
|
213
|
-
|
|
214
|
-
• `Const` **TWO_PI**: `number`
|
|
215
|
-
|
|
216
|
-
#### Defined in
|
|
217
|
-
|
|
218
|
-
[math/core.ts:1](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/math/core.ts#L1)
|
|
219
|
-
|
|
220
|
-
---
|
|
221
|
-
|
|
222
|
-
### random
|
|
223
|
-
|
|
224
|
-
• `Const` **random**: [`Random`](classes/Random.md)
|
|
225
|
-
|
|
226
|
-
#### Defined in
|
|
227
|
-
|
|
228
|
-
[random.ts:193](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/random.ts#L193)
|
|
229
|
-
|
|
230
|
-
## Functions
|
|
231
|
-
|
|
232
|
-
### Isqrt
|
|
233
|
-
|
|
234
|
-
▸ **Isqrt**(`value`): `number`
|
|
235
|
-
|
|
236
|
-
Finds the integer square root of a positive number.
|
|
237
|
-
|
|
238
|
-
#### Parameters
|
|
239
|
-
|
|
240
|
-
| Name | Type | Description |
|
|
241
|
-
| :------ | :------- | :----------------------------------------- |
|
|
242
|
-
| `value` | `number` | The value to calcuate the square root for. |
|
|
243
|
-
|
|
244
|
-
#### Returns
|
|
245
|
-
|
|
246
|
-
`number`
|
|
247
|
-
|
|
248
|
-
The square root for the given value.
|
|
249
|
-
|
|
250
|
-
#### Defined in
|
|
251
|
-
|
|
252
|
-
[math/core.ts:58](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/math/core.ts#L58)
|
|
253
|
-
|
|
254
|
-
---
|
|
255
|
-
|
|
256
|
-
### blend
|
|
257
|
-
|
|
258
|
-
▸ **blend**(`src`, `dst`, `alpha`): `number`
|
|
259
|
-
|
|
260
|
-
Returns a new color that is a blend between a source and a destination
|
|
261
|
-
color linerally. The alpha component in these colors is ignored. Instead, the provided
|
|
262
|
-
`alpha` value is used to blend between the two colors.
|
|
263
|
-
|
|
264
|
-
#### Parameters
|
|
265
|
-
|
|
266
|
-
| Name | Type | Description |
|
|
267
|
-
| :------ | :------- | :----------------------------------- |
|
|
268
|
-
| `src` | `number` | The source color. |
|
|
269
|
-
| `dst` | `number` | The destination color. |
|
|
270
|
-
| `alpha` | `number` | The alpha value to use for blending. |
|
|
271
|
-
|
|
272
|
-
#### Returns
|
|
273
|
-
|
|
274
|
-
`number`
|
|
275
|
-
|
|
276
|
-
The blended color.
|
|
277
|
-
|
|
278
|
-
#### Defined in
|
|
279
|
-
|
|
280
|
-
[graphics/core.ts:413](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L413)
|
|
281
|
-
|
|
282
|
-
---
|
|
283
|
-
|
|
284
|
-
### blendAdditive
|
|
285
|
-
|
|
286
|
-
▸ **blendAdditive**(`src`, `dst`, `alpha`): `number`
|
|
287
|
-
|
|
288
|
-
Returns a new color that is a blend between a source and a destination
|
|
289
|
-
color additively. The alpha component in these colors is ignored. Instead, the provided
|
|
290
|
-
`alpha` value is used to blend between the two colors.
|
|
291
|
-
|
|
292
|
-
#### Parameters
|
|
293
|
-
|
|
294
|
-
| Name | Type | Description |
|
|
295
|
-
| :------ | :------- | :----------------------------------- |
|
|
296
|
-
| `src` | `number` | The source color. |
|
|
297
|
-
| `dst` | `number` | The destination color. |
|
|
298
|
-
| `alpha` | `number` | The alpha value to use for blending. |
|
|
299
|
-
|
|
300
|
-
#### Returns
|
|
301
|
-
|
|
302
|
-
`number`
|
|
303
|
-
|
|
304
|
-
The blended color.
|
|
305
|
-
|
|
306
|
-
#### Defined in
|
|
307
|
-
|
|
308
|
-
[graphics/core.ts:439](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L439)
|
|
309
|
-
|
|
310
|
-
---
|
|
311
|
-
|
|
312
|
-
### blendSubtractive
|
|
313
|
-
|
|
314
|
-
▸ **blendSubtractive**(`src`, `dst`, `alpha`): `number`
|
|
315
|
-
|
|
316
|
-
Returns a new color that is a blend between a source and a destination
|
|
317
|
-
color subtractively. The alpha component in these colors is ignored. Instead, the provided
|
|
318
|
-
`alpha` value is used to blend between the two colors.
|
|
319
|
-
|
|
320
|
-
#### Parameters
|
|
321
|
-
|
|
322
|
-
| Name | Type | Description |
|
|
323
|
-
| :------ | :------- | :----------------------------------- |
|
|
324
|
-
| `src` | `number` | The source color. |
|
|
325
|
-
| `dst` | `number` | The destination color. |
|
|
326
|
-
| `alpha` | `number` | The alpha value to use for blending. |
|
|
327
|
-
|
|
328
|
-
#### Returns
|
|
329
|
-
|
|
330
|
-
`number`
|
|
331
|
-
|
|
332
|
-
The blended color.
|
|
333
|
-
|
|
334
|
-
#### Defined in
|
|
335
|
-
|
|
336
|
-
[graphics/core.ts:463](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L463)
|
|
337
|
-
|
|
338
|
-
---
|
|
339
|
-
|
|
340
|
-
### cosDeg
|
|
341
|
-
|
|
342
|
-
▸ **cosDeg**(`value`): `number`
|
|
343
|
-
|
|
344
|
-
Calculates the cosine for a given degree value.
|
|
345
|
-
|
|
346
|
-
#### Parameters
|
|
347
|
-
|
|
348
|
-
| Name | Type | Description |
|
|
349
|
-
| :------ | :------- | :------------------------------------------------ |
|
|
350
|
-
| `value` | `number` | The value in degrees to calculate the cosine for. |
|
|
351
|
-
|
|
352
|
-
#### Returns
|
|
353
|
-
|
|
354
|
-
`number`
|
|
355
|
-
|
|
356
|
-
The cosine for the given value.
|
|
357
|
-
|
|
358
|
-
#### Defined in
|
|
359
|
-
|
|
360
|
-
[math/core.ts:35](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/math/core.ts#L35)
|
|
361
|
-
|
|
362
|
-
---
|
|
363
|
-
|
|
364
|
-
### deg2rad
|
|
365
|
-
|
|
366
|
-
▸ **deg2rad**(`degrees`): `number`
|
|
367
|
-
|
|
368
|
-
Converts the degrees to radians.
|
|
369
|
-
|
|
370
|
-
#### Parameters
|
|
371
|
-
|
|
372
|
-
| Name | Type | Description |
|
|
373
|
-
| :-------- | :------- | :--------------------------------- |
|
|
374
|
-
| `degrees` | `number` | The degrees to convert to radians. |
|
|
375
|
-
|
|
376
|
-
#### Returns
|
|
377
|
-
|
|
378
|
-
`number`
|
|
379
|
-
|
|
380
|
-
The degrees in radians.
|
|
381
|
-
|
|
382
|
-
#### Defined in
|
|
383
|
-
|
|
384
|
-
[math/core.ts:8](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/math/core.ts#L8)
|
|
385
|
-
|
|
386
|
-
---
|
|
387
|
-
|
|
388
|
-
### difference
|
|
389
|
-
|
|
390
|
-
▸ **difference**\<`T`\>(`a`, `b`): `T`[]
|
|
391
|
-
|
|
392
|
-
Returns an array that holds all items that only appear in `a`.
|
|
393
|
-
|
|
394
|
-
#### Type parameters
|
|
395
|
-
|
|
396
|
-
| Name |
|
|
397
|
-
| :--- |
|
|
398
|
-
| `T` |
|
|
399
|
-
|
|
400
|
-
#### Parameters
|
|
401
|
-
|
|
402
|
-
| Name | Type | Description |
|
|
403
|
-
| :--- | :---- | :---------------- |
|
|
404
|
-
| `a` | `T`[] | The first array. |
|
|
405
|
-
| `b` | `T`[] | The second array. |
|
|
406
|
-
|
|
407
|
-
#### Returns
|
|
408
|
-
|
|
409
|
-
`T`[]
|
|
410
|
-
|
|
411
|
-
A new array which holds the items that ony appear
|
|
412
|
-
in `a`.
|
|
413
|
-
|
|
414
|
-
#### Defined in
|
|
415
|
-
|
|
416
|
-
[array.ts:38](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/array.ts#L38)
|
|
417
|
-
|
|
418
|
-
---
|
|
419
|
-
|
|
420
|
-
### distance
|
|
421
|
-
|
|
422
|
-
▸ **distance**(`x1`, `y1`, `x2`, `y2`): `number`
|
|
423
|
-
|
|
424
|
-
Calculates the distance between two vectors.
|
|
425
|
-
|
|
426
|
-
#### Parameters
|
|
427
|
-
|
|
428
|
-
| Name | Type | Description |
|
|
429
|
-
| :--- | :------- | :------------------------------------ |
|
|
430
|
-
| `x1` | `number` | The X component of the first vector. |
|
|
431
|
-
| `y1` | `number` | The Y comoinent of the first vector. |
|
|
432
|
-
| `x2` | `number` | The X component of the second vector. |
|
|
433
|
-
| `y2` | `number` | The Y component of the second vector. |
|
|
434
|
-
|
|
435
|
-
#### Returns
|
|
436
|
-
|
|
437
|
-
`number`
|
|
438
|
-
|
|
439
|
-
The distance between the two vectors.
|
|
440
|
-
|
|
441
|
-
#### Defined in
|
|
442
|
-
|
|
443
|
-
[math/core.ts:47](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/math/core.ts#L47)
|
|
444
|
-
|
|
445
|
-
---
|
|
446
|
-
|
|
447
|
-
### errorToJSON
|
|
448
|
-
|
|
449
|
-
▸ **errorToJSON**(`error`): `string`
|
|
450
|
-
|
|
451
|
-
Serializes an error into a JSON string.
|
|
452
|
-
|
|
453
|
-
#### Parameters
|
|
454
|
-
|
|
455
|
-
| Name | Type | Description |
|
|
456
|
-
| :------ | :------ | :---------------------- |
|
|
457
|
-
| `error` | `Error` | The error to stringify. |
|
|
458
|
-
|
|
459
|
-
#### Returns
|
|
460
|
-
|
|
461
|
-
`string`
|
|
462
|
-
|
|
463
|
-
A JSON string representing the error.
|
|
464
|
-
|
|
465
|
-
#### Defined in
|
|
466
|
-
|
|
467
|
-
[error-serializer.ts:44](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/error-serializer.ts#L44)
|
|
468
|
-
|
|
469
|
-
---
|
|
470
|
-
|
|
471
|
-
### errorToRecord
|
|
472
|
-
|
|
473
|
-
▸ **errorToRecord**(`error`): `Record`\<`string`, `unknown`\>
|
|
474
|
-
|
|
475
|
-
Converts an error into a regular hash.
|
|
476
|
-
|
|
477
|
-
#### Parameters
|
|
478
|
-
|
|
479
|
-
| Name | Type | Description |
|
|
480
|
-
| :------ | :------ | :-------------------- |
|
|
481
|
-
| `error` | `Error` | The error to convert. |
|
|
482
|
-
|
|
483
|
-
#### Returns
|
|
484
|
-
|
|
485
|
-
`Record`\<`string`, `unknown`\>
|
|
486
|
-
|
|
487
|
-
A new object that contains all the properties of the error.
|
|
488
|
-
|
|
489
|
-
#### Defined in
|
|
490
|
-
|
|
491
|
-
[error-serializer.ts:53](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/error-serializer.ts#L53)
|
|
492
|
-
|
|
493
|
-
---
|
|
494
|
-
|
|
495
|
-
### errorToSimpleSerializable
|
|
496
|
-
|
|
497
|
-
▸ **errorToSimpleSerializable**\<`TError`\>(`error`): [`SerializedError`](modules.md#serializederror)
|
|
498
|
-
|
|
499
|
-
Serializes an error into a simpler shape.
|
|
500
|
-
|
|
501
|
-
#### Type parameters
|
|
502
|
-
|
|
503
|
-
| Name | Type |
|
|
504
|
-
| :------- | :------------------------------------------------------------------------------------------------ |
|
|
505
|
-
| `TError` | extends [`AbstractError`](classes/AbstractError.md) = [`AbstractError`](classes/AbstractError.md) |
|
|
506
|
-
|
|
507
|
-
#### Parameters
|
|
508
|
-
|
|
509
|
-
| Name | Type | Description |
|
|
510
|
-
| :------ | :------- | :---------------------- |
|
|
511
|
-
| `error` | `TError` | The error to serialize. |
|
|
512
|
-
|
|
513
|
-
#### Returns
|
|
514
|
-
|
|
515
|
-
[`SerializedError`](modules.md#serializederror)
|
|
516
|
-
|
|
517
|
-
A simple representation of the error.
|
|
518
|
-
|
|
519
|
-
#### Defined in
|
|
520
|
-
|
|
521
|
-
[error-serializer.ts:66](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/error-serializer.ts#L66)
|
|
522
|
-
|
|
523
|
-
---
|
|
524
|
-
|
|
525
|
-
### filterType
|
|
526
|
-
|
|
527
|
-
▸ **filterType**\<`T`\>(`array`, `InstanceType`): `T`[]
|
|
528
|
-
|
|
529
|
-
From an array with unknown contents, retrieve all the elements
|
|
530
|
-
that are of a certain type and return them as a new array.
|
|
531
|
-
|
|
532
|
-
#### Type parameters
|
|
533
|
-
|
|
534
|
-
| Name |
|
|
535
|
-
| :--- |
|
|
536
|
-
| `T` |
|
|
537
|
-
|
|
538
|
-
#### Parameters
|
|
539
|
-
|
|
540
|
-
| Name | Type | Description |
|
|
541
|
-
| :------------- | :------------------------------------------------- | :---------------------- |
|
|
542
|
-
| `array` | `unknown`[] | The array to filter. |
|
|
543
|
-
| `InstanceType` | [`ConstructorOf`](modules.md#constructorof)\<`T`\> | The type to search for. |
|
|
544
|
-
|
|
545
|
-
#### Returns
|
|
546
|
-
|
|
547
|
-
`T`[]
|
|
548
|
-
|
|
549
|
-
A new array with the filtered items.
|
|
550
|
-
|
|
551
|
-
#### Defined in
|
|
552
|
-
|
|
553
|
-
[array.ts:49](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/array.ts#L49)
|
|
554
|
-
|
|
555
|
-
---
|
|
556
|
-
|
|
557
|
-
### formatString
|
|
558
|
-
|
|
559
|
-
▸ **formatString**(`string`, `...formatArguments`): `string`
|
|
560
|
-
|
|
561
|
-
Formats a given input string with numeric placeholders.
|
|
562
|
-
|
|
563
|
-
#### Parameters
|
|
564
|
-
|
|
565
|
-
| Name | Type | Description |
|
|
566
|
-
| :------------------- | :--------- | :-------------------------------------------------- |
|
|
567
|
-
| `string` | `string` | The input string with placeholders. |
|
|
568
|
-
| `...formatArguments` | `string`[] | An array of strings to place into the placeholders. |
|
|
569
|
-
|
|
570
|
-
#### Returns
|
|
571
|
-
|
|
572
|
-
`string`
|
|
573
|
-
|
|
574
|
-
The formatted string.
|
|
575
|
-
|
|
576
|
-
**`Example`**
|
|
577
|
-
|
|
578
|
-
```ts
|
|
579
|
-
// returns "Hello World"
|
|
580
|
-
formatString("{0} {1}", ["Hello", "World"]);
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
#### Defined in
|
|
584
|
-
|
|
585
|
-
[string-formatter.ts:10](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/string-formatter.ts#L10)
|
|
586
|
-
|
|
587
|
-
---
|
|
588
|
-
|
|
589
|
-
### formatStringTemplate
|
|
590
|
-
|
|
591
|
-
▸ **formatStringTemplate**(`string`, `parameters`): `string`
|
|
592
|
-
|
|
593
|
-
Formats a given input string with alphanumeric placeholders.
|
|
594
|
-
|
|
595
|
-
#### Parameters
|
|
596
|
-
|
|
597
|
-
| Name | Type | Description |
|
|
598
|
-
| :----------- | :-------------------------------------------- | :------------------------------------------------- |
|
|
599
|
-
| `string` | `string` | The input string with placeholders. |
|
|
600
|
-
| `parameters` | `Record`\<`string`, `undefined` \| `string`\> | A hash of parameters to place in the placeholders. |
|
|
601
|
-
|
|
602
|
-
#### Returns
|
|
603
|
-
|
|
604
|
-
`string`
|
|
605
|
-
|
|
606
|
-
The formatted string.
|
|
607
|
-
|
|
608
|
-
**`Example`**
|
|
609
|
-
|
|
610
|
-
```ts
|
|
611
|
-
// returns "Hello World"
|
|
612
|
-
formatString("{first} {second}", { first: "Hello", second: "World" });
|
|
613
|
-
```
|
|
614
|
-
|
|
615
|
-
#### Defined in
|
|
616
|
-
|
|
617
|
-
[string-formatter.ts:25](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/string-formatter.ts#L25)
|
|
618
|
-
|
|
619
|
-
---
|
|
620
|
-
|
|
621
|
-
### fromRGB
|
|
622
|
-
|
|
623
|
-
▸ **fromRGB**(`r`, `g`, `b`): `number`
|
|
624
|
-
|
|
625
|
-
Constructs a 32bit integer value that represents an RGBA color value.
|
|
626
|
-
The A component is fixed to `255`
|
|
627
|
-
|
|
628
|
-
#### Parameters
|
|
629
|
-
|
|
630
|
-
| Name | Type | Description |
|
|
631
|
-
| :--- | :------- | :--------------- |
|
|
632
|
-
| `r` | `number` | The R component. |
|
|
633
|
-
| `g` | `number` | The G component. |
|
|
634
|
-
| `b` | `number` | The B component. |
|
|
635
|
-
|
|
636
|
-
#### Returns
|
|
637
|
-
|
|
638
|
-
`number`
|
|
639
|
-
|
|
640
|
-
The constructed color value.
|
|
641
|
-
|
|
642
|
-
#### Defined in
|
|
643
|
-
|
|
644
|
-
[graphics/core.ts:364](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L364)
|
|
645
|
-
|
|
646
|
-
---
|
|
647
|
-
|
|
648
|
-
### fromRGBA
|
|
649
|
-
|
|
650
|
-
▸ **fromRGBA**(`r`, `g`, `b`, `a`): `number`
|
|
651
|
-
|
|
652
|
-
Constructs a 32bit integer value that represents an RGBA color value.
|
|
653
|
-
|
|
654
|
-
#### Parameters
|
|
655
|
-
|
|
656
|
-
| Name | Type | Description |
|
|
657
|
-
| :--- | :------- | :--------------- |
|
|
658
|
-
| `r` | `number` | The R component. |
|
|
659
|
-
| `g` | `number` | The G component. |
|
|
660
|
-
| `b` | `number` | The B component. |
|
|
661
|
-
| `a` | `number` | The A component. |
|
|
662
|
-
|
|
663
|
-
#### Returns
|
|
664
|
-
|
|
665
|
-
`number`
|
|
666
|
-
|
|
667
|
-
The constructed color value.
|
|
668
|
-
|
|
669
|
-
#### Defined in
|
|
670
|
-
|
|
671
|
-
[graphics/core.ts:347](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L347)
|
|
672
|
-
|
|
673
|
-
---
|
|
674
|
-
|
|
675
|
-
### getA
|
|
676
|
-
|
|
677
|
-
▸ **getA**(`color`): `number`
|
|
678
|
-
|
|
679
|
-
Extracts the A component from a color value.
|
|
680
|
-
|
|
681
|
-
#### Parameters
|
|
682
|
-
|
|
683
|
-
| Name | Type | Description |
|
|
684
|
-
| :------ | :------- | :--------------- |
|
|
685
|
-
| `color` | `number` | The color value. |
|
|
686
|
-
|
|
687
|
-
#### Returns
|
|
688
|
-
|
|
689
|
-
`number`
|
|
690
|
-
|
|
691
|
-
The A component of the color value.
|
|
692
|
-
|
|
693
|
-
#### Defined in
|
|
694
|
-
|
|
695
|
-
[graphics/core.ts:400](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L400)
|
|
696
|
-
|
|
697
|
-
---
|
|
698
|
-
|
|
699
|
-
### getB
|
|
700
|
-
|
|
701
|
-
▸ **getB**(`color`): `number`
|
|
702
|
-
|
|
703
|
-
Extracts the B component from a color value.
|
|
704
|
-
|
|
705
|
-
#### Parameters
|
|
706
|
-
|
|
707
|
-
| Name | Type | Description |
|
|
708
|
-
| :------ | :------- | :--------------- |
|
|
709
|
-
| `color` | `number` | The color value. |
|
|
710
|
-
|
|
711
|
-
#### Returns
|
|
712
|
-
|
|
713
|
-
`number`
|
|
714
|
-
|
|
715
|
-
The B component of the color value.
|
|
716
|
-
|
|
717
|
-
#### Defined in
|
|
718
|
-
|
|
719
|
-
[graphics/core.ts:391](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L391)
|
|
720
|
-
|
|
721
|
-
---
|
|
722
|
-
|
|
723
|
-
### getG
|
|
724
|
-
|
|
725
|
-
▸ **getG**(`color`): `number`
|
|
726
|
-
|
|
727
|
-
Extracts the G component from a color value.
|
|
728
|
-
|
|
729
|
-
#### Parameters
|
|
730
|
-
|
|
731
|
-
| Name | Type | Description |
|
|
732
|
-
| :------ | :------- | :--------------- |
|
|
733
|
-
| `color` | `number` | The color value. |
|
|
734
|
-
|
|
735
|
-
#### Returns
|
|
736
|
-
|
|
737
|
-
`number`
|
|
738
|
-
|
|
739
|
-
The G component of the color value.
|
|
740
|
-
|
|
741
|
-
#### Defined in
|
|
742
|
-
|
|
743
|
-
[graphics/core.ts:382](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L382)
|
|
744
|
-
|
|
745
|
-
---
|
|
746
|
-
|
|
747
|
-
### getR
|
|
748
|
-
|
|
749
|
-
▸ **getR**(`color`): `number`
|
|
750
|
-
|
|
751
|
-
Extracts the R component from a color value.
|
|
752
|
-
|
|
753
|
-
#### Parameters
|
|
754
|
-
|
|
755
|
-
| Name | Type | Description |
|
|
756
|
-
| :------ | :------- | :--------------- |
|
|
757
|
-
| `color` | `number` | The color value. |
|
|
758
|
-
|
|
759
|
-
#### Returns
|
|
760
|
-
|
|
761
|
-
`number`
|
|
762
|
-
|
|
763
|
-
The R component of the color value.
|
|
764
|
-
|
|
765
|
-
#### Defined in
|
|
766
|
-
|
|
767
|
-
[graphics/core.ts:373](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L373)
|
|
768
|
-
|
|
769
|
-
---
|
|
770
|
-
|
|
771
|
-
### intersect
|
|
772
|
-
|
|
773
|
-
▸ **intersect**\<`T`\>(`a`, `b`): `T`[]
|
|
774
|
-
|
|
775
|
-
Returns an array that holds all items that appear in both
|
|
776
|
-
passed arrays.
|
|
777
|
-
|
|
778
|
-
#### Type parameters
|
|
779
|
-
|
|
780
|
-
| Name |
|
|
781
|
-
| :--- |
|
|
782
|
-
| `T` |
|
|
783
|
-
|
|
784
|
-
#### Parameters
|
|
785
|
-
|
|
786
|
-
| Name | Type | Description |
|
|
787
|
-
| :--- | :---- | :---------------- |
|
|
788
|
-
| `a` | `T`[] | The first array. |
|
|
789
|
-
| `b` | `T`[] | The second array. |
|
|
790
|
-
|
|
791
|
-
#### Returns
|
|
792
|
-
|
|
793
|
-
`T`[]
|
|
794
|
-
|
|
795
|
-
A new array which holds the items that appear in
|
|
796
|
-
both passed arrays.
|
|
797
|
-
|
|
798
|
-
#### Defined in
|
|
799
|
-
|
|
800
|
-
[array.ts:27](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/array.ts#L27)
|
|
801
|
-
|
|
802
|
-
---
|
|
803
|
-
|
|
804
|
-
### is
|
|
805
|
-
|
|
806
|
-
▸ **is**\<`T`\>(`nilable`, `InstanceType`): nilable is T
|
|
807
|
-
|
|
808
|
-
Check if something is a concrete value of the given type.
|
|
809
|
-
Can be used as a typeguard.
|
|
810
|
-
|
|
811
|
-
#### Type parameters
|
|
812
|
-
|
|
813
|
-
| Name |
|
|
814
|
-
| :--- |
|
|
815
|
-
| `T` |
|
|
816
|
-
|
|
817
|
-
#### Parameters
|
|
818
|
-
|
|
819
|
-
| Name | Type | Description |
|
|
820
|
-
| :------------- | :------------------------------------------------- | :----------------------------- |
|
|
821
|
-
| `nilable` | [`Maybe`](modules.md#maybe)\<`T`\> | The subject that could be nil. |
|
|
822
|
-
| `InstanceType` | [`ConstructorOf`](modules.md#constructorof)\<`T`\> | The type to check against. |
|
|
823
|
-
|
|
824
|
-
#### Returns
|
|
825
|
-
|
|
826
|
-
nilable is T
|
|
827
|
-
|
|
828
|
-
`true` if the input element matches the given type,
|
|
829
|
-
`false` otherwise.
|
|
830
|
-
|
|
831
|
-
#### Defined in
|
|
832
|
-
|
|
833
|
-
[nil.ts:32](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/nil.ts#L32)
|
|
834
|
-
|
|
835
|
-
---
|
|
836
|
-
|
|
837
|
-
### isError
|
|
838
|
-
|
|
839
|
-
▸ **isError**(`subject`): subject is Error
|
|
840
|
-
|
|
841
|
-
Determine if the given unknown subject is an `Error` instance.
|
|
842
|
-
|
|
843
|
-
#### Parameters
|
|
844
|
-
|
|
845
|
-
| Name | Type | Description |
|
|
846
|
-
| :-------- | :-------- | :--------------------- |
|
|
847
|
-
| `subject` | `unknown` | The object to inspect. |
|
|
848
|
-
|
|
849
|
-
#### Returns
|
|
850
|
-
|
|
851
|
-
subject is Error
|
|
852
|
-
|
|
853
|
-
`true` if the subject is an `Error`, `false` otherwise.
|
|
854
|
-
|
|
855
|
-
#### Defined in
|
|
856
|
-
|
|
857
|
-
[error-serializer.ts:16](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/error-serializer.ts#L16)
|
|
858
|
-
|
|
859
|
-
---
|
|
860
|
-
|
|
861
|
-
### isInteger
|
|
862
|
-
|
|
863
|
-
▸ **isInteger**(`value`): `boolean`
|
|
864
|
-
|
|
865
|
-
Checks whether a number is an integer.
|
|
866
|
-
|
|
867
|
-
#### Parameters
|
|
868
|
-
|
|
869
|
-
| Name | Type | Description |
|
|
870
|
-
| :------ | :------- | :------------------ |
|
|
871
|
-
| `value` | `number` | The value to check. |
|
|
872
|
-
|
|
873
|
-
#### Returns
|
|
874
|
-
|
|
875
|
-
`boolean`
|
|
876
|
-
|
|
877
|
-
`true` when the value is an integer, `false` otherwise.
|
|
878
|
-
|
|
879
|
-
#### Defined in
|
|
880
|
-
|
|
881
|
-
[math/core.ts:76](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/math/core.ts#L76)
|
|
882
|
-
|
|
883
|
-
---
|
|
884
|
-
|
|
885
|
-
### isNil
|
|
886
|
-
|
|
887
|
-
▸ **isNil**\<`T`\>(`subject`): subject is Nil
|
|
888
|
-
|
|
889
|
-
Check if something is nil.
|
|
890
|
-
Can be used as a typeguard.
|
|
891
|
-
|
|
892
|
-
#### Type parameters
|
|
893
|
-
|
|
894
|
-
| Name |
|
|
895
|
-
| :--- |
|
|
896
|
-
| `T` |
|
|
897
|
-
|
|
898
|
-
#### Parameters
|
|
899
|
-
|
|
900
|
-
| Name | Type | Description |
|
|
901
|
-
| :-------- | :--------------------------------- | :----------------------------- |
|
|
902
|
-
| `subject` | [`Maybe`](modules.md#maybe)\<`T`\> | The subject that could be nil. |
|
|
903
|
-
|
|
904
|
-
#### Returns
|
|
905
|
-
|
|
906
|
-
subject is Nil
|
|
907
|
-
|
|
908
|
-
`true` if the subject is nil, `false` otherwise.
|
|
909
|
-
|
|
910
|
-
#### Defined in
|
|
911
|
-
|
|
912
|
-
[nil.ts:20](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/nil.ts#L20)
|
|
913
|
-
|
|
914
|
-
---
|
|
915
|
-
|
|
916
|
-
### mustExist
|
|
917
|
-
|
|
918
|
-
▸ **mustExist**\<`T`\>(`subject`, `errorMessage?`): `T`
|
|
919
|
-
|
|
920
|
-
Ensure that the passed subject is not nil; throw otherwise.
|
|
921
|
-
|
|
922
|
-
#### Type parameters
|
|
923
|
-
|
|
924
|
-
| Name |
|
|
925
|
-
| :--- |
|
|
926
|
-
| `T` |
|
|
927
|
-
|
|
928
|
-
#### Parameters
|
|
929
|
-
|
|
930
|
-
| Name | Type | Description |
|
|
931
|
-
| :-------------- | :--------------------------------- | :---------------------------------------------------------- |
|
|
932
|
-
| `subject` | [`Maybe`](modules.md#maybe)\<`T`\> | A subject that is possible nil. |
|
|
933
|
-
| `errorMessage?` | `string` | An optional error message to throw when the subject is nil. |
|
|
934
|
-
|
|
935
|
-
#### Returns
|
|
936
|
-
|
|
937
|
-
`T`
|
|
938
|
-
|
|
939
|
-
The subject, if it isn't nil.
|
|
940
|
-
|
|
941
|
-
**`Throws`**
|
|
942
|
-
|
|
943
|
-
When the subject is nil.
|
|
944
|
-
|
|
945
|
-
#### Defined in
|
|
946
|
-
|
|
947
|
-
[nil.ts:56](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/nil.ts#L56)
|
|
948
|
-
|
|
949
|
-
---
|
|
950
|
-
|
|
951
|
-
### nextPalette
|
|
952
|
-
|
|
953
|
-
▸ **nextPalette**(): `void`
|
|
954
|
-
|
|
955
|
-
Switches the global palette to the next available preset.
|
|
956
|
-
|
|
957
|
-
#### Returns
|
|
958
|
-
|
|
959
|
-
`void`
|
|
960
|
-
|
|
961
|
-
#### Defined in
|
|
962
|
-
|
|
963
|
-
[graphics/core.ts:491](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L491)
|
|
964
|
-
|
|
965
|
-
---
|
|
966
|
-
|
|
967
|
-
### putPixel32
|
|
968
|
-
|
|
969
|
-
▸ **putPixel32**(`canvas`, `x`, `y`, `color`, `alpha`): `void`
|
|
970
|
-
|
|
971
|
-
Linearly blends a new pixel with an existing color value in a [Canvas](classes/Canvas.md).
|
|
972
|
-
|
|
973
|
-
#### Parameters
|
|
974
|
-
|
|
975
|
-
| Name | Type | Description |
|
|
976
|
-
| :------- | :---------------------------- | :----------------------------------------------------------------------------- |
|
|
977
|
-
| `canvas` | [`Canvas`](classes/Canvas.md) | The [Canvas](classes/Canvas.md) to interact with. |
|
|
978
|
-
| `x` | `number` | The X coordinate at which to place the pixel. |
|
|
979
|
-
| `y` | `number` | The Y coordinate at which to place the pixel. |
|
|
980
|
-
| `color` | `number` | The color of the pixel. |
|
|
981
|
-
| `alpha` | `number` | The alpha value to use to blend the pixel with existing color at the location. |
|
|
982
|
-
|
|
983
|
-
#### Returns
|
|
984
|
-
|
|
985
|
-
`void`
|
|
986
|
-
|
|
987
|
-
#### Defined in
|
|
988
|
-
|
|
989
|
-
[graphics/canvas.ts:97](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L97)
|
|
990
|
-
|
|
991
|
-
---
|
|
992
|
-
|
|
993
|
-
### putPixel32Add
|
|
994
|
-
|
|
995
|
-
▸ **putPixel32Add**(`canvas`, `x`, `y`, `color`, `alpha`): `void`
|
|
996
|
-
|
|
997
|
-
Additively blends a new pixel with an existing color value in a [Canvas](classes/Canvas.md).
|
|
998
|
-
|
|
999
|
-
#### Parameters
|
|
1000
|
-
|
|
1001
|
-
| Name | Type | Description |
|
|
1002
|
-
| :------- | :---------------------------- | :----------------------------------------------------------------------------- |
|
|
1003
|
-
| `canvas` | [`Canvas`](classes/Canvas.md) | The [Canvas](classes/Canvas.md) to interact with. |
|
|
1004
|
-
| `x` | `number` | The X coordinate at which to place the pixel. |
|
|
1005
|
-
| `y` | `number` | The Y coordinate at which to place the pixel. |
|
|
1006
|
-
| `color` | `number` | The color of the pixel. |
|
|
1007
|
-
| `alpha` | `number` | The alpha value to use to blend the pixel with existing color at the location. |
|
|
1008
|
-
|
|
1009
|
-
#### Returns
|
|
1010
|
-
|
|
1011
|
-
`void`
|
|
1012
|
-
|
|
1013
|
-
#### Defined in
|
|
1014
|
-
|
|
1015
|
-
[graphics/canvas.ts:121](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L121)
|
|
1016
|
-
|
|
1017
|
-
---
|
|
1018
|
-
|
|
1019
|
-
### putPixel32Sub
|
|
1020
|
-
|
|
1021
|
-
▸ **putPixel32Sub**(`canvas`, `x`, `y`, `color`, `alpha`): `void`
|
|
1022
|
-
|
|
1023
|
-
Subtractively blends a new pixel with an existing color value in a [Canvas](classes/Canvas.md).
|
|
1024
|
-
|
|
1025
|
-
#### Parameters
|
|
1026
|
-
|
|
1027
|
-
| Name | Type | Description |
|
|
1028
|
-
| :------- | :---------------------------- | :----------------------------------------------------------------------------- |
|
|
1029
|
-
| `canvas` | [`Canvas`](classes/Canvas.md) | The [Canvas](classes/Canvas.md) to interact with. |
|
|
1030
|
-
| `x` | `number` | The X coordinate at which to place the pixel. |
|
|
1031
|
-
| `y` | `number` | The Y coordinate at which to place the pixel. |
|
|
1032
|
-
| `color` | `number` | The color of the pixel. |
|
|
1033
|
-
| `alpha` | `number` | The alpha value to use to blend the pixel with existing color at the location. |
|
|
1034
|
-
|
|
1035
|
-
#### Returns
|
|
1036
|
-
|
|
1037
|
-
`void`
|
|
1038
|
-
|
|
1039
|
-
#### Defined in
|
|
1040
|
-
|
|
1041
|
-
[graphics/canvas.ts:151](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L151)
|
|
1042
|
-
|
|
1043
|
-
---
|
|
1044
|
-
|
|
1045
|
-
### putSubPixel32
|
|
1046
|
-
|
|
1047
|
-
▸ **putSubPixel32**(`canvas`, `x`, `y`, `color`, `alpha`): `void`
|
|
1048
|
-
|
|
1049
|
-
Linearly blends a new pixel with an existing color value in a [Canvas](classes/Canvas.md).
|
|
1050
|
-
Compared to [putPixel32](modules.md#putpixel32), this function supports sub-pixel placement, but is dramatically slower.
|
|
1051
|
-
|
|
1052
|
-
#### Parameters
|
|
1053
|
-
|
|
1054
|
-
| Name | Type | Description |
|
|
1055
|
-
| :------- | :---------------------------- | :----------------------------------------------------------------------------- |
|
|
1056
|
-
| `canvas` | [`Canvas`](classes/Canvas.md) | The [Canvas](classes/Canvas.md) to interact with. |
|
|
1057
|
-
| `x` | `number` | The X coordinate at which to place the pixel. |
|
|
1058
|
-
| `y` | `number` | The Y coordinate at which to place the pixel. |
|
|
1059
|
-
| `color` | `number` | The color of the pixel. |
|
|
1060
|
-
| `alpha` | `number` | The alpha value to use to blend the pixel with existing color at the location. |
|
|
1061
|
-
|
|
1062
|
-
#### Returns
|
|
1063
|
-
|
|
1064
|
-
`void`
|
|
1065
|
-
|
|
1066
|
-
#### Defined in
|
|
1067
|
-
|
|
1068
|
-
[graphics/canvas.ts:182](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/canvas.ts#L182)
|
|
1069
|
-
|
|
1070
|
-
---
|
|
1071
|
-
|
|
1072
|
-
### rad2deg
|
|
1073
|
-
|
|
1074
|
-
▸ **rad2deg**(`radians`): `number`
|
|
1075
|
-
|
|
1076
|
-
Convertrs the radians to degrees.
|
|
1077
|
-
|
|
1078
|
-
#### Parameters
|
|
1079
|
-
|
|
1080
|
-
| Name | Type | Description |
|
|
1081
|
-
| :-------- | :------- | :--------------------------------- |
|
|
1082
|
-
| `radians` | `number` | The radians to convert to degrees. |
|
|
1083
|
-
|
|
1084
|
-
#### Returns
|
|
1085
|
-
|
|
1086
|
-
`number`
|
|
1087
|
-
|
|
1088
|
-
The radians as degrees.
|
|
1089
|
-
|
|
1090
|
-
#### Defined in
|
|
1091
|
-
|
|
1092
|
-
[math/core.ts:17](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/math/core.ts#L17)
|
|
1093
|
-
|
|
1094
|
-
---
|
|
1095
|
-
|
|
1096
|
-
### randomRange
|
|
1097
|
-
|
|
1098
|
-
▸ **randomRange**(`min`, `max`): `number`
|
|
1099
|
-
|
|
1100
|
-
Returns a random value in a given range.
|
|
1101
|
-
Uses the JS-internal `Math.random()`. Use {MathHelper} for a PRNG with more features.
|
|
1102
|
-
|
|
1103
|
-
#### Parameters
|
|
1104
|
-
|
|
1105
|
-
| Name | Type | Description |
|
|
1106
|
-
| :---- | :------- | :--------------- |
|
|
1107
|
-
| `min` | `number` | The lower bound. |
|
|
1108
|
-
| `max` | `number` | The upper bound. |
|
|
1109
|
-
|
|
1110
|
-
#### Returns
|
|
1111
|
-
|
|
1112
|
-
`number`
|
|
1113
|
-
|
|
1114
|
-
A random value between the lower and upper bound.
|
|
1115
|
-
|
|
1116
|
-
#### Defined in
|
|
1117
|
-
|
|
1118
|
-
[random.ts:177](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/random.ts#L177)
|
|
1119
|
-
|
|
1120
|
-
---
|
|
1121
|
-
|
|
1122
|
-
### safeRGBComponent
|
|
1123
|
-
|
|
1124
|
-
▸ **safeRGBComponent**(`c`): `number`
|
|
1125
|
-
|
|
1126
|
-
Constrains a color component value to single-byte range (`0`-`255`).
|
|
1127
|
-
|
|
1128
|
-
#### Parameters
|
|
1129
|
-
|
|
1130
|
-
| Name | Type | Description |
|
|
1131
|
-
| :--- | :------- | :----------------------- |
|
|
1132
|
-
| `c` | `number` | A color component value. |
|
|
1133
|
-
|
|
1134
|
-
#### Returns
|
|
1135
|
-
|
|
1136
|
-
`number`
|
|
1137
|
-
|
|
1138
|
-
The input value constrained into single-byte range.
|
|
1139
|
-
|
|
1140
|
-
#### Defined in
|
|
1141
|
-
|
|
1142
|
-
[graphics/core.ts:329](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L329)
|
|
1143
|
-
|
|
1144
|
-
---
|
|
1145
|
-
|
|
1146
|
-
### seedFromString
|
|
1147
|
-
|
|
1148
|
-
▸ **seedFromString**(`input`): `number`
|
|
1149
|
-
|
|
1150
|
-
Generates a numberic seed, to be used as an input for a PRNG,
|
|
1151
|
-
from a string.
|
|
1152
|
-
|
|
1153
|
-
#### Parameters
|
|
1154
|
-
|
|
1155
|
-
| Name | Type | Description |
|
|
1156
|
-
| :------ | :------- | :--------------------------- |
|
|
1157
|
-
| `input` | `string` | The string to use as a seed. |
|
|
1158
|
-
|
|
1159
|
-
#### Returns
|
|
1160
|
-
|
|
1161
|
-
`number`
|
|
1162
|
-
|
|
1163
|
-
A numeric seed value for a PRNG.
|
|
1164
|
-
|
|
1165
|
-
#### Defined in
|
|
1166
|
-
|
|
1167
|
-
[random.ts:187](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/random.ts#L187)
|
|
1168
|
-
|
|
1169
|
-
---
|
|
1170
|
-
|
|
1171
|
-
### shuffleArray
|
|
1172
|
-
|
|
1173
|
-
▸ **shuffleArray**\<`T`\>(`array`): `T`[]
|
|
1174
|
-
|
|
1175
|
-
Places the items in the array in random order.
|
|
1176
|
-
|
|
1177
|
-
#### Type parameters
|
|
1178
|
-
|
|
1179
|
-
| Name |
|
|
1180
|
-
| :--- |
|
|
1181
|
-
| `T` |
|
|
1182
|
-
|
|
1183
|
-
#### Parameters
|
|
1184
|
-
|
|
1185
|
-
| Name | Type | Description |
|
|
1186
|
-
| :------ | :---- | :-------------------- |
|
|
1187
|
-
| `array` | `T`[] | The array to shuffle. |
|
|
1188
|
-
|
|
1189
|
-
#### Returns
|
|
1190
|
-
|
|
1191
|
-
`T`[]
|
|
1192
|
-
|
|
1193
|
-
The passed array in random order.
|
|
1194
|
-
|
|
1195
|
-
#### Defined in
|
|
1196
|
-
|
|
1197
|
-
[array.ts:9](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/array.ts#L9)
|
|
1198
|
-
|
|
1199
|
-
---
|
|
1200
|
-
|
|
1201
|
-
### sinDeg
|
|
1202
|
-
|
|
1203
|
-
▸ **sinDeg**(`value`): `number`
|
|
1204
|
-
|
|
1205
|
-
Calculates the sine for a given degree value.
|
|
1206
|
-
|
|
1207
|
-
#### Parameters
|
|
1208
|
-
|
|
1209
|
-
| Name | Type | Description |
|
|
1210
|
-
| :------ | :------- | :---------------------------------------------- |
|
|
1211
|
-
| `value` | `number` | The value in degrees to calculate the sine for. |
|
|
1212
|
-
|
|
1213
|
-
#### Returns
|
|
1214
|
-
|
|
1215
|
-
`number`
|
|
1216
|
-
|
|
1217
|
-
The sine for the given value.
|
|
1218
|
-
|
|
1219
|
-
#### Defined in
|
|
1220
|
-
|
|
1221
|
-
[math/core.ts:26](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/math/core.ts#L26)
|
|
1222
|
-
|
|
1223
|
-
---
|
|
1224
|
-
|
|
1225
|
-
### sleep
|
|
1226
|
-
|
|
1227
|
-
▸ **sleep**(`duration`): `Promise`\<`void`\>
|
|
1228
|
-
|
|
1229
|
-
Wait a given period before continuing execution.
|
|
1230
|
-
|
|
1231
|
-
#### Parameters
|
|
1232
|
-
|
|
1233
|
-
| Name | Type | Description |
|
|
1234
|
-
| :--------- | :------- | :----------------------------- |
|
|
1235
|
-
| `duration` | `number` | How many milliseconds to wait. |
|
|
1236
|
-
|
|
1237
|
-
#### Returns
|
|
1238
|
-
|
|
1239
|
-
`Promise`\<`void`\>
|
|
1240
|
-
|
|
1241
|
-
Nothing
|
|
1242
|
-
|
|
1243
|
-
#### Defined in
|
|
1244
|
-
|
|
1245
|
-
[sleep.ts:6](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/sleep.ts#L6)
|
|
1246
|
-
|
|
1247
|
-
---
|
|
1248
|
-
|
|
1249
|
-
### somecolor
|
|
1250
|
-
|
|
1251
|
-
▸ **somecolor**(): `number`
|
|
1252
|
-
|
|
1253
|
-
Retrieves a random color from the current global palette.
|
|
1254
|
-
|
|
1255
|
-
#### Returns
|
|
1256
|
-
|
|
1257
|
-
`number`
|
|
1258
|
-
|
|
1259
|
-
A random color.
|
|
1260
|
-
|
|
1261
|
-
#### Defined in
|
|
1262
|
-
|
|
1263
|
-
[graphics/core.ts:481](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L481)
|
|
1264
|
-
|
|
1265
|
-
---
|
|
1266
|
-
|
|
1267
|
-
### toGrayScale
|
|
1268
|
-
|
|
1269
|
-
▸ **toGrayScale**(`color`): `number`
|
|
1270
|
-
|
|
1271
|
-
Converts a color value to grayscale.
|
|
1272
|
-
|
|
1273
|
-
#### Parameters
|
|
1274
|
-
|
|
1275
|
-
| Name | Type | Description |
|
|
1276
|
-
| :------ | :------- | :-------------------- |
|
|
1277
|
-
| `color` | `number` | The color to convert. |
|
|
1278
|
-
|
|
1279
|
-
#### Returns
|
|
1280
|
-
|
|
1281
|
-
`number`
|
|
1282
|
-
|
|
1283
|
-
The grayscale value appropriate for the color.
|
|
1284
|
-
|
|
1285
|
-
#### Defined in
|
|
1286
|
-
|
|
1287
|
-
[graphics/core.ts:503](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/graphics/core.ts#L503)
|
|
1288
|
-
|
|
1289
|
-
---
|
|
1290
|
-
|
|
1291
|
-
### unknownToError
|
|
1292
|
-
|
|
1293
|
-
▸ **unknownToError**(`subject`): [`AbstractError`](classes/AbstractError.md)
|
|
1294
|
-
|
|
1295
|
-
Returns an `AbstractError` that best represents the passed subject.
|
|
1296
|
-
If the passed subject is already an `AbstractError`, it is returned as-is.
|
|
1297
|
-
Otherwise, it will be converted into an appropriate error type.
|
|
1298
|
-
|
|
1299
|
-
#### Parameters
|
|
1300
|
-
|
|
1301
|
-
| Name | Type | Description |
|
|
1302
|
-
| :-------- | :-------- | :--------------------- |
|
|
1303
|
-
| `subject` | `unknown` | The subject to inspect |
|
|
1304
|
-
|
|
1305
|
-
#### Returns
|
|
1306
|
-
|
|
1307
|
-
[`AbstractError`](classes/AbstractError.md)
|
|
1308
|
-
|
|
1309
|
-
An `AbstractError` instance.
|
|
1310
|
-
|
|
1311
|
-
#### Defined in
|
|
1312
|
-
|
|
1313
|
-
[error-serializer.ts:27](https://github.com/oliversalzburg/js-utils/blob/293b24f/source/error-serializer.ts#L27)
|