@thi.ng/api 8.9.11 → 8.9.13

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
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-12-09T19:12:03Z
3
+ - **Last updated**: 2023-12-18T13:41:19Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/README.md CHANGED
@@ -56,7 +56,7 @@ For Node.js REPL:
56
56
  const api = await import("@thi.ng/api");
57
57
  ```
58
58
 
59
- Package sizes (brotli'd, pre-treeshake): ESM: 2.39 KB
59
+ Package sizes (brotli'd, pre-treeshake): ESM: 2.37 KB
60
60
 
61
61
  ## Dependencies
62
62
 
package/api.js CHANGED
@@ -1,17 +1,15 @@
1
- export const DEFAULT_EPS = 1e-6;
2
- /**
3
- * Internal use only. **Do NOT use in user land code!**
4
- *
5
- * @internal
6
- */
7
- export const SEMAPHORE = Symbol();
8
- /**
9
- * No-effect placeholder function.
10
- */
11
- export const NO_OP = () => { };
12
- /**
13
- * Catch-all event ID
14
- */
15
- export const EVENT_ALL = "*";
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
- * Property decorator factory. Sets `configurable` flag of PropertyDescriptor
3
- * to given state.
4
- *
5
- * @param state - true, if propoerty is configurable
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
  };
@@ -1,20 +1,15 @@
1
- /**
2
- * Method property decorator factory. Augments original method with
3
- * deprecation message (via console), shown when method is invoked.
4
- * Accepts optional message arg. Throws error if assigned property
5
- * is not a function.
6
- *
7
- * @param msg - deprecation message
8
- */
9
- export const deprecated = (msg, log = console.log) => function (target, prop, descriptor) {
10
- const signature = `${target.constructor.name}#${prop.toString()}`;
11
- const fn = descriptor.value;
12
- if (typeof fn !== "function") {
13
- throw new Error(`${signature} is not a function`);
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
  };
@@ -1,10 +1,6 @@
1
- /**
2
- * Method property decorator. Sets `configurable` flag of
3
- * PropertyDescriptor to `false` (same as `@configurable(false)`).
4
- * Intended to be used in combination with mixin decorators to enable
5
- * partial implementations of mixed-in behaviors in target class and
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
  };
@@ -1,9 +1,7 @@
1
- /**
2
- * Class decorator. Seals both constructor and prototype.
3
- *
4
- * @param constructor - class ctor to seal
5
- */
6
- export const sealed = (constructor) => {
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
- * Returns true iff `x` implements {@link IDeref}.
3
- *
4
- * @param x -
5
- */
6
- export const isDeref = (x) => x != null && typeof x["deref"] === "function";
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
- * Identity function: `(x) => x`
3
- *
4
- * @param x
5
- */
6
- export const identity = (x) => x;
7
- /**
8
- * Zero-arg function always returning true.
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
- * Class behavior mixin based on:
3
- * - http://raganwald.com/2015/06/26/decorators-in-es7.html
4
- *
5
- * Additionally only injects/overwrites properties in target, which are NOT
6
- * marked with
7
- * [`@nomixin`](https://docs.thi.ng/umbrella/api/functions/nomixin.html) (i.e.
8
- * those which haven't set their `configurable` property descriptor flag to
9
- * `false`)
10
- *
11
- * @param behaviour - to mixin
12
- * @param sharedBehaviour -
13
- * @returns decorator function
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(_mixin, Symbol.hasInstance, {
42
- value: (x) => !!x[typeTag],
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
- return _mixin;
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
- * Mixin class decorator, injects IEnable default implementation, incl. a
5
- * `_enabled` property. If the target also implements the {@link INotify}
6
- * interface, {@link IEnable.enable} and {@link IEnable.disable} will
7
- * automatically emit the respective events.
8
- */
9
- export const IEnableMixin = mixin({
10
- _enabled: true,
11
- isEnabled() {
12
- return this._enabled;
13
- },
14
- enable() {
15
- $enable(this, true, EVENT_ENABLE);
16
- },
17
- disable() {
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
- target._enabled = state;
27
- if (target.notify) {
28
- target.notify({ id, target });
29
- }
20
+ target._enabled = state;
21
+ if (target.notify) {
22
+ target.notify({ id, target });
23
+ }
24
+ };
25
+ export {
26
+ IEnableMixin
30
27
  };