Similar to act, but functions return empty values instead of Opt. It is useful for typical JavaScript functions (e.g. lodash), properly handles undefined/null/NaN at any point of the chain.
undefined
null
NaN
import {find} from 'lodash/fp';const data = [{}, {f: true, a: [{b: 7, c: 1}]}, {a: [{}]}];opt(data).actToOpt( find(x => Boolean(x?.f)), // {f: true, a: [{b: 7, c: 1}]} x => x?.a, // [{b: 7, c: 1}] find(x => x.b === 8) // undefined); // None
actToOpt
Similar to act, but functions return empty values instead of Opt. It is useful for typical JavaScript functions (e.g. lodash), properly handles
undefined
/null
/NaN
at any point of the chain.