protobufjs 6.11.4 → 6.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/node_modules/.package-lock.json +86 -32
- package/cli/node_modules/@babel/parser/package.json +66 -30
- package/cli/node_modules/@types/linkify-it/package.json +65 -36
- package/cli/node_modules/@types/markdown-it/package.json +67 -39
- package/cli/node_modules/@types/mdurl/package.json +53 -21
- package/cli/node_modules/acorn/package.json +48 -17
- package/cli/node_modules/acorn-jsx/package.json +42 -11
- package/cli/node_modules/argparse/package.json +52 -17
- package/cli/node_modules/bluebird/package.json +65 -38
- package/cli/node_modules/brace-expansion/index.js +14 -12
- package/cli/node_modules/brace-expansion/package.json +4 -1
- package/cli/node_modules/catharsis/package.json +44 -10
- package/cli/node_modules/deep-is/.travis.yml +5 -0
- package/cli/node_modules/deep-is/LICENSE +22 -0
- package/cli/node_modules/deep-is/README.markdown +70 -0
- package/cli/node_modules/deep-is/example/cmp.js +11 -0
- package/cli/node_modules/deep-is/index.js +102 -0
- package/cli/node_modules/deep-is/package.json +58 -0
- package/cli/node_modules/deep-is/test/NaN.js +16 -0
- package/cli/node_modules/deep-is/test/cmp.js +23 -0
- package/cli/node_modules/deep-is/test/neg-vs-pos-0.js +15 -0
- package/cli/node_modules/entities/package.json +95 -60
- package/cli/node_modules/escape-string-regexp/package.json +84 -41
- package/cli/node_modules/escodegen/escodegen.js +25 -66
- package/cli/node_modules/escodegen/package.json +11 -13
- package/cli/node_modules/esprima/package.json +82 -54
- package/cli/node_modules/estraverse/estraverse.js +1 -24
- package/cli/node_modules/estraverse/package.json +1 -1
- package/cli/node_modules/esutils/package.json +52 -21
- package/cli/node_modules/fast-levenshtein/LICENSE.md +25 -0
- package/cli/node_modules/fast-levenshtein/README.md +104 -0
- package/cli/node_modules/fast-levenshtein/levenshtein.js +136 -0
- package/cli/node_modules/fast-levenshtein/package.json +39 -0
- package/cli/node_modules/fs.realpath/package.json +52 -16
- package/cli/node_modules/graceful-fs/package.json +57 -25
- package/cli/node_modules/inflight/package.json +44 -15
- package/cli/node_modules/inherits/package.json +44 -12
- package/cli/node_modules/js2xmlparser/package.json +94 -62
- package/cli/node_modules/klaw/package.json +53 -23
- package/cli/node_modules/levn/LICENSE +22 -0
- package/cli/node_modules/levn/README.md +196 -0
- package/cli/node_modules/levn/lib/cast.js +298 -0
- package/cli/node_modules/levn/lib/coerce.js +285 -0
- package/cli/node_modules/levn/lib/index.js +22 -0
- package/cli/node_modules/levn/lib/parse-string.js +113 -0
- package/cli/node_modules/levn/lib/parse.js +102 -0
- package/cli/node_modules/levn/package.json +47 -0
- package/cli/node_modules/linkify-it/package.json +58 -23
- package/cli/node_modules/lodash/package.json +61 -10
- package/cli/node_modules/markdown-it/package.json +68 -33
- package/cli/node_modules/markdown-it-anchor/package.json +72 -30
- package/cli/node_modules/marked/package.json +87 -52
- package/cli/node_modules/mdurl/package.json +44 -9
- package/cli/node_modules/minimatch/README.md +37 -0
- package/cli/node_modules/minimatch/minimatch.js +160 -102
- package/cli/node_modules/minimatch/package.json +2 -2
- package/cli/node_modules/mkdirp/package.json +56 -22
- package/cli/node_modules/once/package.json +48 -14
- package/cli/node_modules/optionator/CHANGELOG.md +56 -0
- package/cli/node_modules/optionator/LICENSE +22 -0
- package/cli/node_modules/optionator/README.md +238 -0
- package/cli/node_modules/optionator/lib/help.js +260 -0
- package/cli/node_modules/optionator/lib/index.js +465 -0
- package/cli/node_modules/optionator/lib/util.js +54 -0
- package/cli/node_modules/optionator/package.json +44 -0
- package/cli/node_modules/prelude-ls/CHANGELOG.md +99 -0
- package/cli/node_modules/prelude-ls/LICENSE +22 -0
- package/cli/node_modules/prelude-ls/README.md +15 -0
- package/cli/node_modules/prelude-ls/lib/Func.js +65 -0
- package/cli/node_modules/prelude-ls/lib/List.js +686 -0
- package/cli/node_modules/prelude-ls/lib/Num.js +130 -0
- package/cli/node_modules/prelude-ls/lib/Obj.js +154 -0
- package/cli/node_modules/prelude-ls/lib/Str.js +92 -0
- package/cli/node_modules/prelude-ls/lib/index.js +178 -0
- package/cli/node_modules/prelude-ls/package.json +52 -0
- package/cli/node_modules/requizzle/package.json +52 -21
- package/cli/node_modules/source-map/package.json +197 -54
- package/cli/node_modules/strip-json-comments/package.json +80 -45
- package/cli/node_modules/tmp/README.md +47 -21
- package/cli/node_modules/tmp/lib/tmp.js +209 -147
- package/cli/node_modules/tmp/package.json +73 -37
- package/cli/node_modules/type-check/LICENSE +22 -0
- package/cli/node_modules/type-check/README.md +210 -0
- package/cli/node_modules/type-check/lib/check.js +126 -0
- package/cli/node_modules/type-check/lib/index.js +16 -0
- package/cli/node_modules/type-check/lib/parse-type.js +196 -0
- package/cli/node_modules/type-check/package.json +40 -0
- package/cli/node_modules/uc.micro/package.json +45 -9
- package/cli/node_modules/underscore/package.json +95 -61
- package/cli/node_modules/word-wrap/LICENSE +21 -0
- package/cli/node_modules/word-wrap/README.md +201 -0
- package/cli/node_modules/word-wrap/index.d.ts +50 -0
- package/cli/node_modules/word-wrap/index.js +61 -0
- package/cli/node_modules/word-wrap/package.json +77 -0
- package/cli/node_modules/wrappy/package.json +46 -16
- package/cli/node_modules/xmlcreate/package.json +87 -55
- package/cli/package-lock.json +842 -0
- package/cli/package.json +1 -1
- package/dist/light/protobuf.js +3 -2
- package/dist/light/protobuf.js.map +1 -1
- package/dist/light/protobuf.min.js +3 -3
- package/dist/light/protobuf.min.js.map +1 -1
- package/dist/minimal/protobuf.js +2 -2
- package/dist/minimal/protobuf.min.js +3 -3
- package/dist/minimal/protobuf.min.js.map +1 -1
- package/dist/protobuf.js +3 -2
- package/dist/protobuf.js.map +1 -1
- package/dist/protobuf.min.js +3 -3
- package/dist/protobuf.min.js.map +1 -1
- package/package.json +1 -1
- package/src/type.js +1 -0
- package/cli/node_modules/rimraf/CHANGELOG.md +0 -65
- package/cli/node_modules/rimraf/LICENSE +0 -15
- package/cli/node_modules/rimraf/README.md +0 -101
- package/cli/node_modules/rimraf/bin.js +0 -68
- package/cli/node_modules/rimraf/package.json +0 -32
- package/cli/node_modules/rimraf/rimraf.js +0 -360
- package/cli/node_modules/tmp/CHANGELOG.md +0 -288
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// Generated by LiveScript 1.4.0
|
|
2
|
+
(function(){
|
|
3
|
+
var parsedTypeCheck, types, toString$ = {}.toString;
|
|
4
|
+
parsedTypeCheck = require('type-check').parsedTypeCheck;
|
|
5
|
+
types = {
|
|
6
|
+
'*': function(value, options){
|
|
7
|
+
switch (toString$.call(value).slice(8, -1)) {
|
|
8
|
+
case 'Array':
|
|
9
|
+
return typeCast(value, {
|
|
10
|
+
type: 'Array'
|
|
11
|
+
}, options);
|
|
12
|
+
case 'Object':
|
|
13
|
+
return typeCast(value, {
|
|
14
|
+
type: 'Object'
|
|
15
|
+
}, options);
|
|
16
|
+
default:
|
|
17
|
+
return {
|
|
18
|
+
type: 'Just',
|
|
19
|
+
value: typesCast(value, [
|
|
20
|
+
{
|
|
21
|
+
type: 'Undefined'
|
|
22
|
+
}, {
|
|
23
|
+
type: 'Null'
|
|
24
|
+
}, {
|
|
25
|
+
type: 'NaN'
|
|
26
|
+
}, {
|
|
27
|
+
type: 'Boolean'
|
|
28
|
+
}, {
|
|
29
|
+
type: 'Number'
|
|
30
|
+
}, {
|
|
31
|
+
type: 'Date'
|
|
32
|
+
}, {
|
|
33
|
+
type: 'RegExp'
|
|
34
|
+
}, {
|
|
35
|
+
type: 'Array'
|
|
36
|
+
}, {
|
|
37
|
+
type: 'Object'
|
|
38
|
+
}, {
|
|
39
|
+
type: 'String'
|
|
40
|
+
}
|
|
41
|
+
], (options.explicit = true, options))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
Undefined: function(it){
|
|
46
|
+
if (it === 'undefined' || it === void 8) {
|
|
47
|
+
return {
|
|
48
|
+
type: 'Just',
|
|
49
|
+
value: void 8
|
|
50
|
+
};
|
|
51
|
+
} else {
|
|
52
|
+
return {
|
|
53
|
+
type: 'Nothing'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
Null: function(it){
|
|
58
|
+
if (it === 'null') {
|
|
59
|
+
return {
|
|
60
|
+
type: 'Just',
|
|
61
|
+
value: null
|
|
62
|
+
};
|
|
63
|
+
} else {
|
|
64
|
+
return {
|
|
65
|
+
type: 'Nothing'
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
NaN: function(it){
|
|
70
|
+
if (it === 'NaN') {
|
|
71
|
+
return {
|
|
72
|
+
type: 'Just',
|
|
73
|
+
value: NaN
|
|
74
|
+
};
|
|
75
|
+
} else {
|
|
76
|
+
return {
|
|
77
|
+
type: 'Nothing'
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
Boolean: function(it){
|
|
82
|
+
if (it === 'true') {
|
|
83
|
+
return {
|
|
84
|
+
type: 'Just',
|
|
85
|
+
value: true
|
|
86
|
+
};
|
|
87
|
+
} else if (it === 'false') {
|
|
88
|
+
return {
|
|
89
|
+
type: 'Just',
|
|
90
|
+
value: false
|
|
91
|
+
};
|
|
92
|
+
} else {
|
|
93
|
+
return {
|
|
94
|
+
type: 'Nothing'
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
Number: function(it){
|
|
99
|
+
return {
|
|
100
|
+
type: 'Just',
|
|
101
|
+
value: +it
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
Int: function(it){
|
|
105
|
+
return {
|
|
106
|
+
type: 'Just',
|
|
107
|
+
value: +it
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
Float: function(it){
|
|
111
|
+
return {
|
|
112
|
+
type: 'Just',
|
|
113
|
+
value: +it
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
Date: function(value, options){
|
|
117
|
+
var that;
|
|
118
|
+
if (that = /^\#([\s\S]*)\#$/.exec(value)) {
|
|
119
|
+
return {
|
|
120
|
+
type: 'Just',
|
|
121
|
+
value: new Date(+that[1] || that[1])
|
|
122
|
+
};
|
|
123
|
+
} else if (options.explicit) {
|
|
124
|
+
return {
|
|
125
|
+
type: 'Nothing'
|
|
126
|
+
};
|
|
127
|
+
} else {
|
|
128
|
+
return {
|
|
129
|
+
type: 'Just',
|
|
130
|
+
value: new Date(+value || value)
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
RegExp: function(value, options){
|
|
135
|
+
var that;
|
|
136
|
+
if (that = /^\/([\s\S]*)\/([gimy]*)$/.exec(value)) {
|
|
137
|
+
return {
|
|
138
|
+
type: 'Just',
|
|
139
|
+
value: new RegExp(that[1], that[2])
|
|
140
|
+
};
|
|
141
|
+
} else if (options.explicit) {
|
|
142
|
+
return {
|
|
143
|
+
type: 'Nothing'
|
|
144
|
+
};
|
|
145
|
+
} else {
|
|
146
|
+
return {
|
|
147
|
+
type: 'Just',
|
|
148
|
+
value: new RegExp(value)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
Array: function(value, options){
|
|
153
|
+
return castArray(value, {
|
|
154
|
+
of: [{
|
|
155
|
+
type: '*'
|
|
156
|
+
}]
|
|
157
|
+
}, options);
|
|
158
|
+
},
|
|
159
|
+
Object: function(value, options){
|
|
160
|
+
return castFields(value, {
|
|
161
|
+
of: {}
|
|
162
|
+
}, options);
|
|
163
|
+
},
|
|
164
|
+
String: function(it){
|
|
165
|
+
var that;
|
|
166
|
+
if (toString$.call(it).slice(8, -1) !== 'String') {
|
|
167
|
+
return {
|
|
168
|
+
type: 'Nothing'
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
if (that = it.match(/^'([\s\S]*)'$/)) {
|
|
172
|
+
return {
|
|
173
|
+
type: 'Just',
|
|
174
|
+
value: that[1].replace(/\\'/g, "'")
|
|
175
|
+
};
|
|
176
|
+
} else if (that = it.match(/^"([\s\S]*)"$/)) {
|
|
177
|
+
return {
|
|
178
|
+
type: 'Just',
|
|
179
|
+
value: that[1].replace(/\\"/g, '"')
|
|
180
|
+
};
|
|
181
|
+
} else {
|
|
182
|
+
return {
|
|
183
|
+
type: 'Just',
|
|
184
|
+
value: it
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
function castArray(node, type, options){
|
|
190
|
+
var typeOf, element;
|
|
191
|
+
if (toString$.call(node).slice(8, -1) !== 'Array') {
|
|
192
|
+
return {
|
|
193
|
+
type: 'Nothing'
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
typeOf = type.of;
|
|
197
|
+
return {
|
|
198
|
+
type: 'Just',
|
|
199
|
+
value: (function(){
|
|
200
|
+
var i$, ref$, len$, results$ = [];
|
|
201
|
+
for (i$ = 0, len$ = (ref$ = node).length; i$ < len$; ++i$) {
|
|
202
|
+
element = ref$[i$];
|
|
203
|
+
results$.push(typesCast(element, typeOf, options));
|
|
204
|
+
}
|
|
205
|
+
return results$;
|
|
206
|
+
}())
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function castTuple(node, type, options){
|
|
210
|
+
var result, i, i$, ref$, len$, types, cast;
|
|
211
|
+
if (toString$.call(node).slice(8, -1) !== 'Array') {
|
|
212
|
+
return {
|
|
213
|
+
type: 'Nothing'
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
result = [];
|
|
217
|
+
i = 0;
|
|
218
|
+
for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
|
|
219
|
+
types = ref$[i$];
|
|
220
|
+
cast = typesCast(node[i], types, options);
|
|
221
|
+
if (toString$.call(cast).slice(8, -1) !== 'Undefined') {
|
|
222
|
+
result.push(cast);
|
|
223
|
+
}
|
|
224
|
+
i++;
|
|
225
|
+
}
|
|
226
|
+
if (node.length <= i) {
|
|
227
|
+
return {
|
|
228
|
+
type: 'Just',
|
|
229
|
+
value: result
|
|
230
|
+
};
|
|
231
|
+
} else {
|
|
232
|
+
return {
|
|
233
|
+
type: 'Nothing'
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function castFields(node, type, options){
|
|
238
|
+
var typeOf, key, value;
|
|
239
|
+
if (toString$.call(node).slice(8, -1) !== 'Object') {
|
|
240
|
+
return {
|
|
241
|
+
type: 'Nothing'
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
typeOf = type.of;
|
|
245
|
+
return {
|
|
246
|
+
type: 'Just',
|
|
247
|
+
value: (function(){
|
|
248
|
+
var ref$, resultObj$ = {};
|
|
249
|
+
for (key in ref$ = node) {
|
|
250
|
+
value = ref$[key];
|
|
251
|
+
resultObj$[typesCast(key, [{
|
|
252
|
+
type: 'String'
|
|
253
|
+
}], options)] = typesCast(value, typeOf[key] || [{
|
|
254
|
+
type: '*'
|
|
255
|
+
}], options);
|
|
256
|
+
}
|
|
257
|
+
return resultObj$;
|
|
258
|
+
}())
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function typeCast(node, typeObj, options){
|
|
262
|
+
var type, structure, castFunc, ref$;
|
|
263
|
+
type = typeObj.type, structure = typeObj.structure;
|
|
264
|
+
if (type) {
|
|
265
|
+
castFunc = ((ref$ = options.customTypes[type]) != null ? ref$.cast : void 8) || types[type];
|
|
266
|
+
if (!castFunc) {
|
|
267
|
+
throw new Error("Type not defined: " + type + ".");
|
|
268
|
+
}
|
|
269
|
+
return castFunc(node, options, typesCast);
|
|
270
|
+
} else {
|
|
271
|
+
switch (structure) {
|
|
272
|
+
case 'array':
|
|
273
|
+
return castArray(node, typeObj, options);
|
|
274
|
+
case 'tuple':
|
|
275
|
+
return castTuple(node, typeObj, options);
|
|
276
|
+
case 'fields':
|
|
277
|
+
return castFields(node, typeObj, options);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function typesCast(node, types, options){
|
|
282
|
+
var i$, len$, type, ref$, valueType, value;
|
|
283
|
+
for (i$ = 0, len$ = types.length; i$ < len$; ++i$) {
|
|
284
|
+
type = types[i$];
|
|
285
|
+
ref$ = typeCast(node, type, options), valueType = ref$.type, value = ref$.value;
|
|
286
|
+
if (valueType === 'Nothing') {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (parsedTypeCheck([type], value, {
|
|
290
|
+
customTypes: options.customTypes
|
|
291
|
+
})) {
|
|
292
|
+
return value;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
throw new Error("Value " + JSON.stringify(node) + " does not type check against " + JSON.stringify(types) + ".");
|
|
296
|
+
}
|
|
297
|
+
module.exports = typesCast;
|
|
298
|
+
}).call(this);
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
// Generated by LiveScript 1.2.0
|
|
2
|
+
(function(){
|
|
3
|
+
var parsedTypeCheck, types, toString$ = {}.toString;
|
|
4
|
+
parsedTypeCheck = require('type-check').parsedTypeCheck;
|
|
5
|
+
types = {
|
|
6
|
+
'*': function(it){
|
|
7
|
+
switch (toString$.call(it).slice(8, -1)) {
|
|
8
|
+
case 'Array':
|
|
9
|
+
return coerceType(it, {
|
|
10
|
+
type: 'Array'
|
|
11
|
+
});
|
|
12
|
+
case 'Object':
|
|
13
|
+
return coerceType(it, {
|
|
14
|
+
type: 'Object'
|
|
15
|
+
});
|
|
16
|
+
default:
|
|
17
|
+
return {
|
|
18
|
+
type: 'Just',
|
|
19
|
+
value: coerceTypes(it, [
|
|
20
|
+
{
|
|
21
|
+
type: 'Undefined'
|
|
22
|
+
}, {
|
|
23
|
+
type: 'Null'
|
|
24
|
+
}, {
|
|
25
|
+
type: 'NaN'
|
|
26
|
+
}, {
|
|
27
|
+
type: 'Boolean'
|
|
28
|
+
}, {
|
|
29
|
+
type: 'Number'
|
|
30
|
+
}, {
|
|
31
|
+
type: 'Date'
|
|
32
|
+
}, {
|
|
33
|
+
type: 'RegExp'
|
|
34
|
+
}, {
|
|
35
|
+
type: 'Array'
|
|
36
|
+
}, {
|
|
37
|
+
type: 'Object'
|
|
38
|
+
}, {
|
|
39
|
+
type: 'String'
|
|
40
|
+
}
|
|
41
|
+
], {
|
|
42
|
+
explicit: true
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
Undefined: function(it){
|
|
48
|
+
if (it === 'undefined' || it === void 8) {
|
|
49
|
+
return {
|
|
50
|
+
type: 'Just',
|
|
51
|
+
value: void 8
|
|
52
|
+
};
|
|
53
|
+
} else {
|
|
54
|
+
return {
|
|
55
|
+
type: 'Nothing'
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
Null: function(it){
|
|
60
|
+
if (it === 'null') {
|
|
61
|
+
return {
|
|
62
|
+
type: 'Just',
|
|
63
|
+
value: null
|
|
64
|
+
};
|
|
65
|
+
} else {
|
|
66
|
+
return {
|
|
67
|
+
type: 'Nothing'
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
NaN: function(it){
|
|
72
|
+
if (it === 'NaN') {
|
|
73
|
+
return {
|
|
74
|
+
type: 'Just',
|
|
75
|
+
value: NaN
|
|
76
|
+
};
|
|
77
|
+
} else {
|
|
78
|
+
return {
|
|
79
|
+
type: 'Nothing'
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
Boolean: function(it){
|
|
84
|
+
if (it === 'true') {
|
|
85
|
+
return {
|
|
86
|
+
type: 'Just',
|
|
87
|
+
value: true
|
|
88
|
+
};
|
|
89
|
+
} else if (it === 'false') {
|
|
90
|
+
return {
|
|
91
|
+
type: 'Just',
|
|
92
|
+
value: false
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
return {
|
|
96
|
+
type: 'Nothing'
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
Number: function(it){
|
|
101
|
+
return {
|
|
102
|
+
type: 'Just',
|
|
103
|
+
value: +it
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
Int: function(it){
|
|
107
|
+
return {
|
|
108
|
+
type: 'Just',
|
|
109
|
+
value: parseInt(it)
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
Float: function(it){
|
|
113
|
+
return {
|
|
114
|
+
type: 'Just',
|
|
115
|
+
value: parseFloat(it)
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
Date: function(value, options){
|
|
119
|
+
var that;
|
|
120
|
+
if (that = /^\#(.*)\#$/.exec(value)) {
|
|
121
|
+
return {
|
|
122
|
+
type: 'Just',
|
|
123
|
+
value: new Date(+that[1] || that[1])
|
|
124
|
+
};
|
|
125
|
+
} else if (options.explicit) {
|
|
126
|
+
return {
|
|
127
|
+
type: 'Nothing'
|
|
128
|
+
};
|
|
129
|
+
} else {
|
|
130
|
+
return {
|
|
131
|
+
type: 'Just',
|
|
132
|
+
value: new Date(+value || value)
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
RegExp: function(value, options){
|
|
137
|
+
var that;
|
|
138
|
+
if (that = /^\/(.*)\/([gimy]*)$/.exec(value)) {
|
|
139
|
+
return {
|
|
140
|
+
type: 'Just',
|
|
141
|
+
value: new RegExp(that[1], that[2])
|
|
142
|
+
};
|
|
143
|
+
} else if (options.explicit) {
|
|
144
|
+
return {
|
|
145
|
+
type: 'Nothing'
|
|
146
|
+
};
|
|
147
|
+
} else {
|
|
148
|
+
return {
|
|
149
|
+
type: 'Just',
|
|
150
|
+
value: new RegExp(value)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
Array: function(it){
|
|
155
|
+
return coerceArray(it, {
|
|
156
|
+
of: [{
|
|
157
|
+
type: '*'
|
|
158
|
+
}]
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
Object: function(it){
|
|
162
|
+
return coerceFields(it, {
|
|
163
|
+
of: {}
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
String: function(it){
|
|
167
|
+
var that;
|
|
168
|
+
if (toString$.call(it).slice(8, -1) !== 'String') {
|
|
169
|
+
return {
|
|
170
|
+
type: 'Nothing'
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (that = it.match(/^'(.*)'$/)) {
|
|
174
|
+
return {
|
|
175
|
+
type: 'Just',
|
|
176
|
+
value: that[1]
|
|
177
|
+
};
|
|
178
|
+
} else if (that = it.match(/^"(.*)"$/)) {
|
|
179
|
+
return {
|
|
180
|
+
type: 'Just',
|
|
181
|
+
value: that[1]
|
|
182
|
+
};
|
|
183
|
+
} else {
|
|
184
|
+
return {
|
|
185
|
+
type: 'Just',
|
|
186
|
+
value: it
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
function coerceArray(node, type){
|
|
192
|
+
var typeOf, element;
|
|
193
|
+
if (toString$.call(node).slice(8, -1) !== 'Array') {
|
|
194
|
+
return {
|
|
195
|
+
type: 'Nothing'
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
typeOf = type.of;
|
|
199
|
+
return {
|
|
200
|
+
type: 'Just',
|
|
201
|
+
value: (function(){
|
|
202
|
+
var i$, ref$, len$, results$ = [];
|
|
203
|
+
for (i$ = 0, len$ = (ref$ = node).length; i$ < len$; ++i$) {
|
|
204
|
+
element = ref$[i$];
|
|
205
|
+
results$.push(coerceTypes(element, typeOf));
|
|
206
|
+
}
|
|
207
|
+
return results$;
|
|
208
|
+
}())
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function coerceTuple(node, type){
|
|
212
|
+
var result, i$, ref$, len$, i, types, that;
|
|
213
|
+
if (toString$.call(node).slice(8, -1) !== 'Array') {
|
|
214
|
+
return {
|
|
215
|
+
type: 'Nothing'
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
result = [];
|
|
219
|
+
for (i$ = 0, len$ = (ref$ = type.of).length; i$ < len$; ++i$) {
|
|
220
|
+
i = i$;
|
|
221
|
+
types = ref$[i$];
|
|
222
|
+
if (that = coerceTypes(node[i], types)) {
|
|
223
|
+
result.push(that);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
type: 'Just',
|
|
228
|
+
value: result
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function coerceFields(node, type){
|
|
232
|
+
var typeOf, key, value;
|
|
233
|
+
if (toString$.call(node).slice(8, -1) !== 'Object') {
|
|
234
|
+
return {
|
|
235
|
+
type: 'Nothing'
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
typeOf = type.of;
|
|
239
|
+
return {
|
|
240
|
+
type: 'Just',
|
|
241
|
+
value: (function(){
|
|
242
|
+
var ref$, results$ = {};
|
|
243
|
+
for (key in ref$ = node) {
|
|
244
|
+
value = ref$[key];
|
|
245
|
+
results$[key] = coerceTypes(value, typeOf[key] || [{
|
|
246
|
+
type: '*'
|
|
247
|
+
}]);
|
|
248
|
+
}
|
|
249
|
+
return results$;
|
|
250
|
+
}())
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function coerceType(node, typeObj, options){
|
|
254
|
+
var type, structure, coerceFunc;
|
|
255
|
+
type = typeObj.type, structure = typeObj.structure;
|
|
256
|
+
if (type) {
|
|
257
|
+
coerceFunc = types[type];
|
|
258
|
+
return coerceFunc(node, options);
|
|
259
|
+
} else {
|
|
260
|
+
switch (structure) {
|
|
261
|
+
case 'array':
|
|
262
|
+
return coerceArray(node, typeObj);
|
|
263
|
+
case 'tuple':
|
|
264
|
+
return coerceTuple(node, typeObj);
|
|
265
|
+
case 'fields':
|
|
266
|
+
return coerceFields(node, typeObj);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function coerceTypes(node, types, options){
|
|
271
|
+
var i$, len$, type, ref$, valueType, value;
|
|
272
|
+
for (i$ = 0, len$ = types.length; i$ < len$; ++i$) {
|
|
273
|
+
type = types[i$];
|
|
274
|
+
ref$ = coerceType(node, type, options), valueType = ref$.type, value = ref$.value;
|
|
275
|
+
if (valueType === 'Nothing') {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (parsedTypeCheck([type], value)) {
|
|
279
|
+
return value;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
throw new Error("Value " + JSON.stringify(node) + " does not type check against " + JSON.stringify(types) + ".");
|
|
283
|
+
}
|
|
284
|
+
module.exports = coerceTypes;
|
|
285
|
+
}).call(this);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Generated by LiveScript 1.4.0
|
|
2
|
+
(function(){
|
|
3
|
+
var parseString, cast, parseType, VERSION, parsedTypeParse, parse;
|
|
4
|
+
parseString = require('./parse-string');
|
|
5
|
+
cast = require('./cast');
|
|
6
|
+
parseType = require('type-check').parseType;
|
|
7
|
+
VERSION = '0.3.0';
|
|
8
|
+
parsedTypeParse = function(parsedType, string, options){
|
|
9
|
+
options == null && (options = {});
|
|
10
|
+
options.explicit == null && (options.explicit = false);
|
|
11
|
+
options.customTypes == null && (options.customTypes = {});
|
|
12
|
+
return cast(parseString(parsedType, string, options), parsedType, options);
|
|
13
|
+
};
|
|
14
|
+
parse = function(type, string, options){
|
|
15
|
+
return parsedTypeParse(parseType(type), string, options);
|
|
16
|
+
};
|
|
17
|
+
module.exports = {
|
|
18
|
+
VERSION: VERSION,
|
|
19
|
+
parse: parse,
|
|
20
|
+
parsedTypeParse: parsedTypeParse
|
|
21
|
+
};
|
|
22
|
+
}).call(this);
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Generated by LiveScript 1.4.0
|
|
2
|
+
(function(){
|
|
3
|
+
var reject, special, tokenRegex;
|
|
4
|
+
reject = require('prelude-ls').reject;
|
|
5
|
+
function consumeOp(tokens, op){
|
|
6
|
+
if (tokens[0] === op) {
|
|
7
|
+
return tokens.shift();
|
|
8
|
+
} else {
|
|
9
|
+
throw new Error("Expected '" + op + "', but got '" + tokens[0] + "' instead in " + JSON.stringify(tokens) + ".");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function maybeConsumeOp(tokens, op){
|
|
13
|
+
if (tokens[0] === op) {
|
|
14
|
+
return tokens.shift();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function consumeList(tokens, arg$, hasDelimiters){
|
|
18
|
+
var open, close, result, untilTest;
|
|
19
|
+
open = arg$[0], close = arg$[1];
|
|
20
|
+
if (hasDelimiters) {
|
|
21
|
+
consumeOp(tokens, open);
|
|
22
|
+
}
|
|
23
|
+
result = [];
|
|
24
|
+
untilTest = "," + (hasDelimiters ? close : '');
|
|
25
|
+
while (tokens.length && (hasDelimiters && tokens[0] !== close)) {
|
|
26
|
+
result.push(consumeElement(tokens, untilTest));
|
|
27
|
+
maybeConsumeOp(tokens, ',');
|
|
28
|
+
}
|
|
29
|
+
if (hasDelimiters) {
|
|
30
|
+
consumeOp(tokens, close);
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
function consumeArray(tokens, hasDelimiters){
|
|
35
|
+
return consumeList(tokens, ['[', ']'], hasDelimiters);
|
|
36
|
+
}
|
|
37
|
+
function consumeTuple(tokens, hasDelimiters){
|
|
38
|
+
return consumeList(tokens, ['(', ')'], hasDelimiters);
|
|
39
|
+
}
|
|
40
|
+
function consumeFields(tokens, hasDelimiters){
|
|
41
|
+
var result, untilTest, key;
|
|
42
|
+
if (hasDelimiters) {
|
|
43
|
+
consumeOp(tokens, '{');
|
|
44
|
+
}
|
|
45
|
+
result = {};
|
|
46
|
+
untilTest = "," + (hasDelimiters ? '}' : '');
|
|
47
|
+
while (tokens.length && (!hasDelimiters || tokens[0] !== '}')) {
|
|
48
|
+
key = consumeValue(tokens, ':');
|
|
49
|
+
consumeOp(tokens, ':');
|
|
50
|
+
result[key] = consumeElement(tokens, untilTest);
|
|
51
|
+
maybeConsumeOp(tokens, ',');
|
|
52
|
+
}
|
|
53
|
+
if (hasDelimiters) {
|
|
54
|
+
consumeOp(tokens, '}');
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
function consumeValue(tokens, untilTest){
|
|
59
|
+
var out;
|
|
60
|
+
untilTest == null && (untilTest = '');
|
|
61
|
+
out = '';
|
|
62
|
+
while (tokens.length && -1 === untilTest.indexOf(tokens[0])) {
|
|
63
|
+
out += tokens.shift();
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
function consumeElement(tokens, untilTest){
|
|
68
|
+
switch (tokens[0]) {
|
|
69
|
+
case '[':
|
|
70
|
+
return consumeArray(tokens, true);
|
|
71
|
+
case '(':
|
|
72
|
+
return consumeTuple(tokens, true);
|
|
73
|
+
case '{':
|
|
74
|
+
return consumeFields(tokens, true);
|
|
75
|
+
default:
|
|
76
|
+
return consumeValue(tokens, untilTest);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function consumeTopLevel(tokens, types, options){
|
|
80
|
+
var ref$, type, structure, origTokens, result, finalResult, x$, y$;
|
|
81
|
+
ref$ = types[0], type = ref$.type, structure = ref$.structure;
|
|
82
|
+
origTokens = tokens.concat();
|
|
83
|
+
if (!options.explicit && types.length === 1 && ((!type && structure) || (type === 'Array' || type === 'Object'))) {
|
|
84
|
+
result = structure === 'array' || type === 'Array'
|
|
85
|
+
? consumeArray(tokens, tokens[0] === '[')
|
|
86
|
+
: structure === 'tuple'
|
|
87
|
+
? consumeTuple(tokens, tokens[0] === '(')
|
|
88
|
+
: consumeFields(tokens, tokens[0] === '{');
|
|
89
|
+
finalResult = tokens.length ? consumeElement(structure === 'array' || type === 'Array'
|
|
90
|
+
? (x$ = origTokens, x$.unshift('['), x$.push(']'), x$)
|
|
91
|
+
: (y$ = origTokens, y$.unshift('('), y$.push(')'), y$)) : result;
|
|
92
|
+
} else {
|
|
93
|
+
finalResult = consumeElement(tokens);
|
|
94
|
+
}
|
|
95
|
+
return finalResult;
|
|
96
|
+
}
|
|
97
|
+
special = /\[\]\(\)}{:,/.source;
|
|
98
|
+
tokenRegex = RegExp('("(?:\\\\"|[^"])*")|(\'(?:\\\\\'|[^\'])*\')|(/(?:\\\\/|[^/])*/[a-zA-Z]*)|(#.*#)|([' + special + '])|([^\\s' + special + '](?:\\s*[^\\s' + special + ']+)*)|\\s*');
|
|
99
|
+
module.exports = function(types, string, options){
|
|
100
|
+
var tokens, node;
|
|
101
|
+
options == null && (options = {});
|
|
102
|
+
if (!options.explicit && types.length === 1 && types[0].type === 'String') {
|
|
103
|
+
return "'" + string.replace(/\\'/g, "\\\\'") + "'";
|
|
104
|
+
}
|
|
105
|
+
tokens = reject(not$, string.split(tokenRegex));
|
|
106
|
+
node = consumeTopLevel(tokens, types, options);
|
|
107
|
+
if (!node) {
|
|
108
|
+
throw new Error("Error parsing '" + string + "'.");
|
|
109
|
+
}
|
|
110
|
+
return node;
|
|
111
|
+
};
|
|
112
|
+
function not$(x){ return !x; }
|
|
113
|
+
}).call(this);
|