A convenience function to streamline some map operations. Applies transform to those elements which satisfy condition while leaving other elements unchanged.
map
transform
condition
import * as A from "flurp/array";import * as L from "flurp/logic";import * as N from "flurp/number";const negativeToPositive = A.replace(N.isNegative, Math.abs);negativeToPositive([-1, 2, -3, 4, -5]); // [1, 2, 3, 4, 5]const zeroToOne = A.replace(L.equals(0), always(1));zeroToOne([0, 3, 4, 0]); // [1, 3, 4, 1]
A convenience function to streamline some
map
operations. Appliestransform
to those elements which satisfycondition
while leaving other elements unchanged.Example