forked from hakimel/reveal.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerators.js
31 lines (27 loc) · 895 Bytes
/
generators.js
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
var _ = require('underscore')
var moment = require('moment')
var curry = require('prelude-ls').curry
var claire = require('claire')
var gens = claire.data
var resize = curry(function(n, gen){
return claire.sized(function(){return n}, gen)
});
var PosInt = claire.transform(Math.abs, gens.Int)
module.exports = _.extend({
PosInt: PosInt
,BigInt: claire.transform(
function(n){return Math.floor(n*2)},
resize(Number.MAX_VALUE/2, gens.Num)
)
,Time: claire.label('time')(claire.transform(function(hm) {
return { hours: hm[0], minutes: hm[1] }
}, claire.sequence(posIntOf(24), posIntOf(60))))
,Moment: claire.label('moment', claire.transform(moment.unix, posIntOf(2000000000)))
,resize: resize
,posIntOf: posIntOf
,yes: function(){return true}
,id: function(x){return x}
}, gens)
function posIntOf(n) {
return claire.sized(function() { return n; }, PosInt);
}