UNPKG

pragmatic-fp-ts

Version:

Opinionated functional programming library with easy use in mind

18 lines (17 loc) 488 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pickBy = void 0; const main_1 = require("./main"); function pickBy(pred, dict) { if (arguments.length === 1) { return (_dict) => pickBy(pred, _dict); } const dd = (0, main_1.getValueOr)({}, dict); return Object.keys(dd).reduce((accum, key) => { if (pred(dd[key])) { accum[key] = dd[key]; } return accum; }, {}); } exports.pickBy = pickBy;