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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183 | 1
1
9
1
1
1
1
1
116
116
116
116
116
1
1
1
1
127
127
127
1
1
1
1
1
1
2240
2964
1
1272
1272
1272
1962
1272
40
86
86
86
86
86
2
13
13
13
13
2
14
14
14
14
3
10
10
10
10
8
480
480
480
508
480
27
136
136
136
136
136
6
18
18
18
18
18
8
33
33
11
211
211
211
217
211
20
5594
2609
2609
5594
113
199
199
3
1
1
1
| (function() {
var ArgTypeError, ArityError, NotImplementedYetError, assertions, firstFailure, mori, _, _ref, _ref1, _ref2, _ref3, _ref4, _ref5,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { Eif (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__slice = [].slice;
_ = (_ref = (_ref1 = (_ref2 = typeof window !== "undefined" && window !== null ? window._ : void 0) != null ? _ref2 : typeof self !== "undefined" && self !== null ? self._ : void 0) != null ? _ref1 : typeof global !== "undefined" && global !== null ? global._ : void 0) != null ? _ref : require('lodash-node');
mori = (_ref3 = (_ref4 = (_ref5 = typeof window !== "undefined" && window !== null ? window.mori : void 0) != null ? _ref5 : typeof self !== "undefined" && self !== null ? self.mori : void 0) != null ? _ref4 : typeof global !== "undefined" && global !== null ? global.mori : void 0) != null ? _ref3 : require('mori');
ArityError = (function(_super) {
__extends(ArityError, _super);
function ArityError() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
this.name = 'ArityError';
this.message = args.length === 3 ? "Expected " + args[0] + ".." + args[1] + " args, got " + args[2] : args[0];
this.stack = (new Error()).stack;
}
return ArityError;
})(Error);
ArgTypeError = (function(_super) {
__extends(ArgTypeError, _super);
function ArgTypeError(message) {
this.name = 'ArgTypeError';
this.message = message;
this.stack = (new Error()).stack;
}
return ArgTypeError;
})(Error);
NotImplementedYetError = (function(_super) {
__extends(NotImplementedYetError, _super);
function NotImplementedYetError(namespace, fn) {
this.name = 'NotImplementedYetError';
this.message = "clojure." + namespace + "/" + fn + " is not implemented yet";
this.stack = (new Error()).stack;
}
return NotImplementedYetError;
})(Error);
firstFailure = function(args, testFn) {
return _.find(args, function(arg) {
return !testFn(arg);
});
};
assertions = {
numbers: function() {
var args, unexpectedArg;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
unexpectedArg = firstFailure(_.flatten(args), function(arg) {
return typeof arg === 'number';
});
if (unexpectedArg !== void 0) {
throw new ArgTypeError("" + unexpectedArg + " is not a number");
}
},
integers: function() {
var args, unexpectedArg;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
unexpectedArg = firstFailure(_.flatten(args), function(arg) {
return typeof arg === 'number' && arg % 1 === 0;
});
if (unexpectedArg !== void 0) {
throw new ArgTypeError("" + unexpectedArg + " is not a integer");
}
},
associativeOrSet: function() {
var args, unexpectedArg;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (unexpectedArg = firstFailure(args, function(arg) {
return mori.is_associative(arg) || mori.is_set(arg);
})) {
throw new ArgTypeError("" + unexpectedArg + " is not a set or an associative collection");
}
},
associative: function() {
var args, unexpectedArg;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (unexpectedArg = firstFailure(args, function(arg) {
return mori.is_associative(arg);
})) {
throw new ArgTypeError("" + unexpectedArg + " is not an associative collection");
}
},
map: function() {
var args, unexpectedArg;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (unexpectedArg = firstFailure(args, function(arg) {
return mori.is_map(arg);
})) {
throw new ArgTypeError("" + unexpectedArg + " is not a map");
}
},
collection: function() {
var args, unexpectedArg;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
unexpectedArg = firstFailure(args, function(arg) {
return mori.is_seqable(arg) || _.isString(arg) || _.isArray(arg);
});
if (unexpectedArg) {
throw new ArgTypeError("" + unexpectedArg + " is not a collection");
}
},
sequential: function() {
var args, unexpectedArg;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
unexpectedArg = firstFailure(args, function(arg) {
return mori.is_sequential(arg) || _.isString(arg) || _.isArray(arg);
});
if (unexpectedArg) {
throw new ArgTypeError("" + unexpectedArg + " is not a sequential collection");
}
},
stack: function() {
var args, unexpectedArg;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
unexpectedArg = firstFailure(args, function(arg) {
return mori.is_vector(arg) || mori.is_list(arg);
});
if (unexpectedArg) {
throw new ArgTypeError("" + unexpectedArg + " does not support stack operations");
}
},
type_custom: function(checkFn) {
var msg;
if (msg = checkFn()) {
throw new ArgTypeError(msg);
}
},
"function": function() {
var args, unexpectedArg;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
unexpectedArg = firstFailure(args, function(arg) {
return typeof arg === 'function' || mori.is_vector(arg) || mori.is_map(arg) || mori.is_set(arg) || mori.is_keyword(arg);
});
if (unexpectedArg) {
throw new ArgTypeError("" + unexpectedArg + " is not a function");
}
},
arity: function(expected_min, expected_max, actual) {
if (arguments.length === 2) {
actual = expected_max;
expected_max = expected_min;
}
if (!((expected_min <= actual && actual <= expected_max))) {
throw new ArityError(expected_min, expected_max, actual);
}
},
arity_custom: function(args, checkFn) {
var msg;
if (msg = checkFn(args)) {
throw new ArityError(msg);
}
},
unimplemented: function(namespace, fn) {
throw new NotImplementedYetError(namespace, fn);
}
};
module.exports = assertions;
Iif (typeof self !== "undefined" && self !== null) {
self.closerAssertions = assertions;
}
Iif (typeof window !== "undefined" && window !== null) {
window.closerAssertions = assertions;
}
}).call(this);
|