import type { Predicate } from "@thi.ng/api" ; import { isIterable } from "@thi.ng/checks/is-iterable" ; import type { Transducer } from "./api.js" ; import { comp } from "./comp.js" ; import { filter } from "./filter.js" ; import { iterator } from "./iterator.js" ; import { takeLast } from "./take-last.js" ; example example param pred param src export function matchLast < T > ( pred ) ; export function matchLast < T > ( pred , src ) ; export function matchLast < T > ( pred , src ? ) { return isIterable ( src ) ? [ ... iterator ( matchLast ( pred ) , src ) ] [ 0 ] : comp ( filter ( pred ) , takeLast ( 1 ) ) ; }