UNPKG

dts-element-fp

Version:

typescript definition generator for functional programming

24 lines (23 loc) 692 B
"use strict"; exports.__esModule = true; var R = require("ramda"); var match_1 = require("./match"); /** * (object: any, target: any) => boolean * * Returns `true` if `object` contains something matches `target` recursively, `false` otherwise. */ exports.has = R.curry(internal_has)(R.__, R.__, []); function internal_has(object, target, path) { return R.cond([ [/* is cyclic */ R.contains(R.__, path), R.F], [match_1.match(target), R.T], [R.isNil, R.F], [ R.T, R.pipe(R.keys, R.any(function (key) { return internal_has(object[key], target, R.append(object, path)); })), ], ])(object); }