@cgtk/std 0.0.187 → 0.0.188

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgtk/std",
3
- "version": "0.0.187",
3
+ "version": "0.0.188",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "exports": {
package/resource.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Fn, Dispose, Resource, RecordOf } from "./types";
2
2
  export declare const resource: <T>(x: T, d?: Dispose) => Resource<T>;
3
3
  export declare const map: <T, S>(r: Resource<T>, g: Fn<T, S>) => Resource<S>;
4
+ export declare const flatMap: <T, S>(r: Resource<T>, g: Fn<T, Resource<S>>) => Resource<S>;
4
5
  type Structure<T> = T | Structure<T>[] | RecordOf<Structure<T>>;
5
6
  type Resolved<T extends Structure<Resource<any>>> = {
6
7
  [K in keyof T]: T[K] extends Resource<infer R> ? R : T[K] extends Structure<Resource<any>> ? Resolved<T[K]> : never;
package/resource.js CHANGED
@@ -5,6 +5,7 @@ import { reduceRec } from './iterable';
5
5
  import { isFunction } from "./checks";
6
6
  export const resource = (x, d = noop) => (f) => forEach(f(x) ?? noop, d);
7
7
  export const map = (r, g) => f => r(comp(g, f));
8
+ export const flatMap = (r, g) => f => r(x => g(x)(f));
8
9
  const isResource = (r) => isFunction(r);
9
10
  export const combine = (rs) => f => {
10
11
  const rec = (rs, f) => {