uneventful 0.0.4 → 0.0.6
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/dist/call-or-wait-DHkBd_bM.mjs +773 -0
- package/dist/call-or-wait-DHkBd_bM.mjs.map +1 -0
- package/dist/mod.d.ts +22 -1575
- package/dist/mod.mjs +8 -1341
- package/dist/mod.mjs.map +1 -1
- package/dist/signals.d.ts +470 -0
- package/dist/signals.mjs +590 -0
- package/dist/signals.mjs.map +1 -0
- package/dist/sinks-kEzJo6Hc.d.ts +182 -0
- package/dist/types-N2ua11te.d.ts +966 -0
- package/dist/utils.d.ts +58 -0
- package/dist/utils.mjs +18 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +25 -8
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { A as AnyFunction } from './types-N2ua11te.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utilities that aren't part of Uneventful's core feature set, but are exposed
|
|
5
|
+
* anyway, because they're boilerplate that can save duplication elsewhere if
|
|
6
|
+
* you happen to need them.
|
|
7
|
+
*
|
|
8
|
+
* @module uneventful/utils
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Set a value in a Map or WeakMap, and return the value.
|
|
13
|
+
*
|
|
14
|
+
* Commonly used with constructions like `return map.get(key) ?? setMap(map,
|
|
15
|
+
* key, calculateDefault())`.
|
|
16
|
+
*
|
|
17
|
+
* @template K The type of key accepted by the map
|
|
18
|
+
* @template V The type of value accepted by the map
|
|
19
|
+
*/
|
|
20
|
+
declare function setMap<K, V>(map: {
|
|
21
|
+
set(key: K, val: V): void;
|
|
22
|
+
}, key: K, val: V): V;
|
|
23
|
+
/**
|
|
24
|
+
* Is the given value a function? (Shorthand for `typeof f === "function"`)
|
|
25
|
+
*/
|
|
26
|
+
declare function isFunction(f: any): f is Function;
|
|
27
|
+
/**
|
|
28
|
+
* This class hides the implementation details of inheriting from Function in
|
|
29
|
+
* the documentation. (By default, typedoc exposes all the inherited properties
|
|
30
|
+
* and members, which we don't want. By inheriting from it instead of from
|
|
31
|
+
* Function, we keep the documentation free of unimportant details.)
|
|
32
|
+
*
|
|
33
|
+
* The way this works is that you subclass CallableObject and define a
|
|
34
|
+
* constructor that calls `super(someClosure)` where `someClosure` is a unique
|
|
35
|
+
* function object, which will then pick up any properties or methods defined by
|
|
36
|
+
* the subclass.
|
|
37
|
+
*
|
|
38
|
+
* @template T The call/return signature that instances of the class will
|
|
39
|
+
* implement.
|
|
40
|
+
*/
|
|
41
|
+
declare class CallableObject<T extends AnyFunction> extends Function {
|
|
42
|
+
/**
|
|
43
|
+
* @param fn A unique function or closure, to be passed to super() in a
|
|
44
|
+
* subclass. The function object will gain a prototype from `new.target`,
|
|
45
|
+
* thereby picking up any properties or methods defined by the class,
|
|
46
|
+
* and becoming `this` for the calling constructor.
|
|
47
|
+
*
|
|
48
|
+
* (Note that calling the constructor by any means other than super() from
|
|
49
|
+
* a constructor will result in an error or some other unhelpful result.)
|
|
50
|
+
*/
|
|
51
|
+
constructor(fn: T);
|
|
52
|
+
}
|
|
53
|
+
interface CallableObject<T extends AnyFunction> extends T {
|
|
54
|
+
}
|
|
55
|
+
declare const CallableObject: () => any;
|
|
56
|
+
declare const apply: typeof Reflect.apply;
|
|
57
|
+
|
|
58
|
+
export { CallableObject, apply, isFunction, setMap };
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function setMap(map, key, val) {
|
|
2
|
+
map.set(key, val);
|
|
3
|
+
return val;
|
|
4
|
+
}
|
|
5
|
+
function isFunction(f) {
|
|
6
|
+
return typeof f === "function";
|
|
7
|
+
}
|
|
8
|
+
const CallableObject = () => Object.assign(
|
|
9
|
+
function CallableObject2(fn) {
|
|
10
|
+
return Object.setPrototypeOf(fn, new.target.prototype);
|
|
11
|
+
},
|
|
12
|
+
{ prototype: Function.prototype }
|
|
13
|
+
// No need to have extra prototypes in the chain
|
|
14
|
+
);
|
|
15
|
+
const { apply } = Reflect;
|
|
16
|
+
|
|
17
|
+
export { CallableObject, apply, isFunction, setMap };
|
|
18
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../src/utils.ts"],"sourcesContent":["/**\n * Utilities that aren't part of Uneventful's core feature set, but are exposed\n * anyway, because they're boilerplate that can save duplication elsewhere if\n * you happen to need them.\n *\n * @module uneventful/utils\n */\nimport { AnyFunction } from \"./types.ts\";\n\n/**\n * Set a value in a Map or WeakMap, and return the value.\n *\n * Commonly used with constructions like `return map.get(key) ?? setMap(map,\n * key, calculateDefault())`.\n *\n * @template K The type of key accepted by the map\n * @template V The type of value accepted by the map\n */\nexport function setMap<K, V>(map: { set(key: K, val: V): void; }, key: K, val: V) {\n map.set(key, val);\n return val;\n}\n\n/**\n * Is the given value a function? (Shorthand for `typeof f === \"function\"`)\n */\nexport function isFunction(f: any): f is Function {\n return typeof f === \"function\";\n}\n\n/**\n * This class hides the implementation details of inheriting from Function in\n * the documentation. (By default, typedoc exposes all the inherited properties\n * and members, which we don't want. By inheriting from it instead of from\n * Function, we keep the documentation free of unimportant details.)\n *\n * The way this works is that you subclass CallableObject and define a\n * constructor that calls `super(someClosure)` where `someClosure` is a unique\n * function object, which will then pick up any properties or methods defined by\n * the subclass.\n *\n * @template T The call/return signature that instances of the class will\n * implement.\n */\n//@ts-ignore not really a duplicate\nexport declare class CallableObject<T extends AnyFunction> extends Function {\n /**\n * @param fn A unique function or closure, to be passed to super() in a\n * subclass. The function object will gain a prototype from `new.target`,\n * thereby picking up any properties or methods defined by the class,\n * and becoming `this` for the calling constructor.\n *\n * (Note that calling the constructor by any means other than super() from\n * a constructor will result in an error or some other unhelpful result.)\n */\n constructor(fn: T);\n /** @internal */ declare length: number;\n /** @internal */ declare arguments: any;\n /** @internal */ declare caller: Function;\n /** @internal */ declare prototype: any;\n /** @internal */ declare name: string;\n}\n//@ts-ignore CallableObject<T> adheres to the constraint of T in its *implementation*\nexport interface CallableObject<T extends AnyFunction> extends T {\n /** @internal */ [Symbol.hasInstance](value: any): boolean;\n /** @internal */ apply(this: Function, thisArg: any, argArray?: any): any;\n /** @internal */ bind(this: Function, thisArg: any, ...argArray: any[]): any;\n /** @internal */ call(this: Function, thisArg: any, ...argArray: any[]): any;\n /** @internal */ toString(): string;\n}\n//@ts-ignore This is the real implementation of the above declarations\nexport const CallableObject = /* @__PURE__ */ ( () => <typeof CallableObject> Object.assign(\n function CallableObject<T>(fn: T) { return Object.setPrototypeOf(fn, new.target.prototype); },\n {prototype: Function.prototype } // No need to have extra prototypes in the chain\n));\n\nexport const {apply} = Reflect;\n"],"names":[],"mappings":"AAAO,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE;AACtC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACpB,EAAE,OAAO,GAAG,CAAC;AACb,CAAC;AACM,SAAS,UAAU,CAAC,CAAC,EAAE;AAC9B,EAAE,OAAO,OAAO,CAAC,KAAK,UAAU,CAAC;AACjC,CAAC;AACW,MAAC,cAAc,GAAG,MAAM,MAAM,CAAC,MAAM;AACjD,EAAE,SAAS,eAAe,CAAC,EAAE,EAAE;AAC/B,IAAI,OAAO,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAC3D,GAAG;AACH,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE;AACnC;AACA,EAAE;AACU,MAAC,EAAE,KAAK,EAAE,GAAG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uneventful",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Declarative, event-driven reactivity: signals, streams, structured concurrency, and easy resource cleanup",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"signals",
|
|
@@ -15,11 +15,28 @@
|
|
|
15
15
|
"homepage": "https://uneventful.js.org",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"type": "module",
|
|
18
|
-
"
|
|
18
|
+
"types": "./dist/mod.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"./dist/*"
|
|
21
|
+
],
|
|
19
22
|
"exports": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
+
".": {
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/mod.d.ts",
|
|
26
|
+
"default": "./dist/mod.mjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"./signals": {
|
|
30
|
+
"import": {
|
|
31
|
+
"types": "./dist/signals.d.ts",
|
|
32
|
+
"default": "./dist/signals.mjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"./utils": {
|
|
36
|
+
"import": {
|
|
37
|
+
"types": "./dist/utils.d.ts",
|
|
38
|
+
"default": "./dist/utils.mjs"
|
|
39
|
+
}
|
|
23
40
|
}
|
|
24
41
|
},
|
|
25
42
|
"scripts": {
|
|
@@ -28,7 +45,7 @@
|
|
|
28
45
|
"watch": "mocha -r tsx --watch",
|
|
29
46
|
"watch-docs": "onchange -i --kill \"*.md\" \"guides/**/*.md\" \"typedoc.config.*\" \"typedoc/*\" -- tsx typedoc/run.mts --watch",
|
|
30
47
|
"test": "mocha -r tsx && pkgroll",
|
|
31
|
-
"prepare": "pkgroll --sourcemap"
|
|
48
|
+
"prepare": "pkgroll --sourcemap --clean-dist"
|
|
32
49
|
},
|
|
33
50
|
"mocha": {
|
|
34
51
|
"spec": "specs/*.spec.ts",
|
|
@@ -53,9 +70,9 @@
|
|
|
53
70
|
"chai": "^4.3.10",
|
|
54
71
|
"chai-as-promised": "^7.1.1",
|
|
55
72
|
"mocha": "^10.2.0",
|
|
56
|
-
"monkey-around": "^
|
|
73
|
+
"monkey-around": "^3",
|
|
57
74
|
"onchange": "^7.1.0",
|
|
58
|
-
"pkgroll": "^2.
|
|
75
|
+
"pkgroll": "^2.1",
|
|
59
76
|
"sinon": "^17.0.1",
|
|
60
77
|
"sinon-chai": "^3.7.0",
|
|
61
78
|
"ts-node": "^10.9.1",
|