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

x/rimbu/deep/index.ts>Deep.selectWith

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

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

Examples

Example 1

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

Parameters

selector: Selector.Shape<SL>
  • a shape indicating the selection from the source values

Returns

(source: T) => Selector.Result<T, SL>