@cgtk/std 0.0.193 → 0.0.195

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/array.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Fn, Tuple } from "./types";
1
+ import type { Fn, Tuple } from "./types.js";
2
2
  export declare const empty: <T>() => T[];
3
3
  export declare const push: <T>(xs: T[], x: T) => T[];
4
4
  export declare const unshift: <T>(xs: T[], x: T) => T[];
package/array.js CHANGED
@@ -1,4 +1,4 @@
1
- import { comp, scan } from "./fn";
1
+ import { comp, scan } from "./fn.js";
2
2
  export const empty = () => [];
3
3
  export const push = (xs, x) => (xs.push(x), xs);
4
4
  export const unshift = (xs, x) => (xs.unshift(x), xs);
package/assign.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RecordOf } from "./types";
1
+ import type { RecordOf } from "./types.js";
2
2
  type PO = RecordOf<unknown>;
3
3
  type Merge<T extends PO, S extends PO> = {
4
4
  [K in keyof (T & S)]: K extends keyof S ? (K extends keyof T ? (S[K] extends PO ? (T[K] extends PO ? Merge<T[K], S[K]> : S[K]) : S[K]) : S[K]) : (K extends keyof T ? T[K] : never);
package/assign.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isUndefined, isNull } from "./checks";
1
+ import { isUndefined, isNull } from "./checks.js";
2
2
  const isPrimitive = (x) => {
3
3
  const t = typeof x;
4
4
  return t === "string" || t === "number" || t === "boolean";
package/async.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { Fn, Constantly, Maybe, Dispose, MaybePromise } from "./types";
1
+ import type { Fn, Lazy, Maybe, Dispose, MaybePromise } from "./types.js";
2
2
  export declare const timeout: (ms: number, signal?: AbortSignal) => Promise<unknown>;
3
3
  export declare const delay: (ms: number, signal?: AbortSignal) => <T>(x: T) => Promise<T>;
4
- export declare const probing: <T>(p: Promise<T>) => Constantly<Maybe<T>>;
4
+ export declare const probing: <T>(p: Promise<T>) => Lazy<Maybe<T>>;
5
5
  export declare const resolved: <T>(p: Promise<T>) => (f: Fn<T>) => () => void;
6
6
  export declare const promise: <T>(x: MaybePromise<T>) => Promise<any>;
7
7
  export declare const then: <T>(p: Promise<T>) => <R>(f: Fn<T, R>) => Promise<R>;
package/async.js CHANGED
@@ -1,5 +1,5 @@
1
- import { filterT, disposable } from "./fn";
2
- import { isDefined } from "./checks";
1
+ import { filterT, disposable } from "./fn.js";
2
+ import { isDefined } from "./checks.js";
3
3
  export const timeout = (ms, signal) => new Promise((resolve, reject) => {
4
4
  if (signal?.aborted)
5
5
  reject(signal.reason);
package/basen.js CHANGED
@@ -1,4 +1,4 @@
1
- import { toFixedMax } from "./number";
1
+ import { toFixedMax } from "./number.js";
2
2
  export const basen = (b) => (m = 0, n = 0) => [b, m, n];
3
3
  export const base10 = basen(10);
4
4
  export const normalize = (x) => {
package/buffer.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Fn } from "./types";
1
+ import type { Fn } from "./types.js";
2
2
  export interface BufReader {
3
3
  offset: number;
4
4
  line: Fn<void, string>;
package/buffer.js CHANGED
@@ -1,4 +1,4 @@
1
- import { readLine } from './string';
1
+ import { readLine } from './string.js';
2
2
  export const bufReader = (data, offset = 0) => {
3
3
  const rl = readLine();
4
4
  const dv = new DataView(data.buffer, data.byteOffset);
package/checks.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { TypedArray, NumberArray, BigIntArray, Pred, TPred, Maybe } from "./types";
1
+ import type { TypedArray, NumberArray, BigIntArray, Pred, TPred, Maybe } from "./types.js";
2
2
  export declare const isTypedArray: (x: any) => x is TypedArray;
3
3
  export declare const isNumberArray: (x: any) => x is NumberArray;
4
4
  export declare const isBigIntArray: (x: any) => x is BigIntArray;
package/checks.js CHANGED
@@ -1,5 +1,5 @@
1
- import { comp, not, apply, and } from "./fn";
2
- import { retain } from "./array";
1
+ import { comp, not, apply, and } from "./fn.js";
2
+ import { retain } from "./array.js";
3
3
  export const isTypedArray = (x) => x && (x instanceof Uint8Array || x instanceof Uint8ClampedArray ||
4
4
  x instanceof Uint16Array || x instanceof Uint32Array ||
5
5
  x instanceof Int8Array || x instanceof Int16Array || x instanceof Int32Array ||
package/dom.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Fn, Dispose, RecordOf, Maybe } from "./types";
1
+ import type { Fn, Dispose, RecordOf, Maybe } from "./types.js";
2
2
  export declare const customEvent: <T>(type: string, detail: T, { composed, bubbles, cancelable }?: EventInit) => CustomEvent<T>;
3
3
  type ListenOpts = boolean | AddEventListenerOptions;
4
4
  export declare const on: {
@@ -47,4 +47,5 @@ export declare const preventDefault: <T extends Event>(e: T) => void;
47
47
  export declare const loadImage: (img: HTMLImageElement, src: string) => Promise<HTMLImageElement>;
48
48
  export declare const pushState: (path: string, query?: RecordOf<string>, data?: any) => void;
49
49
  export declare const qs: (search?: string) => Maybe<RecordOf<string>>;
50
+ export declare const imageData: (img: HTMLImageElement) => ImageData;
50
51
  export {};
package/dom.js CHANGED
@@ -1,6 +1,6 @@
1
- import { forEach, noop } from "./fn";
2
- import { isDefined } from "./checks";
3
- import { EMPTY } from "./constants";
1
+ import { forEach, noop } from "./fn.js";
2
+ import { isDefined } from "./checks.js";
3
+ import { EMPTY } from "./constants.js";
4
4
  export const customEvent = (type, detail, { composed = false, bubbles = false, cancelable = false } = EMPTY.OBJ) => new CustomEvent(type, { bubbles, cancelable, composed, detail });
5
5
  export const on = (el, name, listener, opts = false) => {
6
6
  el.addEventListener(name, listener, opts);
@@ -34,3 +34,8 @@ export const pushState = (path, query, data) => history.pushState(data, EMPTY.ST
34
34
  export const qs = (search = location.search) => search.length > 0
35
35
  ? Object.fromEntries(new URLSearchParams(search).entries())
36
36
  : undefined;
37
+ export const imageData = (img) => {
38
+ const ctx = new OffscreenCanvas(img.width, img.height).getContext("2d");
39
+ ctx.drawImage(img, 0, 0);
40
+ return ctx.getImageData(0, 0, img.width, img.height);
41
+ };
package/fn.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- import type { Fn, FnV, FnF, Pred, TPred, FirstParam, Last, Constantly, Maybe, Dispose, Reactive } from "./types";
1
+ import type { Fn, FnV, FnF, Pred, TPred, FirstParam, Last, Lazy, Maybe, Dispose, Reactive } from "./types.js";
2
2
  export declare const tee: <T>(f: Fn<T, void>) => Fn<T, T>;
3
3
  export declare const comp: <Fs extends Fn[]>(...fs: Fs) => (x: FirstParam<Fs[0]>) => Last<Fs> extends Fn<any, infer R> ? R : never;
4
4
  export declare const pipe: <T, Fs extends [Fn<T>, ...Fn[]]>(x: T, ...fs: Fs) => Last<Fs> extends Fn<any, infer R> ? R : never;
5
5
  export declare const forEach: <T, R = any>(...fs: Fn<T, R>[]) => (x: T) => void;
6
- export declare const map: <T, R>(...fs: Fn<T, R>[]) => (x: T) => R[];
6
+ export declare const map: <T, S, U>(f: Fn<T, S>, g: Fn<S, U>) => Fn<T, U>;
7
7
  export declare const and: <T>(...fs: Pred<T>[]) => (x: T) => boolean;
8
8
  export declare const or: <T>(...fs: Pred<T>[]) => (x: T) => boolean;
9
9
  export declare const not: <T>(p: Pred<T>) => (x: T) => boolean;
10
10
  export declare const comb: <C extends FnV<Fn[]>>(c: C) => (...fs: Fn<FirstParam<FirstParam<C>>, ReturnType<FirstParam<C>>>[]) => (x: FirstParam<FirstParam<C>>) => ReturnType<C>;
11
11
  export declare const noop: () => void;
12
12
  export declare const identity: <S, T = S>(x: S) => T;
13
- export declare const constantly: <T>(x: T) => Constantly<T>;
13
+ export declare const constantly: <T>(x: T) => Lazy<T>;
14
14
  export declare const apply: <F extends FnV>(f: F) => (x: Parameters<F>) => ReturnType<F>;
15
15
  export declare const call: <T extends unknown[]>(f: Fn<T>) => (...xs: T) => ReturnType<typeof f>;
16
16
  export declare const bind: <A extends unknown[], B extends unknown[], R>(f: (...args: [...A, ...B]) => R, ...args: A) => (...args: B) => R;
@@ -18,7 +18,6 @@ export declare const lazy: <F extends FnV>(f: F, ...xs: Parameters<F>) => Fn<voi
18
18
  export declare const where: <T, U, V>(p: Pred<T>, f: Fn<T, U>, g: Fn<T, V>) => (x: T) => U | V;
19
19
  export declare const before: <F extends Fn<void>>(f: F) => FnF;
20
20
  export declare const after: <F extends Fn<void>>(f: F) => FnF;
21
- export declare const mapForEach: <T, R>(...fs: Fn<T, Fn<R>>[]) => (x: T) => (x: R) => void;
22
21
  export declare const filter: <T>(p: Pred<T>, f: Fn<T>) => (x: T) => void;
23
22
  export declare const filterT: <T>(p: TPred<T>, f: Fn<T>) => <S>(x: S) => void;
24
23
  export declare const scan: <T, S>(f: FnV<[S, T], S>, a: S) => Fn<T, S>;
package/fn.js CHANGED
@@ -1,9 +1,9 @@
1
- import { add } from "./set";
1
+ import { add } from "./set.js";
2
2
  export const tee = f => x => (f(x), x);
3
3
  export const comp = (...fs) => (x) => fs.reduce((x, f) => f(x), x);
4
4
  export const pipe = (x, ...fs) => fs.reduce((x, f) => f(x), x);
5
5
  export const forEach = (...fs) => (x) => fs.forEach(f => f(x));
6
- export const map = (...fs) => (x) => fs.map(f => f(x));
6
+ export const map = (f, g) => comp(f, g);
7
7
  export const and = (...fs) => (x) => fs.reduce((a, f) => a && f(x), true);
8
8
  export const or = (...fs) => (x) => fs.reduce((a, f) => a || f(x), false);
9
9
  export const not = (p) => (x) => !p(x);
@@ -22,7 +22,6 @@ export const after = (f) => g => (...xs) => {
22
22
  f();
23
23
  return r;
24
24
  };
25
- export const mapForEach = (...fs) => comp(map(...fs), apply((forEach)));
26
25
  export const filter = (p, f) => (x) => { if (p(x))
27
26
  f(x); };
28
27
  export const filterT = (p, f) => (x) => { if (p(x))
package/http.js CHANGED
@@ -1,5 +1,5 @@
1
- import { tee } from "./fn";
2
- import { assert } from "./checks";
1
+ import { tee } from "./fn.js";
2
+ import { assert } from "./checks.js";
3
3
  export const assertStatus = (status) => (resp) => assert(resp.status == status, `Invalid HTTP Status ${resp.status}: ${resp.url}`);
4
4
  export const contentLength = (response) => {
5
5
  const cl = response.headers.get("content-length");
package/iterable.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Fn, FnV, Indexed, Pred } from "./types";
1
+ import type { Fn, FnV, Indexed, Pred } from "./types.js";
2
2
  export declare const next: <T>(xs: Iterator<T>) => T;
3
3
  export declare const repeat: (n: number) => <A>(x: A) => Iterator<A>;
4
4
  export declare const just: <T>(x: T) => IteratorObject<T>;
package/iterable.js CHANGED
@@ -1,6 +1,6 @@
1
- import { assert, isDefined } from "./checks";
2
- import { pipe, comp, scan, apply, noop, identity, constantly } from "./fn";
3
- import { set } from "./map";
1
+ import { assert, isDefined } from "./checks.js";
2
+ import { pipe, comp, scan, apply, noop, identity, constantly } from "./fn.js";
3
+ import { set } from "./map.js";
4
4
  export const next = (xs) => {
5
5
  const { done, value } = xs.next();
6
6
  assert(isDefined(done) && !done, "iterator done");
package/map.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { FnV, Maybe } from "./types";
1
+ import type { FnV, Maybe } from "./types.js";
2
2
  export declare const transform: <K, S, V>({ create, update, remove }: {
3
3
  create: FnV<[S, K, Map<K, V>], V>;
4
4
  update: FnV<[V, S, K, Map<K, V>], V>;
package/map.js CHANGED
@@ -1,5 +1,5 @@
1
- import { isDefined } from "./checks";
2
- import * as I from "./iterable";
1
+ import { isDefined } from "./checks.js";
2
+ import * as I from "./iterable.js";
3
3
  export const transform = ({ create, update, remove }, dst = new Map()) => (src) => {
4
4
  for (const k of dst.keys())
5
5
  if (!src.has(k)) {
package/math.d.ts CHANGED
@@ -32,3 +32,4 @@ export declare const zoom: (x: number, s: number, p: number) => number;
32
32
  export declare const align: (x: number, b: number) => number;
33
33
  export declare const sign11: (x: number) => 1 | -1;
34
34
  export declare const nudge: (x: number, v?: number, eps?: number) => number;
35
+ export declare const divCeil: (a: number, b: number) => number;
package/math.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isclose } from "./checks";
1
+ import { isclose } from "./checks.js";
2
2
  export const PI = Math.PI;
3
3
  export const TAU = PI * 2;
4
4
  export const HALF_PI = PI / 2;
@@ -41,3 +41,4 @@ export const zoom = (x, s, p) => (x - p) * s + p;
41
41
  export const align = (x, b) => (x + b - 1) & -b;
42
42
  export const sign11 = (x) => x >= 0 ? 1 : -1;
43
43
  export const nudge = (x, v = 0, eps = EPS) => isclose(x, v, eps) ? sign11(x - v) * eps + v : x;
44
+ export const divCeil = (a, b) => Math.ceil(a / b);
package/npy.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { TypedArray, Elements } from "./types";
1
+ import type { TypedArray, Elements } from "./types.js";
2
2
  declare const DTYPES: readonly ["|u1", "<u2", "<u4", "|i1", "<i2", "<i4", "<f4", "<f8"];
3
3
  type DType = Elements<typeof DTYPES>;
4
4
  export interface NDArray {
package/number.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isBigInt } from "./checks";
1
+ import { isBigInt } from "./checks.js";
2
2
  export const add = (a, x) => a + x;
3
3
  export const toFixed = (x, n = 0) => isBigInt(x) ? x : x.toFixed(n);
4
4
  export const toFixedMax = (x, n = 0) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgtk/std",
3
- "version": "0.0.193",
3
+ "version": "0.0.195",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "exports": {
@@ -40,9 +40,6 @@
40
40
  "./resource": "./resource.js",
41
41
  "./utils": "./utils.js"
42
42
  },
43
- "devDependencies": {
44
- "typescript": "^5.9.3"
45
- },
46
43
  "publishConfig": {
47
44
  "access": "public"
48
45
  }
package/port.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Dispose, Fn, Fns, FnV, RecordOf, MaybePromise, Reactive } from "./types";
1
+ import type { Dispose, Fn, Fns, FnV, RecordOf, MaybePromise, Reactive } from "./types.js";
2
2
  export interface Message<K, V> {
3
3
  type: K;
4
4
  payload: V;
package/port.js CHANGED
@@ -1,7 +1,7 @@
1
- import { forEach, noop, bind } from "./fn";
2
- import { isDefined } from "./checks";
3
- import { on } from "./dom";
4
- import { promise } from "./async";
1
+ import { forEach, noop, bind } from "./fn.js";
2
+ import { isDefined } from "./checks.js";
3
+ import { on } from "./dom.js";
4
+ import { promise } from "./async.js";
5
5
  ;
6
6
  export const onMessages = (target, fs) => on(target, "message", ({ data: { type, payload } }) => (type in fs) && fs[type](payload));
7
7
  export const onMessage = (target, name, f) => on(target, "message", ({ data: { type, payload } }) => type == name && f(payload));
package/progress.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Fn } from './types';
1
+ import type { Fn } from './types.js';
2
2
  export type Progress = {
3
3
  begin: Fn<void>;
4
4
  progress: Fn<number>;
package/rect.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Tuple } from "./types";
1
+ import type { Tuple } from "./types.js";
2
2
  export type Rect = Tuple<number, 4>;
3
3
  export declare const rect: (x: number, y: number, w: number, h: number) => Rect;
4
4
  export declare const vertical: (ratio: number[]) => (i: number) => ([x, _, w, h]: Rect) => Rect;
package/rect.js CHANGED
@@ -1,4 +1,4 @@
1
- import { add } from "./number";
1
+ import { add } from "./number.js";
2
2
  export const rect = (x, y, w, h) => [x, y, w, h];
3
3
  export const vertical = (ratio) => {
4
4
  const tot = ratio.reduce(add, 0);
package/resource.d.ts CHANGED
@@ -1,10 +1,13 @@
1
- import type { Fn, Dispose, Structure, Reactive } from "./types";
1
+ import type { Fn, Dispose, Structure, Reactive } from "./types.js";
2
2
  export type Resource<T> = Reactive<T, Dispose | void> & {
3
3
  value: T;
4
4
  dispose: Dispose;
5
5
  map<S>(f: Fn<T, S>): Resource<S>;
6
+ flatMap<S>(f: Fn<T, Resource<S>>): Resource<S>;
7
+ promise(f: Fn<T, Promise<Dispose | void>>): Promise<Dispose>;
6
8
  };
7
9
  export declare const resource: <T>(value: T, dispose?: Dispose) => Resource<T>;
10
+ export declare const awaited: <T>({ value, dispose }: Resource<Promise<T>>) => Promise<Resource<Awaited<T>>>;
8
11
  type Unwrapped<T> = T extends Resource<infer U> ? U : {
9
12
  [K in keyof T]: Unwrapped<T[K]>;
10
13
  };
package/resource.js CHANGED
@@ -1,12 +1,18 @@
1
- import { forEach, noop } from "./fn";
2
- import { isFunction } from "./checks";
1
+ import { forEach, noop } from "./fn.js";
2
+ import { isFunction } from "./checks.js";
3
3
  export const resource = (value, dispose = noop) => {
4
4
  const res = ((f) => forEach(f(value) ?? noop, dispose));
5
5
  res.value = value;
6
6
  res.dispose = dispose;
7
7
  res.map = (f) => resource(f(value), dispose);
8
+ res.flatMap = (f) => {
9
+ const res = f(value);
10
+ return resource(res.value, forEach(res.dispose, dispose));
11
+ };
12
+ res.promise = async (f) => forEach((await f(value)) ?? noop, dispose);
8
13
  return res;
9
14
  };
15
+ export const awaited = async ({ value, dispose }) => resource(await value, dispose);
10
16
  const isResource = (r) => isFunction(r)
11
17
  && Object.hasOwn(r, "value")
12
18
  && Object.hasOwn(r, "dispose")
package/schedule.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Dispose, Fn, FnV, Reactive } from './types';
1
+ import type { Dispose, Fn, FnV, Reactive } from './types.js';
2
2
  export declare const raf: Reactive<number>;
3
3
  export declare const timeout: (ms: number) => Reactive<void>;
4
4
  export declare const schedule: <T>(s: Reactive<T>) => <F extends FnV>(f: F) => FnV<Parameters<F>, Dispose>;
package/schedule.js CHANGED
@@ -1,5 +1,5 @@
1
- import { isUndefined, isDefined, counted } from './checks';
2
- import { comp, lazy, bind, apply, call, where, disposing, noop } from './fn';
1
+ import { isUndefined, isDefined, counted } from './checks.js';
2
+ import { comp, lazy, bind, apply, call, where, disposing, noop } from './fn.js';
3
3
  export const raf = f => bind(cancelAnimationFrame, requestAnimationFrame(f));
4
4
  export const timeout = (ms) => f => bind(clearTimeout, setTimeout(f, ms));
5
5
  export const schedule = (s) => (f) => call(comp(apply(bind((lazy), f)), s));
package/signal.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Fn, FnV, Fns, Pred, Reactive, RecordOf, Structure } from "./types";
1
+ import type { Fn, FnV, Fns, Pred, Reactive, RecordOf, Structure } from "./types.js";
2
2
  export type Signal<T> = Fn<T> & {
3
3
  on: Reactive<T>;
4
4
  };
package/signal.js CHANGED
@@ -1,7 +1,7 @@
1
- import { after, constantly, noop, bind, comp, forEach, filter as filter_, identity } from "./fn";
2
- import { mapValues } from "./object";
3
- import { isDefined, isFunction } from "./checks";
4
- import { add } from "./set";
1
+ import { after, constantly, noop, bind, comp, forEach, filter as filter_, identity } from "./fn.js";
2
+ import { mapValues } from "./object.js";
3
+ import { isDefined, isFunction } from "./checks.js";
4
+ import { add } from "./set.js";
5
5
  export const create = (f, on) => {
6
6
  const g = f;
7
7
  g.on = on;
package/stream.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Fn } from "./types";
1
+ import type { Fn } from "./types.js";
2
2
  export declare const readable: <T>(x: T) => ReadableStream<any>;
3
3
  export declare function iterate<T>(rs: ReadableStream<T>): AsyncGenerator<Awaited<T>, void, unknown>;
4
4
  export declare const map: <T, S>(f: Fn<T, S>) => TransformStream<T, S>;
package/stream.js CHANGED
@@ -1,5 +1,5 @@
1
- import { push } from "./array";
2
- import { reduceA } from "./iterable";
1
+ import { push } from "./array.js";
2
+ import { reduceA } from "./iterable.js";
3
3
  export const readable = (x) => new ReadableStream({
4
4
  start: c => (c.enqueue(x), c.close())
5
5
  });
package/string.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Tuple } from "./types";
1
+ import type { Tuple } from "./types.js";
2
2
  export declare const basename: (path: string) => string;
3
3
  export declare const dirname: (path: string) => string;
4
4
  export declare const splitext: (path: string) => Tuple<string, 2>;
package/string.js CHANGED
@@ -1,5 +1,5 @@
1
- import { EMPTY } from "./constants";
2
- import { seek } from "./array";
1
+ import { EMPTY } from "./constants.js";
2
+ import { seek } from "./array.js";
3
3
  export const basename = (path) => path.split("/").at(-1) ?? "";
4
4
  export const dirname = (path) => {
5
5
  const parts = path.split("/");
package/struct.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { TypedArray, Fn, NumberArray } from "./types";
2
- import type { Constructor } from "./typedarray";
1
+ import type { TypedArray, Fn, NumberArray } from "./types.js";
2
+ import type { Constructor } from "./typedarray.js";
3
3
  export interface Type {
4
4
  size: number;
5
5
  align: number;
package/struct.js CHANGED
@@ -1,5 +1,5 @@
1
- import { align as _align } from "./math";
2
- import { isBigIntArray, isNumberArray } from "./checks";
1
+ import { align as _align } from "./math.js";
2
+ import { isBigIntArray, isNumberArray } from "./checks.js";
3
3
  const vec = (type) => (length = 1, align = type.BYTES_PER_ELEMENT) => ({
4
4
  type, align, length, size: type.BYTES_PER_ELEMENT * length,
5
5
  });
package/tree.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Fn, FnV, TPred, PredV } from './types';
1
+ import type { Fn, FnV, TPred, PredV } from './types.js';
2
2
  export type Node<S, T = S> = T | Tree<S, T>;
3
3
  export type Tree<S, T = S> = [S, Node<S, T>[]];
4
4
  export declare const tree: <S, T = S>(value: S, children?: Node<S, T>[]) => Tree<S, T>;
package/tree.js CHANGED
@@ -1,6 +1,6 @@
1
- import { identity } from './fn';
2
- import { EMPTY } from './constants';
3
- import { zip as zipI } from './iterable';
1
+ import { identity } from './fn.js';
2
+ import { EMPTY } from './constants.js';
3
+ import { zip as zipI } from './iterable.js';
4
4
  export const tree = (value, children = []) => [value, children];
5
5
  export const isTree = (x) => Array.isArray(x) && x.length == 2 && Array.isArray(x[1]);
6
6
  export const children = (x, p = isTree) => p(x) ? x[1] : EMPTY.LIST;
package/treemap.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Maybe } from "./types";
1
+ import type { Maybe } from "./types.js";
2
2
  export interface Treemap<T = number> {
3
3
  set(node: T, parent?: T): Treemap<T>;
4
4
  delete(key: T): void;
package/treemap.js CHANGED
@@ -1,6 +1,6 @@
1
- import { before } from "./fn";
2
- import { isDefined } from "./checks";
3
- import { EMPTY } from "./constants";
1
+ import { before } from "./fn.js";
2
+ import { isDefined } from "./checks.js";
3
+ import { EMPTY } from "./constants.js";
4
4
  export const treemap = () => {
5
5
  const nodes = new Set();
6
6
  const parents = new Map();
package/typedarray.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { FnV, TypedArray, NumberArray, BufferType, Number } from "./types";
1
+ import type { FnV, TypedArray, NumberArray, BufferType, Number } from "./types.js";
2
2
  export interface Constructor<T extends TypedArray> {
3
3
  new (length: number): T;
4
4
  new (buffer: BufferType<T> | ArrayBufferLike, byteOffset?: number, length?: number): T;
package/typedarray.js CHANGED
@@ -1,6 +1,6 @@
1
- import { bind } from "./fn";
2
- import { zmap, map as mapI, reduce } from "./iterable";
3
- import { push } from "./array";
1
+ import { bind } from "./fn.js";
2
+ import { zmap, map as mapI, reduce } from "./iterable.js";
3
+ import { push } from "./array.js";
4
4
  export const view = (type, length) => (buf = new ArrayBuffer(type.BYTES_PER_ELEMENT * length), offset = 0) => new type(buf, offset, length);
5
5
  export const u8 = bind((view), Uint8Array);
6
6
  export const u16 = bind((view), Uint16Array);
package/types.d.ts CHANGED
@@ -18,7 +18,7 @@ export type Fns<T> = {
18
18
  export type FnF = <F extends FnV>(f: F) => (...xs: Parameters<F>) => ReturnType<F>;
19
19
  export type Dispose = Fn<void>;
20
20
  export type Reactive<T = unknown, R = any> = Fn<Fn<T, R>, Dispose>;
21
- export type Constantly<T> = () => T;
21
+ export type Lazy<T> = () => T;
22
22
  export type FirstParam<F extends FnV> = MaybeFirst<Parameters<F>>;
23
23
  export type MaybePromise<T = unknown> = T | PromiseLike<T>;
24
24
  export type Last<T extends any[]> = T extends [...any, infer Rest] ? Rest : never;
@@ -39,7 +39,7 @@ export type Entries<T> = {
39
39
  export type EntriesTuple<T, K extends UnionToTuple<keyof T> = UnionToTuple<keyof T>> = {
40
40
  [I in keyof K]: K[I] extends keyof T ? [K[I], T[K[I]]] : never;
41
41
  };
42
- export type UintArray<T extends ArrayBufferLike = ArrayBufferLike> = Uint8Array<T> | Uint16Array<T> | Uint32Array<T>;
42
+ export type UintArray<T extends ArrayBufferLike = ArrayBufferLike> = Uint8Array<T> | Uint8ClampedArray<T> | Uint16Array<T> | Uint32Array<T>;
43
43
  export type IntArray<T extends ArrayBufferLike = ArrayBufferLike> = Int8Array<T> | Int16Array<T> | Int32Array<T>;
44
44
  export type FloatArray<T extends ArrayBufferLike = ArrayBufferLike> = Float16Array<T> | Float32Array<T> | Float64Array<T>;
45
45
  export type BigIntArray<T extends ArrayBufferLike = ArrayBufferLike> = BigUint64Array<T> | BigInt64Array<T>;
package/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Tuple } from "./types";
1
+ import type { Tuple } from "./types.js";
2
2
  export declare function toposort(nodes: number[]): Generator<number | undefined, void, unknown>;
3
3
  export declare const hex2rgb: (hex: string) => number[];
4
4
  export declare const rgb2hex: (rgb: Tuple<number, 3>) => string;
package/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { assert } from "./checks";
1
+ import { assert } from "./checks.js";
2
2
  export function* toposort(nodes) {
3
3
  const n = nodes.length;
4
4
  const queue = [], children = new Map();
package/weak.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import type { Fn, Maybe } from "./types";
1
+ import type { Fn, Maybe } from "./types.js";
2
2
  export declare const deref: <T extends WeakKey, F extends Fn<T>>(r: WeakRef<T>, f: F) => Maybe<ReturnType<F>>;
package/weak.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isDefined } from "./checks";
1
+ import { isDefined } from "./checks.js";
2
2
  export const deref = (r, f) => {
3
3
  const x = r.deref();
4
4
  return isDefined(x) ? f(x) : undefined;