UNPKG

fast-check

Version:

Property based testing framework for JavaScript (like QuickCheck)

18 lines (17 loc) 596 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dictionary = exports.toObject = void 0; const SetArbitrary_1 = require("./SetArbitrary"); const TupleArbitrary_1 = require("./TupleArbitrary"); function toObject(items) { const obj = {}; for (const keyValue of items) { obj[keyValue[0]] = keyValue[1]; } return obj; } exports.toObject = toObject; function dictionary(keyArb, valueArb) { return SetArbitrary_1.set(TupleArbitrary_1.tuple(keyArb, valueArb), (t1, t2) => t1[0] === t2[0]).map(toObject); } exports.dictionary = dictionary;