@grain/stdlib 0.5.13 → 0.6.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.
Files changed (155) hide show
  1. package/CHANGELOG.md +201 -0
  2. package/LICENSE +1 -1
  3. package/README.md +25 -2
  4. package/array.gr +1512 -199
  5. package/array.md +2032 -94
  6. package/bigint.gr +239 -140
  7. package/bigint.md +450 -106
  8. package/buffer.gr +595 -102
  9. package/buffer.md +903 -145
  10. package/bytes.gr +401 -110
  11. package/bytes.md +551 -63
  12. package/char.gr +228 -49
  13. package/char.md +373 -7
  14. package/exception.gr +26 -12
  15. package/exception.md +29 -5
  16. package/float32.gr +130 -109
  17. package/float32.md +185 -57
  18. package/float64.gr +112 -99
  19. package/float64.md +185 -57
  20. package/hash.gr +62 -40
  21. package/hash.md +27 -3
  22. package/int16.gr +430 -0
  23. package/int16.md +618 -0
  24. package/int32.gr +200 -269
  25. package/int32.md +254 -289
  26. package/int64.gr +142 -225
  27. package/int64.md +254 -289
  28. package/int8.gr +511 -0
  29. package/int8.md +786 -0
  30. package/json.gr +2071 -0
  31. package/json.md +646 -0
  32. package/list.gr +120 -68
  33. package/list.md +125 -80
  34. package/map.gr +560 -57
  35. package/map.md +672 -56
  36. package/marshal.gr +239 -227
  37. package/marshal.md +36 -4
  38. package/number.gr +626 -676
  39. package/number.md +738 -153
  40. package/option.gr +33 -35
  41. package/option.md +58 -42
  42. package/package.json +2 -2
  43. package/path.gr +148 -187
  44. package/path.md +47 -96
  45. package/pervasives.gr +75 -416
  46. package/pervasives.md +85 -180
  47. package/priorityqueue.gr +433 -74
  48. package/priorityqueue.md +422 -54
  49. package/queue.gr +362 -80
  50. package/queue.md +433 -38
  51. package/random.gr +67 -75
  52. package/random.md +68 -40
  53. package/range.gr +135 -63
  54. package/range.md +198 -43
  55. package/rational.gr +284 -0
  56. package/rational.md +545 -0
  57. package/regex.gr +933 -1066
  58. package/regex.md +59 -60
  59. package/result.gr +23 -25
  60. package/result.md +54 -39
  61. package/runtime/atof/common.gr +78 -82
  62. package/runtime/atof/common.md +22 -10
  63. package/runtime/atof/decimal.gr +102 -127
  64. package/runtime/atof/decimal.md +28 -7
  65. package/runtime/atof/lemire.gr +56 -71
  66. package/runtime/atof/lemire.md +9 -1
  67. package/runtime/atof/parse.gr +83 -110
  68. package/runtime/atof/parse.md +12 -2
  69. package/runtime/atof/slow.gr +28 -35
  70. package/runtime/atof/slow.md +9 -1
  71. package/runtime/atof/table.gr +19 -18
  72. package/runtime/atof/table.md +10 -2
  73. package/runtime/atoi/parse.gr +153 -136
  74. package/runtime/atoi/parse.md +50 -1
  75. package/runtime/bigint.gr +410 -517
  76. package/runtime/bigint.md +71 -57
  77. package/runtime/compare.gr +176 -85
  78. package/runtime/compare.md +31 -1
  79. package/runtime/dataStructures.gr +144 -32
  80. package/runtime/dataStructures.md +267 -31
  81. package/runtime/debugPrint.gr +34 -15
  82. package/runtime/debugPrint.md +37 -5
  83. package/runtime/equal.gr +53 -52
  84. package/runtime/equal.md +30 -1
  85. package/runtime/exception.gr +38 -47
  86. package/runtime/exception.md +10 -8
  87. package/runtime/gc.gr +23 -152
  88. package/runtime/gc.md +13 -17
  89. package/runtime/malloc.gr +31 -31
  90. package/runtime/malloc.md +11 -3
  91. package/runtime/numberUtils.gr +193 -174
  92. package/runtime/numberUtils.md +29 -9
  93. package/runtime/numbers.gr +1695 -1021
  94. package/runtime/numbers.md +1098 -134
  95. package/runtime/string.gr +543 -245
  96. package/runtime/string.md +76 -6
  97. package/runtime/unsafe/constants.gr +30 -13
  98. package/runtime/unsafe/constants.md +80 -0
  99. package/runtime/unsafe/conv.gr +55 -28
  100. package/runtime/unsafe/conv.md +41 -9
  101. package/runtime/unsafe/memory.gr +10 -30
  102. package/runtime/unsafe/memory.md +15 -19
  103. package/runtime/unsafe/tags.gr +37 -21
  104. package/runtime/unsafe/tags.md +88 -8
  105. package/runtime/unsafe/wasmf32.gr +30 -36
  106. package/runtime/unsafe/wasmf32.md +64 -56
  107. package/runtime/unsafe/wasmf64.gr +30 -36
  108. package/runtime/unsafe/wasmf64.md +64 -56
  109. package/runtime/unsafe/wasmi32.gr +49 -66
  110. package/runtime/unsafe/wasmi32.md +102 -94
  111. package/runtime/unsafe/wasmi64.gr +52 -79
  112. package/runtime/unsafe/wasmi64.md +108 -100
  113. package/runtime/utils/printing.gr +13 -15
  114. package/runtime/utils/printing.md +11 -3
  115. package/runtime/wasi.gr +294 -295
  116. package/runtime/wasi.md +62 -42
  117. package/set.gr +574 -64
  118. package/set.md +634 -54
  119. package/stack.gr +181 -64
  120. package/stack.md +271 -42
  121. package/string.gr +453 -533
  122. package/string.md +241 -151
  123. package/uint16.gr +369 -0
  124. package/uint16.md +585 -0
  125. package/uint32.gr +470 -0
  126. package/uint32.md +737 -0
  127. package/uint64.gr +471 -0
  128. package/uint64.md +737 -0
  129. package/uint8.gr +369 -0
  130. package/uint8.md +585 -0
  131. package/uri.gr +1093 -0
  132. package/uri.md +477 -0
  133. package/{sys → wasi}/file.gr +914 -500
  134. package/{sys → wasi}/file.md +454 -50
  135. package/wasi/process.gr +292 -0
  136. package/{sys → wasi}/process.md +164 -6
  137. package/wasi/random.gr +77 -0
  138. package/wasi/random.md +80 -0
  139. package/{sys → wasi}/time.gr +15 -22
  140. package/{sys → wasi}/time.md +5 -5
  141. package/immutablearray.gr +0 -929
  142. package/immutablearray.md +0 -1038
  143. package/immutablemap.gr +0 -493
  144. package/immutablemap.md +0 -479
  145. package/immutablepriorityqueue.gr +0 -360
  146. package/immutablepriorityqueue.md +0 -291
  147. package/immutableset.gr +0 -498
  148. package/immutableset.md +0 -449
  149. package/runtime/debug.gr +0 -2
  150. package/runtime/debug.md +0 -6
  151. package/runtime/unsafe/errors.gr +0 -36
  152. package/runtime/unsafe/errors.md +0 -204
  153. package/sys/process.gr +0 -254
  154. package/sys/random.gr +0 -79
  155. package/sys/random.md +0 -66
package/number.md CHANGED
@@ -10,38 +10,77 @@ No other changes yet.
10
10
  </details>
11
11
 
12
12
  ```grain
13
- import Number from "number"
13
+ from "number" include Number
14
14
  ```
15
15
 
16
- ## Constants
16
+ ```grain
17
+ 1
18
+ ```
17
19
 
18
- Number constant values.
20
+ ```grain
21
+ -1
22
+ ```
19
23
 
20
- ### Number.**nan**
24
+ ```grain
25
+ 0.5
26
+ ```
21
27
 
22
- <details disabled>
23
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
24
- No other changes yet.
25
- </details>
28
+ ```grain
29
+ 1/2
30
+ ```
26
31
 
27
32
  ```grain
28
- nan : Number
33
+ Infinity
29
34
  ```
30
35
 
31
- NaN represented as a Number value.
36
+ ```grain
37
+ NaN
38
+ ```
39
+
40
+ ## Types
41
+
42
+ Type declarations included in the Number module.
32
43
 
33
- ### Number.**infinity**
44
+ ### Number.**ParseIntError**
34
45
 
35
46
  <details disabled>
36
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
47
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
37
48
  No other changes yet.
38
49
  </details>
39
50
 
40
51
  ```grain
41
- infinity : Number
52
+ enum ParseIntError {
53
+ ParseIntEmptyString,
54
+ ParseIntInvalidDigit,
55
+ ParseIntInvalidRadix,
56
+ }
57
+ ```
58
+
59
+ Represents an error that occurred trying to parse an integer.
60
+
61
+ Variants:
62
+
63
+ ```grain
64
+ ParseIntEmptyString
65
+ ```
66
+
67
+ Represents an error caused by trying to parse an empty string.
68
+
69
+ ```grain
70
+ ParseIntInvalidDigit
71
+ ```
72
+
73
+ Represents an error caused by trying to parse a string with an invalid character.
74
+
75
+ ```grain
76
+ ParseIntInvalidRadix
42
77
  ```
43
78
 
44
- Infinity represented as a Number value.
79
+ Represents an error caused by trying to parse with an invalid radix.
80
+
81
+ ## Values
82
+
83
+ Functions and constants included in the Number module.
45
84
 
46
85
  ### Number.**pi**
47
86
 
@@ -82,19 +121,22 @@ e : Number
82
121
 
83
122
  Euler's number represented as a Number value.
84
123
 
85
- ## Operations
124
+ ### Number.**(+)**
86
125
 
87
- Functions for operating on values of the Number type.
88
-
89
- ### Number.**add**
90
-
91
- <details disabled>
92
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
93
- No other changes yet.
126
+ <details>
127
+ <summary>Added in <code>0.6.0</code></summary>
128
+ <table>
129
+ <thead>
130
+ <tr><th>version</th><th>changes</th></tr>
131
+ </thead>
132
+ <tbody>
133
+ <tr><td><code>0.4.0</code></td><td>Originally named `add`</td></tr>
134
+ </tbody>
135
+ </table>
94
136
  </details>
95
137
 
96
138
  ```grain
97
- add : (Number, Number) -> Number
139
+ (+) : (num1: Number, num2: Number) => Number
98
140
  ```
99
141
 
100
142
  Computes the sum of its operands.
@@ -103,8 +145,8 @@ Parameters:
103
145
 
104
146
  |param|type|description|
105
147
  |-----|----|-----------|
106
- |`x`|`Number`|The first operand|
107
- |`y`|`Number`|The second operand|
148
+ |`num1`|`Number`|The first operand|
149
+ |`num2`|`Number`|The second operand|
108
150
 
109
151
  Returns:
110
152
 
@@ -112,15 +154,29 @@ Returns:
112
154
  |----|-----------|
113
155
  |`Number`|The sum of the two operands|
114
156
 
115
- ### Number.**sub**
157
+ Examples:
158
+
159
+ ```grain
160
+ from Number use { (+) }
161
+ assert 1 + 2 == 3
162
+ ```
116
163
 
117
- <details disabled>
118
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
119
- No other changes yet.
164
+ ### Number.**(-)**
165
+
166
+ <details>
167
+ <summary>Added in <code>0.6.0</code></summary>
168
+ <table>
169
+ <thead>
170
+ <tr><th>version</th><th>changes</th></tr>
171
+ </thead>
172
+ <tbody>
173
+ <tr><td><code>0.4.0</code></td><td>Originally named `sub`</td></tr>
174
+ </tbody>
175
+ </table>
120
176
  </details>
121
177
 
122
178
  ```grain
123
- sub : (Number, Number) -> Number
179
+ (-) : (num1: Number, num2: Number) => Number
124
180
  ```
125
181
 
126
182
  Computes the difference of its operands.
@@ -129,8 +185,8 @@ Parameters:
129
185
 
130
186
  |param|type|description|
131
187
  |-----|----|-----------|
132
- |`x`|`Number`|The first operand|
133
- |`y`|`Number`|The second operand|
188
+ |`num1`|`Number`|The first operand|
189
+ |`num2`|`Number`|The second operand|
134
190
 
135
191
  Returns:
136
192
 
@@ -138,15 +194,29 @@ Returns:
138
194
  |----|-----------|
139
195
  |`Number`|The difference of the two operands|
140
196
 
141
- ### Number.**mul**
197
+ Examples:
142
198
 
143
- <details disabled>
144
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
145
- No other changes yet.
199
+ ```grain
200
+ from Number use { (-) }
201
+ assert 5 - 2 == 3
202
+ ```
203
+
204
+ ### Number.**(*)**
205
+
206
+ <details>
207
+ <summary>Added in <code>0.6.0</code></summary>
208
+ <table>
209
+ <thead>
210
+ <tr><th>version</th><th>changes</th></tr>
211
+ </thead>
212
+ <tbody>
213
+ <tr><td><code>0.4.0</code></td><td>Originally named `mul`</td></tr>
214
+ </tbody>
215
+ </table>
146
216
  </details>
147
217
 
148
218
  ```grain
149
- mul : (Number, Number) -> Number
219
+ (*) : (num1: Number, num2: Number) => Number
150
220
  ```
151
221
 
152
222
  Computes the product of its operands.
@@ -155,8 +225,8 @@ Parameters:
155
225
 
156
226
  |param|type|description|
157
227
  |-----|----|-----------|
158
- |`x`|`Number`|The first operand|
159
- |`y`|`Number`|The second operand|
228
+ |`num1`|`Number`|The first operand|
229
+ |`num2`|`Number`|The second operand|
160
230
 
161
231
  Returns:
162
232
 
@@ -164,15 +234,29 @@ Returns:
164
234
  |----|-----------|
165
235
  |`Number`|The product of the two operands|
166
236
 
167
- ### Number.**div**
237
+ Examples:
168
238
 
169
- <details disabled>
170
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
171
- No other changes yet.
239
+ ```grain
240
+ from Number use { (*) }
241
+ assert 5 * 4 == 20
242
+ ```
243
+
244
+ ### Number.**(/)**
245
+
246
+ <details>
247
+ <summary>Added in <code>0.6.0</code></summary>
248
+ <table>
249
+ <thead>
250
+ <tr><th>version</th><th>changes</th></tr>
251
+ </thead>
252
+ <tbody>
253
+ <tr><td><code>0.4.0</code></td><td>Originally named `div`</td></tr>
254
+ </tbody>
255
+ </table>
172
256
  </details>
173
257
 
174
258
  ```grain
175
- div : (Number, Number) -> Number
259
+ (/) : (num1: Number, num2: Number) => Number
176
260
  ```
177
261
 
178
262
  Computes the quotient of its operands.
@@ -181,8 +265,8 @@ Parameters:
181
265
 
182
266
  |param|type|description|
183
267
  |-----|----|-----------|
184
- |`x`|`Number`|The dividend|
185
- |`y`|`Number`|The divisor|
268
+ |`num1`|`Number`|The dividend|
269
+ |`num2`|`Number`|The divisor|
186
270
 
187
271
  Returns:
188
272
 
@@ -190,15 +274,29 @@ Returns:
190
274
  |----|-----------|
191
275
  |`Number`|The quotient of the two operands|
192
276
 
193
- ### Number.**pow**
277
+ Examples:
194
278
 
195
- <details disabled>
196
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
197
- No other changes yet.
279
+ ```grain
280
+ from Number use { (/) }
281
+ assert 10 / 2.5 == 4
282
+ ```
283
+
284
+ ### Number.**(\*\*)**
285
+
286
+ <details>
287
+ <summary>Added in <code>0.6.0</code></summary>
288
+ <table>
289
+ <thead>
290
+ <tr><th>version</th><th>changes</th></tr>
291
+ </thead>
292
+ <tbody>
293
+ <tr><td><code>0.5.4</code></td><td>Originally named `pow`</td></tr>
294
+ </tbody>
295
+ </table>
198
296
  </details>
199
297
 
200
298
  ```grain
201
- pow : (Number, Number) -> Number
299
+ (**) : (base: Number, power: Number) => Number
202
300
  ```
203
301
 
204
302
  Computes the exponentiation of the given base and power.
@@ -216,6 +314,13 @@ Returns:
216
314
  |----|-----------|
217
315
  |`Number`|The base raised to the given power|
218
316
 
317
+ Examples:
318
+
319
+ ```grain
320
+ from Number use { (**) }
321
+ assert 10 ** 2 == 100
322
+ ```
323
+
219
324
  ### Number.**exp**
220
325
 
221
326
  <details disabled>
@@ -224,7 +329,7 @@ No other changes yet.
224
329
  </details>
225
330
 
226
331
  ```grain
227
- exp : Number -> Number
332
+ exp : (power: Number) => Number
228
333
  ```
229
334
 
230
335
  Computes the exponentiation of Euler's number to the given power.
@@ -241,6 +346,16 @@ Returns:
241
346
  |----|-----------|
242
347
  |`Number`|The `Number.e` value raised to the given power|
243
348
 
349
+ Examples:
350
+
351
+ ```grain
352
+ Number.exp(1) == Number.e
353
+ ```
354
+
355
+ ```grain
356
+ Number.exp(10) == 22026.465794806703
357
+ ```
358
+
244
359
  ### Number.**sqrt**
245
360
 
246
361
  <details disabled>
@@ -249,7 +364,7 @@ No other changes yet.
249
364
  </details>
250
365
 
251
366
  ```grain
252
- sqrt : Number -> Number
367
+ sqrt : (x: Number) => Number
253
368
  ```
254
369
 
255
370
  Computes the square root of its operand.
@@ -266,10 +381,21 @@ Returns:
266
381
  |----|-----------|
267
382
  |`Number`|The square root of the operand|
268
383
 
384
+ Examples:
385
+
386
+ ```grain
387
+ Number.sqrt(25) == 5
388
+ ```
389
+
269
390
  ### Number.**sign**
270
391
 
392
+ <details disabled>
393
+ <summary tabindex="-1">Added in <code>0.5.0</code></summary>
394
+ No other changes yet.
395
+ </details>
396
+
271
397
  ```grain
272
- sign : Number -> Number
398
+ sign : (x: Number) => Number
273
399
  ```
274
400
 
275
401
  Determine the positivity or negativity of a Number.
@@ -315,7 +441,7 @@ Number.sign(0) == 0
315
441
  </details>
316
442
 
317
443
  ```grain
318
- min : (Number, Number) -> Number
444
+ min : (x: Number, y: Number) => Number
319
445
  ```
320
446
 
321
447
  Returns the smaller of its operands.
@@ -333,6 +459,12 @@ Returns:
333
459
  |----|-----------|
334
460
  |`Number`|The smaller of the two operands|
335
461
 
462
+ Examples:
463
+
464
+ ```grain
465
+ Number.min(5, 2) == 2
466
+ ```
467
+
336
468
  ### Number.**max**
337
469
 
338
470
  <details>
@@ -348,7 +480,7 @@ Returns:
348
480
  </details>
349
481
 
350
482
  ```grain
351
- max : (Number, Number) -> Number
483
+ max : (x: Number, y: Number) => Number
352
484
  ```
353
485
 
354
486
  Returns the larger of its operands.
@@ -366,6 +498,12 @@ Returns:
366
498
  |----|-----------|
367
499
  |`Number`|The larger of the two operands|
368
500
 
501
+ Examples:
502
+
503
+ ```grain
504
+ Number.max(5, 2) == 5
505
+ ```
506
+
369
507
  ### Number.**ceil**
370
508
 
371
509
  <details>
@@ -381,7 +519,7 @@ Returns:
381
519
  </details>
382
520
 
383
521
  ```grain
384
- ceil : Number -> Number
522
+ ceil : (x: Number) => Number
385
523
  ```
386
524
 
387
525
  Rounds its operand up to the next largest integer.
@@ -398,6 +536,16 @@ Returns:
398
536
  |----|-----------|
399
537
  |`Number`|The next largest integer of the operand|
400
538
 
539
+ Examples:
540
+
541
+ ```grain
542
+ Number.ceil(5.5) == 6
543
+ ```
544
+
545
+ ```grain
546
+ Number.ceil(-5.5) == -5
547
+ ```
548
+
401
549
  ### Number.**floor**
402
550
 
403
551
  <details>
@@ -413,7 +561,7 @@ Returns:
413
561
  </details>
414
562
 
415
563
  ```grain
416
- floor : Number -> Number
564
+ floor : (x: Number) => Number
417
565
  ```
418
566
 
419
567
  Rounds its operand down to the largest integer less than the operand.
@@ -430,6 +578,16 @@ Returns:
430
578
  |----|-----------|
431
579
  |`Number`|The previous integer of the operand|
432
580
 
581
+ Examples:
582
+
583
+ ```grain
584
+ Number.floor(5.5) == 5
585
+ ```
586
+
587
+ ```grain
588
+ Number.floor(-5.5) == -6
589
+ ```
590
+
433
591
  ### Number.**trunc**
434
592
 
435
593
  <details>
@@ -445,7 +603,7 @@ Returns:
445
603
  </details>
446
604
 
447
605
  ```grain
448
- trunc : Number -> Number
606
+ trunc : (x: Number) => Number
449
607
  ```
450
608
 
451
609
  Returns the integer part of its operand, removing any fractional value.
@@ -462,6 +620,12 @@ Returns:
462
620
  |----|-----------|
463
621
  |`Number`|The integer part of the operand|
464
622
 
623
+ Examples:
624
+
625
+ ```grain
626
+ Number.trunc(5.5) == 5
627
+ ```
628
+
465
629
  ### Number.**round**
466
630
 
467
631
  <details>
@@ -477,7 +641,7 @@ Returns:
477
641
  </details>
478
642
 
479
643
  ```grain
480
- round : Number -> Number
644
+ round : (x: Number) => Number
481
645
  ```
482
646
 
483
647
  Returns its operand rounded to its nearest integer.
@@ -494,6 +658,24 @@ Returns:
494
658
  |----|-----------|
495
659
  |`Number`|The nearest integer to the operand|
496
660
 
661
+ Examples:
662
+
663
+ ```grain
664
+ Number.round(5.5) == 6
665
+ ```
666
+
667
+ ```grain
668
+ Number.round(5.4) == 5
669
+ ```
670
+
671
+ ```grain
672
+ Number.round(-5.5) == -6
673
+ ```
674
+
675
+ ```grain
676
+ Number.round(-5.4) == -5
677
+ ```
678
+
497
679
  ### Number.**abs**
498
680
 
499
681
  <details disabled>
@@ -502,7 +684,7 @@ No other changes yet.
502
684
  </details>
503
685
 
504
686
  ```grain
505
- abs : Number -> Number
687
+ abs : (x: Number) => Number
506
688
  ```
507
689
 
508
690
  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.
@@ -519,6 +701,16 @@ Returns:
519
701
  |----|-----------|
520
702
  |`Number`|The absolute value of the operand|
521
703
 
704
+ Examples:
705
+
706
+ ```grain
707
+ Number.abs(-1) == 1
708
+ ```
709
+
710
+ ```grain
711
+ Number.abs(5) == 5
712
+ ```
713
+
522
714
  ### Number.**neg**
523
715
 
524
716
  <details disabled>
@@ -527,7 +719,7 @@ No other changes yet.
527
719
  </details>
528
720
 
529
721
  ```grain
530
- neg : Number -> Number
722
+ neg : (x: Number) => Number
531
723
  ```
532
724
 
533
725
  Returns the negation of its operand.
@@ -544,6 +736,16 @@ Returns:
544
736
  |----|-----------|
545
737
  |`Number`|The negated operand|
546
738
 
739
+ Examples:
740
+
741
+ ```grain
742
+ Number.neg(-1) == 1
743
+ ```
744
+
745
+ ```grain
746
+ Number.neg(1) == -1
747
+ ```
748
+
547
749
  ### Number.**isFloat**
548
750
 
549
751
  <details disabled>
@@ -552,7 +754,7 @@ No other changes yet.
552
754
  </details>
553
755
 
554
756
  ```grain
555
- isFloat : Number -> Bool
757
+ isFloat : (x: Number) => Bool
556
758
  ```
557
759
 
558
760
  Checks if a number is a floating point value.
@@ -569,6 +771,32 @@ Returns:
569
771
  |----|-----------|
570
772
  |`Bool`|`true` if the value is a floating point number or `false` otherwise|
571
773
 
774
+ Examples:
775
+
776
+ ```grain
777
+ Number.isFloat(0.5)
778
+ ```
779
+
780
+ ```grain
781
+ Number.isFloat(1.0)
782
+ ```
783
+
784
+ ```grain
785
+ Number.isFloat(Infinity)
786
+ ```
787
+
788
+ ```grain
789
+ Number.isFloat(NaN)
790
+ ```
791
+
792
+ ```grain
793
+ Number.isFloat(1/2) == false
794
+ ```
795
+
796
+ ```grain
797
+ Number.isFloat(1) == false
798
+ ```
799
+
572
800
  ### Number.**isInteger**
573
801
 
574
802
  <details disabled>
@@ -577,7 +805,7 @@ No other changes yet.
577
805
  </details>
578
806
 
579
807
  ```grain
580
- isInteger : Number -> Bool
808
+ isInteger : (x: Number) => Bool
581
809
  ```
582
810
 
583
811
  Checks if a number is an integer.
@@ -594,6 +822,32 @@ Returns:
594
822
  |----|-----------|
595
823
  |`Bool`|`true` if the value is an integer or `false` otherwise|
596
824
 
825
+ Examples:
826
+
827
+ ```grain
828
+ Number.isInteger(1)
829
+ ```
830
+
831
+ ```grain
832
+ Number.isInteger(0.5) == false
833
+ ```
834
+
835
+ ```grain
836
+ Number.isInteger(1.0) == false
837
+ ```
838
+
839
+ ```grain
840
+ Number.isInteger(1/2) == false
841
+ ```
842
+
843
+ ```grain
844
+ Number.isInteger(Infinity) == false
845
+ ```
846
+
847
+ ```grain
848
+ Number.isInteger(NaN) == false
849
+ ```
850
+
597
851
  ### Number.**isRational**
598
852
 
599
853
  <details disabled>
@@ -602,7 +856,7 @@ No other changes yet.
602
856
  </details>
603
857
 
604
858
  ```grain
605
- isRational : Number -> Bool
859
+ isRational : (x: Number) => Bool
606
860
  ```
607
861
 
608
862
  Checks if a number is a non-integer rational value.
@@ -619,25 +873,51 @@ Returns:
619
873
  |----|-----------|
620
874
  |`Bool`|`true` if the value is a non-integer rational number or `false` otherwise|
621
875
 
622
- ### Number.**isFinite**
876
+ Examples:
623
877
 
624
- <details disabled>
625
- <summary tabindex="-1">Added in <code>0.4.0</code></summary>
626
- No other changes yet.
627
- </details>
878
+ ```grain
879
+ Number.isRational(1/2)
880
+ ```
628
881
 
629
882
  ```grain
630
- isFinite : Number -> Bool
883
+ Number.isRational(0.5) == false
631
884
  ```
632
885
 
633
- Checks if a number is finite.
634
- All values are finite exept for floating point NaN, infinity or negative infinity.
886
+ ```grain
887
+ Number.isRational(1.0) == false
888
+ ```
635
889
 
636
- Parameters:
890
+ ```grain
891
+ Number.isRational(1) == false
892
+ ```
637
893
 
638
- |param|type|description|
639
- |-----|----|-----------|
640
- |`x`|`Number`|The number to check|
894
+ ```grain
895
+ Number.isRational(Infinity) == false
896
+ ```
897
+
898
+ ```grain
899
+ Number.isRational(NaN) == false
900
+ ```
901
+
902
+ ### Number.**isFinite**
903
+
904
+ <details disabled>
905
+ <summary tabindex="-1">Added in <code>0.4.0</code></summary>
906
+ No other changes yet.
907
+ </details>
908
+
909
+ ```grain
910
+ isFinite : (x: Number) => Bool
911
+ ```
912
+
913
+ Checks if a number is finite.
914
+ All values are finite exept for floating point NaN, infinity or negative infinity.
915
+
916
+ Parameters:
917
+
918
+ |param|type|description|
919
+ |-----|----|-----------|
920
+ |`x`|`Number`|The number to check|
641
921
 
642
922
  Returns:
643
923
 
@@ -645,6 +925,36 @@ Returns:
645
925
  |----|-----------|
646
926
  |`Bool`|`true` if the value is finite or `false` otherwise|
647
927
 
928
+ Examples:
929
+
930
+ ```grain
931
+ Number.isFinite(1/2)
932
+ ```
933
+
934
+ ```grain
935
+ Number.isFinite(0.5)
936
+ ```
937
+
938
+ ```grain
939
+ Number.isFinite(1.0)
940
+ ```
941
+
942
+ ```grain
943
+ Number.isFinite(1)
944
+ ```
945
+
946
+ ```grain
947
+ Number.isFinite(Infinity) == false
948
+ ```
949
+
950
+ ```grain
951
+ Number.isFinite(-Infinity) == false
952
+ ```
953
+
954
+ ```grain
955
+ Number.isFinite(NaN) == false
956
+ ```
957
+
648
958
  ### Number.**isNaN**
649
959
 
650
960
  <details disabled>
@@ -653,7 +963,7 @@ No other changes yet.
653
963
  </details>
654
964
 
655
965
  ```grain
656
- isNaN : Number -> Bool
966
+ isNaN : (x: Number) => Bool
657
967
  ```
658
968
 
659
969
  Checks if a number is the float NaN value (Not A Number).
@@ -670,6 +980,36 @@ Returns:
670
980
  |----|-----------|
671
981
  |`Bool`|`true` if the value is NaN, otherwise `false`|
672
982
 
983
+ Examples:
984
+
985
+ ```grain
986
+ Number.isNaN(NaN)
987
+ ```
988
+
989
+ ```grain
990
+ Number.isNaN(Infinity) == false
991
+ ```
992
+
993
+ ```grain
994
+ Number.isNaN(-Infinity) == false
995
+ ```
996
+
997
+ ```grain
998
+ Number.isNaN(1/2) == false
999
+ ```
1000
+
1001
+ ```grain
1002
+ Number.isNaN(0.5) == false
1003
+ ```
1004
+
1005
+ ```grain
1006
+ Number.isNaN(1.0) == false
1007
+ ```
1008
+
1009
+ ```grain
1010
+ Number.isNaN(1) == false
1011
+ ```
1012
+
673
1013
  ### Number.**isInfinite**
674
1014
 
675
1015
  <details disabled>
@@ -678,7 +1018,7 @@ No other changes yet.
678
1018
  </details>
679
1019
 
680
1020
  ```grain
681
- isInfinite : Number -> Bool
1021
+ isInfinite : (x: Number) => Bool
682
1022
  ```
683
1023
 
684
1024
  Checks if a number is infinite, that is either of floating point positive or negative infinity.
@@ -696,15 +1036,117 @@ Returns:
696
1036
  |----|-----------|
697
1037
  |`Bool`|`true` if the value is infinite or `false` otherwise|
698
1038
 
699
- ### Number.**parseInt**
1039
+ Examples:
1040
+
1041
+ ```grain
1042
+ Number.isInfinite(Infinity)
1043
+ ```
1044
+
1045
+ ```grain
1046
+ Number.isInfinite(-Infinity)
1047
+ ```
1048
+
1049
+ ```grain
1050
+ Number.isInfinite(NaN) == false
1051
+ ```
1052
+
1053
+ ```grain
1054
+ Number.isInfinite(1/2) == false
1055
+ ```
1056
+
1057
+ ```grain
1058
+ Number.isInfinite(0.5) == false
1059
+ ```
1060
+
1061
+ ```grain
1062
+ Number.isInfinite(1.0) == false
1063
+ ```
1064
+
1065
+ ```grain
1066
+ Number.isInfinite(1) == false
1067
+ ```
1068
+
1069
+ ### Number.**isClose**
700
1070
 
701
1071
  <details disabled>
702
- <summary tabindex="-1">Added in <code>0.4.5</code></summary>
1072
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
703
1073
  No other changes yet.
704
1074
  </details>
705
1075
 
706
1076
  ```grain
707
- parseInt : (String, Number) -> Result<Number, String>
1077
+ isClose :
1078
+ (a: Number, b: Number, ?relativeTolerance: Number,
1079
+ ?absoluteTolerance: Number) => Bool
1080
+ ```
1081
+
1082
+ Determines whether two values are considered close to each other using a relative and absolute tolerance.
1083
+
1084
+ Parameters:
1085
+
1086
+ |param|type|description|
1087
+ |-----|----|-----------|
1088
+ |`a`|`Number`|The first value|
1089
+ |`b`|`Number`|The second value|
1090
+ |`?relativeTolerance`|`Number`|The maximum tolerance to use relative to the larger absolute value `a` or `b`|
1091
+ |`?absoluteTolerance`|`Number`|The absolute tolerance to use, regardless of the values of `a` or `b`|
1092
+
1093
+ Returns:
1094
+
1095
+ |type|description|
1096
+ |----|-----------|
1097
+ |`Bool`|`true` if the values are considered close to each other or `false` otherwise|
1098
+
1099
+ Examples:
1100
+
1101
+ ```grain
1102
+ Number.isClose(1.233, 1.233)
1103
+ ```
1104
+
1105
+ ```grain
1106
+ Number.isClose(1.233, 1.233000001)
1107
+ ```
1108
+
1109
+ ```grain
1110
+ Number.isClose(8.005, 8.450, absoluteTolerance=0.5)
1111
+ ```
1112
+
1113
+ ```grain
1114
+ Number.isClose(4, 4.1, relativeTolerance=0.025)
1115
+ ```
1116
+
1117
+ ```grain
1118
+ Number.isClose(1.233, 1.24) == false
1119
+ ```
1120
+
1121
+ ```grain
1122
+ Number.isClose(1.233, 1.4566) == false
1123
+ ```
1124
+
1125
+ ```grain
1126
+ Number.isClose(8.005, 8.450, absoluteTolerance=0.4) == false
1127
+ ```
1128
+
1129
+ ```grain
1130
+ Number.isClose(4, 4.1, relativeTolerance=0.024) == false
1131
+ ```
1132
+
1133
+ ### Number.**parseInt**
1134
+
1135
+ <details>
1136
+ <summary>Added in <code>0.4.5</code></summary>
1137
+ <table>
1138
+ <thead>
1139
+ <tr><th>version</th><th>changes</th></tr>
1140
+ </thead>
1141
+ <tbody>
1142
+ <tr><td><code>0.6.0</code></td><td>Switched from a string-based error message to a structured error enum</td></tr>
1143
+ </tbody>
1144
+ </table>
1145
+ </details>
1146
+
1147
+ ```grain
1148
+ parseInt :
1149
+ (string: String, radix: Number) => Result<Number, Atoi.ParseIntError>
708
1150
  ```
709
1151
 
710
1152
  Parses a string representation of an integer into a `Number` using the
@@ -719,14 +1161,28 @@ Parameters:
719
1161
 
720
1162
  |param|type|description|
721
1163
  |-----|----|-----------|
722
- |`input`|`String`|The string to parse|
1164
+ |`string`|`String`|The string to parse|
723
1165
  |`radix`|`Number`|The number system base to use when parsing the input string|
724
1166
 
725
1167
  Returns:
726
1168
 
727
1169
  |type|description|
728
1170
  |----|-----------|
729
- |`Result<Number, String>`|`Ok(value)` containing the parsed number on a successful parse or `Err(msg)` containing an error message string otherwise|
1171
+ |`Result<Number, Atoi.ParseIntError>`|`Ok(value)` containing the parsed number on a successful parse or `Err(err)` containing a variant of `ParseIntError`|
1172
+
1173
+ Examples:
1174
+
1175
+ ```grain
1176
+ Number.parseInt("1", radix=10) == Ok(1)
1177
+ ```
1178
+
1179
+ ```grain
1180
+ Number.parseInt("-1", radix=10) == Ok(-1)
1181
+ ```
1182
+
1183
+ ```grain
1184
+ Number.parseInt("0xf0", radix=16) == Ok(0x0f0)
1185
+ ```
730
1186
 
731
1187
  ### Number.**parseFloat**
732
1188
 
@@ -736,7 +1192,7 @@ No other changes yet.
736
1192
  </details>
737
1193
 
738
1194
  ```grain
739
- parseFloat : String -> Result<Number, String>
1195
+ parseFloat : (string: String) => Result<Number, String>
740
1196
  ```
741
1197
 
742
1198
  Parses a string representation of a float into a `Number`. Underscores that appear
@@ -746,7 +1202,7 @@ Parameters:
746
1202
 
747
1203
  |param|type|description|
748
1204
  |-----|----|-----------|
749
- |`input`|`String`|The string to parse|
1205
+ |`string`|`String`|The string to parse|
750
1206
 
751
1207
  Returns:
752
1208
 
@@ -754,6 +1210,20 @@ Returns:
754
1210
  |----|-----------|
755
1211
  |`Result<Number, String>`|`Ok(value)` containing the parsed number on a successful parse or `Err(msg)` containing an error message string otherwise|
756
1212
 
1213
+ Examples:
1214
+
1215
+ ```grain
1216
+ Number.parseFloat("1") == Ok(1.0)
1217
+ ```
1218
+
1219
+ ```grain
1220
+ Number.parseFloat("-1") == Ok(-1.0)
1221
+ ```
1222
+
1223
+ ```grain
1224
+ Number.parseFloat("-1.5") == Ok(-1.5)
1225
+ ```
1226
+
757
1227
  ### Number.**parse**
758
1228
 
759
1229
  <details disabled>
@@ -762,7 +1232,7 @@ No other changes yet.
762
1232
  </details>
763
1233
 
764
1234
  ```grain
765
- parse : String -> Result<Number, String>
1235
+ parse : (input: String) => Result<Number, Atoi.ParseIntError>
766
1236
  ```
767
1237
 
768
1238
  Parses a string representation of an integer, float, or rational into a `Number`.
@@ -778,129 +1248,195 @@ Returns:
778
1248
 
779
1249
  |type|description|
780
1250
  |----|-----------|
781
- |`Result<Number, String>`|`Ok(value)` containing the parsed number on a successful parse or `Err(msg)` containing an error message string otherwise|
1251
+ |`Result<Number, Atoi.ParseIntError>`|`Ok(value)` containing the parsed number on a successful parse or `Err(msg)` containing an error message string otherwise|
782
1252
 
783
- ### Number.**sin**
1253
+ Examples:
784
1254
 
785
- <details>
786
- <summary>Added in <code>0.5.2</code></summary>
787
- <table>
788
- <thead>
789
- <tr><th>version</th><th>changes</th></tr>
790
- </thead>
791
- <tbody>
792
- <tr><td><code>0.5.4</code></td><td>Handle NaN and Infinity</td></tr>
793
- </tbody>
794
- </table>
1255
+ ```grain
1256
+ Number.parse("1") == Ok(1)
1257
+ ```
1258
+
1259
+ ```grain
1260
+ Number.parse("-1") == Ok(-1)
1261
+ ```
1262
+
1263
+ ```grain
1264
+ Number.parse("0xf0") == Ok(0x0f0)
1265
+ ```
1266
+
1267
+ ```grain
1268
+ Number.parse("-1.5") == Ok(-1.5)
1269
+ ```
1270
+
1271
+ ### Number.**asin**
1272
+
1273
+ <details disabled>
1274
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
1275
+ No other changes yet.
795
1276
  </details>
796
1277
 
797
1278
  ```grain
798
- sin : Number -> Number
1279
+ asin : (angle: Number) => Number
799
1280
  ```
800
1281
 
801
- Computes the sine of a number (in radians) using Chebyshev polynomials.
1282
+ Computes the inverse sine of the given angle.
802
1283
 
803
1284
  Parameters:
804
1285
 
805
1286
  |param|type|description|
806
1287
  |-----|----|-----------|
807
- |`radians`|`Number`|The input in radians|
1288
+ |`angle`|`Number`|A number between -1 and 1, representing the angle's sine value|
808
1289
 
809
1290
  Returns:
810
1291
 
811
1292
  |type|description|
812
1293
  |----|-----------|
813
- |`Number`|The computed sine|
1294
+ |`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`|
814
1295
 
815
- ### Number.**cos**
1296
+ Examples:
816
1297
 
817
- <details>
818
- <summary>Added in <code>0.5.2</code></summary>
819
- <table>
820
- <thead>
821
- <tr><th>version</th><th>changes</th></tr>
822
- </thead>
823
- <tbody>
824
- <tr><td><code>0.5.4</code></td><td>Handle NaN and Infinity</td></tr>
825
- </tbody>
826
- </table>
1298
+ ```grain
1299
+ Number.asin(0) == 0
1300
+ ```
1301
+
1302
+ ```grain
1303
+ Number.asin(1) == 1.5707963267948966
1304
+ ```
1305
+
1306
+ ### Number.**acos**
1307
+
1308
+ <details disabled>
1309
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
1310
+ No other changes yet.
827
1311
  </details>
828
1312
 
829
1313
  ```grain
830
- cos : Number -> Number
1314
+ acos : (angle: Number) => Number
831
1315
  ```
832
1316
 
833
- Computes the cosine of a number (in radians) using Chebyshev polynomials.
1317
+ Computes the inverse cosine of the given angle.
834
1318
 
835
1319
  Parameters:
836
1320
 
837
1321
  |param|type|description|
838
1322
  |-----|----|-----------|
839
- |`radians`|`Number`|The input in radians|
1323
+ |`angle`|`Number`|A number between -1 and 1, representing the angle's cosine value|
840
1324
 
841
1325
  Returns:
842
1326
 
843
1327
  |type|description|
844
1328
  |----|-----------|
845
- |`Number`|The computed cosine|
1329
+ |`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`|
846
1330
 
847
- ### Number.**tan**
1331
+ Examples:
1332
+
1333
+ ```grain
1334
+ Number.acos(1) == 0
1335
+ ```
1336
+
1337
+ ```grain
1338
+ Number.acos(0) == 1.5707963267948966
1339
+ ```
1340
+
1341
+ ### Number.**atan**
848
1342
 
849
1343
  <details disabled>
850
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
1344
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
851
1345
  No other changes yet.
852
1346
  </details>
853
1347
 
854
1348
  ```grain
855
- tan : Number -> Number
1349
+ atan : (angle: Number) => Number
856
1350
  ```
857
1351
 
858
- Computes the tangent of a number (in radians) using Chebyshev polynomials.
1352
+ Computes the inverse tangent of the given angle.
859
1353
 
860
1354
  Parameters:
861
1355
 
862
1356
  |param|type|description|
863
1357
  |-----|----|-----------|
864
- |`radians`|`Number`|The input in radians|
1358
+ |`angle`|`Number`|A number between -1 and 1, representing the angle's tangent value|
865
1359
 
866
1360
  Returns:
867
1361
 
868
1362
  |type|description|
869
1363
  |----|-----------|
870
- |`Number`|The computed tangent|
1364
+ |`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`|
871
1365
 
872
- ### Number.**gamma**
1366
+ Examples:
1367
+
1368
+ ```grain
1369
+ Number.atan(0) == 0
1370
+ ```
1371
+
1372
+ ```grain
1373
+ Number.atan(1) == 0.7853981633974483
1374
+ ```
1375
+
1376
+ ### Number.**atan2**
873
1377
 
874
1378
  <details disabled>
875
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
1379
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
876
1380
  No other changes yet.
877
1381
  </details>
878
1382
 
879
1383
  ```grain
880
- gamma : Number -> Number
1384
+ atan2 : (y: Number, x: Number) => Number
881
1385
  ```
882
1386
 
883
- Computes the gamma function of a value using Lanczos approximation.
1387
+ Computes the angle between the positive x-axis and the ray from the origin to the point (x, y).
884
1388
 
885
1389
  Parameters:
886
1390
 
887
1391
  |param|type|description|
888
1392
  |-----|----|-----------|
889
- |`z`|`Number`|The value to interpolate|
1393
+ |`y`|`Number`|The given y coordinate|
1394
+ |`x`|`Number`|The given x coordinate|
890
1395
 
891
1396
  Returns:
892
1397
 
893
1398
  |type|description|
894
1399
  |----|-----------|
895
- |`Number`|The gamma of the given value|
1400
+ |`Number`|The angle in radians between the positive x-axis and the point (x, y)|
896
1401
 
897
- Throws:
1402
+ Examples:
898
1403
 
899
- `InvalidArgument(String)`
1404
+ ```grain
1405
+ Number.atan2(0, 1) == Number.pi
1406
+ ```
1407
+
1408
+ ### Number.**toRadians**
1409
+
1410
+ <details disabled>
1411
+ <summary tabindex="-1">Added in <code>0.5.4</code></summary>
1412
+ No other changes yet.
1413
+ </details>
900
1414
 
901
- * When `z` is zero
1415
+ ```grain
1416
+ toRadians : (degrees: Number) => Number
1417
+ ```
1418
+
1419
+ Converts degrees to radians.
1420
+
1421
+ Parameters:
902
1422
 
903
- ### Number.**factorial**
1423
+ |param|type|description|
1424
+ |-----|----|-----------|
1425
+ |`degrees`|`Number`|The value to convert|
1426
+
1427
+ Returns:
1428
+
1429
+ |type|description|
1430
+ |----|-----------|
1431
+ |`Number`|The value in radians|
1432
+
1433
+ Examples:
1434
+
1435
+ ```grain
1436
+ Number.toRadians(180) == Number.pi
1437
+ ```
1438
+
1439
+ ### Number.**toDegrees**
904
1440
 
905
1441
  <details disabled>
906
1442
  <summary tabindex="-1">Added in <code>0.5.4</code></summary>
@@ -908,76 +1444,125 @@ No other changes yet.
908
1444
  </details>
909
1445
 
910
1446
  ```grain
911
- factorial : Number -> Number
1447
+ toDegrees : (radians: Number) => Number
912
1448
  ```
913
1449
 
914
- Computes the product of consecutive integers for an integer input and computes the gamma function for non-integer inputs.
1450
+ Converts radians to degrees.
915
1451
 
916
1452
  Parameters:
917
1453
 
918
1454
  |param|type|description|
919
1455
  |-----|----|-----------|
920
- |`n`|`Number`|The value to factorialize|
1456
+ |`radians`|`Number`|The value to convert|
921
1457
 
922
1458
  Returns:
923
1459
 
924
1460
  |type|description|
925
1461
  |----|-----------|
926
- |`Number`|The factorial of the given value|
1462
+ |`Number`|The value in degrees|
927
1463
 
928
- Throws:
1464
+ Examples:
929
1465
 
930
- `InvalidArgument(String)`
1466
+ ```grain
1467
+ Number.toRadians(Number.pi) == 180
1468
+ ```
931
1469
 
932
- * When `n` is negative
1470
+ ### Number.**clamp**
933
1471
 
934
- ### Number.**toRadians**
1472
+ <details disabled>
1473
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
1474
+ No other changes yet.
1475
+ </details>
1476
+
1477
+ ```grain
1478
+ clamp : (range: Range<Number>, input: Number) => Number
1479
+ ```
1480
+
1481
+ Constrains a number within the given inclusive range.
1482
+
1483
+ Parameters:
1484
+
1485
+ |param|type|description|
1486
+ |-----|----|-----------|
1487
+ |`range`|`Range<Number>`|The inclusive range to clamp within|
1488
+ |`input`|`Number`|The number to clamp|
1489
+
1490
+ Returns:
1491
+
1492
+ |type|description|
1493
+ |----|-----------|
1494
+ |`Number`|The constrained number|
1495
+
1496
+ ### Number.**linearInterpolate**
935
1497
 
936
1498
  <details disabled>
937
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
1499
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
938
1500
  No other changes yet.
939
1501
  </details>
940
1502
 
941
1503
  ```grain
942
- toRadians : Number -> Number
1504
+ linearInterpolate : (range: Range<Number>, weight: Number) => Number
943
1505
  ```
944
1506
 
945
- Converts degrees to radians.
1507
+ Maps a weight between 0 and 1 within the given inclusive range.
946
1508
 
947
1509
  Parameters:
948
1510
 
949
1511
  |param|type|description|
950
1512
  |-----|----|-----------|
951
- |`degrees`|`Number`|The value to convert|
1513
+ |`range`|`Range<Number>`|The inclusive range to interpolate within|
1514
+ |`weight`|`Number`|The weight to interpolate|
952
1515
 
953
1516
  Returns:
954
1517
 
955
1518
  |type|description|
956
1519
  |----|-----------|
957
- |`Number`|The value in radians|
1520
+ |`Number`|The blended value|
958
1521
 
959
- ### Number.**toDegrees**
1522
+ Throws:
1523
+
1524
+ `InvalidArgument(String)`
1525
+
1526
+ * When `weight` is not between 0 and 1
1527
+ * When `range` is not finite
1528
+ * When `range` includes NaN
1529
+
1530
+ ### Number.**linearMap**
960
1531
 
961
1532
  <details disabled>
962
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
1533
+ <summary tabindex="-1">Added in <code>0.6.0</code></summary>
963
1534
  No other changes yet.
964
1535
  </details>
965
1536
 
966
1537
  ```grain
967
- toDegrees : Number -> Number
1538
+ linearMap :
1539
+ (inputRange: Range<Number>, outputRange: Range<Number>, current: Number) =>
1540
+ Number
968
1541
  ```
969
1542
 
970
- Converts radians to degrees.
1543
+ Scales a number from one inclusive range to another inclusive range.
1544
+ If the number is outside the input range, it will be clamped.
971
1545
 
972
1546
  Parameters:
973
1547
 
974
1548
  |param|type|description|
975
1549
  |-----|----|-----------|
976
- |`radians`|`Number`|The value to convert|
1550
+ |`inputRange`|`Range<Number>`|The inclusive range you are mapping from|
1551
+ |`outputRange`|`Range<Number>`|The inclusive range you are mapping to|
1552
+ |`current`|`Number`|The number to map|
977
1553
 
978
1554
  Returns:
979
1555
 
980
1556
  |type|description|
981
1557
  |----|-----------|
982
- |`Number`|The value in degrees|
1558
+ |`Number`|The mapped number|
1559
+
1560
+ Throws:
1561
+
1562
+ `InvalidArgument(String)`
1563
+
1564
+ * When `inputRange` is not finite
1565
+ * When `inputRange` includes NaN
1566
+ * When `outputRange` is not finite
1567
+ * When `outputRange` includes NaN
983
1568