@thi.ng/api 8.1.0 → 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 +16 -0
- package/README.md +1 -1
- package/grid.d.ts +318 -56
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/mixins/igrid.d.ts +17 -0
- package/mixins/igrid.js +163 -0
- package/mixins/inotify.js +1 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.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
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **api:** add missing module exports ([fc8805e](https://github.com/thi-ng/umbrella/commit/fc8805eb26a828d4ee9683c714a73a7ad35ef16c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **api:** update IGrid types, add mixins ([f0f3236](https://github.com/thi-ng/umbrella/commit/f0f3236448e7277e089654c725d2b9335bd4706a))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
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)
|
|
7
23
|
|
|
8
24
|
|
package/README.md
CHANGED
package/grid.d.ts
CHANGED
|
@@ -1,89 +1,351 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
|
|
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,
|
|
10
37
|
* returns a suitable zero value.
|
|
11
38
|
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param y -
|
|
39
|
+
* @param pos -
|
|
14
40
|
*/
|
|
15
|
-
getAt(
|
|
41
|
+
getAt(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): T;
|
|
16
42
|
/**
|
|
17
|
-
* Non-boundschecked version of {@link
|
|
43
|
+
* Non-boundschecked version of {@link IGridND.getAt}. Assumes given
|
|
18
44
|
* position is valid.
|
|
19
45
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param y -
|
|
46
|
+
* @param pos -
|
|
22
47
|
*/
|
|
23
|
-
getAtUnsafe(
|
|
48
|
+
getAtUnsafe(...pos: [number] | [number, number] | [number, number, number] | [number, number, number, number]): T;
|
|
24
49
|
/**
|
|
25
50
|
* Writes value at given position. Has no effect if outside of the defined
|
|
26
|
-
* region.
|
|
51
|
+
* region. Returns true, if succeeded.
|
|
27
52
|
*
|
|
28
|
-
* @param
|
|
29
|
-
* @param y -
|
|
30
|
-
* @param col -
|
|
53
|
+
* @param args -
|
|
31
54
|
*/
|
|
32
|
-
setAt(
|
|
55
|
+
setAt(...args: [number, T] | [number, number, T] | [number, number, number, T] | [number, number, number, number, T]): boolean;
|
|
33
56
|
/**
|
|
34
|
-
* Non-boundschecked version of {@link
|
|
35
|
-
* position is valid.
|
|
57
|
+
* Non-boundschecked version of {@link IGridND.setAt}. Assumes given
|
|
58
|
+
* position is valid. Returns true, if succeeded.
|
|
36
59
|
*
|
|
37
|
-
* @param
|
|
38
|
-
* @param y -
|
|
60
|
+
* @param args -
|
|
39
61
|
*/
|
|
40
|
-
setAtUnsafe(
|
|
62
|
+
setAtUnsafe(...args: [number, T] | [number, number, T] | [number, number, number, T] | [number, number, number, number, T]): boolean;
|
|
41
63
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
readonly
|
|
50
|
-
/**
|
|
51
|
-
* Returns
|
|
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,
|
|
52
94
|
* returns a suitable zero value.
|
|
53
95
|
*
|
|
54
|
-
* @param
|
|
55
|
-
* @param y -
|
|
56
|
-
* @param z -
|
|
96
|
+
* @param d0 -
|
|
57
97
|
*/
|
|
58
|
-
getAt(
|
|
98
|
+
getAt(d0: number): T;
|
|
59
99
|
/**
|
|
60
|
-
* Non-boundschecked version of {@link
|
|
100
|
+
* Non-boundschecked version of {@link IGrid1D.getAt}. Assumes given
|
|
61
101
|
* position is valid.
|
|
62
102
|
*
|
|
63
|
-
* @param
|
|
64
|
-
* @param y -
|
|
65
|
-
* @param z -
|
|
103
|
+
* @param d0 -
|
|
66
104
|
*/
|
|
67
|
-
getAtUnsafe(
|
|
105
|
+
getAtUnsafe(d0: number): T;
|
|
68
106
|
/**
|
|
69
107
|
* Writes value at given position. Has no effect if outside of the defined
|
|
70
|
-
* region.
|
|
108
|
+
* region. Returns true, if succeeded.
|
|
71
109
|
*
|
|
72
|
-
* @param
|
|
73
|
-
* @param
|
|
74
|
-
* @param z -
|
|
75
|
-
* @param col -
|
|
110
|
+
* @param d0 -
|
|
111
|
+
* @param value -
|
|
76
112
|
*/
|
|
77
|
-
setAt(
|
|
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;
|
|
78
257
|
/**
|
|
79
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
|
|
80
298
|
* position is valid.
|
|
81
299
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @param
|
|
84
|
-
* @param
|
|
85
|
-
* @param
|
|
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 -
|
|
86
348
|
*/
|
|
87
|
-
setAtUnsafe(
|
|
349
|
+
setAtUnsafe(d0: number, d1: number, d2: number, d3: number, value: T): boolean;
|
|
88
350
|
}
|
|
89
351
|
//# sourceMappingURL=grid.d.ts.map
|
package/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export * from "./decorators/deprecated.js";
|
|
|
44
44
|
export * from "./decorators/nomixin.js";
|
|
45
45
|
export * from "./decorators/sealed.js";
|
|
46
46
|
export * from "./mixins/ienable.js";
|
|
47
|
+
export * from "./mixins/igrid.js";
|
|
47
48
|
export * from "./mixins/inotify.js";
|
|
48
49
|
export * from "./mixins/iterable.js";
|
|
49
50
|
export * from "./mixins/iwatch.js";
|
package/index.js
CHANGED
|
@@ -44,6 +44,7 @@ export * from "./decorators/deprecated.js";
|
|
|
44
44
|
export * from "./decorators/nomixin.js";
|
|
45
45
|
export * from "./decorators/sealed.js";
|
|
46
46
|
export * from "./mixins/ienable.js";
|
|
47
|
+
export * from "./mixins/igrid.js";
|
|
47
48
|
export * from "./mixins/inotify.js";
|
|
48
49
|
export * from "./mixins/iterable.js";
|
|
49
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
|
package/mixins/igrid.js
ADDED
|
@@ -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/api",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "Common, generic types, interfaces & mixins",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -159,6 +159,9 @@
|
|
|
159
159
|
"./mixins/ienable": {
|
|
160
160
|
"import": "./mixins/ienable.js"
|
|
161
161
|
},
|
|
162
|
+
"./mixins/igrid": {
|
|
163
|
+
"import": "./mixins/igrid.js"
|
|
164
|
+
},
|
|
162
165
|
"./mixins/inotify": {
|
|
163
166
|
"import": "./mixins/inotify.js"
|
|
164
167
|
},
|
|
@@ -214,5 +217,5 @@
|
|
|
214
217
|
"import": "./watch.js"
|
|
215
218
|
}
|
|
216
219
|
},
|
|
217
|
-
"gitHead": "
|
|
220
|
+
"gitHead": "5fe52419af63984ebe53032201b2a6174b9cb159"
|
|
218
221
|
}
|