@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/CHANGELOG.md +1 -1
- package/README.md +1 -1
- package/api.js +15 -17
- package/assoc.js +0 -1
- package/bind.js +0 -1
- package/buffered.js +0 -1
- package/clear.js +0 -1
- package/compare.js +0 -1
- package/contains.js +0 -1
- package/copy.js +0 -1
- package/decorators/configurable.js +5 -8
- package/decorators/deprecated.js +14 -19
- package/decorators/nomixin.js +5 -9
- package/decorators/sealed.js +6 -8
- package/deref.js +6 -13
- package/dissoc.js +0 -1
- package/empty.js +0 -1
- package/enable.js +0 -1
- package/equiv.js +0 -1
- package/event.js +0 -1
- package/fn.js +8 -14
- package/get.js +0 -1
- package/grid.js +0 -1
- package/hash.js +0 -1
- package/hiccup.js +0 -1
- package/id.js +0 -1
- package/indexed.js +0 -1
- package/into.js +0 -1
- package/keyval.js +0 -1
- package/length.js +0 -1
- package/meta.js +0 -1
- package/mixin.js +31 -41
- package/mixins/ienable.js +22 -25
- package/mixins/igrid.js +116 -158
- package/mixins/inotify.js +57 -58
- package/mixins/iterable.js +7 -4
- package/mixins/iwatch.js +29 -26
- package/null.js +0 -1
- package/object.js +0 -1
- package/package.json +6 -4
- package/path.js +0 -1
- package/predicate.js +0 -1
- package/prim.js +0 -1
- package/range.js +0 -1
- package/release.js +0 -1
- package/reset.js +0 -1
- package/select.js +0 -1
- package/seq.js +0 -1
- package/set.js +0 -1
- package/stack.js +0 -1
- package/tuple.js +0 -1
- package/typedarray.js +142 -261
- package/watch.js +0 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
package/api.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export const EVENT_ENABLE = "enable";
|
|
17
|
-
export const EVENT_DISABLE = "disable";
|
|
1
|
+
const DEFAULT_EPS = 1e-6;
|
|
2
|
+
const SEMAPHORE = Symbol();
|
|
3
|
+
const NO_OP = () => {
|
|
4
|
+
};
|
|
5
|
+
const EVENT_ALL = "*";
|
|
6
|
+
const EVENT_ENABLE = "enable";
|
|
7
|
+
const EVENT_DISABLE = "disable";
|
|
8
|
+
export {
|
|
9
|
+
DEFAULT_EPS,
|
|
10
|
+
EVENT_ALL,
|
|
11
|
+
EVENT_DISABLE,
|
|
12
|
+
EVENT_ENABLE,
|
|
13
|
+
NO_OP,
|
|
14
|
+
SEMAPHORE
|
|
15
|
+
};
|
package/assoc.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/bind.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/buffered.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/clear.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/compare.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/contains.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/copy.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export const configurable = (state) => function (_, __, descriptor) {
|
|
8
|
-
descriptor.configurable = state;
|
|
1
|
+
const configurable = (state) => function(_, __, descriptor) {
|
|
2
|
+
descriptor.configurable = state;
|
|
3
|
+
};
|
|
4
|
+
export {
|
|
5
|
+
configurable
|
|
9
6
|
};
|
package/decorators/deprecated.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
descriptor.value = function () {
|
|
16
|
-
log(`DEPRECATED ${signature}: ${msg || "will be removed soon"}`);
|
|
17
|
-
return fn.apply(this, arguments);
|
|
18
|
-
};
|
|
19
|
-
return descriptor;
|
|
1
|
+
const deprecated = (msg, log = console.log) => function(target, prop, descriptor) {
|
|
2
|
+
const signature = `${target.constructor.name}#${prop.toString()}`;
|
|
3
|
+
const fn = descriptor.value;
|
|
4
|
+
if (typeof fn !== "function") {
|
|
5
|
+
throw new Error(`${signature} is not a function`);
|
|
6
|
+
}
|
|
7
|
+
descriptor.value = function() {
|
|
8
|
+
log(`DEPRECATED ${signature}: ${msg || "will be removed soon"}`);
|
|
9
|
+
return fn.apply(this, arguments);
|
|
10
|
+
};
|
|
11
|
+
return descriptor;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
deprecated
|
|
20
15
|
};
|
package/decorators/nomixin.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* avoid them being overidden by mixed-in behaviour.
|
|
7
|
-
*/
|
|
8
|
-
export const nomixin = (_, __, descriptor) => {
|
|
9
|
-
descriptor.configurable = false;
|
|
1
|
+
const nomixin = (_, __, descriptor) => {
|
|
2
|
+
descriptor.configurable = false;
|
|
3
|
+
};
|
|
4
|
+
export {
|
|
5
|
+
nomixin
|
|
10
6
|
};
|
package/decorators/sealed.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.seal(constructor);
|
|
8
|
-
Object.seal(constructor.prototype);
|
|
1
|
+
const sealed = (constructor) => {
|
|
2
|
+
Object.seal(constructor);
|
|
3
|
+
Object.seal(constructor.prototype);
|
|
4
|
+
};
|
|
5
|
+
export {
|
|
6
|
+
sealed
|
|
9
7
|
};
|
package/deref.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* If `x` implements {@link IDeref}, returns its wrapped value, else
|
|
9
|
-
* returns `x` itself.
|
|
10
|
-
*
|
|
11
|
-
* @param x -
|
|
12
|
-
*/
|
|
13
|
-
export const deref = (x) => (isDeref(x) ? x.deref() : x);
|
|
1
|
+
const isDeref = (x) => x != null && typeof x["deref"] === "function";
|
|
2
|
+
const deref = (x) => isDeref(x) ? x.deref() : x;
|
|
3
|
+
export {
|
|
4
|
+
deref,
|
|
5
|
+
isDeref
|
|
6
|
+
};
|
package/dissoc.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/empty.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/enable.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/equiv.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/event.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/fn.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
export const always = () => true;
|
|
11
|
-
/**
|
|
12
|
-
* Zero-arg function always returning false.
|
|
13
|
-
*/
|
|
14
|
-
export const never = () => false;
|
|
1
|
+
const identity = (x) => x;
|
|
2
|
+
const always = () => true;
|
|
3
|
+
const never = () => false;
|
|
4
|
+
export {
|
|
5
|
+
always,
|
|
6
|
+
identity,
|
|
7
|
+
never
|
|
8
|
+
};
|
package/get.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/grid.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/hash.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/hiccup.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/id.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/indexed.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/into.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/keyval.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/length.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/meta.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/mixin.js
CHANGED
|
@@ -1,45 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const mixin = (behaviour, sharedBehaviour = {}) => {
|
|
16
|
-
const instanceKeys = Reflect.ownKeys(behaviour);
|
|
17
|
-
const sharedKeys = Reflect.ownKeys(sharedBehaviour);
|
|
18
|
-
const typeTag = Symbol("isa");
|
|
19
|
-
function _mixin(clazz) {
|
|
20
|
-
for (let key of instanceKeys) {
|
|
21
|
-
const existing = Object.getOwnPropertyDescriptor(clazz.prototype, key);
|
|
22
|
-
if (!existing || existing.configurable) {
|
|
23
|
-
Object.defineProperty(clazz.prototype, key, {
|
|
24
|
-
value: behaviour[key],
|
|
25
|
-
writable: true,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
// console.log(`not patching: ${clazz.name}.${key.toString()}`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
Object.defineProperty(clazz.prototype, typeTag, { value: true });
|
|
33
|
-
return clazz;
|
|
34
|
-
}
|
|
35
|
-
for (let key of sharedKeys) {
|
|
36
|
-
Object.defineProperty(_mixin, key, {
|
|
37
|
-
value: sharedBehaviour[key],
|
|
38
|
-
enumerable: sharedBehaviour.propertyIsEnumerable(key),
|
|
1
|
+
const mixin = (behaviour, sharedBehaviour = {}) => {
|
|
2
|
+
const instanceKeys = Reflect.ownKeys(behaviour);
|
|
3
|
+
const sharedKeys = Reflect.ownKeys(sharedBehaviour);
|
|
4
|
+
const typeTag = Symbol("isa");
|
|
5
|
+
function _mixin(clazz) {
|
|
6
|
+
for (let key of instanceKeys) {
|
|
7
|
+
const existing = Object.getOwnPropertyDescriptor(
|
|
8
|
+
clazz.prototype,
|
|
9
|
+
key
|
|
10
|
+
);
|
|
11
|
+
if (!existing || existing.configurable) {
|
|
12
|
+
Object.defineProperty(clazz.prototype, key, {
|
|
13
|
+
value: behaviour[key],
|
|
14
|
+
writable: true
|
|
39
15
|
});
|
|
16
|
+
} else {
|
|
17
|
+
}
|
|
40
18
|
}
|
|
41
|
-
Object.defineProperty(
|
|
42
|
-
|
|
19
|
+
Object.defineProperty(clazz.prototype, typeTag, { value: true });
|
|
20
|
+
return clazz;
|
|
21
|
+
}
|
|
22
|
+
for (let key of sharedKeys) {
|
|
23
|
+
Object.defineProperty(_mixin, key, {
|
|
24
|
+
value: sharedBehaviour[key],
|
|
25
|
+
enumerable: sharedBehaviour.propertyIsEnumerable(key)
|
|
43
26
|
});
|
|
44
|
-
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(_mixin, Symbol.hasInstance, {
|
|
29
|
+
value: (x) => !!x[typeTag]
|
|
30
|
+
});
|
|
31
|
+
return _mixin;
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
mixin
|
|
45
35
|
};
|
package/mixins/ienable.js
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import { EVENT_DISABLE, EVENT_ENABLE } from "../api.js";
|
|
2
2
|
import { mixin } from "../mixin.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
$enable(this, false, EVENT_DISABLE);
|
|
19
|
-
},
|
|
20
|
-
toggle() {
|
|
21
|
-
this._enabled ? this.disable() : this.enable();
|
|
22
|
-
return this._enabled;
|
|
23
|
-
},
|
|
3
|
+
const IEnableMixin = mixin({
|
|
4
|
+
_enabled: true,
|
|
5
|
+
isEnabled() {
|
|
6
|
+
return this._enabled;
|
|
7
|
+
},
|
|
8
|
+
enable() {
|
|
9
|
+
$enable(this, true, EVENT_ENABLE);
|
|
10
|
+
},
|
|
11
|
+
disable() {
|
|
12
|
+
$enable(this, false, EVENT_DISABLE);
|
|
13
|
+
},
|
|
14
|
+
toggle() {
|
|
15
|
+
this._enabled ? this.disable() : this.enable();
|
|
16
|
+
return this._enabled;
|
|
17
|
+
}
|
|
24
18
|
});
|
|
25
19
|
const $enable = (target, state, id) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
target._enabled = state;
|
|
21
|
+
if (target.notify) {
|
|
22
|
+
target.notify({ id, target });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
IEnableMixin
|
|
30
27
|
};
|