@unsplash/sum-types-fast-check
Version:
fast-check bindings for @unsplash/sum-types.
14 lines (13 loc) • 512 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getArb = exports.nullaryArb = void 0;
const fast_check_1 = require("fast-check");
exports.nullaryArb = fast_check_1.default.constant(null);
const getArb = (sum) => (arbs) => {
const tags = Object.keys(arbs);
const tagArb = fast_check_1.default.constantFrom(...tags);
return (tagArb
.chain(tag => arbs[tag].map(val => [tag, val]))
.map(([tag, val]) => sum.mk[tag](val)));
};
exports.getArb = getArb;