forked from adleroliveira/dreamjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.js
More file actions
119 lines (97 loc) · 2.07 KB
/
examples.js
File metadata and controls
119 lines (97 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//Examples used in the Readme.md
var dream = require('./dream');
var helloworld = dream.output();
console.log(helloworld);
dream.output(function(err, result){
console.log(result);
});
var data = dream
.schema({
name: String
})
.output();
console.log(data);
dream.schema('User',{
name: String,
age: Number
});
dream.schema('Location',{
address: String,
postcode: Number
});
dream
.useSchema('Location')
.output(function(err, result){
console.log(result);
});
dream.schema('User',{
name: String,
});
var data1 = dream
.useSchema('User')
.generate(3)
.output();
var data2 = dream
.useSchema('User')
.generateRnd(3)
.output();
console.log(data1);
console.log(data2);
dream.customType('pi', function(){
return Math.PI;
});
dream.customType('hello', /hello+ (world|to you)/);
dream
.schema({
name: 'name',
age: 'age',
address: 'address',
contact: {
phone: 'phone',
servicePhone: /^(800[1-9]{6})$/,
},
foo: function(){
return 'bar';
},
pi: 'pi',
hello: 'hello'
})
.generateRnd(2)
.output(function(err, result){
console.log(result);
});
dream.customType('FiveWordsSentence', function(helper){
return helper.chance.sentence({words:5});
});
dream
.schema({
frase: 'FiveWordsSentence',
})
.generateRnd(2)
.output(function(err, result){
console.log(result);
});
dream.customType('customTypeWithInput', function(helper){
return helper.input.value;
});
dream
.input({value: 'Provided by an input'})
.schema({
result: 'customTypeWithInput',
})
.generateRnd()
.output(function(err, result){
console.log(result);
});
dream.customType('icecreamTruckDay', function (helper) {
var businessDays = ['Monday', 'Wednesday', 'Friday'];
return helper.oneOf(businessDays);
});
dream
.schema({
icecreamDay: 'icecreamTruckDay',
})
.generateRnd(2)
.output(function(err, result){
console.log(result);
});