or run

npx @tessl/cli init
Log in

Version

Files

docs

index.md
tile.json

task.mdevals/scenario-1/

Descriptor-Driven Pipeline

A small utility that converts shorthand descriptors into filter/map callbacks and applies them to collections.

Capabilities

Descriptor conversion

  • A string descriptor produces an accessor for the nested property it names, so filters drop items whose property value is falsy. @test
  • A [path, value] descriptor produces a predicate that keeps only items whose nested property strictly equals that value. @test
  • A plain-object descriptor produces a predicate that keeps only items containing the matching nested structure. @test
  • A function descriptor is returned unchanged to allow custom callbacks. @test

Pipeline execution

  • Running ordered steps (one or more filters followed by a single mapper) against a collection returns mapped values for items that satisfy all filters, preserving order. @test

Implementation

@generates

API

export type Descriptor =
  | string
  | [string, any]
  | Record<string, any>
  | ((value: any) => any);

export type Step =
  | { kind: "filter"; descriptor: Descriptor }
  | { kind: "map"; descriptor: Descriptor };

export function toCallback(descriptor: Descriptor): (value: any) => any;

/**
 * Applies each step to the collection in order. Filter steps keep items for which
 * the descriptor-based callback returns truthy. A single map step replaces each item
 * with the descriptor-based callback result. The map step must be last and is required.
 */
export function runPipeline(collection: any[], steps: Step[]): any[];

Dependencies { .dependencies }

lodash { .dependency }

Provides callback builders and matchers for property paths and shorthand descriptors.