@thi.ng/transducers
Version:
Collection of ~170 lightweight, composable transducers, reducers, generators, iterators for functional data transformations
12 lines (11 loc) • 373 B
JavaScript
import { isIterable } from "@thi.ng/checks/is-iterable";
import { comp } from "./comp.js";
import { filter } from "./filter.js";
import { iterator } from "./iterator.js";
import { takeLast } from "./take-last.js";
function matchLast(pred, src) {
return isIterable(src) ? [...iterator(matchLast(pred), src)][0] : comp(filter(pred), takeLast(1));
}
export {
matchLast
};