pragmatic-fp-ts
Version:
Opinionated functional programming library with easy use in mind
20 lines (19 loc) • 670 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNotEmpty = exports.isEmpty = void 0;
const main_1 = require("./main");
function isEmpty(coll) {
const theColl = (0, main_1.getValue)(coll);
return typeof coll === "number"
? false
: (0, main_1.isNothing)(coll) || (0, main_1.isNil)(theColl) || (0, main_1.isLeft)(coll)
? true
: coll instanceof Array || typeof coll === "string"
? coll.length === 0
: Object.keys(theColl).length === 0;
}
exports.isEmpty = isEmpty;
function isNotEmpty(coll) {
return !isEmpty(coll);
}
exports.isNotEmpty = isNotEmpty;