-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ls
91 lines (32 loc) · 937 Bytes
/
main.ls
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
flyd = require "flyd"
initial-utils = require "@sourcevault/initial.utils"
{is-positive-integer-number} = initial-utils.numTypes
throwError = require "./throwError"
flyd = require "flyd"
wait = (t,f) -> setTimeout f,t
_until = (amount,stream) ->
count = 0
flyd.combine do
(downstream,self) ->
if (count < amount)
count += 1
if count is amount
do
<- wait 0
downstream.end true
return downstream!
else
downstream.end true
return void
[stream]
validate_and_run = (amount,stream) ->
if not (flyd.isStream stream)
throwError.not-flyd-stream!
return null
[is-correct-type,type] = is-positive-integer-number amount
if is-correct-type
_until amount,stream
else
throwError.amount-is-not-integer type
return null
module.exports = flyd.curryN 2 ,validate_and_run