-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.ls
143 lines (73 loc) · 2.12 KB
/
utils.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
MODULE_NAME = "flyd-group-within"
_ = require "ramda"
chalk = require "chalk"
data = {}
..name = "#{MODULE_NAME}"
..readmeURL = "github.com/sourcevault/#{MODULE_NAME}/readme.md"
..flydURL = "github.com/paldepind/flyd"
color = {}
..highlight = chalk.bold.yellow
..main-attention = chalk.red.bold
..attention = chalk.blueBright
..focus = chalk.redBright
..normal = chalk.white
inform = {}
print-type-error = (text) ->
name = color.highlight data.name
err-text = color.normal """
[#{color.main-attention ('TYPE ERROR')}] from [#{name}]
#{text}
- more details on [#{name}] at:
#{color.highlight(data.readmeURL)}
"""
console.log err-text
inform.not-flyd-stream = !->
text = """
- second argument (stream) is of wrong type.
- stream value should be a #{color.highlight('flyd stream')} object.
- more details on [#{color.highlight('flyd')}] can be read at:
#{color.highlight(data.flydURL)}
"""
print-type-error text
inform.invalid-value-for-time = ({message,type})->
current-val-str = color.main-attention message
type-str = color.main-attention type
text = """
- first argument (time) is of wrong type [#{type-str}].
- time value should be #{color.highlight('positive and a number')}.
- current #{color.focus('incorrect')} value:
#{current-val-str}
"""
print-type-error text
is-postive-number = (input) ->
type = typeof input
data = {}
data.type = type
switch type
| 'number' =>
if 0 <= input < Infinity
return [true]
else
return [false,input]
| 'object' =>
if input is null
data.message = input
return [false,data]
else
data.message = JSON.stringify input,1,""
return [false,data]
| 'boolean' =>
data.message = input
return [false,data]
| 'undefined' =>
data.message = input
return [false,data]
| 'function' =>
data.message = input.toString!
return [false,data]
| 'string' =>
data.message = input
return [false,data]
module.exports =
is-postive-number:is-postive-number
inform:inform