thi-ng/umbrella

View on GitHub
packages/transducers/src/push-copy.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { Reducer } from "./api.js";
import { reducer } from "./reduce.js";

export const pushCopy = <T>(): Reducer<T, T[]> =>
    reducer<T, T[]>(
        () => [],
        (acc, x) => ((acc = acc.slice()).push(x), acc)
    );