Class Arr<T>

    Type Parameters

    • T
    Hierarchy
    Index

    Accessors

    • get cells(): Elems<T>

      The element cells in order; tracked when read in an effect/derive.

      Returns Elems<T>

    • get values(): Read<readonly T[]>

      Snapshot of element values, readonly T[]; re-derives on any value or structural change. Memoized per instance.

      Returns Read<readonly T[]>

    Constructors

    Methods

    • Make e appear in this view: insert into the base if absent, then assert each view's constraint up the chain.

      Parameters

      Returns void

    • Read-only same-type view: the RO dual of the endo .lens. For a cross-type view use the typed static Target.derive(src, fn).

      Parameters

      • this: Cell<Elems<T>>
      • fn: (v: Elems) => Elems

      Returns this

    • Subset whose elements pass pred (which reads element values, so the view re-derives reactively). Shares the element cells. insert adds to the parent and asserts the predicate.

      Parameters

      Returns Arr<T>

    • Partition by a per-element key field into derived sub-Arrs, one writable filter view per bucket. move(e, key, index) writes the key field and splices the base so e lands at index in its new group. order seeds empty buckets and pins their order.

      Type Parameters

      • K

      Parameters

      Returns GroupArr<K, T>

    • This element's index as a writable Num: reading gives its position, writing reorders (splices the reference to the rounded, clamped target). Writable on a base Arr; read-only over a derived view.

      Parameters

      Returns Writable<Num>

    • Insert at at (default: end). On a view, delegates through the view's insert (a filter asserts its predicate; map has none, so it throws).

      Parameters

      • v: T | Cell<T>
      • Optionalat: number

      Returns Cell<T>

    • Endomorphic lens. A 2-arg bwd(view, current) consults the current source; a 1-arg bwd(view) reconstructs it from the view alone.

      Parameters

      • this: Cell<Elems<T>>
      • fwd: (v: Elems) => Elems
      • bwd: (target: Elems, current: Elems) => Elems

      Returns this

    • Per-element map. f projects each element value; with the inverse g the mapped elements are writable lenses (editing one writes the source cell), else they're read-only. Element identity is stable: one lens per source cell, memoized.

      Type Parameters

      • U

      Parameters

      • f: (v: T) => U
      • Optionalg: (u: U, v: T) => T

      Returns Arr<U>

    • Backward fan-in: forwards its parent's value unchanged; on write, folds N contributors into one value. fold defaults to last-writer-wins.

      Parameters

      • this: Cell<Elems<T>>
      • Optionalfold: MergeFold<Elems<T>>

      Returns Cell<Elems<T>>

    • Splice e to just before anchor (or to the end when anchor is null). On a base Arr this rewrites the reference order; on a view it delegates through the view's moveBefore, where the shared anchor cell stays meaningful in the base order. No-op if e isn't present.

      Parameters

      Returns void

    • Remove the element at index i in this (view's) order.

      Parameters

      • i: number

      Returns void

    • Projection ordered by key (read off each element, so it re-sorts reactively). Shares the element cells; structural edits delegate to the base (a move/insert repositions in the base order, not the view's).

      Parameters

      • key: (c: Cell<T>) => number

      Returns Arr<T>

    • Coerce Val<Inner<Cls>> → Cls: instance → identity, RO cell → tracked derive, literal → fresh seed.

      Type Parameters

      • C extends AnyCellCtor

      Parameters

      Returns InstanceType<C>

    • Read-only typed view. Cls.derive(parent, fn) (1-input), Cls.derive(parents, fn) (N-input), or Cls.derive(fn) (closure). Polymorphic-this: Vec.derive(...) → Vec.

      Type Parameters

      • C extends AnyCellCtor
      • P

      Parameters

      Returns InstanceType<C>

    • Read-only typed view. Cls.derive(parent, fn) (1-input), Cls.derive(parents, fn) (N-input), or Cls.derive(fn) (closure). Polymorphic-this: Vec.derive(...) → Vec.

      Type Parameters

      • C extends AnyCellCtor
      • P extends readonly Read<unknown>[]

      Parameters

      • this: C
      • parents: P
      • fn: (vals: ReadValues<P>) => Inner<InstanceType<C>>

      Returns InstanceType<C>

    • Read-only typed view. Cls.derive(parent, fn) (1-input), Cls.derive(parents, fn) (N-input), or Cls.derive(fn) (closure). Polymorphic-this: Vec.derive(...) → Vec.

      Type Parameters

      • C extends AnyCellCtor

      Parameters

      • this: C
      • fn: () => Inner<InstanceType<C>>

      Returns InstanceType<C>

    • An Arr whose elements are derived from an external source and whose structural edits rewrite that source via ops.

      Type Parameters

      • S
      • R

      Parameters

      • source: Read<S>
      • getter: (s: S) => Elems<R>
      • ops: {
            insert?: (v: R | Cell<R>, at?: number) => Cell<R>;
            moveBefore?: (e: Cell<R>, anchor: Cell<R> | null) => void;
            remove?: (e: Cell<R>) => void;
        }

      Returns Arr<R>

    • Type predicate against this class: Vec.is(x) narrows x to Vec. Inherited static; works for any subclass via polymorphic this.

      Type Parameters

      • C extends AnyCellCtor

      Parameters

      • this: C
      • v: unknown

      Returns v is InstanceType<C>

    • Writable lens. Cls.lens(parent, fwd, bwd) for one input, Cls.lens(parents, fwd, bwd) for N; a 2-arg bwd reads the source, a 1-arg bwd reconstructs it. Cls.lens(parent(s), spec) builds a complement-carrying lens from { init, step, fwd, bwd }.

      Type Parameters

      • C extends AnyCellCtor
      • P

      Parameters

      • this: C
      • parent: Read<P>
      • fwd: (v: P) => Inner<InstanceType<C>>
      • bwd: (target: Inner<InstanceType<C>>, v: P) => P

      Returns Writable<InstanceType<C>>

    • Writable lens. Cls.lens(parent, fwd, bwd) for one input, Cls.lens(parents, fwd, bwd) for N; a 2-arg bwd reads the source, a 1-arg bwd reconstructs it. Cls.lens(parent(s), spec) builds a complement-carrying lens from { init, step, fwd, bwd }.

      Type Parameters

      • C extends AnyCellCtor
      • P extends readonly Read<unknown>[]

      Parameters

      • this: C
      • parents: P
      • fwd: (vals: ReadValues<P>) => Inner<InstanceType<C>>
      • bwd: (
            target: Inner<InstanceType<C>>,
            vals: ReadValues<P>,
        ) => BackUpdates<ReadValuesOrSkip<P>>

      Returns Writable<InstanceType<C>>

    • Writable lens. Cls.lens(parent, fwd, bwd) for one input, Cls.lens(parents, fwd, bwd) for N; a 2-arg bwd reads the source, a 1-arg bwd reconstructs it. Cls.lens(parent(s), spec) builds a complement-carrying lens from { init, step, fwd, bwd }.

      Type Parameters

      • C extends AnyCellCtor
      • P
      • Cm

      Parameters

      Returns Writable<InstanceType<C>>

    • Writable lens. Cls.lens(parent, fwd, bwd) for one input, Cls.lens(parents, fwd, bwd) for N; a 2-arg bwd reads the source, a 1-arg bwd reconstructs it. Cls.lens(parent(s), spec) builds a complement-carrying lens from { init, step, fwd, bwd }.

      Type Parameters

      • C extends AnyCellCtor
      • P extends readonly Read<unknown>[]
      • Cm

      Parameters

      Returns Writable<InstanceType<C>>

    • Writable-shaped constant: always reads v, absorbs writes (parentless sink lens), for APIs demanding bidirectionality.

      Type Parameters

      • C extends AnyCellCtor

      Parameters

      Returns Writable<InstanceType<C>>

    Properties

    _t: { equals: <E>(a: readonly E[], b: readonly E[]) => boolean }

    Type Declaration

    • equals: <E>(a: readonly E[], b: readonly E[]) => boolean
    name: string | undefined

    Optional debug label (cell(0, { name })); used by errors and graph dumps.

    value: Elems
    traits: { equals: <E>(a: readonly E[], b: readonly E[]) => boolean } = ...

    Type Declaration

    • equals: <E>(a: readonly E[], b: readonly E[]) => boolean