/
Number.cljs
352 lines (242 loc) · 9.7 KB
/
Number.cljs
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
(ns js.Number
"The Number JavaScript object is a wrapper object allowing you
work with numerical values. A Number object is created using
Number() constructor. A primitive type object number is created
the Number() function."
(:refer-clojure :exclude []))
(defn is-na-n
"Method.
The Number.isNaN() method determines whether the passed value
`js.NaN` and its type is `js.Number`. It is a more robust version
the original, global `isNaN()`.
`Number.isNaN(value)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN`"
[this value]
(-> this (.isNaN value)))
(defn is-finite
"Method.
The Number.isFinite() method determines whether the passed value
a finite number.
`Number.isFinite(value)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite`"
[this value]
(-> this (.isFinite value)))
(defn is-integer
"Method.
The Number.isInteger() method determines whether the passed value
an integer.
`Number.isInteger(value)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger`"
[this value]
(-> this (.isInteger value)))
(defn is-safe-integer
"Method.
The Number.isSafeInteger() method determines whether the provided
is a number that is a safe integer.
`Number.isSafeInteger(testValue)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger`"
[this test-value]
(-> this (.isSafeInteger test-value)))
(defn to-integer
"Method.
Used to evaluate the passed value and convert it to an integer
Infinity), but has been removed."
[this & args]
(-> this .-toInteger (.apply this (clj->js args))))
(defn parse-float
"Method.
The Number.parseFloat() method parses a string argument and returns
floating point number.
`Number.parseFloat(string)`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseFloat`"
[this string]
(-> this (.parseFloat string)))
(defn parse-int
"Method.
The Number.parseInt() method parses a string argument and returns
integer of the specified radix or base.
`Number.parseInt(string,[ radix])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt`"
[this & args]
(-> this .-parseInt (.apply this (clj->js args))))
(defn to-exponential
"Method.
The toExponential() method returns a string representing the
object in exponential notation.
`numObj.toExponential([fractionDigits])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential`"
[this & args]
(-> this .-toExponential (.apply this (clj->js args))))
(defn to-fixed
"Method.
The toFixed() method formats a number using fixed-point notation.
`numObj.toFixed([digits])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed`"
[this & args]
(-> this .-toFixed (.apply this (clj->js args))))
(defn to-locale-string
"Method.
The toLocaleString() method returns a string with a language-sensitive
of this number.
`numObj.toLocaleString([locales [, options]])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString`"
[this & args]
(-> this .-toLocaleString (.apply this (clj->js args))))
(defn to-precision
"Method.
The toPrecision() method returns a string representing the `js.Number`
to the specified precision.
`numObj.toPrecision([precision])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision`"
[this & args]
(-> this .-toPrecision (.apply this (clj->js args))))
(defn to-source
"Method.
[Non Standard]
The toSource() method returns a string representing the source
of the object.
`numObj.toSource()
Number.toSource()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toSource`"
[this & args]
(-> this .-toSource (.apply this (clj->js args))))
(defn to-string
"Method.
The toString() method returns a string representing the specified
object.
`numObj.toString([radix])`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString`"
[this & args]
(-> this .-toString (.apply this (clj->js args))))
(defn value-of
"Method.
The valueOf() method returns the wrapped primitive value of a
object.
`numObj.valueOf()`
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/valueOf`"
[this ]
(-> this (.valueOf)))
(defn epsilon
"Property.
The Number.EPSILON property represents the difference between
and the smallest floating point number greater than 1.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON`"
[this]
(-> this (.-EPSILON)))
(defn set-epsilon!
"Property.
The Number.EPSILON property represents the difference between
and the smallest floating point number greater than 1.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON`"
[this val]
(aset this "EPSILON" val))
(defn max-safe-integer
"Property.
The Number.MAX_SAFE_INTEGER constant represents the maximum safe
in JavaScript (253 - 1).
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER`"
[this]
(-> this (.-MAX_SAFE_INTEGER)))
(defn set-max-safe-integer!
"Property.
The Number.MAX_SAFE_INTEGER constant represents the maximum safe
in JavaScript (253 - 1).
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER`"
[this val]
(aset this "MAX_SAFE_INTEGER" val))
(defn max-value
"Property.
The Number.MAX_VALUE property represents the maximum numeric
representable in JavaScript.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE`"
[this]
(-> this (.-MAX_VALUE)))
(defn set-max-value!
"Property.
The Number.MAX_VALUE property represents the maximum numeric
representable in JavaScript.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE`"
[this val]
(aset this "MAX_VALUE" val))
(defn min-safe-integer
"Property.
The Number.MIN_SAFE_INTEGER constant represents the minimum safe
in JavaScript (-(253 - 1)).
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER`"
[this]
(-> this (.-MIN_SAFE_INTEGER)))
(defn set-min-safe-integer!
"Property.
The Number.MIN_SAFE_INTEGER constant represents the minimum safe
in JavaScript (-(253 - 1)).
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER`"
[this val]
(aset this "MIN_SAFE_INTEGER" val))
(defn min-value
"Property.
The Number.MIN_VALUE property represents the smallest positive
value representable in JavaScript.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE`"
[this]
(-> this (.-MIN_VALUE)))
(defn set-min-value!
"Property.
The Number.MIN_VALUE property represents the smallest positive
value representable in JavaScript.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE`"
[this val]
(aset this "MIN_VALUE" val))
(defn na-n
"Property.
The Number.NaN property represents Not-A-Number. Equivalent of
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN`"
[this]
(-> this (.-NaN)))
(defn set-na-n!
"Property.
The Number.NaN property represents Not-A-Number. Equivalent of
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN`"
[this val]
(aset this "NaN" val))
(defn negative-infinity
"Property.
The Number.NEGATIVE_INFINITY property represents the negative
value.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY`"
[this]
(-> this (.-NEGATIVE_INFINITY)))
(defn set-negative-infinity!
"Property.
The Number.NEGATIVE_INFINITY property represents the negative
value.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY`"
[this val]
(aset this "NEGATIVE_INFINITY" val))
(defn positive-infinity
"Property.
The Number.POSITIVE_INFINITY property represents the positive
value.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY`"
[this]
(-> this (.-POSITIVE_INFINITY)))
(defn set-positive-infinity!
"Property.
The Number.POSITIVE_INFINITY property represents the positive
value.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY`"
[this val]
(aset this "POSITIVE_INFINITY" val))
(defn prototype
"Property.
The Number.prototype property represents the prototype for the
constructor.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/prototype`"
[this]
(-> this (.-prototype)))
(defn set-prototype!
"Property.
The Number.prototype property represents the prototype for the
constructor.
See also: `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/prototype`"
[this val]
(aset this "prototype" val))