@grain/stdlib 0.6.6 → 0.7.1
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/CHANGELOG.md +67 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +606 -560
- package/bigint.md +228 -228
- package/buffer.gr +85 -53
- package/buffer.md +442 -319
- package/bytes.gr +112 -35
- package/bytes.md +299 -219
- package/char.gr +201 -99
- package/char.md +447 -120
- package/exception.gr +11 -11
- package/exception.md +29 -4
- package/float32.gr +327 -3
- package/float32.md +698 -111
- package/float64.gr +320 -3
- package/float64.md +698 -111
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +105 -17
- package/int16.md +178 -178
- package/int32.gr +26 -5
- package/int32.md +266 -231
- package/int64.gr +27 -2
- package/int64.md +266 -231
- package/int8.md +178 -178
- package/json.gr +366 -51
- package/json.md +431 -15
- package/list.gr +328 -31
- package/list.md +759 -336
- package/map.gr +20 -12
- package/map.md +266 -260
- package/marshal.gr +41 -40
- package/marshal.md +14 -14
- package/number.gr +278 -35
- package/number.md +688 -269
- package/option.md +162 -162
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +180 -89
- package/pervasives.gr +2 -2
- package/pervasives.md +275 -275
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +131 -131
- package/queue.gr +183 -29
- package/queue.md +404 -148
- package/random.md +43 -43
- package/range.gr +4 -4
- package/range.md +42 -42
- package/rational.md +123 -123
- package/regex.gr +52 -51
- package/regex.md +102 -102
- package/result.md +118 -118
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +14 -14
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +8 -8
- package/runtime/dataStructures.md +211 -211
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +8 -8
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +13 -13
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +348 -342
- package/runtime/string.gr +37 -105
- package/runtime/string.md +20 -26
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +19 -19
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +147 -147
- package/set.gr +18 -11
- package/set.md +253 -247
- package/stack.gr +171 -2
- package/stack.md +371 -89
- package/string.gr +352 -557
- package/string.md +298 -255
- package/uint16.md +170 -170
- package/uint32.gr +25 -4
- package/uint32.md +249 -214
- package/uint64.gr +25 -5
- package/uint64.md +249 -214
- package/uint8.md +170 -170
- package/uri.gr +57 -53
- package/uri.md +88 -89
- package/wasi/file.gr +67 -59
- package/wasi/file.md +308 -308
- package/wasi/process.md +26 -26
- package/wasi/random.md +12 -12
- package/wasi/time.md +16 -16
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/number.md
CHANGED
|
@@ -90,7 +90,7 @@ No other changes yet.
|
|
|
90
90
|
</details>
|
|
91
91
|
|
|
92
92
|
```grain
|
|
93
|
-
pi
|
|
93
|
+
pi: Number
|
|
94
94
|
```
|
|
95
95
|
|
|
96
96
|
Pi represented as a Number value.
|
|
@@ -103,7 +103,7 @@ No other changes yet.
|
|
|
103
103
|
</details>
|
|
104
104
|
|
|
105
105
|
```grain
|
|
106
|
-
tau
|
|
106
|
+
tau: Number
|
|
107
107
|
```
|
|
108
108
|
|
|
109
109
|
Tau represented as a Number value.
|
|
@@ -116,7 +116,7 @@ No other changes yet.
|
|
|
116
116
|
</details>
|
|
117
117
|
|
|
118
118
|
```grain
|
|
119
|
-
e
|
|
119
|
+
e: Number
|
|
120
120
|
```
|
|
121
121
|
|
|
122
122
|
Euler's number represented as a Number value.
|
|
@@ -136,28 +136,28 @@ Euler's number represented as a Number value.
|
|
|
136
136
|
</details>
|
|
137
137
|
|
|
138
138
|
```grain
|
|
139
|
-
(+)
|
|
139
|
+
(+): (num1: Number, num2: Number) => Number
|
|
140
140
|
```
|
|
141
141
|
|
|
142
142
|
Computes the sum of its operands.
|
|
143
143
|
|
|
144
144
|
Parameters:
|
|
145
145
|
|
|
146
|
-
|param|type|description|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
| param | type | description |
|
|
147
|
+
| ------ | -------- | ------------------ |
|
|
148
|
+
| `num1` | `Number` | The first operand |
|
|
149
|
+
| `num2` | `Number` | The second operand |
|
|
150
150
|
|
|
151
151
|
Returns:
|
|
152
152
|
|
|
153
|
-
|type|description|
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
| type | description |
|
|
154
|
+
| -------- | --------------------------- |
|
|
155
|
+
| `Number` | The sum of the two operands |
|
|
156
156
|
|
|
157
157
|
Examples:
|
|
158
158
|
|
|
159
159
|
```grain
|
|
160
|
-
|
|
160
|
+
use Number.{ (+) }
|
|
161
161
|
assert 1 + 2 == 3
|
|
162
162
|
```
|
|
163
163
|
|
|
@@ -176,28 +176,28 @@ assert 1 + 2 == 3
|
|
|
176
176
|
</details>
|
|
177
177
|
|
|
178
178
|
```grain
|
|
179
|
-
(-)
|
|
179
|
+
(-): (num1: Number, num2: Number) => Number
|
|
180
180
|
```
|
|
181
181
|
|
|
182
182
|
Computes the difference of its operands.
|
|
183
183
|
|
|
184
184
|
Parameters:
|
|
185
185
|
|
|
186
|
-
|param|type|description|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
186
|
+
| param | type | description |
|
|
187
|
+
| ------ | -------- | ------------------ |
|
|
188
|
+
| `num1` | `Number` | The first operand |
|
|
189
|
+
| `num2` | `Number` | The second operand |
|
|
190
190
|
|
|
191
191
|
Returns:
|
|
192
192
|
|
|
193
|
-
|type|description|
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
| type | description |
|
|
194
|
+
| -------- | ---------------------------------- |
|
|
195
|
+
| `Number` | The difference of the two operands |
|
|
196
196
|
|
|
197
197
|
Examples:
|
|
198
198
|
|
|
199
199
|
```grain
|
|
200
|
-
|
|
200
|
+
use Number.{ (-) }
|
|
201
201
|
assert 5 - 2 == 3
|
|
202
202
|
```
|
|
203
203
|
|
|
@@ -216,28 +216,28 @@ assert 5 - 2 == 3
|
|
|
216
216
|
</details>
|
|
217
217
|
|
|
218
218
|
```grain
|
|
219
|
-
(*)
|
|
219
|
+
(*): (num1: Number, num2: Number) => Number
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
Computes the product of its operands.
|
|
223
223
|
|
|
224
224
|
Parameters:
|
|
225
225
|
|
|
226
|
-
|param|type|description|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
226
|
+
| param | type | description |
|
|
227
|
+
| ------ | -------- | ------------------ |
|
|
228
|
+
| `num1` | `Number` | The first operand |
|
|
229
|
+
| `num2` | `Number` | The second operand |
|
|
230
230
|
|
|
231
231
|
Returns:
|
|
232
232
|
|
|
233
|
-
|type|description|
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
| type | description |
|
|
234
|
+
| -------- | ------------------------------- |
|
|
235
|
+
| `Number` | The product of the two operands |
|
|
236
236
|
|
|
237
237
|
Examples:
|
|
238
238
|
|
|
239
239
|
```grain
|
|
240
|
-
|
|
240
|
+
use Number.{ (*) }
|
|
241
241
|
assert 5 * 4 == 20
|
|
242
242
|
```
|
|
243
243
|
|
|
@@ -256,31 +256,65 @@ assert 5 * 4 == 20
|
|
|
256
256
|
</details>
|
|
257
257
|
|
|
258
258
|
```grain
|
|
259
|
-
(/)
|
|
259
|
+
(/): (num1: Number, num2: Number) => Number
|
|
260
260
|
```
|
|
261
261
|
|
|
262
262
|
Computes the quotient of its operands.
|
|
263
263
|
|
|
264
264
|
Parameters:
|
|
265
265
|
|
|
266
|
-
|param|type|description|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
266
|
+
| param | type | description |
|
|
267
|
+
| ------ | -------- | ------------ |
|
|
268
|
+
| `num1` | `Number` | The dividend |
|
|
269
|
+
| `num2` | `Number` | The divisor |
|
|
270
270
|
|
|
271
271
|
Returns:
|
|
272
272
|
|
|
273
|
-
|type|description|
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
| type | description |
|
|
274
|
+
| -------- | -------------------------------- |
|
|
275
|
+
| `Number` | The quotient of the two operands |
|
|
276
276
|
|
|
277
277
|
Examples:
|
|
278
278
|
|
|
279
279
|
```grain
|
|
280
|
-
|
|
280
|
+
use Number.{ (/) }
|
|
281
281
|
assert 10 / 2.5 == 4
|
|
282
282
|
```
|
|
283
283
|
|
|
284
|
+
### Number.**(%)**
|
|
285
|
+
|
|
286
|
+
<details disabled>
|
|
287
|
+
<summary tabindex="-1">Added in <code>0.7.1</code></summary>
|
|
288
|
+
No other changes yet.
|
|
289
|
+
</details>
|
|
290
|
+
|
|
291
|
+
```grain
|
|
292
|
+
(%): (num1: Number, num2: Number) => Number
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
Computes the remainder of the division of the first operand by the second.
|
|
296
|
+
The result will have the sign of the second operand.
|
|
297
|
+
|
|
298
|
+
Parameters:
|
|
299
|
+
|
|
300
|
+
| param | type | description |
|
|
301
|
+
| ------ | -------- | ------------------ |
|
|
302
|
+
| `num1` | `Number` | The first operand |
|
|
303
|
+
| `num2` | `Number` | The second operand |
|
|
304
|
+
|
|
305
|
+
Returns:
|
|
306
|
+
|
|
307
|
+
| type | description |
|
|
308
|
+
| -------- | --------------------------- |
|
|
309
|
+
| `Number` | The modulus of its operands |
|
|
310
|
+
|
|
311
|
+
Examples:
|
|
312
|
+
|
|
313
|
+
```grain
|
|
314
|
+
use Number.{ (%) }
|
|
315
|
+
assert 10 % 3 == 1
|
|
316
|
+
```
|
|
317
|
+
|
|
284
318
|
### Number.**(\*\*)**
|
|
285
319
|
|
|
286
320
|
<details>
|
|
@@ -296,31 +330,239 @@ assert 10 / 2.5 == 4
|
|
|
296
330
|
</details>
|
|
297
331
|
|
|
298
332
|
```grain
|
|
299
|
-
(**)
|
|
333
|
+
(**): (base: Number, power: Number) => Number
|
|
300
334
|
```
|
|
301
335
|
|
|
302
336
|
Computes the exponentiation of the given base and power.
|
|
303
337
|
|
|
304
338
|
Parameters:
|
|
305
339
|
|
|
306
|
-
|param|type|description|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
340
|
+
| param | type | description |
|
|
341
|
+
| ------- | -------- | ------------------- |
|
|
342
|
+
| `base` | `Number` | The base number |
|
|
343
|
+
| `power` | `Number` | The exponent number |
|
|
310
344
|
|
|
311
345
|
Returns:
|
|
312
346
|
|
|
313
|
-
|type|description|
|
|
314
|
-
|
|
315
|
-
|
|
347
|
+
| type | description |
|
|
348
|
+
| -------- | ---------------------------------- |
|
|
349
|
+
| `Number` | The base raised to the given power |
|
|
316
350
|
|
|
317
351
|
Examples:
|
|
318
352
|
|
|
319
353
|
```grain
|
|
320
|
-
|
|
354
|
+
use Number.{ (**) }
|
|
321
355
|
assert 10 ** 2 == 100
|
|
322
356
|
```
|
|
323
357
|
|
|
358
|
+
### Number.**(==)**
|
|
359
|
+
|
|
360
|
+
<details disabled>
|
|
361
|
+
<summary tabindex="-1">Added in <code>0.7.1</code></summary>
|
|
362
|
+
No other changes yet.
|
|
363
|
+
</details>
|
|
364
|
+
|
|
365
|
+
```grain
|
|
366
|
+
(==): (x: Number, y: Number) => Bool
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
Checks if the first value is equal to the second value.
|
|
370
|
+
|
|
371
|
+
Parameters:
|
|
372
|
+
|
|
373
|
+
| param | type | description |
|
|
374
|
+
| ----- | -------- | ---------------- |
|
|
375
|
+
| `x` | `Number` | The first value |
|
|
376
|
+
| `y` | `Number` | The second value |
|
|
377
|
+
|
|
378
|
+
Returns:
|
|
379
|
+
|
|
380
|
+
| type | description |
|
|
381
|
+
| ------ | --------------------------------------------------------------------------- |
|
|
382
|
+
| `Bool` | `true` if the first value is equal to the second value or `false` otherwise |
|
|
383
|
+
|
|
384
|
+
Examples:
|
|
385
|
+
|
|
386
|
+
```grain
|
|
387
|
+
use Number.{ (==) }
|
|
388
|
+
assert 1 == 1
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### Number.**(!=)**
|
|
392
|
+
|
|
393
|
+
<details disabled>
|
|
394
|
+
<summary tabindex="-1">Added in <code>0.7.1</code></summary>
|
|
395
|
+
No other changes yet.
|
|
396
|
+
</details>
|
|
397
|
+
|
|
398
|
+
```grain
|
|
399
|
+
(!=): (x: Number, y: Number) => Bool
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
Checks if the first value is equal to the second value.
|
|
403
|
+
|
|
404
|
+
Parameters:
|
|
405
|
+
|
|
406
|
+
| param | type | description |
|
|
407
|
+
| ----- | -------- | ---------------- |
|
|
408
|
+
| `x` | `Number` | The first value |
|
|
409
|
+
| `y` | `Number` | The second value |
|
|
410
|
+
|
|
411
|
+
Returns:
|
|
412
|
+
|
|
413
|
+
| type | description |
|
|
414
|
+
| ------ | --------------------------------------------------------------------------- |
|
|
415
|
+
| `Bool` | `true` if the first value is equal to the second value or `false` otherwise |
|
|
416
|
+
|
|
417
|
+
Examples:
|
|
418
|
+
|
|
419
|
+
```grain
|
|
420
|
+
use Number.{ (==) }
|
|
421
|
+
assert 1 == 1
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Number.**(<)**
|
|
425
|
+
|
|
426
|
+
<details disabled>
|
|
427
|
+
<summary tabindex="-1">Added in <code>0.7.1</code></summary>
|
|
428
|
+
No other changes yet.
|
|
429
|
+
</details>
|
|
430
|
+
|
|
431
|
+
```grain
|
|
432
|
+
(<): (num1: Number, num2: Number) => Bool
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
Checks if the first value is less than the second value.
|
|
436
|
+
|
|
437
|
+
Parameters:
|
|
438
|
+
|
|
439
|
+
| param | type | description |
|
|
440
|
+
| ------ | -------- | ---------------- |
|
|
441
|
+
| `num1` | `Number` | The first value |
|
|
442
|
+
| `num2` | `Number` | The second value |
|
|
443
|
+
|
|
444
|
+
Returns:
|
|
445
|
+
|
|
446
|
+
| type | description |
|
|
447
|
+
| ------ | ---------------------------------------------------------------------------- |
|
|
448
|
+
| `Bool` | `true` if the first value is less than the second value or `false` otherwise |
|
|
449
|
+
|
|
450
|
+
Examples:
|
|
451
|
+
|
|
452
|
+
```grain
|
|
453
|
+
use Number.{ (<) }
|
|
454
|
+
assert 1 < 5
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Number.**(>)**
|
|
458
|
+
|
|
459
|
+
<details disabled>
|
|
460
|
+
<summary tabindex="-1">Added in <code>0.7.1</code></summary>
|
|
461
|
+
No other changes yet.
|
|
462
|
+
</details>
|
|
463
|
+
|
|
464
|
+
```grain
|
|
465
|
+
(>): (num1: Number, num2: Number) => Bool
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
Checks if the first value is greater than the second value.
|
|
469
|
+
|
|
470
|
+
Parameters:
|
|
471
|
+
|
|
472
|
+
| param | type | description |
|
|
473
|
+
| ------ | -------- | ---------------- |
|
|
474
|
+
| `num1` | `Number` | The first value |
|
|
475
|
+
| `num2` | `Number` | The second value |
|
|
476
|
+
|
|
477
|
+
Returns:
|
|
478
|
+
|
|
479
|
+
| type | description |
|
|
480
|
+
| ------ | ------------------------------------------------------------------------------- |
|
|
481
|
+
| `Bool` | `true` if the first value is greater than the second value or `false` otherwise |
|
|
482
|
+
|
|
483
|
+
Examples:
|
|
484
|
+
|
|
485
|
+
```grain
|
|
486
|
+
use Number.{ (>) }
|
|
487
|
+
assert 5 > 1
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Number.**(<=)**
|
|
491
|
+
|
|
492
|
+
<details disabled>
|
|
493
|
+
<summary tabindex="-1">Added in <code>0.7.1</code></summary>
|
|
494
|
+
No other changes yet.
|
|
495
|
+
</details>
|
|
496
|
+
|
|
497
|
+
```grain
|
|
498
|
+
(<=): (num1: Number, num2: Number) => Bool
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
Checks if the first value is less than or equal to the second value.
|
|
502
|
+
|
|
503
|
+
Parameters:
|
|
504
|
+
|
|
505
|
+
| param | type | description |
|
|
506
|
+
| ------ | -------- | ---------------- |
|
|
507
|
+
| `num1` | `Number` | The first value |
|
|
508
|
+
| `num2` | `Number` | The second value |
|
|
509
|
+
|
|
510
|
+
Returns:
|
|
511
|
+
|
|
512
|
+
| type | description |
|
|
513
|
+
| ------ | ---------------------------------------------------------------------------------------- |
|
|
514
|
+
| `Bool` | `true` if the first value is less than or equal to the second value or `false` otherwise |
|
|
515
|
+
|
|
516
|
+
Examples:
|
|
517
|
+
|
|
518
|
+
```grain
|
|
519
|
+
use Number.{ (<=) }
|
|
520
|
+
assert 1 <= 2
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
```grain
|
|
524
|
+
use Number.{ (<=) }
|
|
525
|
+
assert 1 <= 1
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
### Number.**(>=)**
|
|
529
|
+
|
|
530
|
+
<details disabled>
|
|
531
|
+
<summary tabindex="-1">Added in <code>0.7.1</code></summary>
|
|
532
|
+
No other changes yet.
|
|
533
|
+
</details>
|
|
534
|
+
|
|
535
|
+
```grain
|
|
536
|
+
(>=): (num1: Number, num2: Number) => Bool
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
Checks if the first value is greater than or equal to the second value.
|
|
540
|
+
|
|
541
|
+
Parameters:
|
|
542
|
+
|
|
543
|
+
| param | type | description |
|
|
544
|
+
| ------ | -------- | ---------------- |
|
|
545
|
+
| `num1` | `Number` | The first value |
|
|
546
|
+
| `num2` | `Number` | The second value |
|
|
547
|
+
|
|
548
|
+
Returns:
|
|
549
|
+
|
|
550
|
+
| type | description |
|
|
551
|
+
| ------ | ------------------------------------------------------------------------------------------- |
|
|
552
|
+
| `Bool` | `true` if the first value is greater than or equal to the second value or `false` otherwise |
|
|
553
|
+
|
|
554
|
+
Examples:
|
|
555
|
+
|
|
556
|
+
```grain
|
|
557
|
+
use Number.{ (>=) }
|
|
558
|
+
assert 3 >= 2
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
```grain
|
|
562
|
+
use Number.{ (>=) }
|
|
563
|
+
assert 1 >= 1
|
|
564
|
+
```
|
|
565
|
+
|
|
324
566
|
### Number.**exp**
|
|
325
567
|
|
|
326
568
|
<details disabled>
|
|
@@ -329,22 +571,22 @@ No other changes yet.
|
|
|
329
571
|
</details>
|
|
330
572
|
|
|
331
573
|
```grain
|
|
332
|
-
exp
|
|
574
|
+
exp: (power: Number) => Number
|
|
333
575
|
```
|
|
334
576
|
|
|
335
577
|
Computes the exponentiation of Euler's number to the given power.
|
|
336
578
|
|
|
337
579
|
Parameters:
|
|
338
580
|
|
|
339
|
-
|param|type|description|
|
|
340
|
-
|
|
341
|
-
|
|
581
|
+
| param | type | description |
|
|
582
|
+
| ------- | -------- | ------------------- |
|
|
583
|
+
| `power` | `Number` | The exponent number |
|
|
342
584
|
|
|
343
585
|
Returns:
|
|
344
586
|
|
|
345
|
-
|type|description|
|
|
346
|
-
|
|
347
|
-
|
|
587
|
+
| type | description |
|
|
588
|
+
| -------- | ---------------------------------------------- |
|
|
589
|
+
| `Number` | The `Number.e` value raised to the given power |
|
|
348
590
|
|
|
349
591
|
Examples:
|
|
350
592
|
|
|
@@ -364,22 +606,22 @@ No other changes yet.
|
|
|
364
606
|
</details>
|
|
365
607
|
|
|
366
608
|
```grain
|
|
367
|
-
sqrt
|
|
609
|
+
sqrt: (x: Number) => Number
|
|
368
610
|
```
|
|
369
611
|
|
|
370
612
|
Computes the square root of its operand.
|
|
371
613
|
|
|
372
614
|
Parameters:
|
|
373
615
|
|
|
374
|
-
|param|type|description|
|
|
375
|
-
|
|
376
|
-
|
|
616
|
+
| param | type | description |
|
|
617
|
+
| ----- | -------- | ------------------------- |
|
|
618
|
+
| `x` | `Number` | The number to square root |
|
|
377
619
|
|
|
378
620
|
Returns:
|
|
379
621
|
|
|
380
|
-
|type|description|
|
|
381
|
-
|
|
382
|
-
|
|
622
|
+
| type | description |
|
|
623
|
+
| -------- | ------------------------------ |
|
|
624
|
+
| `Number` | The square root of the operand |
|
|
383
625
|
|
|
384
626
|
Examples:
|
|
385
627
|
|
|
@@ -395,22 +637,22 @@ No other changes yet.
|
|
|
395
637
|
</details>
|
|
396
638
|
|
|
397
639
|
```grain
|
|
398
|
-
sign
|
|
640
|
+
sign: (x: Number) => Number
|
|
399
641
|
```
|
|
400
642
|
|
|
401
643
|
Determine the positivity or negativity of a Number.
|
|
402
644
|
|
|
403
645
|
Parameters:
|
|
404
646
|
|
|
405
|
-
|param|type|description|
|
|
406
|
-
|
|
407
|
-
|
|
647
|
+
| param | type | description |
|
|
648
|
+
| ----- | -------- | --------------------- |
|
|
649
|
+
| `x` | `Number` | The number to inspect |
|
|
408
650
|
|
|
409
651
|
Returns:
|
|
410
652
|
|
|
411
|
-
|type|description|
|
|
412
|
-
|
|
413
|
-
|
|
653
|
+
| type | description |
|
|
654
|
+
| -------- | ---------------------------------------------------------------------------------------------------- |
|
|
655
|
+
| `Number` | `-1` if the number is negative, `1` if positive, or `0` otherwise; signedness of `-0.0` is preserved |
|
|
414
656
|
|
|
415
657
|
Examples:
|
|
416
658
|
|
|
@@ -441,23 +683,23 @@ Number.sign(0) == 0
|
|
|
441
683
|
</details>
|
|
442
684
|
|
|
443
685
|
```grain
|
|
444
|
-
min
|
|
686
|
+
min: (x: Number, y: Number) => Number
|
|
445
687
|
```
|
|
446
688
|
|
|
447
689
|
Returns the smaller of its operands.
|
|
448
690
|
|
|
449
691
|
Parameters:
|
|
450
692
|
|
|
451
|
-
|param|type|description|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
693
|
+
| param | type | description |
|
|
694
|
+
| ----- | -------- | ------------------ |
|
|
695
|
+
| `x` | `Number` | The first operand |
|
|
696
|
+
| `y` | `Number` | The second operand |
|
|
455
697
|
|
|
456
698
|
Returns:
|
|
457
699
|
|
|
458
|
-
|type|description|
|
|
459
|
-
|
|
460
|
-
|
|
700
|
+
| type | description |
|
|
701
|
+
| -------- | ------------------------------- |
|
|
702
|
+
| `Number` | The smaller of the two operands |
|
|
461
703
|
|
|
462
704
|
Examples:
|
|
463
705
|
|
|
@@ -480,23 +722,23 @@ Number.min(5, 2) == 2
|
|
|
480
722
|
</details>
|
|
481
723
|
|
|
482
724
|
```grain
|
|
483
|
-
max
|
|
725
|
+
max: (x: Number, y: Number) => Number
|
|
484
726
|
```
|
|
485
727
|
|
|
486
728
|
Returns the larger of its operands.
|
|
487
729
|
|
|
488
730
|
Parameters:
|
|
489
731
|
|
|
490
|
-
|param|type|description|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
732
|
+
| param | type | description |
|
|
733
|
+
| ----- | -------- | ------------------ |
|
|
734
|
+
| `x` | `Number` | The first operand |
|
|
735
|
+
| `y` | `Number` | The second operand |
|
|
494
736
|
|
|
495
737
|
Returns:
|
|
496
738
|
|
|
497
|
-
|type|description|
|
|
498
|
-
|
|
499
|
-
|
|
739
|
+
| type | description |
|
|
740
|
+
| -------- | ------------------------------ |
|
|
741
|
+
| `Number` | The larger of the two operands |
|
|
500
742
|
|
|
501
743
|
Examples:
|
|
502
744
|
|
|
@@ -519,22 +761,22 @@ Number.max(5, 2) == 5
|
|
|
519
761
|
</details>
|
|
520
762
|
|
|
521
763
|
```grain
|
|
522
|
-
ceil
|
|
764
|
+
ceil: (x: Number) => Number
|
|
523
765
|
```
|
|
524
766
|
|
|
525
767
|
Rounds its operand up to the next largest integer.
|
|
526
768
|
|
|
527
769
|
Parameters:
|
|
528
770
|
|
|
529
|
-
|param|type|description|
|
|
530
|
-
|
|
531
|
-
|
|
771
|
+
| param | type | description |
|
|
772
|
+
| ----- | -------- | ------------------- |
|
|
773
|
+
| `x` | `Number` | The number to round |
|
|
532
774
|
|
|
533
775
|
Returns:
|
|
534
776
|
|
|
535
|
-
|type|description|
|
|
536
|
-
|
|
537
|
-
|
|
777
|
+
| type | description |
|
|
778
|
+
| -------- | --------------------------------------- |
|
|
779
|
+
| `Number` | The next largest integer of the operand |
|
|
538
780
|
|
|
539
781
|
Examples:
|
|
540
782
|
|
|
@@ -561,22 +803,22 @@ Number.ceil(-5.5) == -5
|
|
|
561
803
|
</details>
|
|
562
804
|
|
|
563
805
|
```grain
|
|
564
|
-
floor
|
|
806
|
+
floor: (x: Number) => Number
|
|
565
807
|
```
|
|
566
808
|
|
|
567
809
|
Rounds its operand down to the largest integer less than the operand.
|
|
568
810
|
|
|
569
811
|
Parameters:
|
|
570
812
|
|
|
571
|
-
|param|type|description|
|
|
572
|
-
|
|
573
|
-
|
|
813
|
+
| param | type | description |
|
|
814
|
+
| ----- | -------- | ------------------- |
|
|
815
|
+
| `x` | `Number` | The number to round |
|
|
574
816
|
|
|
575
817
|
Returns:
|
|
576
818
|
|
|
577
|
-
|type|description|
|
|
578
|
-
|
|
579
|
-
|
|
819
|
+
| type | description |
|
|
820
|
+
| -------- | ----------------------------------- |
|
|
821
|
+
| `Number` | The previous integer of the operand |
|
|
580
822
|
|
|
581
823
|
Examples:
|
|
582
824
|
|
|
@@ -603,22 +845,22 @@ Number.floor(-5.5) == -6
|
|
|
603
845
|
</details>
|
|
604
846
|
|
|
605
847
|
```grain
|
|
606
|
-
trunc
|
|
848
|
+
trunc: (x: Number) => Number
|
|
607
849
|
```
|
|
608
850
|
|
|
609
851
|
Returns the integer part of its operand, removing any fractional value.
|
|
610
852
|
|
|
611
853
|
Parameters:
|
|
612
854
|
|
|
613
|
-
|param|type|description|
|
|
614
|
-
|
|
615
|
-
|
|
855
|
+
| param | type | description |
|
|
856
|
+
| ----- | -------- | ---------------------- |
|
|
857
|
+
| `x` | `Number` | The number to truncate |
|
|
616
858
|
|
|
617
859
|
Returns:
|
|
618
860
|
|
|
619
|
-
|type|description|
|
|
620
|
-
|
|
621
|
-
|
|
861
|
+
| type | description |
|
|
862
|
+
| -------- | ------------------------------- |
|
|
863
|
+
| `Number` | The integer part of the operand |
|
|
622
864
|
|
|
623
865
|
Examples:
|
|
624
866
|
|
|
@@ -641,22 +883,22 @@ Number.trunc(5.5) == 5
|
|
|
641
883
|
</details>
|
|
642
884
|
|
|
643
885
|
```grain
|
|
644
|
-
round
|
|
886
|
+
round: (x: Number) => Number
|
|
645
887
|
```
|
|
646
888
|
|
|
647
889
|
Returns its operand rounded to its nearest integer.
|
|
648
890
|
|
|
649
891
|
Parameters:
|
|
650
892
|
|
|
651
|
-
|param|type|description|
|
|
652
|
-
|
|
653
|
-
|
|
893
|
+
| param | type | description |
|
|
894
|
+
| ----- | -------- | ------------------- |
|
|
895
|
+
| `x` | `Number` | The number to round |
|
|
654
896
|
|
|
655
897
|
Returns:
|
|
656
898
|
|
|
657
|
-
|type|description|
|
|
658
|
-
|
|
659
|
-
|
|
899
|
+
| type | description |
|
|
900
|
+
| -------- | ---------------------------------- |
|
|
901
|
+
| `Number` | The nearest integer to the operand |
|
|
660
902
|
|
|
661
903
|
Examples:
|
|
662
904
|
|
|
@@ -684,22 +926,22 @@ No other changes yet.
|
|
|
684
926
|
</details>
|
|
685
927
|
|
|
686
928
|
```grain
|
|
687
|
-
abs
|
|
929
|
+
abs: (x: Number) => Number
|
|
688
930
|
```
|
|
689
931
|
|
|
690
932
|
Returns the absolute value of a number. That is, it returns `x` if `x` is positive or zero and the negation of `x` if `x` is negative.
|
|
691
933
|
|
|
692
934
|
Parameters:
|
|
693
935
|
|
|
694
|
-
|param|type|description|
|
|
695
|
-
|
|
696
|
-
|
|
936
|
+
| param | type | description |
|
|
937
|
+
| ----- | -------- | ----------- |
|
|
938
|
+
| `x` | `Number` | The operand |
|
|
697
939
|
|
|
698
940
|
Returns:
|
|
699
941
|
|
|
700
|
-
|type|description|
|
|
701
|
-
|
|
702
|
-
|
|
942
|
+
| type | description |
|
|
943
|
+
| -------- | --------------------------------- |
|
|
944
|
+
| `Number` | The absolute value of the operand |
|
|
703
945
|
|
|
704
946
|
Examples:
|
|
705
947
|
|
|
@@ -719,22 +961,22 @@ No other changes yet.
|
|
|
719
961
|
</details>
|
|
720
962
|
|
|
721
963
|
```grain
|
|
722
|
-
neg
|
|
964
|
+
neg: (x: Number) => Number
|
|
723
965
|
```
|
|
724
966
|
|
|
725
967
|
Returns the negation of its operand.
|
|
726
968
|
|
|
727
969
|
Parameters:
|
|
728
970
|
|
|
729
|
-
|param|type|description|
|
|
730
|
-
|
|
731
|
-
|
|
971
|
+
| param | type | description |
|
|
972
|
+
| ----- | -------- | -------------------- |
|
|
973
|
+
| `x` | `Number` | The number to negate |
|
|
732
974
|
|
|
733
975
|
Returns:
|
|
734
976
|
|
|
735
|
-
|type|description|
|
|
736
|
-
|
|
737
|
-
|
|
977
|
+
| type | description |
|
|
978
|
+
| -------- | ------------------- |
|
|
979
|
+
| `Number` | The negated operand |
|
|
738
980
|
|
|
739
981
|
Examples:
|
|
740
982
|
|
|
@@ -754,22 +996,22 @@ No other changes yet.
|
|
|
754
996
|
</details>
|
|
755
997
|
|
|
756
998
|
```grain
|
|
757
|
-
isFloat
|
|
999
|
+
isFloat: (x: Number) => Bool
|
|
758
1000
|
```
|
|
759
1001
|
|
|
760
1002
|
Checks if a number is a floating point value.
|
|
761
1003
|
|
|
762
1004
|
Parameters:
|
|
763
1005
|
|
|
764
|
-
|param|type|description|
|
|
765
|
-
|
|
766
|
-
|
|
1006
|
+
| param | type | description |
|
|
1007
|
+
| ----- | -------- | ------------------- |
|
|
1008
|
+
| `x` | `Number` | The number to check |
|
|
767
1009
|
|
|
768
1010
|
Returns:
|
|
769
1011
|
|
|
770
|
-
|type|description|
|
|
771
|
-
|
|
772
|
-
|
|
1012
|
+
| type | description |
|
|
1013
|
+
| ------ | ------------------------------------------------------------------- |
|
|
1014
|
+
| `Bool` | `true` if the value is a floating point number or `false` otherwise |
|
|
773
1015
|
|
|
774
1016
|
Examples:
|
|
775
1017
|
|
|
@@ -805,22 +1047,22 @@ No other changes yet.
|
|
|
805
1047
|
</details>
|
|
806
1048
|
|
|
807
1049
|
```grain
|
|
808
|
-
isInteger
|
|
1050
|
+
isInteger: (x: Number) => Bool
|
|
809
1051
|
```
|
|
810
1052
|
|
|
811
1053
|
Checks if a number is an integer.
|
|
812
1054
|
|
|
813
1055
|
Parameters:
|
|
814
1056
|
|
|
815
|
-
|param|type|description|
|
|
816
|
-
|
|
817
|
-
|
|
1057
|
+
| param | type | description |
|
|
1058
|
+
| ----- | -------- | ------------------- |
|
|
1059
|
+
| `x` | `Number` | The number to check |
|
|
818
1060
|
|
|
819
1061
|
Returns:
|
|
820
1062
|
|
|
821
|
-
|type|description|
|
|
822
|
-
|
|
823
|
-
|
|
1063
|
+
| type | description |
|
|
1064
|
+
| ------ | ------------------------------------------------------ |
|
|
1065
|
+
| `Bool` | `true` if the value is an integer or `false` otherwise |
|
|
824
1066
|
|
|
825
1067
|
Examples:
|
|
826
1068
|
|
|
@@ -856,22 +1098,22 @@ No other changes yet.
|
|
|
856
1098
|
</details>
|
|
857
1099
|
|
|
858
1100
|
```grain
|
|
859
|
-
isRational
|
|
1101
|
+
isRational: (x: Number) => Bool
|
|
860
1102
|
```
|
|
861
1103
|
|
|
862
1104
|
Checks if a number is a non-integer rational value.
|
|
863
1105
|
|
|
864
1106
|
Parameters:
|
|
865
1107
|
|
|
866
|
-
|param|type|description|
|
|
867
|
-
|
|
868
|
-
|
|
1108
|
+
| param | type | description |
|
|
1109
|
+
| ----- | -------- | ------------------- |
|
|
1110
|
+
| `x` | `Number` | The number to check |
|
|
869
1111
|
|
|
870
1112
|
Returns:
|
|
871
1113
|
|
|
872
|
-
|type|description|
|
|
873
|
-
|
|
874
|
-
|
|
1114
|
+
| type | description |
|
|
1115
|
+
| ------ | ------------------------------------------------------------------------- |
|
|
1116
|
+
| `Bool` | `true` if the value is a non-integer rational number or `false` otherwise |
|
|
875
1117
|
|
|
876
1118
|
Examples:
|
|
877
1119
|
|
|
@@ -907,7 +1149,7 @@ No other changes yet.
|
|
|
907
1149
|
</details>
|
|
908
1150
|
|
|
909
1151
|
```grain
|
|
910
|
-
isFinite
|
|
1152
|
+
isFinite: (x: Number) => Bool
|
|
911
1153
|
```
|
|
912
1154
|
|
|
913
1155
|
Checks if a number is finite.
|
|
@@ -915,15 +1157,15 @@ All values are finite exept for floating point NaN, infinity or negative infinit
|
|
|
915
1157
|
|
|
916
1158
|
Parameters:
|
|
917
1159
|
|
|
918
|
-
|param|type|description|
|
|
919
|
-
|
|
920
|
-
|
|
1160
|
+
| param | type | description |
|
|
1161
|
+
| ----- | -------- | ------------------- |
|
|
1162
|
+
| `x` | `Number` | The number to check |
|
|
921
1163
|
|
|
922
1164
|
Returns:
|
|
923
1165
|
|
|
924
|
-
|type|description|
|
|
925
|
-
|
|
926
|
-
|
|
1166
|
+
| type | description |
|
|
1167
|
+
| ------ | -------------------------------------------------- |
|
|
1168
|
+
| `Bool` | `true` if the value is finite or `false` otherwise |
|
|
927
1169
|
|
|
928
1170
|
Examples:
|
|
929
1171
|
|
|
@@ -963,22 +1205,22 @@ No other changes yet.
|
|
|
963
1205
|
</details>
|
|
964
1206
|
|
|
965
1207
|
```grain
|
|
966
|
-
isNaN
|
|
1208
|
+
isNaN: (x: Number) => Bool
|
|
967
1209
|
```
|
|
968
1210
|
|
|
969
1211
|
Checks if a number is the float NaN value (Not A Number).
|
|
970
1212
|
|
|
971
1213
|
Parameters:
|
|
972
1214
|
|
|
973
|
-
|param|type|description|
|
|
974
|
-
|
|
975
|
-
|
|
1215
|
+
| param | type | description |
|
|
1216
|
+
| ----- | -------- | ------------------- |
|
|
1217
|
+
| `x` | `Number` | The number to check |
|
|
976
1218
|
|
|
977
1219
|
Returns:
|
|
978
1220
|
|
|
979
|
-
|type|description|
|
|
980
|
-
|
|
981
|
-
|
|
1221
|
+
| type | description |
|
|
1222
|
+
| ------ | --------------------------------------------- |
|
|
1223
|
+
| `Bool` | `true` if the value is NaN, otherwise `false` |
|
|
982
1224
|
|
|
983
1225
|
Examples:
|
|
984
1226
|
|
|
@@ -1018,7 +1260,7 @@ No other changes yet.
|
|
|
1018
1260
|
</details>
|
|
1019
1261
|
|
|
1020
1262
|
```grain
|
|
1021
|
-
isInfinite
|
|
1263
|
+
isInfinite: (x: Number) => Bool
|
|
1022
1264
|
```
|
|
1023
1265
|
|
|
1024
1266
|
Checks if a number is infinite, that is either of floating point positive or negative infinity.
|
|
@@ -1026,15 +1268,15 @@ Note that this function is not the exact opposite of isFinite(Number) in that it
|
|
|
1026
1268
|
|
|
1027
1269
|
Parameters:
|
|
1028
1270
|
|
|
1029
|
-
|param|type|description|
|
|
1030
|
-
|
|
1031
|
-
|
|
1271
|
+
| param | type | description |
|
|
1272
|
+
| ----- | -------- | ------------------- |
|
|
1273
|
+
| `x` | `Number` | The number to check |
|
|
1032
1274
|
|
|
1033
1275
|
Returns:
|
|
1034
1276
|
|
|
1035
|
-
|type|description|
|
|
1036
|
-
|
|
1037
|
-
|
|
1277
|
+
| type | description |
|
|
1278
|
+
| ------ | ---------------------------------------------------- |
|
|
1279
|
+
| `Bool` | `true` if the value is infinite or `false` otherwise |
|
|
1038
1280
|
|
|
1039
1281
|
Examples:
|
|
1040
1282
|
|
|
@@ -1074,7 +1316,7 @@ No other changes yet.
|
|
|
1074
1316
|
</details>
|
|
1075
1317
|
|
|
1076
1318
|
```grain
|
|
1077
|
-
isClose
|
|
1319
|
+
isClose:
|
|
1078
1320
|
(a: Number, b: Number, ?relativeTolerance: Number,
|
|
1079
1321
|
?absoluteTolerance: Number) => Bool
|
|
1080
1322
|
```
|
|
@@ -1083,18 +1325,18 @@ Determines whether two values are considered close to each other using a relativ
|
|
|
1083
1325
|
|
|
1084
1326
|
Parameters:
|
|
1085
1327
|
|
|
1086
|
-
|param|type|description|
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1328
|
+
| param | type | description |
|
|
1329
|
+
| -------------------- | -------- | ----------------------------------------------------------------------------- |
|
|
1330
|
+
| `a` | `Number` | The first value |
|
|
1331
|
+
| `b` | `Number` | The second value |
|
|
1332
|
+
| `?relativeTolerance` | `Number` | The maximum tolerance to use relative to the larger absolute value `a` or `b` |
|
|
1333
|
+
| `?absoluteTolerance` | `Number` | The absolute tolerance to use, regardless of the values of `a` or `b` |
|
|
1092
1334
|
|
|
1093
1335
|
Returns:
|
|
1094
1336
|
|
|
1095
|
-
|type|description|
|
|
1096
|
-
|
|
1097
|
-
|
|
1337
|
+
| type | description |
|
|
1338
|
+
| ------ | ---------------------------------------------------------------------------- |
|
|
1339
|
+
| `Bool` | `true` if the values are considered close to each other or `false` otherwise |
|
|
1098
1340
|
|
|
1099
1341
|
Examples:
|
|
1100
1342
|
|
|
@@ -1145,7 +1387,7 @@ Number.isClose(4, 4.1, relativeTolerance=0.024) == false
|
|
|
1145
1387
|
</details>
|
|
1146
1388
|
|
|
1147
1389
|
```grain
|
|
1148
|
-
parseInt
|
|
1390
|
+
parseInt:
|
|
1149
1391
|
(string: String, radix: Number) => Result<Number, Atoi.ParseIntError>
|
|
1150
1392
|
```
|
|
1151
1393
|
|
|
@@ -1159,16 +1401,16 @@ input are ignored.
|
|
|
1159
1401
|
|
|
1160
1402
|
Parameters:
|
|
1161
1403
|
|
|
1162
|
-
|param|type|description|
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1404
|
+
| param | type | description |
|
|
1405
|
+
| -------- | -------- | ----------------------------------------------------------- |
|
|
1406
|
+
| `string` | `String` | The string to parse |
|
|
1407
|
+
| `radix` | `Number` | The number system base to use when parsing the input string |
|
|
1166
1408
|
|
|
1167
1409
|
Returns:
|
|
1168
1410
|
|
|
1169
|
-
|type|description|
|
|
1170
|
-
|
|
1171
|
-
|
|
1411
|
+
| type | description |
|
|
1412
|
+
| ------------------------------------ | -------------------------------------------------------------------------------------------------------------------- |
|
|
1413
|
+
| `Result<Number, Atoi.ParseIntError>` | `Ok(value)` containing the parsed number on a successful parse or `Err(err)` containing a variant of `ParseIntError` |
|
|
1172
1414
|
|
|
1173
1415
|
Examples:
|
|
1174
1416
|
|
|
@@ -1192,7 +1434,7 @@ No other changes yet.
|
|
|
1192
1434
|
</details>
|
|
1193
1435
|
|
|
1194
1436
|
```grain
|
|
1195
|
-
parseFloat
|
|
1437
|
+
parseFloat: (string: String) => Result<Number, String>
|
|
1196
1438
|
```
|
|
1197
1439
|
|
|
1198
1440
|
Parses a string representation of a float into a `Number`. Underscores that appear
|
|
@@ -1200,15 +1442,15 @@ in numeric portions of the input are ignored.
|
|
|
1200
1442
|
|
|
1201
1443
|
Parameters:
|
|
1202
1444
|
|
|
1203
|
-
|param|type|description|
|
|
1204
|
-
|
|
1205
|
-
|
|
1445
|
+
| param | type | description |
|
|
1446
|
+
| -------- | -------- | ------------------- |
|
|
1447
|
+
| `string` | `String` | The string to parse |
|
|
1206
1448
|
|
|
1207
1449
|
Returns:
|
|
1208
1450
|
|
|
1209
|
-
|type|description|
|
|
1210
|
-
|
|
1211
|
-
|
|
1451
|
+
| type | description |
|
|
1452
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
|
|
1453
|
+
| `Result<Number, String>` | `Ok(value)` containing the parsed number on a successful parse or `Err(msg)` containing an error message string otherwise |
|
|
1212
1454
|
|
|
1213
1455
|
Examples:
|
|
1214
1456
|
|
|
@@ -1232,7 +1474,7 @@ No other changes yet.
|
|
|
1232
1474
|
</details>
|
|
1233
1475
|
|
|
1234
1476
|
```grain
|
|
1235
|
-
parse
|
|
1477
|
+
parse: (input: String) => Result<Number, Atoi.ParseIntError>
|
|
1236
1478
|
```
|
|
1237
1479
|
|
|
1238
1480
|
Parses a string representation of an integer, float, or rational into a `Number`.
|
|
@@ -1240,15 +1482,15 @@ Underscores that appear in the numeric portion of the input are ignored.
|
|
|
1240
1482
|
|
|
1241
1483
|
Parameters:
|
|
1242
1484
|
|
|
1243
|
-
|param|type|description|
|
|
1244
|
-
|
|
1245
|
-
|
|
1485
|
+
| param | type | description |
|
|
1486
|
+
| ------- | -------- | ------------------- |
|
|
1487
|
+
| `input` | `String` | The string to parse |
|
|
1246
1488
|
|
|
1247
1489
|
Returns:
|
|
1248
1490
|
|
|
1249
|
-
|type|description|
|
|
1250
|
-
|
|
1251
|
-
|
|
1491
|
+
| type | description |
|
|
1492
|
+
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
|
|
1493
|
+
| `Result<Number, Atoi.ParseIntError>` | `Ok(value)` containing the parsed number on a successful parse or `Err(msg)` containing an error message string otherwise |
|
|
1252
1494
|
|
|
1253
1495
|
Examples:
|
|
1254
1496
|
|
|
@@ -1276,22 +1518,22 @@ No other changes yet.
|
|
|
1276
1518
|
</details>
|
|
1277
1519
|
|
|
1278
1520
|
```grain
|
|
1279
|
-
asin
|
|
1521
|
+
asin: (angle: Number) => Number
|
|
1280
1522
|
```
|
|
1281
1523
|
|
|
1282
1524
|
Computes the inverse sine of the given angle.
|
|
1283
1525
|
|
|
1284
1526
|
Parameters:
|
|
1285
1527
|
|
|
1286
|
-
|param|type|description|
|
|
1287
|
-
|
|
1288
|
-
|
|
1528
|
+
| param | type | description |
|
|
1529
|
+
| ------- | -------- | -------------------------------------------------------------- |
|
|
1530
|
+
| `angle` | `Number` | A number between -1 and 1, representing the angle's sine value |
|
|
1289
1531
|
|
|
1290
1532
|
Returns:
|
|
1291
1533
|
|
|
1292
|
-
|type|description|
|
|
1293
|
-
|
|
1294
|
-
|
|
1534
|
+
| type | description |
|
|
1535
|
+
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1536
|
+
| `Number` | The inverse sine (angle in radians between `-pi/2` and `pi/2`) of the given `angle` or `NaN` if the given `angle` is not between`-1` and `1` |
|
|
1295
1537
|
|
|
1296
1538
|
Examples:
|
|
1297
1539
|
|
|
@@ -1311,22 +1553,22 @@ No other changes yet.
|
|
|
1311
1553
|
</details>
|
|
1312
1554
|
|
|
1313
1555
|
```grain
|
|
1314
|
-
acos
|
|
1556
|
+
acos: (angle: Number) => Number
|
|
1315
1557
|
```
|
|
1316
1558
|
|
|
1317
1559
|
Computes the inverse cosine of the given angle.
|
|
1318
1560
|
|
|
1319
1561
|
Parameters:
|
|
1320
1562
|
|
|
1321
|
-
|param|type|description|
|
|
1322
|
-
|
|
1323
|
-
|
|
1563
|
+
| param | type | description |
|
|
1564
|
+
| ------- | -------- | ---------------------------------------------------------------- |
|
|
1565
|
+
| `angle` | `Number` | A number between -1 and 1, representing the angle's cosine value |
|
|
1324
1566
|
|
|
1325
1567
|
Returns:
|
|
1326
1568
|
|
|
1327
|
-
|type|description|
|
|
1328
|
-
|
|
1329
|
-
|
|
1569
|
+
| type | description |
|
|
1570
|
+
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1571
|
+
| `Number` | The inverse cosine (angle in radians between `-pi/2` and `pi/2`) of the given `angle` or `NaN` if the given `angle` is not between`-1` and `1` |
|
|
1330
1572
|
|
|
1331
1573
|
Examples:
|
|
1332
1574
|
|
|
@@ -1346,22 +1588,22 @@ No other changes yet.
|
|
|
1346
1588
|
</details>
|
|
1347
1589
|
|
|
1348
1590
|
```grain
|
|
1349
|
-
atan
|
|
1591
|
+
atan: (angle: Number) => Number
|
|
1350
1592
|
```
|
|
1351
1593
|
|
|
1352
1594
|
Computes the inverse tangent of the given angle.
|
|
1353
1595
|
|
|
1354
1596
|
Parameters:
|
|
1355
1597
|
|
|
1356
|
-
|param|type|description|
|
|
1357
|
-
|
|
1358
|
-
|
|
1598
|
+
| param | type | description |
|
|
1599
|
+
| ------- | -------- | ----------------------------------------------------------------- |
|
|
1600
|
+
| `angle` | `Number` | A number between -1 and 1, representing the angle's tangent value |
|
|
1359
1601
|
|
|
1360
1602
|
Returns:
|
|
1361
1603
|
|
|
1362
|
-
|type|description|
|
|
1363
|
-
|
|
1364
|
-
|
|
1604
|
+
| type | description |
|
|
1605
|
+
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1606
|
+
| `Number` | The inverse tangent (angle in radians between `-pi/2` and `pi/2`) of the given `angle` or `NaN` if the given `angle` is not between`-1` and `1` |
|
|
1365
1607
|
|
|
1366
1608
|
Examples:
|
|
1367
1609
|
|
|
@@ -1381,23 +1623,23 @@ No other changes yet.
|
|
|
1381
1623
|
</details>
|
|
1382
1624
|
|
|
1383
1625
|
```grain
|
|
1384
|
-
atan2
|
|
1626
|
+
atan2: (y: Number, x: Number) => Number
|
|
1385
1627
|
```
|
|
1386
1628
|
|
|
1387
1629
|
Computes the angle between the positive x-axis and the ray from the origin to the point (x, y).
|
|
1388
1630
|
|
|
1389
1631
|
Parameters:
|
|
1390
1632
|
|
|
1391
|
-
|param|type|description|
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1633
|
+
| param | type | description |
|
|
1634
|
+
| ----- | -------- | ---------------------- |
|
|
1635
|
+
| `y` | `Number` | The given y coordinate |
|
|
1636
|
+
| `x` | `Number` | The given x coordinate |
|
|
1395
1637
|
|
|
1396
1638
|
Returns:
|
|
1397
1639
|
|
|
1398
|
-
|type|description|
|
|
1399
|
-
|
|
1400
|
-
|
|
1640
|
+
| type | description |
|
|
1641
|
+
| -------- | --------------------------------------------------------------------- |
|
|
1642
|
+
| `Number` | The angle in radians between the positive x-axis and the point (x, y) |
|
|
1401
1643
|
|
|
1402
1644
|
Examples:
|
|
1403
1645
|
|
|
@@ -1413,22 +1655,22 @@ No other changes yet.
|
|
|
1413
1655
|
</details>
|
|
1414
1656
|
|
|
1415
1657
|
```grain
|
|
1416
|
-
toRadians
|
|
1658
|
+
toRadians: (degrees: Number) => Number
|
|
1417
1659
|
```
|
|
1418
1660
|
|
|
1419
1661
|
Converts degrees to radians.
|
|
1420
1662
|
|
|
1421
1663
|
Parameters:
|
|
1422
1664
|
|
|
1423
|
-
|param|type|description|
|
|
1424
|
-
|
|
1425
|
-
|
|
1665
|
+
| param | type | description |
|
|
1666
|
+
| --------- | -------- | -------------------- |
|
|
1667
|
+
| `degrees` | `Number` | The value to convert |
|
|
1426
1668
|
|
|
1427
1669
|
Returns:
|
|
1428
1670
|
|
|
1429
|
-
|type|description|
|
|
1430
|
-
|
|
1431
|
-
|
|
1671
|
+
| type | description |
|
|
1672
|
+
| -------- | -------------------- |
|
|
1673
|
+
| `Number` | The value in radians |
|
|
1432
1674
|
|
|
1433
1675
|
Examples:
|
|
1434
1676
|
|
|
@@ -1444,22 +1686,22 @@ No other changes yet.
|
|
|
1444
1686
|
</details>
|
|
1445
1687
|
|
|
1446
1688
|
```grain
|
|
1447
|
-
toDegrees
|
|
1689
|
+
toDegrees: (radians: Number) => Number
|
|
1448
1690
|
```
|
|
1449
1691
|
|
|
1450
1692
|
Converts radians to degrees.
|
|
1451
1693
|
|
|
1452
1694
|
Parameters:
|
|
1453
1695
|
|
|
1454
|
-
|param|type|description|
|
|
1455
|
-
|
|
1456
|
-
|
|
1696
|
+
| param | type | description |
|
|
1697
|
+
| --------- | -------- | -------------------- |
|
|
1698
|
+
| `radians` | `Number` | The value to convert |
|
|
1457
1699
|
|
|
1458
1700
|
Returns:
|
|
1459
1701
|
|
|
1460
|
-
|type|description|
|
|
1461
|
-
|
|
1462
|
-
|
|
1702
|
+
| type | description |
|
|
1703
|
+
| -------- | -------------------- |
|
|
1704
|
+
| `Number` | The value in degrees |
|
|
1463
1705
|
|
|
1464
1706
|
Examples:
|
|
1465
1707
|
|
|
@@ -1475,23 +1717,23 @@ No other changes yet.
|
|
|
1475
1717
|
</details>
|
|
1476
1718
|
|
|
1477
1719
|
```grain
|
|
1478
|
-
clamp
|
|
1720
|
+
clamp: (range: Range<Number>, input: Number) => Number
|
|
1479
1721
|
```
|
|
1480
1722
|
|
|
1481
1723
|
Constrains a number within the given inclusive range.
|
|
1482
1724
|
|
|
1483
1725
|
Parameters:
|
|
1484
1726
|
|
|
1485
|
-
|param|type|description|
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1727
|
+
| param | type | description |
|
|
1728
|
+
| ------- | --------------- | ----------------------------------- |
|
|
1729
|
+
| `range` | `Range<Number>` | The inclusive range to clamp within |
|
|
1730
|
+
| `input` | `Number` | The number to clamp |
|
|
1489
1731
|
|
|
1490
1732
|
Returns:
|
|
1491
1733
|
|
|
1492
|
-
|type|description|
|
|
1493
|
-
|
|
1494
|
-
|
|
1734
|
+
| type | description |
|
|
1735
|
+
| -------- | ---------------------- |
|
|
1736
|
+
| `Number` | The constrained number |
|
|
1495
1737
|
|
|
1496
1738
|
### Number.**linearInterpolate**
|
|
1497
1739
|
|
|
@@ -1501,23 +1743,23 @@ No other changes yet.
|
|
|
1501
1743
|
</details>
|
|
1502
1744
|
|
|
1503
1745
|
```grain
|
|
1504
|
-
linearInterpolate
|
|
1746
|
+
linearInterpolate: (range: Range<Number>, weight: Number) => Number
|
|
1505
1747
|
```
|
|
1506
1748
|
|
|
1507
1749
|
Maps a weight between 0 and 1 within the given inclusive range.
|
|
1508
1750
|
|
|
1509
1751
|
Parameters:
|
|
1510
1752
|
|
|
1511
|
-
|param|type|description|
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1753
|
+
| param | type | description |
|
|
1754
|
+
| -------- | --------------- | ----------------------------------------- |
|
|
1755
|
+
| `range` | `Range<Number>` | The inclusive range to interpolate within |
|
|
1756
|
+
| `weight` | `Number` | The weight to interpolate |
|
|
1515
1757
|
|
|
1516
1758
|
Returns:
|
|
1517
1759
|
|
|
1518
|
-
|type|description|
|
|
1519
|
-
|
|
1520
|
-
|
|
1760
|
+
| type | description |
|
|
1761
|
+
| -------- | ----------------- |
|
|
1762
|
+
| `Number` | The blended value |
|
|
1521
1763
|
|
|
1522
1764
|
Throws:
|
|
1523
1765
|
|
|
@@ -1535,7 +1777,7 @@ No other changes yet.
|
|
|
1535
1777
|
</details>
|
|
1536
1778
|
|
|
1537
1779
|
```grain
|
|
1538
|
-
linearMap
|
|
1780
|
+
linearMap:
|
|
1539
1781
|
(inputRange: Range<Number>, outputRange: Range<Number>, current: Number) =>
|
|
1540
1782
|
Number
|
|
1541
1783
|
```
|
|
@@ -1545,17 +1787,17 @@ If the number is outside the input range, it will be clamped.
|
|
|
1545
1787
|
|
|
1546
1788
|
Parameters:
|
|
1547
1789
|
|
|
1548
|
-
|param|type|description|
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1790
|
+
| param | type | description |
|
|
1791
|
+
| ------------- | --------------- | ---------------------------------------- |
|
|
1792
|
+
| `inputRange` | `Range<Number>` | The inclusive range you are mapping from |
|
|
1793
|
+
| `outputRange` | `Range<Number>` | The inclusive range you are mapping to |
|
|
1794
|
+
| `current` | `Number` | The number to map |
|
|
1553
1795
|
|
|
1554
1796
|
Returns:
|
|
1555
1797
|
|
|
1556
|
-
|type|description|
|
|
1557
|
-
|
|
1558
|
-
|
|
1798
|
+
| type | description |
|
|
1799
|
+
| -------- | ----------------- |
|
|
1800
|
+
| `Number` | The mapped number |
|
|
1559
1801
|
|
|
1560
1802
|
Throws:
|
|
1561
1803
|
|
|
@@ -1566,3 +1808,180 @@ Throws:
|
|
|
1566
1808
|
* When `outputRange` is not finite
|
|
1567
1809
|
* When `outputRange` includes NaN
|
|
1568
1810
|
|
|
1811
|
+
### Number.**sin**
|
|
1812
|
+
|
|
1813
|
+
<details disabled>
|
|
1814
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
1815
|
+
No other changes yet.
|
|
1816
|
+
</details>
|
|
1817
|
+
|
|
1818
|
+
```grain
|
|
1819
|
+
sin: (radians: Number) => Number
|
|
1820
|
+
```
|
|
1821
|
+
|
|
1822
|
+
Computes the sine of a number (in radians).
|
|
1823
|
+
|
|
1824
|
+
Parameters:
|
|
1825
|
+
|
|
1826
|
+
| param | type | description |
|
|
1827
|
+
| --------- | -------- | -------------------- |
|
|
1828
|
+
| `radians` | `Number` | The input in radians |
|
|
1829
|
+
|
|
1830
|
+
Returns:
|
|
1831
|
+
|
|
1832
|
+
| type | description |
|
|
1833
|
+
| -------- | ----------------- |
|
|
1834
|
+
| `Number` | The computed sine |
|
|
1835
|
+
|
|
1836
|
+
Examples:
|
|
1837
|
+
|
|
1838
|
+
```grain
|
|
1839
|
+
Number.sin(0) == 0
|
|
1840
|
+
```
|
|
1841
|
+
|
|
1842
|
+
### Number.**cos**
|
|
1843
|
+
|
|
1844
|
+
<details disabled>
|
|
1845
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
1846
|
+
No other changes yet.
|
|
1847
|
+
</details>
|
|
1848
|
+
|
|
1849
|
+
```grain
|
|
1850
|
+
cos: (radians: Number) => Number
|
|
1851
|
+
```
|
|
1852
|
+
|
|
1853
|
+
Computes the cosine of a number (in radians).
|
|
1854
|
+
|
|
1855
|
+
Parameters:
|
|
1856
|
+
|
|
1857
|
+
| param | type | description |
|
|
1858
|
+
| --------- | -------- | -------------------- |
|
|
1859
|
+
| `radians` | `Number` | The input in radians |
|
|
1860
|
+
|
|
1861
|
+
Returns:
|
|
1862
|
+
|
|
1863
|
+
| type | description |
|
|
1864
|
+
| -------- | ------------------- |
|
|
1865
|
+
| `Number` | The computed cosine |
|
|
1866
|
+
|
|
1867
|
+
Examples:
|
|
1868
|
+
|
|
1869
|
+
```grain
|
|
1870
|
+
Number.cos(0) == 1
|
|
1871
|
+
```
|
|
1872
|
+
|
|
1873
|
+
### Number.**tan**
|
|
1874
|
+
|
|
1875
|
+
<details disabled>
|
|
1876
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
1877
|
+
No other changes yet.
|
|
1878
|
+
</details>
|
|
1879
|
+
|
|
1880
|
+
```grain
|
|
1881
|
+
tan: (radians: Number) => Number
|
|
1882
|
+
```
|
|
1883
|
+
|
|
1884
|
+
Computes the tangent of a number (in radians).
|
|
1885
|
+
|
|
1886
|
+
Parameters:
|
|
1887
|
+
|
|
1888
|
+
| param | type | description |
|
|
1889
|
+
| --------- | -------- | -------------------- |
|
|
1890
|
+
| `radians` | `Number` | The input in radians |
|
|
1891
|
+
|
|
1892
|
+
Returns:
|
|
1893
|
+
|
|
1894
|
+
| type | description |
|
|
1895
|
+
| -------- | -------------------- |
|
|
1896
|
+
| `Number` | The computed tangent |
|
|
1897
|
+
|
|
1898
|
+
Examples:
|
|
1899
|
+
|
|
1900
|
+
```grain
|
|
1901
|
+
Number.tan(0) == 0
|
|
1902
|
+
```
|
|
1903
|
+
|
|
1904
|
+
### Number.**gamma**
|
|
1905
|
+
|
|
1906
|
+
<details disabled>
|
|
1907
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
1908
|
+
No other changes yet.
|
|
1909
|
+
</details>
|
|
1910
|
+
|
|
1911
|
+
```grain
|
|
1912
|
+
gamma: (z: Number) => Number
|
|
1913
|
+
```
|
|
1914
|
+
|
|
1915
|
+
Computes the gamma function of a value using the Lanczos approximation.
|
|
1916
|
+
|
|
1917
|
+
Parameters:
|
|
1918
|
+
|
|
1919
|
+
| param | type | description |
|
|
1920
|
+
| ----- | -------- | ------------------------ |
|
|
1921
|
+
| `z` | `Number` | The value to interpolate |
|
|
1922
|
+
|
|
1923
|
+
Returns:
|
|
1924
|
+
|
|
1925
|
+
| type | description |
|
|
1926
|
+
| -------- | ---------------------------- |
|
|
1927
|
+
| `Number` | The gamma of the given value |
|
|
1928
|
+
|
|
1929
|
+
Examples:
|
|
1930
|
+
|
|
1931
|
+
```grain
|
|
1932
|
+
Number.gamma(1) == 1
|
|
1933
|
+
```
|
|
1934
|
+
|
|
1935
|
+
```grain
|
|
1936
|
+
Number.gamma(3) == 2
|
|
1937
|
+
```
|
|
1938
|
+
|
|
1939
|
+
```grain
|
|
1940
|
+
Number.isClose(Number.gamma(0.5), Number.sqrt(Number.pi))
|
|
1941
|
+
```
|
|
1942
|
+
|
|
1943
|
+
### Number.**factorial**
|
|
1944
|
+
|
|
1945
|
+
<details disabled>
|
|
1946
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
1947
|
+
No other changes yet.
|
|
1948
|
+
</details>
|
|
1949
|
+
|
|
1950
|
+
```grain
|
|
1951
|
+
factorial: (n: Number) => Number
|
|
1952
|
+
```
|
|
1953
|
+
|
|
1954
|
+
Computes the factorial of an integer input or the gamma function of a non-integer input.
|
|
1955
|
+
|
|
1956
|
+
Parameters:
|
|
1957
|
+
|
|
1958
|
+
| param | type | description |
|
|
1959
|
+
| ----- | -------- | ------------------------- |
|
|
1960
|
+
| `n` | `Number` | The value to factorialize |
|
|
1961
|
+
|
|
1962
|
+
Returns:
|
|
1963
|
+
|
|
1964
|
+
| type | description |
|
|
1965
|
+
| -------- | -------------------------------- |
|
|
1966
|
+
| `Number` | The factorial of the given value |
|
|
1967
|
+
|
|
1968
|
+
Throws:
|
|
1969
|
+
|
|
1970
|
+
`InvalidArgument(String)`
|
|
1971
|
+
|
|
1972
|
+
* When `n` is a negative integer
|
|
1973
|
+
|
|
1974
|
+
Examples:
|
|
1975
|
+
|
|
1976
|
+
```grain
|
|
1977
|
+
Number.factorial(0) == 1
|
|
1978
|
+
```
|
|
1979
|
+
|
|
1980
|
+
```grain
|
|
1981
|
+
Number.factorial(3) == 6
|
|
1982
|
+
```
|
|
1983
|
+
|
|
1984
|
+
```grain
|
|
1985
|
+
Number.isClose(Number.factorial(0.5), (1/2) * Number.sqrt(Number.pi))
|
|
1986
|
+
```
|
|
1987
|
+
|