Skip to main content
Module

x/fae/transduce.ts>transduce

A functional module for Deno inspired from Ramda.
Latest
function transduce
import { transduce } from "https://deno.land/x/fae@v1.1.1/transduce.ts";

Initializes a transducer using supplied iterator function transformer2. Returns a single item by iterating through the list, successively calling the transformed transformer2 and passing it acc and the current value from the array, and then passing through transformer1 and then passing the result to the next call.

 const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
 const t1 = Fae.pipe(
   Fae.map(inc),
   Fae.filter(even),
   Fae.take(2)
 )
 t1(arr) // [2, 4]
 Fae.transduce(t1, Fae.flip(Fae.append), [], arr) // [3]

Type Parameters

T
optional
L = T

Parameters

transformer1: Func
transformer2: Func | Transformer
acc: T
functor: L[]

Returns

unknown