pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
23 lines (22 loc) • 761 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.empty = void 0;
const main_1 = require("./main");
function empty(val) {
return typeof val === "string"
? ""
: val instanceof Array
? []
: (0, main_1.isMaybe)(val)
? (0, main_1.nothing)()
: (0, main_1.isChain)(val)
? (0, main_1.chain)(null)
: val instanceof Function
? () => undefined
: val instanceof Object
? val.empty instanceof Function
? val.empty()
: {}
: null;
}
exports.empty = empty;