@thi.ng/api 8.8.2 → 8.9.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 +10 -1
- package/README.md +1 -1
- package/event.d.ts +12 -7
- package/fn.d.ts +14 -0
- package/fn.js +14 -1
- package/id.d.ts +16 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2023-
|
|
3
|
+
- **Last updated**: 2023-08-04T10:58: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.
|
|
@@ -9,6 +9,15 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [8.9.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/api@8.9.0) (2023-08-04)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add generics for Event & INotify ([7702882](https://github.com/thi-ng/umbrella/commit/7702882))
|
|
17
|
+
- add basic utility functions: identity, always, never ([4801e2d](https://github.com/thi-ng/umbrella/commit/4801e2d))
|
|
18
|
+
- add generics for INotify, Event, Listener types ([dd0a6ed](https://github.com/thi-ng/umbrella/commit/dd0a6ed))
|
|
19
|
+
- add IIDGen interface ([26cf9d1](https://github.com/thi-ng/umbrella/commit/26cf9d1))
|
|
20
|
+
|
|
12
21
|
## [8.8.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/api@8.8.0) (2023-04-19)
|
|
13
22
|
|
|
14
23
|
#### 🚀 Features
|
package/README.md
CHANGED
package/event.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { Fn } from "./fn.js";
|
|
2
2
|
import type { IID } from "./id.js";
|
|
3
3
|
/**
|
|
4
|
-
* Event listener.
|
|
4
|
+
* Event listener for {@link Event}.
|
|
5
5
|
*/
|
|
6
|
-
export type Listener = Fn<Event
|
|
7
|
-
|
|
6
|
+
export type Listener<T extends string = string> = Fn<Event<T>, void>;
|
|
7
|
+
/**
|
|
8
|
+
* Event type used in combination with {@link INotify}.
|
|
9
|
+
*/
|
|
10
|
+
export interface Event<T extends string = string> extends IID<T> {
|
|
8
11
|
target?: any;
|
|
9
12
|
canceled?: boolean;
|
|
10
13
|
value?: any;
|
|
@@ -12,10 +15,12 @@ export interface Event extends IID<PropertyKey> {
|
|
|
12
15
|
/**
|
|
13
16
|
* Interface to provide event emitter functionality. Also see
|
|
14
17
|
* {@link INotifyMixin} decorator mixin.
|
|
18
|
+
*
|
|
19
|
+
* The type param `T` can be used to constrain the event type/id.
|
|
15
20
|
*/
|
|
16
|
-
export interface INotify {
|
|
17
|
-
addListener(id:
|
|
18
|
-
removeListener(id:
|
|
21
|
+
export interface INotify<T extends string = string> {
|
|
22
|
+
addListener(id: T, fn: Listener<T>, scope?: any): boolean;
|
|
23
|
+
removeListener(id: T, fn: Listener<T>, scope?: any): boolean;
|
|
19
24
|
/**
|
|
20
25
|
* Broadcasts all registered listeners for given event type (in order
|
|
21
26
|
* registration) and returns true if any of them have been successfully
|
|
@@ -29,6 +34,6 @@ export interface INotify {
|
|
|
29
34
|
*
|
|
30
35
|
* @param event
|
|
31
36
|
*/
|
|
32
|
-
notify(event: Event): boolean;
|
|
37
|
+
notify(event: Event<T>): boolean;
|
|
33
38
|
}
|
|
34
39
|
//# sourceMappingURL=event.d.ts.map
|
package/fn.d.ts
CHANGED
|
@@ -120,4 +120,18 @@ export type FnN7 = FnU7<number>;
|
|
|
120
120
|
export type FnN8 = FnU8<number>;
|
|
121
121
|
export type FnN9 = FnU9<number>;
|
|
122
122
|
export type FnN10 = FnU10<number>;
|
|
123
|
+
/**
|
|
124
|
+
* Identity function: `(x) => x`
|
|
125
|
+
*
|
|
126
|
+
* @param x
|
|
127
|
+
*/
|
|
128
|
+
export declare const identity: <T>(x: T) => T;
|
|
129
|
+
/**
|
|
130
|
+
* Zero-arg function always returning true.
|
|
131
|
+
*/
|
|
132
|
+
export declare const always: () => boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Zero-arg function always returning false.
|
|
135
|
+
*/
|
|
136
|
+
export declare const never: () => boolean;
|
|
123
137
|
//# sourceMappingURL=fn.d.ts.map
|
package/fn.js
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
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;
|
package/id.d.ts
CHANGED
|
@@ -4,4 +4,20 @@
|
|
|
4
4
|
export interface IID<T> {
|
|
5
5
|
readonly id: T;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Common minimal base interface for ID generators.
|
|
9
|
+
*/
|
|
10
|
+
export interface IIDGen<T> {
|
|
11
|
+
/**
|
|
12
|
+
* Returns next available ID (or throws an error if none available).
|
|
13
|
+
*/
|
|
14
|
+
next(): T;
|
|
15
|
+
/**
|
|
16
|
+
* Releases given ID (to be called when ID isn't needed anymore). Actual
|
|
17
|
+
* behavior is implementation specific.
|
|
18
|
+
*
|
|
19
|
+
* @param id
|
|
20
|
+
*/
|
|
21
|
+
free(id: T): boolean;
|
|
22
|
+
}
|
|
7
23
|
//# sourceMappingURL=id.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/api",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"description": "Common, generic types, interfaces & mixins",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"test": "testament test"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@microsoft/api-extractor": "^7.
|
|
41
|
-
"@thi.ng/testament": "^0.3.
|
|
40
|
+
"@microsoft/api-extractor": "^7.36.3",
|
|
41
|
+
"@thi.ng/testament": "^0.3.18",
|
|
42
42
|
"rimraf": "^5.0.1",
|
|
43
43
|
"tools": "^0.0.1",
|
|
44
44
|
"typedoc": "^0.24.8",
|
|
45
|
-
"typescript": "^5.1.
|
|
45
|
+
"typescript": "^5.1.6"
|
|
46
46
|
},
|
|
47
47
|
"keywords": [
|
|
48
48
|
"assert",
|
|
@@ -225,5 +225,5 @@
|
|
|
225
225
|
"default": "./watch.js"
|
|
226
226
|
}
|
|
227
227
|
},
|
|
228
|
-
"gitHead": "
|
|
228
|
+
"gitHead": "9fa3f7f8169efa30e3c71b43c82f77393581c3b5\n"
|
|
229
229
|
}
|