1 | "use strict";
|
2 |
|
3 | var environment = require("./environment.js");
|
4 | var record = require("./record.js");
|
5 | var typify = require("./typify.js");
|
6 | var utils = require("./utils.js");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function recordWithEnv(spec, userenv) {
|
16 | var env = userenv ? utils.merge(environment, userenv) : environment;
|
17 |
|
18 | var parsedSpec = {};
|
19 | Object.keys(spec).forEach(function (k) {
|
20 | var arb = spec[k];
|
21 | parsedSpec[k] = typeof arb === "string" ? typify.parseTypify(env, arb) : arb;
|
22 | });
|
23 |
|
24 | return record.arbitrary(parsedSpec);
|
25 | }
|
26 |
|
27 | module.exports = recordWithEnv;
|