@thi.ng/api 8.9.10 → 8.9.12

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/mixins/igrid.js CHANGED
@@ -1,163 +1,121 @@
1
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
- },
2
+ const IGrid1DMixin = mixin({
3
+ order() {
4
+ return [0];
5
+ },
6
+ includes(x) {
7
+ return x >= 0 && x < this.size[0];
8
+ },
9
+ indexAt(x) {
10
+ return this.includes(x) ? this.indexAtUnsafe(x) : -1;
11
+ },
12
+ indexAtUnsafe(x) {
13
+ return this.offset + (x | 0) * this.stride[0];
14
+ },
15
+ getAt(x) {
16
+ return this.includes(x) ? this.data[this.indexAtUnsafe(x)] : 0;
17
+ },
18
+ getAtUnsafe(x) {
19
+ return this.data[this.indexAtUnsafe(x)];
20
+ },
21
+ setAt(x, val) {
22
+ return this.includes(x) ? (this.data[this.indexAtUnsafe(x)] = val, true) : false;
23
+ },
24
+ setAtUnsafe(x, val) {
25
+ this.data[this.indexAtUnsafe(x)] = val;
26
+ return true;
27
+ }
33
28
  });
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
- },
29
+ const IGrid2DMixin = mixin({
30
+ order() {
31
+ return Math.abs(this.stride[1]) > Math.abs(this.stride[0]) ? [1, 0] : [0, 1];
32
+ },
33
+ includes(x, y) {
34
+ const size = this.size;
35
+ return x >= 0 && x < size[0] && y >= 0 && y < size[1];
36
+ },
37
+ indexAt(x, y) {
38
+ return this.includes(x, y) ? this.indexAtUnsafe(x, y) : -1;
39
+ },
40
+ indexAtUnsafe(x, y) {
41
+ return this.offset + (x | 0) * this.stride[0] + (y | 0) * this.stride[1];
42
+ },
43
+ getAt(x, y) {
44
+ return this.includes(x, y) ? this.data[this.indexAtUnsafe(x, y)] : 0;
45
+ },
46
+ getAtUnsafe(x, y) {
47
+ return this.data[this.indexAtUnsafe(x, y)];
48
+ },
49
+ setAt(x, y, val) {
50
+ return this.includes(x, y) ? (this.data[this.indexAtUnsafe(x, y)] = val, true) : false;
51
+ },
52
+ setAtUnsafe(x, y, val) {
53
+ this.data[this.indexAtUnsafe(x, y)] = val;
54
+ return true;
55
+ }
68
56
  });
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
- },
57
+ const IGrid3DMixin = mixin({
58
+ order() {
59
+ return strideOrder(this.stride);
60
+ },
61
+ includes(x, y, z) {
62
+ const size = this.size;
63
+ return x >= 0 && x < size[0] && y >= 0 && y < size[1] && z >= 0 && z < size[2];
64
+ },
65
+ indexAt(x, y, z) {
66
+ return this.includes(x, y, z) ? this.indexAtUnsafe(x, y, z) : -1;
67
+ },
68
+ indexAtUnsafe(x, y, z) {
69
+ const stride = this.stride;
70
+ return this.offset + (x | 0) * stride[0] + (y | 0) * stride[1] + (z | 0) * stride[2];
71
+ },
72
+ getAt(x, y, z) {
73
+ return this.includes(x, y, z) ? this.data[this.indexAtUnsafe(x, y, z)] : 0;
74
+ },
75
+ getAtUnsafe(x, y, z) {
76
+ return this.data[this.indexAtUnsafe(x, y, z)];
77
+ },
78
+ setAt(x, y, z, val) {
79
+ return this.includes(x, y, z) ? (this.data[this.indexAtUnsafe(x, y, z)] = val, true) : false;
80
+ },
81
+ setAtUnsafe(x, y, z, val) {
82
+ this.data[this.indexAtUnsafe(x, y, z)] = val;
83
+ return true;
84
+ }
112
85
  });
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
- },
86
+ const IGrid4DMixin = mixin({
87
+ order() {
88
+ return strideOrder(this.stride);
89
+ },
90
+ includes(x, y, z, w) {
91
+ const size = this.size;
92
+ return x >= 0 && x < size[0] && y >= 0 && y < size[1] && z >= 0 && z < size[2] && w >= 0 && w < size[3];
93
+ },
94
+ indexAt(x, y, z, w) {
95
+ return this.includes(x, y, z, w) ? this.indexAtUnsafe(x, y, z, w) : -1;
96
+ },
97
+ indexAtUnsafe(x, y, z, w) {
98
+ const stride = this.stride;
99
+ return this.offset + (x | 0) * stride[0] + (y | 0) * stride[1] + (z | 0) * stride[2] + (w | 0) * stride[3];
100
+ },
101
+ getAt(x, y, z, w) {
102
+ return this.includes(x, y, z, w) ? this.data[this.indexAtUnsafe(x, y, z, w)] : 0;
103
+ },
104
+ getAtUnsafe(x, y, z, w) {
105
+ return this.data[this.indexAtUnsafe(x, y, z, w)];
106
+ },
107
+ setAt(x, y, z, w, val) {
108
+ return this.includes(x, y, z, w) ? (this.data[this.indexAtUnsafe(x, y, z, w)] = val, true) : false;
109
+ },
110
+ setAtUnsafe(x, y, z, w, val) {
111
+ this.data[this.indexAtUnsafe(x, y, z, w)] = val;
112
+ return true;
113
+ }
159
114
  });
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]);
115
+ const strideOrder = (strides) => [...strides].map((x, i) => [x, i]).sort((a, b) => Math.abs(b[0]) - Math.abs(a[0])).map((x) => x[1]);
116
+ export {
117
+ IGrid1DMixin,
118
+ IGrid2DMixin,
119
+ IGrid3DMixin,
120
+ IGrid4DMixin
121
+ };
package/mixins/inotify.js CHANGED
@@ -1,63 +1,62 @@
1
1
  import { EVENT_ALL } from "../api.js";
2
2
  import { mixin } from "../mixin.js";
3
- export const inotify_dispatch = (listeners, e) => {
4
- if (!listeners)
5
- return false;
6
- for (let i = 0, n = listeners.length, l; i < n; i++) {
7
- l = listeners[i];
8
- l[0].call(l[1], e);
9
- if (e.canceled) {
10
- return false;
11
- }
3
+ const inotify_dispatch = (listeners, e) => {
4
+ if (!listeners)
5
+ return false;
6
+ for (let i = 0, n = listeners.length, l; i < n; i++) {
7
+ l = listeners[i];
8
+ l[0].call(l[1], e);
9
+ if (e.canceled) {
10
+ return false;
12
11
  }
13
- return true;
12
+ }
13
+ return true;
14
14
  };
15
- /**
16
- * Mixin class decorator, injects INotify default implementation, incl.
17
- * a lazily instantiated `_listeners` property object, storing
18
- * registered listeners.
19
- */
20
- export const INotifyMixin = mixin({
21
- addListener(id, fn, scope) {
22
- let l = (this._listeners = this._listeners || {})[id];
23
- !l && (l = this._listeners[id] = []);
24
- if (this.__listener(l, fn, scope) === -1) {
25
- l.push([fn, scope]);
26
- return true;
27
- }
28
- return false;
29
- },
30
- removeListener(id, fn, scope) {
31
- let listeners;
32
- if (!(listeners = this._listeners))
33
- return false;
34
- const l = listeners[id];
35
- if (l) {
36
- const idx = this.__listener(l, fn, scope);
37
- if (idx !== -1) {
38
- l.splice(idx, 1);
39
- !l.length && delete listeners[id];
40
- return true;
41
- }
42
- }
43
- return false;
44
- },
45
- notify(e) {
46
- let listeners;
47
- if (!(listeners = this._listeners))
48
- return false;
49
- e.target === undefined && (e.target = this);
50
- const res = inotify_dispatch(listeners[e.id], e);
51
- return inotify_dispatch(listeners[EVENT_ALL], e) || res;
52
- },
53
- __listener(listeners, f, scope) {
54
- let i = listeners.length;
55
- while (i-- > 0) {
56
- const l = listeners[i];
57
- if (l[0] === f && l[1] === scope) {
58
- break;
59
- }
60
- }
61
- return i;
62
- },
15
+ const INotifyMixin = mixin({
16
+ addListener(id, fn, scope) {
17
+ let l = (this._listeners = this._listeners || {})[id];
18
+ !l && (l = this._listeners[id] = []);
19
+ if (this.__listener(l, fn, scope) === -1) {
20
+ l.push([fn, scope]);
21
+ return true;
22
+ }
23
+ return false;
24
+ },
25
+ removeListener(id, fn, scope) {
26
+ let listeners;
27
+ if (!(listeners = this._listeners))
28
+ return false;
29
+ const l = listeners[id];
30
+ if (l) {
31
+ const idx = this.__listener(l, fn, scope);
32
+ if (idx !== -1) {
33
+ l.splice(idx, 1);
34
+ !l.length && delete listeners[id];
35
+ return true;
36
+ }
37
+ }
38
+ return false;
39
+ },
40
+ notify(e) {
41
+ let listeners;
42
+ if (!(listeners = this._listeners))
43
+ return false;
44
+ e.target === void 0 && (e.target = this);
45
+ const res = inotify_dispatch(listeners[e.id], e);
46
+ return inotify_dispatch(listeners[EVENT_ALL], e) || res;
47
+ },
48
+ __listener(listeners, f, scope) {
49
+ let i = listeners.length;
50
+ while (i-- > 0) {
51
+ const l = listeners[i];
52
+ if (l[0] === f && l[1] === scope) {
53
+ break;
54
+ }
55
+ }
56
+ return i;
57
+ }
63
58
  });
59
+ export {
60
+ INotifyMixin,
61
+ inotify_dispatch
62
+ };
@@ -1,6 +1,9 @@
1
1
  import { mixin } from "../mixin.js";
2
- export const iterable = (prop) => mixin({
3
- *[Symbol.iterator]() {
4
- yield* this[prop];
5
- },
2
+ const iterable = (prop) => mixin({
3
+ *[Symbol.iterator]() {
4
+ yield* this[prop];
5
+ }
6
6
  });
7
+ export {
8
+ iterable
9
+ };
package/mixins/iwatch.js CHANGED
@@ -1,28 +1,31 @@
1
1
  import { mixin } from "../mixin.js";
2
- export const IWatchMixin = mixin({
3
- addWatch(id, fn) {
4
- this._watches = this._watches || {};
5
- if (this._watches[id]) {
6
- return false;
7
- }
8
- this._watches[id] = fn;
9
- return true;
10
- },
11
- removeWatch(id) {
12
- if (!this._watches)
13
- return;
14
- if (this._watches[id]) {
15
- delete this._watches[id];
16
- return true;
17
- }
18
- return false;
19
- },
20
- notifyWatches(oldState, newState) {
21
- if (!this._watches)
22
- return;
23
- const w = this._watches;
24
- for (let id in w) {
25
- w[id](id, oldState, newState);
26
- }
27
- },
2
+ const IWatchMixin = mixin({
3
+ addWatch(id, fn) {
4
+ this._watches = this._watches || {};
5
+ if (this._watches[id]) {
6
+ return false;
7
+ }
8
+ this._watches[id] = fn;
9
+ return true;
10
+ },
11
+ removeWatch(id) {
12
+ if (!this._watches)
13
+ return;
14
+ if (this._watches[id]) {
15
+ delete this._watches[id];
16
+ return true;
17
+ }
18
+ return false;
19
+ },
20
+ notifyWatches(oldState, newState) {
21
+ if (!this._watches)
22
+ return;
23
+ const w = this._watches;
24
+ for (let id in w) {
25
+ w[id](id, oldState, newState);
26
+ }
27
+ }
28
28
  });
29
+ export {
30
+ IWatchMixin
31
+ };
package/null.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/object.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/api",
3
- "version": "8.9.10",
3
+ "version": "8.9.12",
4
4
  "description": "Common, generic types, interfaces & mixins",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -27,7 +27,9 @@
27
27
  ],
28
28
  "license": "Apache-2.0",
29
29
  "scripts": {
30
- "build": "yarn clean && tsc --declaration",
30
+ "build": "yarn build:esbuild && yarn build:decl",
31
+ "build:decl": "tsc --declaration --emitDeclarationOnly",
32
+ "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
31
33
  "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc api decorators mixins",
32
34
  "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
33
35
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
@@ -37,7 +39,7 @@
37
39
  },
38
40
  "devDependencies": {
39
41
  "@microsoft/api-extractor": "^7.38.3",
40
- "@thi.ng/testament": "^0.4.3",
42
+ "esbuild": "^0.19.8",
41
43
  "rimraf": "^5.0.5",
42
44
  "tools": "^0.0.1",
43
45
  "typedoc": "^0.25.4",
@@ -224,5 +226,5 @@
224
226
  "default": "./watch.js"
225
227
  }
226
228
  },
227
- "gitHead": "04d1de79f256d7a53c6b5fd157b37f49bc88e11d\n"
229
+ "gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
228
230
  }
package/path.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/predicate.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/prim.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/range.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/release.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/reset.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/select.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/seq.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/set.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/stack.js CHANGED
@@ -1 +0,0 @@
1
- export {};
package/tuple.js CHANGED
@@ -1 +0,0 @@
1
- export {};