@thi.ng/api 8.9.31 → 8.10.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-03-27T09:53:45Z
3
+ - **Last updated**: 2024-04-08T14:59:29Z
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,14 @@ 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.10.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/api@8.10.0) (2024-04-08)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add async types ([35ad820](https://github.com/thi-ng/umbrella/commit/35ad820))
17
+ - add async function types ([afb4200](https://github.com/thi-ng/umbrella/commit/afb4200))
18
+ - add Values<T> ([8a799ea](https://github.com/thi-ng/umbrella/commit/8a799ea))
19
+
12
20
  ## [8.9.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/api@8.9.0) (2023-08-04)
13
21
 
14
22
  #### 🚀 Features
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
8
8
 
9
9
  > [!NOTE]
10
- > This is one of 190 standalone projects, maintained as part
10
+ > This is one of 191 standalone projects, maintained as part
11
11
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
12
12
  > and anti-framework.
13
13
  >
@@ -46,7 +46,13 @@ defines:
46
46
  yarn add @thi.ng/api
47
47
  ```
48
48
 
49
- ES module import:
49
+ ESM import:
50
+
51
+ ```ts
52
+ import * as api from "@thi.ng/api";
53
+ ```
54
+
55
+ Browser ESM import:
50
56
 
51
57
  ```html
52
58
  <script type="module" src="https://cdn.skypack.dev/@thi.ng/api"></script>
@@ -60,7 +66,7 @@ For Node.js REPL:
60
66
  const api = await import("@thi.ng/api");
61
67
  ```
62
68
 
63
- Package sizes (brotli'd, pre-treeshake): ESM: 2.37 KB
69
+ Package sizes (brotli'd, pre-treeshake): ESM: 2.41 KB
64
70
 
65
71
  ## Dependencies
66
72
 
package/async.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import type { Fn, Fn0, Fn10, Fn2, Fn3, Fn4, Fn5, Fn6, Fn7, Fn8, Fn9, FnAny } from "./fn.js";
2
+ export type MaybePromise<T> = T | Promise<T>;
3
+ export type MaybeAsyncIterable<T> = Iterable<T> | AsyncIterable<T>;
4
+ export type MaybeAsyncGenerator<T> = IterableIterator<T> | AsyncIterableIterator<T>;
5
+ export type AsyncPredicate<T> = FnA<T, boolean>;
6
+ export type AsyncPredicate2<T> = FnA2<T, T, boolean>;
7
+ export type AsyncStatefulPredicate<T> = Fn0<AsyncPredicate<T>>;
8
+ export type AsyncStatefulPredicate2<T> = Fn0<AsyncPredicate2<T>>;
9
+ export type Fn0A<A> = Fn0<Promise<A>>;
10
+ export type FnA<A, B> = Fn<A, Promise<B>>;
11
+ export type FnA2<A, B, C> = Fn2<A, B, Promise<C>>;
12
+ export type FnA3<A, B, C, D> = Fn3<A, B, C, Promise<D>>;
13
+ export type FnA4<A, B, C, D, E> = Fn4<A, B, C, D, Promise<E>>;
14
+ export type FnA5<A, B, C, D, E, F> = Fn5<A, B, C, D, E, Promise<F>>;
15
+ export type FnA6<A, B, C, D, E, F, G> = Fn6<A, B, C, D, E, F, Promise<G>>;
16
+ export type FnA7<A, B, C, D, E, F, G, H> = Fn7<A, B, C, D, E, F, G, Promise<H>>;
17
+ export type FnA8<A, B, C, D, E, F, G, H, I> = Fn8<A, B, C, D, E, F, G, H, Promise<I>>;
18
+ export type FnA9<A, B, C, D, E, F, G, H, I, J> = Fn9<A, B, C, D, E, F, G, H, I, Promise<J>>;
19
+ export type FnA10<A, B, C, D, E, F, G, H, I, J, K> = Fn10<A, B, C, D, E, F, G, H, I, J, Promise<K>>;
20
+ export type FnAnyA<T> = FnAny<Promise<T>>;
21
+ /**
22
+ * Async version of {@link identity}.
23
+ *
24
+ * @param x
25
+ */
26
+ export declare const asyncIdentity: <T>(x: T) => Promise<T>;
27
+ //# sourceMappingURL=async.d.ts.map
package/async.js ADDED
@@ -0,0 +1,4 @@
1
+ const asyncIdentity = async (x) => x;
2
+ export {
3
+ asyncIdentity
4
+ };
package/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./assoc.js";
2
+ export * from "./async.js";
2
3
  export * from "./bind.js";
3
4
  export * from "./buffered.js";
4
5
  export * from "./clear.js";
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./assoc.js";
2
+ export * from "./async.js";
2
3
  export * from "./bind.js";
3
4
  export * from "./buffered.js";
4
5
  export * from "./clear.js";
package/keyval.d.ts CHANGED
@@ -41,6 +41,10 @@ type KeysNReducer<T, L, R extends unknown[]> = L extends keyof T ? {
41
41
  * Generalised version of Keys0 - Keys7.
42
42
  */
43
43
  export type KeysN<T, L extends unknown[]> = L extends [] ? Keys<T> : KeysNReducer<T, Head<L>, Tail<L>>;
44
+ /**
45
+ * Type union of values of all keys in T.
46
+ */
47
+ export type Values<T> = Val1<T, Keys<T>>;
44
48
  export type Val1<T, A extends Keys<T>> = T[A];
45
49
  export type Val2<T, A extends Keys<T>, B extends Keys1<T, A>> = ValN<T, [A, B]>;
46
50
  export type Val3<T, A extends Keys<T>, B extends Keys1<T, A>, C extends Keys2<T, A, B>> = ValN<T, [A, B, C]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/api",
3
- "version": "8.9.31",
3
+ "version": "8.10.0",
4
4
  "description": "Common, generic types, interfaces & mixins",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -81,6 +81,9 @@
81
81
  "./assoc": {
82
82
  "default": "./assoc.js"
83
83
  },
84
+ "./async": {
85
+ "default": "./async.js"
86
+ },
84
87
  "./bind": {
85
88
  "default": "./bind.js"
86
89
  },
@@ -226,5 +229,5 @@
226
229
  "default": "./watch.js"
227
230
  }
228
231
  },
229
- "gitHead": "feb3b24654f2c931cd3c3308c1c0c807ee14d0e4\n"
232
+ "gitHead": "85ac4bd4d6d89f8e3689e2863d5bea0cecdb371c\n"
230
233
  }