@cgtk/std 0.0.186 → 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 +1 -1
- package/resource.d.ts +1 -0
- package/resource.js +1 -0
- package/typedarray.d.ts +1 -1
- package/typedarray.js +0 -1
package/package.json
CHANGED
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) => {
|
package/typedarray.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Fn, FnV, TypedArray, BufferType, Numbers } from "./types";
|
|
2
2
|
export interface Constructor<T extends TypedArray> {
|
|
3
3
|
new (length: number): T;
|
|
4
|
-
new (buffer: BufferType<T
|
|
4
|
+
new (buffer: BufferType<T> | ArrayBufferLike, byteOffset?: number, length?: number): T;
|
|
5
5
|
readonly BYTES_PER_ELEMENT: number;
|
|
6
6
|
of(...items: number[]): T;
|
|
7
7
|
from(arrayLike: ArrayLike<number>): T;
|
package/typedarray.js
CHANGED
|
@@ -24,7 +24,6 @@ export const iter = (size, stride = size) => function* (data) {
|
|
|
24
24
|
const C = ctor(data);
|
|
25
25
|
for (let i = 0, n = data.length; i < n - size + 1; i += stride) {
|
|
26
26
|
const offset = data.byteOffset + i * C.BYTES_PER_ELEMENT;
|
|
27
|
-
// https://github.com/microsoft/TypeScript/pull/59417
|
|
28
27
|
yield new C(data.buffer, offset, size);
|
|
29
28
|
}
|
|
30
29
|
};
|