@thi.ng/api 8.0.3 → 8.2.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/CHANGELOG.md CHANGED
@@ -3,25 +3,29 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [8.0.3](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@8.0.2...@thi.ng/api@8.0.3) (2021-10-15)
6
+ # [8.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@8.1.0...@thi.ng/api@8.2.0) (2021-11-10)
7
7
 
8
- **Note:** Version bump only for package @thi.ng/api
9
8
 
9
+ ### Bug Fixes
10
+
11
+ * **api:** add missing module exports ([fc8805e](https://github.com/thi-ng/umbrella/commit/fc8805eb26a828d4ee9683c714a73a7ad35ef16c))
10
12
 
11
13
 
14
+ ### Features
12
15
 
16
+ * **api:** update IGrid types, add mixins ([f0f3236](https://github.com/thi-ng/umbrella/commit/f0f3236448e7277e089654c725d2b9335bd4706a))
13
17
 
14
- ## [8.0.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@8.0.1...@thi.ng/api@8.0.2) (2021-10-15)
15
18
 
16
- **Note:** Version bump only for package @thi.ng/api
17
19
 
18
20
 
19
21
 
22
+ # [8.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@8.0.6...@thi.ng/api@8.1.0) (2021-11-03)
20
23
 
21
24
 
22
- ## [8.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@8.0.0...@thi.ng/api@8.0.1) (2021-10-13)
25
+ ### Features
23
26
 
24
- **Note:** Version bump only for package @thi.ng/api
27
+ * **api:** add asInt() coercion helper ([49cd772](https://github.com/thi-ng/umbrella/commit/49cd772a328b7c71fb16ed3041e03832ebd1f884))
28
+ * **api:** add IGrid2D/3D interfaces ([e57ad7e](https://github.com/thi-ng/umbrella/commit/e57ad7e8139512bf4146c4c70ef693b810eee24a))
25
29
 
26
30
 
27
31
 
@@ -78,31 +82,31 @@ Also:
78
82
 
79
83
 
80
84
 
81
- # [7.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@7.1.9...@thi.ng/api@7.2.0) (2021-09-03)
85
+ # [7.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@7.1.9...@thi.ng/api@7.2.0) (2021-09-03)
82
86
 
83
- ### Features
87
+ ### Features
84
88
 
85
- - **api:** add DeepArrayValue type ([a309fac](https://github.com/thi-ng/umbrella/commit/a309faca831651f611b9b056d9c7587f85b60087))
89
+ - **api:** add DeepArrayValue type ([a309fac](https://github.com/thi-ng/umbrella/commit/a309faca831651f611b9b056d9c7587f85b60087))
86
90
 
87
- # [7.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@7.0.0...@thi.ng/api@7.1.0) (2021-03-03)
91
+ # [7.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@7.0.0...@thi.ng/api@7.1.0) (2021-03-03)
88
92
 
89
- ### Features
93
+ ### Features
90
94
 
91
- - **api:** add StringOrSym type alias ([fb92c9d](https://github.com/thi-ng/umbrella/commit/fb92c9d93b4e795f60118e1167d5adb1bb108380))
95
+ - **api:** add StringOrSym type alias ([fb92c9d](https://github.com/thi-ng/umbrella/commit/fb92c9d93b4e795f60118e1167d5adb1bb108380))
92
96
 
93
- # [7.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@6.13.6...@thi.ng/api@7.0.0) (2021-02-20)
97
+ # [7.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@6.13.6...@thi.ng/api@7.0.0) (2021-02-20)
94
98
 
95
- ### Features
99
+ ### Features
96
100
 
97
- - **api:** add Range type ([5d94974](https://github.com/thi-ng/umbrella/commit/5d94974c34ca81513d40743f2a9b9a3ed20146d3))
98
- - **api:** add typedArrayType() classifier ([5c81fd8](https://github.com/thi-ng/umbrella/commit/5c81fd859514401c2c419b2ed3ec0f12025356c3))
99
- - **api:** more finely grained typedarray types ([8316d05](https://github.com/thi-ng/umbrella/commit/8316d058f0b5f760afd89e8590619670210a970a))
100
- - **api:** replace Type enum w/ strings consts ([a333d41](https://github.com/thi-ng/umbrella/commit/a333d418222972373cc1f9b256def2f79610d3fa))
101
+ - **api:** add Range type ([5d94974](https://github.com/thi-ng/umbrella/commit/5d94974c34ca81513d40743f2a9b9a3ed20146d3))
102
+ - **api:** add typedArrayType() classifier ([5c81fd8](https://github.com/thi-ng/umbrella/commit/5c81fd859514401c2c419b2ed3ec0f12025356c3))
103
+ - **api:** more finely grained typedarray types ([8316d05](https://github.com/thi-ng/umbrella/commit/8316d058f0b5f760afd89e8590619670210a970a))
104
+ - **api:** replace Type enum w/ strings consts ([a333d41](https://github.com/thi-ng/umbrella/commit/a333d418222972373cc1f9b256def2f79610d3fa))
101
105
 
102
- ### BREAKING CHANGES
106
+ ### BREAKING CHANGES
103
107
 
104
- - **api:** replace Type enum w/ string consts
105
- - update Type, UintType, IntType, FloatType aliases
108
+ - **api:** replace Type enum w/ string consts
109
+ - update Type, UintType, IntType, FloatType aliases
106
110
  - update GL2TYPE, TYPE2GL, SIZEOF, TYPEDARRAY_CTORS tables
107
111
  - add asNativeType(), asGLType() conversions
108
112
  - add sizeOf()
@@ -228,156 +232,156 @@ Also:
228
232
  ### Features
229
233
 
230
234
  - **api:** add common logging types & default impls ([4578604](https://github.com/thi-ng/umbrella/commit/4578604))
231
- - **api:** update ILogger, freeze NULL_LOGGER ([27ff8de](https://github.com/thi-ng/umbrella/commit/27ff8de))
235
+ - **api:** update ILogger, freeze NULL_LOGGER ([27ff8de](https://github.com/thi-ng/umbrella/commit/27ff8de))
232
236
 
233
- # [6.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@5.1.0...@thi.ng/api@6.0.0) (2019-03-28)
237
+ # [6.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@5.1.0...@thi.ng/api@6.0.0) (2019-03-28)
234
238
 
235
- ### Features
239
+ ### Features
236
240
 
237
- - **api:** add new types, update existing ([560eb90](https://github.com/thi-ng/umbrella/commit/560eb90))
241
+ - **api:** add new types, update existing ([560eb90](https://github.com/thi-ng/umbrella/commit/560eb90))
238
242
 
239
- ### BREAKING CHANGES
243
+ ### BREAKING CHANGES
240
244
 
241
- - **api:** split up, remove & update various interfaces
242
- - split IAssociative => IAssoc, IAssocIn
243
- - update IDissoc, add IDissocIn
244
- - split IGet => IGet, IGetIn
245
- - update IInto generics & return type
246
- - update ISet, remove IImmutableSet
247
- - update IStack, remove IImmutableStack
245
+ - **api:** split up, remove & update various interfaces
246
+ - split IAssociative => IAssoc, IAssocIn
247
+ - update IDissoc, add IDissocIn
248
+ - split IGet => IGet, IGetIn
249
+ - update IInto generics & return type
250
+ - update ISet, remove IImmutableSet
251
+ - update IStack, remove IImmutableStack
248
252
 
249
- # [5.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@5.0.3...@thi.ng/api@5.1.0) (2019-03-10)
253
+ # [5.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@5.0.3...@thi.ng/api@5.1.0) (2019-03-10)
250
254
 
251
- ### Features
255
+ ### Features
252
256
 
253
- - **api:** add additional Fn arities ([33c7dfe](https://github.com/thi-ng/umbrella/commit/33c7dfe))
254
- - **api:** add more Fn type aliases, update existing ([3707e61](https://github.com/thi-ng/umbrella/commit/3707e61))
257
+ - **api:** add additional Fn arities ([33c7dfe](https://github.com/thi-ng/umbrella/commit/33c7dfe))
258
+ - **api:** add more Fn type aliases, update existing ([3707e61](https://github.com/thi-ng/umbrella/commit/3707e61))
255
259
 
256
- # [5.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@4.2.4...@thi.ng/api@5.0.0) (2019-01-21)
260
+ # [5.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@4.2.4...@thi.ng/api@5.0.0) (2019-01-21)
257
261
 
258
- ### Bug Fixes
262
+ ### Bug Fixes
259
263
 
260
- - **api:** update assert(), re-export mixin() ([9f91cfa](https://github.com/thi-ng/umbrella/commit/9f91cfa))
264
+ - **api:** update assert(), re-export mixin() ([9f91cfa](https://github.com/thi-ng/umbrella/commit/9f91cfa))
261
265
 
262
- ### Build System
266
+ ### Build System
263
267
 
264
- - **api:** update package build scripts / outputs ([f913d7b](https://github.com/thi-ng/umbrella/commit/f913d7b))
268
+ - **api:** update package build scripts / outputs ([f913d7b](https://github.com/thi-ng/umbrella/commit/f913d7b))
265
269
 
266
- ### Features
270
+ ### Features
267
271
 
268
- - **api:** add assert() ([d381ace](https://github.com/thi-ng/umbrella/commit/d381ace))
272
+ - **api:** add assert() ([d381ace](https://github.com/thi-ng/umbrella/commit/d381ace))
269
273
 
270
- ### BREAKING CHANGES
274
+ ### BREAKING CHANGES
271
275
 
272
- - **api:** rename mixins to avoid name clashes, update decorators
273
- - append `Mixin` suffix to all mixins (i.e. `INotify` => `INotifyMixin`)
274
- - update re-exports of mixins & decorators (no more nested child namespace)
276
+ - **api:** rename mixins to avoid name clashes, update decorators
277
+ - append `Mixin` suffix to all mixins (i.e. `INotify` => `INotifyMixin`)
278
+ - update re-exports of mixins & decorators (no more nested child namespace)
275
279
 
276
- # [4.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@4.1.1...@thi.ng/api@4.2.0) (2018-09-22)
280
+ # [4.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@4.1.1...@thi.ng/api@4.2.0) (2018-09-22)
277
281
 
278
- ### Features
282
+ ### Features
279
283
 
280
- - **api:** add `IToHiccup` interface ([e390a54](https://github.com/thi-ng/umbrella/commit/e390a54))
284
+ - **api:** add `IToHiccup` interface ([e390a54](https://github.com/thi-ng/umbrella/commit/e390a54))
281
285
 
282
- # [4.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@4.0.6...@thi.ng/api@4.1.0) (2018-08-24)
286
+ # [4.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@4.0.6...@thi.ng/api@4.1.0) (2018-08-24)
283
287
 
284
- ### Features
288
+ ### Features
285
289
 
286
- - **api:** add new/move type aliases into api.ts ([cf30ba2](https://github.com/thi-ng/umbrella/commit/cf30ba2))
287
- - **api:** add NumericArray and TypedArray types ([519394b](https://github.com/thi-ng/umbrella/commit/519394b))
290
+ - **api:** add new/move type aliases into api.ts ([cf30ba2](https://github.com/thi-ng/umbrella/commit/cf30ba2))
291
+ - **api:** add NumericArray and TypedArray types ([519394b](https://github.com/thi-ng/umbrella/commit/519394b))
288
292
 
289
- # [4.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@3.0.1...@thi.ng/api@4.0.0) (2018-05-12)
293
+ # [4.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@3.0.1...@thi.ng/api@4.0.0) (2018-05-12)
290
294
 
291
- ### Code Refactoring
295
+ ### Code Refactoring
292
296
 
293
- - **api:** update interfaces, add docs ([9b38860](https://github.com/thi-ng/umbrella/commit/9b38860))
297
+ - **api:** update interfaces, add docs ([9b38860](https://github.com/thi-ng/umbrella/commit/9b38860))
294
298
 
295
- ### BREAKING CHANGES
299
+ ### BREAKING CHANGES
296
300
 
297
- - **api:** IBind, IEnable now include generics, update IIndexed, IMeta, ISet, IStack
298
- - add IInto
299
- - add IImmutableSet
300
- - add IImmutableStack
301
- - minor update IEnabled mixin
301
+ - **api:** IBind, IEnable now include generics, update IIndexed, IMeta, ISet, IStack
302
+ - add IInto
303
+ - add IImmutableSet
304
+ - add IImmutableStack
305
+ - minor update IEnabled mixin
302
306
 
303
- # [3.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.3.2...@thi.ng/api@3.0.0) (2018-05-10)
307
+ # [3.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.3.2...@thi.ng/api@3.0.0) (2018-05-10)
304
308
 
305
- ### Code Refactoring
309
+ ### Code Refactoring
306
310
 
307
- - **api:** remove obsolete files from package ([f051ca3](https://github.com/thi-ng/umbrella/commit/f051ca3))
311
+ - **api:** remove obsolete files from package ([f051ca3](https://github.com/thi-ng/umbrella/commit/f051ca3))
308
312
 
309
- ### BREAKING CHANGES
313
+ ### BREAKING CHANGES
310
314
 
311
- - **api:** @thi.ng/api now only contains type declarations, decorators and mixins. All other features have been moved to new dedicated packages:
312
- - @thi.ng/bench
313
- - @thi.ng/compare
314
- - @thi.ng/equiv
315
- - @thi.ng/errors
315
+ - **api:** @thi.ng/api now only contains type declarations, decorators and mixins. All other features have been moved to new dedicated packages:
316
+ - @thi.ng/bench
317
+ - @thi.ng/compare
318
+ - @thi.ng/equiv
319
+ - @thi.ng/errors
316
320
 
317
- ## [2.3.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.3.0...@thi.ng/api@2.3.1) (2018-04-29)
321
+ ## [2.3.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.3.0...@thi.ng/api@2.3.1) (2018-04-29)
318
322
 
319
- ### Performance Improvements
323
+ ### Performance Improvements
320
324
 
321
- - **api:** major speedup equivObject(), update equivSet() ([7fdf172](https://github.com/thi-ng/umbrella/commit/7fdf172))
325
+ - **api:** major speedup equivObject(), update equivSet() ([7fdf172](https://github.com/thi-ng/umbrella/commit/7fdf172))
322
326
 
323
- # [2.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.2.0...@thi.ng/api@2.3.0) (2018-04-26)
327
+ # [2.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.2.0...@thi.ng/api@2.3.0) (2018-04-26)
324
328
 
325
- ### Features
329
+ ### Features
326
330
 
327
- - **api:** support more types in equiv(), add tests ([2ac8bff](https://github.com/thi-ng/umbrella/commit/2ac8bff))
331
+ - **api:** support more types in equiv(), add tests ([2ac8bff](https://github.com/thi-ng/umbrella/commit/2ac8bff))
328
332
 
329
- # [2.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.1.3...@thi.ng/api@2.2.0) (2018-04-08)
333
+ # [2.2.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.1.3...@thi.ng/api@2.2.0) (2018-04-08)
330
334
 
331
- ### Features
335
+ ### Features
332
336
 
333
- - **api:** add bench() & timed() utils ([d310345](https://github.com/thi-ng/umbrella/commit/d310345))
337
+ - **api:** add bench() & timed() utils ([d310345](https://github.com/thi-ng/umbrella/commit/d310345))
334
338
 
335
- ## [2.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.1.0...@thi.ng/api@2.1.1) (2018-03-28)
339
+ ## [2.1.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.1.0...@thi.ng/api@2.1.1) (2018-03-28)
336
340
 
337
- ### Bug Fixes
341
+ ### Bug Fixes
338
342
 
339
- - **api:** illegalState() creates IllegalStateError ([2b7e99b](https://github.com/thi-ng/umbrella/commit/2b7e99b))
343
+ - **api:** illegalState() creates IllegalStateError ([2b7e99b](https://github.com/thi-ng/umbrella/commit/2b7e99b))
340
344
 
341
- # [2.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.0.4...@thi.ng/api@2.1.0) (2018-03-21)
345
+ # [2.1.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.0.4...@thi.ng/api@2.1.0) (2018-03-21)
342
346
 
343
- ### Features
347
+ ### Features
344
348
 
345
- - **api:** add error types & ctor fns ([4d3785f](https://github.com/thi-ng/umbrella/commit/4d3785f))
349
+ - **api:** add error types & ctor fns ([4d3785f](https://github.com/thi-ng/umbrella/commit/4d3785f))
346
350
 
347
- ## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.0.0...@thi.ng/api@2.0.1) (2018-02-02)
351
+ ## [2.0.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@2.0.0...@thi.ng/api@2.0.1) (2018-02-02)
348
352
 
349
- ### Bug Fixes
353
+ ### Bug Fixes
350
354
 
351
- - **api:** update compare() & equiv() ([110a9de](https://github.com/thi-ng/umbrella/commit/110a9de))
355
+ - **api:** update compare() & equiv() ([110a9de](https://github.com/thi-ng/umbrella/commit/110a9de))
352
356
 
353
- # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@1.5.0...@thi.ng/api@2.0.0) (2018-02-01)
357
+ # [2.0.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@1.5.0...@thi.ng/api@2.0.0) (2018-02-01)
354
358
 
355
- ### Bug Fixes
359
+ ### Bug Fixes
356
360
 
357
- - **api:** fix equiv string handling, update tests ([1354e29](https://github.com/thi-ng/umbrella/commit/1354e29))
361
+ - **api:** fix equiv string handling, update tests ([1354e29](https://github.com/thi-ng/umbrella/commit/1354e29))
358
362
 
359
- ### Features
363
+ ### Features
360
364
 
361
- - **api:** update equiv() null handling, add tests ([878520e](https://github.com/thi-ng/umbrella/commit/878520e))
365
+ - **api:** update equiv() null handling, add tests ([878520e](https://github.com/thi-ng/umbrella/commit/878520e))
362
366
 
363
- ### BREAKING CHANGES
367
+ ### BREAKING CHANGES
364
368
 
365
- - **api:** equiv now treats null & undefined as equal
369
+ - **api:** equiv now treats null & undefined as equal
366
370
 
367
- # [1.5.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@1.4.2...@thi.ng/api@1.5.0) (2018-01-31)
371
+ # [1.5.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@1.4.2...@thi.ng/api@1.5.0) (2018-01-31)
368
372
 
369
- ### Features
373
+ ### Features
370
374
 
371
- - **api:** add Predicate2 & StatefulPredicate2 types ([fbf8453](https://github.com/thi-ng/umbrella/commit/fbf8453))
375
+ - **api:** add Predicate2 & StatefulPredicate2 types ([fbf8453](https://github.com/thi-ng/umbrella/commit/fbf8453))
372
376
 
373
- # [1.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@1.3.0...@thi.ng/api@1.4.0) (2018-01-29)
377
+ # [1.4.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@1.3.0...@thi.ng/api@1.4.0) (2018-01-29)
374
378
 
375
- ### Features
379
+ ### Features
376
380
 
377
- - **api:** update IWatch & mixin, boolean returns ([bddd5ce](https://github.com/thi-ng/umbrella/commit/bddd5ce))
381
+ - **api:** update IWatch & mixin, boolean returns ([bddd5ce](https://github.com/thi-ng/umbrella/commit/bddd5ce))
378
382
 
379
- # [1.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@1.2.1...@thi.ng/api@1.3.0) (2018-01-28)
383
+ # [1.3.0](https://github.com/thi-ng/umbrella/compare/@thi.ng/api@1.2.1...@thi.ng/api@1.3.0) (2018-01-28)
380
384
 
381
- ### Features
385
+ ### Features
382
386
 
383
387
  - **api:** add StatefulPredicate ([c74353b](https://github.com/thi-ng/umbrella/commit/c74353b))
package/README.md CHANGED
@@ -60,7 +60,7 @@ node --experimental-repl-await
60
60
  > const api = await import("@thi.ng/api");
61
61
  ```
62
62
 
63
- Package sizes (gzipped, pre-treeshake): ESM: 1.73 KB
63
+ Package sizes (gzipped, pre-treeshake): ESM: 2.27 KB
64
64
 
65
65
  ## Dependencies
66
66
 
package/grid.d.ts ADDED
@@ -0,0 +1,351 @@
1
+ import type { NumericArray, TypedArray } from "./typedarray.js";
2
+ export interface INDBase<BUF extends any[] | TypedArray = any[]> {
3
+ size: NumericArray;
4
+ stride: NumericArray;
5
+ offset: number;
6
+ data: BUF;
7
+ readonly dim: number;
8
+ order(): number[];
9
+ }
10
+ /**
11
+ * Semi-typechecked interface for cases accepting 1D-4D grids, i.e.
12
+ * {@link IGrid1D} - {@link IGrid4D}.
13
+ */
14
+ export interface IGridND<BUF extends any[] | TypedArray = any[], T = any> extends INDBase<BUF> {
15
+ /**
16
+ * Returns true if given position is valid (i.e. within grid bounds).
17
+ *
18
+ * @param pos -
19
+ */
20
+ includes(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): boolean;
21
+ /**
22
+ * Returns index for given position. Returns negative value if outside the
23
+ * grid's defined region.
24
+ *
25
+ * @param pos -
26
+ */
27
+ indexAt(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): number;
28
+ /**
29
+ * Non-boundschecked version of {@link IGridND.indexAt}. Assumes given
30
+ * position is valid.
31
+ *
32
+ * @param pos -
33
+ */
34
+ indexAtUnsafe(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): number;
35
+ /**
36
+ * Returns value at given position. If outside the grid's defined region,
37
+ * returns a suitable zero value.
38
+ *
39
+ * @param pos -
40
+ */
41
+ getAt(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): T;
42
+ /**
43
+ * Non-boundschecked version of {@link IGridND.getAt}. Assumes given
44
+ * position is valid.
45
+ *
46
+ * @param pos -
47
+ */
48
+ getAtUnsafe(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): T;
49
+ /**
50
+ * Writes value at given position. Has no effect if outside of the defined
51
+ * region. Returns true, if succeeded.
52
+ *
53
+ * @param args -
54
+ */
55
+ setAt(...args: [number, T] | [number, number, T] | [number, number, number, T] | [number, number, number, number, T]): boolean;
56
+ /**
57
+ * Non-boundschecked version of {@link IGridND.setAt}. Assumes given
58
+ * position is valid. Returns true, if succeeded.
59
+ *
60
+ * @param args -
61
+ */
62
+ setAtUnsafe(...args: [number, T] | [number, number, T] | [number, number, number, T] | [number, number, number, number, T]): boolean;
63
+ }
64
+ /**
65
+ * Gridlike container for 1D accessible data.
66
+ *
67
+ * @remarks
68
+ * See {@link IGrid1DMixin} for mixin implementation.
69
+ */
70
+ export interface IGrid1D<BUF extends any[] | TypedArray = any[], T = any> extends INDBase<BUF> {
71
+ readonly dim: 1;
72
+ /**
73
+ * Returns true if given position is valid (i.e. within grid bounds).
74
+ *
75
+ * @param d0 -
76
+ */
77
+ includes(d0: number): boolean;
78
+ /**
79
+ * Returns index for given position. Returns negative value if outside the
80
+ * grid's defined region.
81
+ *
82
+ * @param d0 -
83
+ */
84
+ indexAt(d0: number): number;
85
+ /**
86
+ * Non-boundschecked version of {@link IGrid1D.indexAt}. Assumes given
87
+ * position is valid.
88
+ *
89
+ * @param d0 -
90
+ */
91
+ indexAtUnsafe(d0: number): number;
92
+ /**
93
+ * Returns value at given position. If outside the grid's defined region,
94
+ * returns a suitable zero value.
95
+ *
96
+ * @param d0 -
97
+ */
98
+ getAt(d0: number): T;
99
+ /**
100
+ * Non-boundschecked version of {@link IGrid1D.getAt}. Assumes given
101
+ * position is valid.
102
+ *
103
+ * @param d0 -
104
+ */
105
+ getAtUnsafe(d0: number): T;
106
+ /**
107
+ * Writes value at given position. Has no effect if outside of the defined
108
+ * region. Returns true, if succeeded.
109
+ *
110
+ * @param d0 -
111
+ * @param value -
112
+ */
113
+ setAt(d0: number, value: T): boolean;
114
+ /**
115
+ * Non-boundschecked version of {@link IGrid1D.setAt}. Assumes given
116
+ * position is valid. Returns true, if succeeded.
117
+ *
118
+ * @param d0 -
119
+ * @param value -
120
+ */
121
+ setAtUnsafe(d0: number, value: T): boolean;
122
+ }
123
+ /**
124
+ * Gridlike container for 2D accessible data.
125
+ *
126
+ * @remarks
127
+ * See {@link IGrid2DMixin} for mixin implementation.
128
+ */
129
+ export interface IGrid2D<BUF extends any[] | TypedArray = any[], T = any> extends INDBase<BUF> {
130
+ readonly dim: 2;
131
+ /**
132
+ * Returns true if given position is valid (i.e. within grid bounds).
133
+ *
134
+ * @param d0 -
135
+ * @param d1 -
136
+ */
137
+ includes(d0: number, d1: number): boolean;
138
+ /**
139
+ * Returns index for given position (stated in same order as
140
+ * {@link IGrid2D.size} and {@link IGrid2D.stride}). Returns negative value
141
+ * if outside the grid's defined region.
142
+ *
143
+ * @param d0 -
144
+ * @param d1 -
145
+ */
146
+ indexAt(d0: number, d1: number): number;
147
+ /**
148
+ * Non-boundschecked version of {@link IGrid2D.indexAt}. Assumes given
149
+ * position is valid.
150
+ *
151
+ * @param d0 -
152
+ * @param d1 -
153
+ */
154
+ indexAtUnsafe(d0: number, d1: number): number;
155
+ /**
156
+ * Returns value at given position (given in same order as
157
+ * {@link IGrid2D.size} and {@link IGrid2D.stride}). If outside the grid's
158
+ * defined region, returns a suitable zero value.
159
+ *
160
+ * @param d0 -
161
+ * @param d1 -
162
+ */
163
+ getAt(d0: number, d1: number): T;
164
+ /**
165
+ * Non-boundschecked version of {@link IGrid2D.getAt}. Assumes given
166
+ * position is valid.
167
+ *
168
+ * @param d0 -
169
+ * @param d1 -
170
+ */
171
+ getAtUnsafe(d0: number, d1: number): T;
172
+ /**
173
+ * Writes value at given position (given in same order as
174
+ * {@link IGrid2D.size} and {@link IGrid2D.stride}). Has no effect if
175
+ * outside of the defined region. Returns true, if succeeded.
176
+ *
177
+ * @param d0 -
178
+ * @param d1 -
179
+ * @param value -
180
+ */
181
+ setAt(d0: number, d1: number, value: T): boolean;
182
+ /**
183
+ * Non-boundschecked version of {@link IGrid2D.setAt}. Assumes given
184
+ * position is valid. Returns true, if succeeded.
185
+ *
186
+ * @param d0 -
187
+ * @param d1 -
188
+ * @param value -
189
+ */
190
+ setAtUnsafe(d0: number, d1: number, value: T): boolean;
191
+ }
192
+ /**
193
+ * Gridlike container for 3D accessible data.
194
+ *
195
+ * @remarks
196
+ * See {@link IGrid3DMixin} for mixin implementation.
197
+ */
198
+ export interface IGrid3D<BUF extends any[] | TypedArray = any[], T = any> extends INDBase<BUF> {
199
+ readonly dim: 3;
200
+ /**
201
+ * Returns true if given position is valid (i.e. within grid bounds).
202
+ *
203
+ * @param d0 -
204
+ * @param d1 -
205
+ * @param d2 -
206
+ */
207
+ includes(d0: number, d1: number, d2: number): boolean;
208
+ /**
209
+ * Returns index for given position (stated in same order as
210
+ * {@link IGrid3D.size} and {@link IGrid3D.stride}). Returns negative value
211
+ * if outside the grid's defined region.
212
+ *
213
+ * @param d0 -
214
+ * @param d1 -
215
+ * @param d2 -
216
+ */
217
+ indexAt(d0: number, d1: number, d2: number): number;
218
+ /**
219
+ * Non-boundschecked version of {@link IGrid3D.indexAt}. Assumes given
220
+ * position is valid.
221
+ *
222
+ * @param d0 -
223
+ * @param d1 -
224
+ * @param d2 -
225
+ */
226
+ indexAtUnsafe(d0: number, d1: number, d2: number): number;
227
+ /**
228
+ * Returns value at given position (given in same order as
229
+ * {@link IGrid3D.size} and {@link IGrid3D.stride}). If outside the grid's
230
+ * defined region, returns a suitable zero value.
231
+ *
232
+ * @param d0 -
233
+ * @param d1 -
234
+ * @param d2 -
235
+ */
236
+ getAt(d0: number, d1: number, d2: number): T;
237
+ /**
238
+ * Non-boundschecked version of {@link IGrid3D.getAt}. Assumes given
239
+ * position is valid.
240
+ *
241
+ * @param d0 -
242
+ * @param d1 -
243
+ * @param d2 -
244
+ */
245
+ getAtUnsafe(d0: number, d1: number, d2: number): T;
246
+ /**
247
+ * Writes value at given position (given in same order as
248
+ * {@link IGrid3D.size} and {@link IGrid3D.stride}). Has no effect if
249
+ * outside of the defined region. Returns true, if succeeded.
250
+ *
251
+ * @param d0 -
252
+ * @param d1 -
253
+ * @param d2 -
254
+ * @param value -
255
+ */
256
+ setAt(d0: number, d1: number, d2: number, value: T): boolean;
257
+ /**
258
+ * Non-boundschecked version of {@link IGrid3D.setAt}. Assumes given
259
+ * position is valid. Returns true, if succeeded.
260
+ *
261
+ * @param d0 -
262
+ * @param d1 -
263
+ * @param d2 -
264
+ * @param value -
265
+ */
266
+ setAtUnsafe(d0: number, d1: number, d2: number, value: T): boolean;
267
+ }
268
+ /**
269
+ * Gridlike container for 4D accessible data.
270
+ *
271
+ * @remarks
272
+ * See {@link IGrid4DMixin} for mixin implementation.
273
+ */
274
+ export interface IGrid4D<BUF extends any[] | TypedArray = any[], T = any> extends INDBase<BUF> {
275
+ readonly dim: 4;
276
+ /**
277
+ * Returns true if given position is valid (i.e. within grid bounds).
278
+ *
279
+ * @param d0 -
280
+ * @param d1 -
281
+ * @param d2 -
282
+ * @param d3 -
283
+ */
284
+ includes(d0: number, d1: number, d2: number, d3: number): boolean;
285
+ /**
286
+ * Returns index for given position (stated in same order as
287
+ * {@link IGrid4D.size} and {@link IGrid4D.stride}). Returns negative value
288
+ * if outside the grid's defined region.
289
+ *
290
+ * @param d0 -
291
+ * @param d1 -
292
+ * @param d2 -
293
+ * @param d3 -
294
+ */
295
+ indexAt(d0: number, d1: number, d2: number, d3: number): number;
296
+ /**
297
+ * Non-boundschecked version of {@link IGrid4D.indexAt}. Assumes given
298
+ * position is valid.
299
+ *
300
+ * @param d0 -
301
+ * @param d1 -
302
+ * @param d2 -
303
+ * @param d3 -
304
+ */
305
+ indexAtUnsafe(d0: number, d1: number, d2: number, d3: number): number;
306
+ /**
307
+ * Returns value at given position (given in same order as
308
+ * {@link IGrid4D.size} and {@link IGrid4D.stride}). If outside the grid's
309
+ * defined region, returns a suitable zero value.
310
+ *
311
+ * @param d0 -
312
+ * @param d1 -
313
+ * @param d2 -
314
+ * @param d3 -
315
+ */
316
+ getAt(d0: number, d1: number, d2: number, d3: number): T;
317
+ /**
318
+ * Non-boundschecked version of {@link IGrid4D.getAt}. Assumes given
319
+ * position is valid.
320
+ *
321
+ * @param d0 -
322
+ * @param d1 -
323
+ * @param d2 -
324
+ * @param d3 -
325
+ */
326
+ getAtUnsafe(d0: number, d1: number, d2: number, d3: number): T;
327
+ /**
328
+ * Writes value at given position (given in same order as
329
+ * {@link IGrid4D.size} and {@link IGrid4D.stride}). Has no effect if
330
+ * outside of the defined region. Returns true, if succeeded.
331
+ *
332
+ * @param d0 -
333
+ * @param d1 -
334
+ * @param d2 -
335
+ * @param d3 -
336
+ * @param value -
337
+ */
338
+ setAt(d0: number, d1: number, d2: number, d3: number, value: T): boolean;
339
+ /**
340
+ * Non-boundschecked version of {@link IGrid4D.setAt}. Assumes given
341
+ * position is valid. Returns true, if succeeded.
342
+ *
343
+ * @param d0 -
344
+ * @param d1 -
345
+ * @param d2 -
346
+ * @param d3 -
347
+ * @param value -
348
+ */
349
+ setAtUnsafe(d0: number, d1: number, d2: number, d3: number, value: T): boolean;
350
+ }
351
+ //# sourceMappingURL=grid.d.ts.map
package/grid.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/index.d.ts CHANGED
@@ -13,6 +13,7 @@ export * from "./equiv.js";
13
13
  export * from "./event.js";
14
14
  export * from "./fn.js";
15
15
  export * from "./get.js";
16
+ export * from "./grid.js";
16
17
  export * from "./hash.js";
17
18
  export * from "./hiccup.js";
18
19
  export * from "./id.js";
@@ -43,6 +44,7 @@ export * from "./decorators/deprecated.js";
43
44
  export * from "./decorators/nomixin.js";
44
45
  export * from "./decorators/sealed.js";
45
46
  export * from "./mixins/ienable.js";
47
+ export * from "./mixins/igrid.js";
46
48
  export * from "./mixins/inotify.js";
47
49
  export * from "./mixins/iterable.js";
48
50
  export * from "./mixins/iwatch.js";
package/index.js CHANGED
@@ -13,6 +13,7 @@ export * from "./equiv.js";
13
13
  export * from "./event.js";
14
14
  export * from "./fn.js";
15
15
  export * from "./get.js";
16
+ export * from "./grid.js";
16
17
  export * from "./hash.js";
17
18
  export * from "./hiccup.js";
18
19
  export * from "./id.js";
@@ -43,6 +44,7 @@ export * from "./decorators/deprecated.js";
43
44
  export * from "./decorators/nomixin.js";
44
45
  export * from "./decorators/sealed.js";
45
46
  export * from "./mixins/ienable.js";
47
+ export * from "./mixins/igrid.js";
46
48
  export * from "./mixins/inotify.js";
47
49
  export * from "./mixins/iterable.js";
48
50
  export * from "./mixins/iwatch.js";
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Default implementation for {@link IGrid1D} methods.
3
+ */
4
+ export declare const IGrid1DMixin: (clazz: any) => any;
5
+ /**
6
+ * Default implementation for {@link IGrid2D} methods.
7
+ */
8
+ export declare const IGrid2DMixin: (clazz: any) => any;
9
+ /**
10
+ * Default implementation for {@link IGrid3D} methods.
11
+ */
12
+ export declare const IGrid3DMixin: (clazz: any) => any;
13
+ /**
14
+ * Default implementation for {@link IGrid4D} methods.
15
+ */
16
+ export declare const IGrid4DMixin: (clazz: any) => any;
17
+ //# sourceMappingURL=igrid.d.ts.map
@@ -0,0 +1,163 @@
1
+ import { mixin } from "../mixin.js";
2
+ /**
3
+ * Default implementation for {@link IGrid1D} methods.
4
+ */
5
+ export const IGrid1DMixin = mixin({
6
+ order() {
7
+ return [0];
8
+ },
9
+ includes(x) {
10
+ return x >= 0 && x < this.size[0];
11
+ },
12
+ indexAt(x) {
13
+ return this.includes(x) ? this.indexAtUnsafe(x) : -1;
14
+ },
15
+ indexAtUnsafe(x) {
16
+ return this.offset + (x | 0) * this.stride[0];
17
+ },
18
+ getAt(x) {
19
+ return this.includes(x) ? this.data[this.indexAtUnsafe(x)] : 0;
20
+ },
21
+ getAtUnsafe(x) {
22
+ return this.data[this.indexAtUnsafe(x)];
23
+ },
24
+ setAt(x, val) {
25
+ return this.includes(x)
26
+ ? ((this.data[this.indexAtUnsafe(x)] = val), true)
27
+ : false;
28
+ },
29
+ setAtUnsafe(x, val) {
30
+ this.data[this.indexAtUnsafe(x)] = val;
31
+ return true;
32
+ },
33
+ });
34
+ /**
35
+ * Default implementation for {@link IGrid2D} methods.
36
+ */
37
+ export const IGrid2DMixin = mixin({
38
+ order() {
39
+ return Math.abs(this.stride[1]) > Math.abs(this.stride[0])
40
+ ? [1, 0]
41
+ : [0, 1];
42
+ },
43
+ includes(x, y) {
44
+ const size = this.size;
45
+ return x >= 0 && x < size[0] && y >= 0 && y < size[1];
46
+ },
47
+ indexAt(x, y) {
48
+ return this.includes(x, y) ? this.indexAtUnsafe(x, y) : -1;
49
+ },
50
+ indexAtUnsafe(x, y) {
51
+ return (this.offset + (x | 0) * this.stride[0] + (y | 0) * this.stride[1]);
52
+ },
53
+ getAt(x, y) {
54
+ return this.includes(x, y) ? this.data[this.indexAtUnsafe(x, y)] : 0;
55
+ },
56
+ getAtUnsafe(x, y) {
57
+ return this.data[this.indexAtUnsafe(x, y)];
58
+ },
59
+ setAt(x, y, val) {
60
+ return this.includes(x, y)
61
+ ? ((this.data[this.indexAtUnsafe(x, y)] = val), true)
62
+ : false;
63
+ },
64
+ setAtUnsafe(x, y, val) {
65
+ this.data[this.indexAtUnsafe(x, y)] = val;
66
+ return true;
67
+ },
68
+ });
69
+ /**
70
+ * Default implementation for {@link IGrid3D} methods.
71
+ */
72
+ export const IGrid3DMixin = mixin({
73
+ order() {
74
+ return strideOrder(this.stride);
75
+ },
76
+ includes(x, y, z) {
77
+ const size = this.size;
78
+ return (x >= 0 &&
79
+ x < size[0] &&
80
+ y >= 0 &&
81
+ y < size[1] &&
82
+ z >= 0 &&
83
+ z < size[2]);
84
+ },
85
+ indexAt(x, y, z) {
86
+ return this.includes(x, y, z) ? this.indexAtUnsafe(x, y, z) : -1;
87
+ },
88
+ indexAtUnsafe(x, y, z) {
89
+ const stride = this.stride;
90
+ return (this.offset +
91
+ (x | 0) * stride[0] +
92
+ (y | 0) * stride[1] +
93
+ (z | 0) * stride[2]);
94
+ },
95
+ getAt(x, y, z) {
96
+ return this.includes(x, y, z)
97
+ ? this.data[this.indexAtUnsafe(x, y, z)]
98
+ : 0;
99
+ },
100
+ getAtUnsafe(x, y, z) {
101
+ return this.data[this.indexAtUnsafe(x, y, z)];
102
+ },
103
+ setAt(x, y, z, val) {
104
+ return this.includes(x, y, z)
105
+ ? ((this.data[this.indexAtUnsafe(x, y, z)] = val), true)
106
+ : false;
107
+ },
108
+ setAtUnsafe(x, y, z, val) {
109
+ this.data[this.indexAtUnsafe(x, y, z)] = val;
110
+ return true;
111
+ },
112
+ });
113
+ /**
114
+ * Default implementation for {@link IGrid4D} methods.
115
+ */
116
+ export const IGrid4DMixin = mixin({
117
+ order() {
118
+ return strideOrder(this.stride);
119
+ },
120
+ includes(x, y, z, w) {
121
+ const size = this.size;
122
+ return (x >= 0 &&
123
+ x < size[0] &&
124
+ y >= 0 &&
125
+ y < size[1] &&
126
+ z >= 0 &&
127
+ z < size[2] &&
128
+ w >= 0 &&
129
+ w < size[3]);
130
+ },
131
+ indexAt(x, y, z, w) {
132
+ return this.includes(x, y, z, w) ? this.indexAtUnsafe(x, y, z, w) : -1;
133
+ },
134
+ indexAtUnsafe(x, y, z, w) {
135
+ const stride = this.stride;
136
+ return (this.offset +
137
+ (x | 0) * stride[0] +
138
+ (y | 0) * stride[1] +
139
+ (z | 0) * stride[2] +
140
+ (w | 0) * stride[3]);
141
+ },
142
+ getAt(x, y, z, w) {
143
+ return this.includes(x, y, z, w)
144
+ ? this.data[this.indexAtUnsafe(x, y, z, w)]
145
+ : 0;
146
+ },
147
+ getAtUnsafe(x, y, z, w) {
148
+ return this.data[this.indexAtUnsafe(x, y, z, w)];
149
+ },
150
+ setAt(x, y, z, w, val) {
151
+ return this.includes(x, y, z, w)
152
+ ? ((this.data[this.indexAtUnsafe(x, y, z, w)] = val), true)
153
+ : false;
154
+ },
155
+ setAtUnsafe(x, y, z, w, val) {
156
+ this.data[this.indexAtUnsafe(x, y, z, w)] = val;
157
+ return true;
158
+ },
159
+ });
160
+ const strideOrder = (strides) => [...strides]
161
+ .map((x, i) => [x, i])
162
+ .sort((a, b) => Math.abs(b[0]) - Math.abs(a[0]))
163
+ .map((x) => x[1]);
package/mixins/inotify.js CHANGED
@@ -51,7 +51,7 @@ export const INotifyMixin = mixin({
51
51
  },
52
52
  __listener(listeners, f, scope) {
53
53
  let i = listeners.length;
54
- while (--i >= 0) {
54
+ while (i-- > 0) {
55
55
  const l = listeners[i];
56
56
  if (l[0] === f && l[1] === scope) {
57
57
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/api",
3
- "version": "8.0.3",
3
+ "version": "8.2.0",
4
4
  "description": "Common, generic types, interfaces & mixins",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -34,7 +34,7 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "devDependencies": {
37
- "@thi.ng/testament": "^0.1.3"
37
+ "@thi.ng/testament": "^0.1.6"
38
38
  },
39
39
  "keywords": [
40
40
  "assert",
@@ -126,6 +126,9 @@
126
126
  "./get": {
127
127
  "import": "./get.js"
128
128
  },
129
+ "./grid": {
130
+ "import": "./grid.js"
131
+ },
129
132
  "./hash": {
130
133
  "import": "./hash.js"
131
134
  },
@@ -156,6 +159,9 @@
156
159
  "./mixins/ienable": {
157
160
  "import": "./mixins/ienable.js"
158
161
  },
162
+ "./mixins/igrid": {
163
+ "import": "./mixins/igrid.js"
164
+ },
159
165
  "./mixins/inotify": {
160
166
  "import": "./mixins/inotify.js"
161
167
  },
@@ -211,5 +217,5 @@
211
217
  "import": "./watch.js"
212
218
  }
213
219
  },
214
- "gitHead": "1fb38cac74d6c009d96855c28784a267a81badf1"
220
+ "gitHead": "5fe52419af63984ebe53032201b2a6174b9cb159"
215
221
  }
package/typedarray.d.ts CHANGED
@@ -108,6 +108,10 @@ export declare const asNativeType: (type: GLType | Type) => Type;
108
108
  * @param type -
109
109
  */
110
110
  export declare const asGLType: (type: GLType | Type) => GLType;
111
+ /**
112
+ * Coerces given numeric args to integer values.
113
+ */
114
+ export declare const asInt: (...args: number[]) => number[];
111
115
  /**
112
116
  * Returns byte size for given {@link Type} ID or {@link GLType} enum.
113
117
  *
package/typedarray.js CHANGED
@@ -111,6 +111,10 @@ export const asGLType = (type) => {
111
111
  const t = TYPE2GL[type];
112
112
  return t !== undefined ? t : type;
113
113
  };
114
+ /**
115
+ * Coerces given numeric args to integer values.
116
+ */
117
+ export const asInt = (...args) => args.map((x) => x | 0);
114
118
  /**
115
119
  * Returns byte size for given {@link Type} ID or {@link GLType} enum.
116
120
  *