pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
17 lines (16 loc) • 614 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.contains = void 0;
const main_1 = require("./main");
function contains(what, who) {
if (arguments.length === 1) {
const fn = (_who) => contains(what, _who);
return fn;
}
if ((0, main_1.isNil)((0, main_1.getValue)(who)) || (0, main_1.isNil)(what))
return false;
return typeof what === "string"
? (0, main_1.getValueOr)("", who).includes((0, main_1.getValueOr)("", what))
: (0, main_1.getValueOr)([], who).includes((0, main_1.getValue)(what));
}
exports.contains = contains;