Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/deep/internal.ts>Deep.WithType

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
interface Deep.WithType
import { type Deep } from "https://deno.land/x/rimbu@1.2.0/deep/internal.ts";
const { WithType } = Deep;

Typed and curried Deep API, used in situations where the target type is known but the value will be applied later.

Examples

Example 1

const s = { a: 1, b: { c: 'a', d: true }};
const upd = Deep.withType<typeof s>().patchWith([{ a: (v) => v + 1 }]);
upd(s);
// => { a: 2, b: { c: 'a', d: true }}

Methods

getAtWith<P extends Path.Get<T>>(path: P): (source: T) => Path.Result<T, P>

Returns a function that given an object returns the value at the given path.

patchWith<TE extends T = T, TT = T>(patchItem: Patch<TT, TE>): (source: TE) => T

Returns a function that patches a given value with the given patchItems.

patchAtWith<P extends Path.Set<T>, TT = T>(path: P, patchItem: Patch<Path.Result<T, P>, Path.Result<TT, P>>): (source: T) => T

Returns a function that patches a given value with the given patchItems at the given path.

matchWith(matcher: Match<T>): (source: T) => boolean

Returns a function that matches a given value with the given matcher.

matchAtWith<P extends Path.Get<T>>(path: P, matcher: Match<Path.Result<T, P>>): (source: T) => boolean

Returns a function that matches a given value with the given matcher at the given string path.

selectWith<SL extends Selector<T>>(selector: Selector.Shape<SL>): (source: T) => Selector.Result<T, SL>

Returns a function that selects a certain shape from a given value with the given selector.

selectAtWith<P extends Path.Get<T>, SL extends Selector<Path.Result<T, P>>>(path: P, selector: Selector.Shape<SL>): (source: T) => Selector.Result<Path.Result<T, P>, SL>

Returns a function that selects a certain shape from a given value with the given selector at the given string path.