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

x/rimbu/core/main/exports.ts>Deep.selectAtWith

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function Deep.selectAtWith
import { Deep } from "https://deno.land/x/rimbu@1.0.3/core/main/exports.ts";
const { selectAtWith } = Deep;

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

Examples

Example 1

const items = [{ a: { b:  1, c: 'a' } }, { a: { b: 2, c: 'b' } }];
items.map(Deep.selectAtWith('a', { q: 'c', z: ['b', v => v.b + 1] as const }));
// => [{ q: 'a', z: [1, 2] }, { q: 'b', z: [2, 3] }]

Type Parameters

T
P extends Path.Get<T>
SL extends Selector<Path.Result<T, P>>

Parameters

path: P
  • the string path in the object
selector: Selector.Shape<SL>
  • a shape indicating the selection from the source values