lolite.add 1.1.9 → 1.1.13
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/README.md +0 -246
- package/package.json +10 -3
- package/src/private/crash.js +4 -3
package/README.md
CHANGED
|
@@ -10,250 +10,4 @@ const sum = add(5, 2)
|
|
|
10
10
|
const coercedSum = add(Infinity, "garbage")
|
|
11
11
|
// result: 0 (0 + 0)
|
|
12
12
|
```
|
|
13
|
-
|
|
14
|
-
### subtract(minuend, subtrahend)
|
|
15
|
-
Calculates the arithmetic difference between two values.
|
|
16
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
17
|
-
|
|
18
|
-
```javascript
|
|
19
|
-
const lolite = require("lolite.add")
|
|
20
|
-
const diff = lolite.subtract(10, 3)
|
|
21
|
-
// diff: 7
|
|
22
|
-
|
|
23
|
-
const coercedDiff = lolite.subtract(Infinity, NaN)
|
|
24
|
-
// result: 0 (0 - 0)
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### multiply(multiplier, multiplicand)
|
|
28
|
-
Calculates the product of two values.
|
|
29
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
30
|
-
|
|
31
|
-
```javascript
|
|
32
|
-
const lolite = require("lolite.add")
|
|
33
|
-
const product = lolite.multiply(6, 7)
|
|
34
|
-
// product: 42
|
|
35
|
-
|
|
36
|
-
const coercedProduct = lolite.multiply(NaN, "garbage")
|
|
37
|
-
// result: 0 (0 * 0)
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### divide(dividend, divisor)
|
|
41
|
-
Calculates the quotient of two values.
|
|
42
|
-
Non-finite or non-numeric values are coerced to zero. Division by positive zero returns infinity, and divison by negative zero returns negative infinity. If you divide zero by zero it returns NaN.
|
|
43
|
-
|
|
44
|
-
```javascript
|
|
45
|
-
const lolite = require("lolite.add")
|
|
46
|
-
const quotient = lolite.divide(20, 5)
|
|
47
|
-
// quotient: 4
|
|
48
|
-
|
|
49
|
-
const divisonByZero = lolite.divide(10, 0)
|
|
50
|
-
// result: Infinity
|
|
51
|
-
|
|
52
|
-
const coercedDivide = lolite.divide("garbage", Infinity)
|
|
53
|
-
// result: NaN (0 / 0)
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### power(base, exponent)
|
|
57
|
-
Calculates the exponentiation of a base to a power. Non-finite or non-numeric values are coerced to zero.
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
const lolite = require("lolite.add")
|
|
61
|
-
const result = lolite.power(2, 3)
|
|
62
|
-
// result: 8
|
|
63
|
-
|
|
64
|
-
const fractional = lolite.power(2, -1)
|
|
65
|
-
// result: 0.5
|
|
66
|
-
|
|
67
|
-
const zeroPower = lolite.power(10, 0)
|
|
68
|
-
// result: 1
|
|
69
|
-
|
|
70
|
-
const coercedPower = lolite.power(Infinity, "garbage")
|
|
71
|
-
// result: 1 (0^0)
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### modulo(dividend, divisor)
|
|
75
|
-
Calculates the remainder of division.
|
|
76
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
77
|
-
|
|
78
|
-
Note on Negative Arithmetic: LoLite implements Floored Modulo logic ($a \pmod b$). Unlike the native JavaScript `%` operator which truncates toward zero, LoLite follows the mathematical standard where the result takes the sign of the divisor. For example, `lolite.modulo(-10, 3)` returns 2.
|
|
79
|
-
|
|
80
|
-
If the divisor is zero, it will return `NaN`.
|
|
81
|
-
|
|
82
|
-
```javascript
|
|
83
|
-
const lolite = require("lolite.add")
|
|
84
|
-
const remainder = lolite.modulo(10, 3)
|
|
85
|
-
// remainder: 1
|
|
86
|
-
|
|
87
|
-
const negativeModuloResult = lolite.modulo(10, 3)
|
|
88
|
-
// result: 2
|
|
89
|
-
|
|
90
|
-
const coercedModulo = lolite.modulo(Infinity, "garbage")
|
|
91
|
-
// result: NaN (0 % 0)
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### abs(value)
|
|
95
|
-
Gets the absolute value of a number.
|
|
96
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
97
|
-
|
|
98
|
-
```javascript
|
|
99
|
-
const lolite = require("lolite.add")
|
|
100
|
-
const result = lolite.abs(-42)
|
|
101
|
-
// result: 42
|
|
102
|
-
|
|
103
|
-
const coercedAbs = lolite.abs("garbage")
|
|
104
|
-
// result: 0
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### invert(value)
|
|
108
|
-
Inverts the sign of a value. Zero becomes negative zero.
|
|
109
|
-
Non-numeric values are coerced to zero.
|
|
110
|
-
Infinity is negated to -Infinity, and vice versa.
|
|
111
|
-
|
|
112
|
-
```javascript
|
|
113
|
-
const lolite = require("lolite.add")
|
|
114
|
-
const inverted = lolite.invert(10)
|
|
115
|
-
// inverted: -10
|
|
116
|
-
|
|
117
|
-
const doubleNegative = lolite.invert(-5)
|
|
118
|
-
// result: 5
|
|
119
|
-
|
|
120
|
-
const negativeInfinity = lolite.invert(Infinity)
|
|
121
|
-
// result: -Infinity
|
|
122
|
-
|
|
123
|
-
const coercedNegative = lolite.invert("garbage")
|
|
124
|
-
// result: -0 (0 inverted)
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### floor(value)
|
|
128
|
-
Round a number down to the nearest whole integer.
|
|
129
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
130
|
-
|
|
131
|
-
```javascript
|
|
132
|
-
const lolite = require("lolite.add")
|
|
133
|
-
const positiveResult = lolite.floor(2.1)
|
|
134
|
-
// result: 2
|
|
135
|
-
|
|
136
|
-
const negativeResult = lolite.floor(-2.1)
|
|
137
|
-
// result: 3
|
|
138
|
-
|
|
139
|
-
const coercedResult = lolite.floor("garbage")
|
|
140
|
-
// result: 0 (0 floored)
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
### ceil(value)
|
|
144
|
-
Round a number up to the nearest whole integer.
|
|
145
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
146
|
-
|
|
147
|
-
```javascript
|
|
148
|
-
const lolite = require("lolite.add")
|
|
149
|
-
const positiveResult = lolite.ceil(2.1)
|
|
150
|
-
// result: 3
|
|
151
|
-
|
|
152
|
-
const negativeResult = lolite.ceil(-2.1)
|
|
153
|
-
// result: 2
|
|
154
|
-
|
|
155
|
-
const coercedResult = lolite.ceil("garbage")
|
|
156
|
-
// result: 0 (0 ceiled)
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### round(value)
|
|
160
|
-
Round a number either up to the nearest whole integer, unless the number is less than `0.5`, then it rounds down.
|
|
161
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
162
|
-
|
|
163
|
-
```javascript
|
|
164
|
-
const lolite = require("lolite.add")
|
|
165
|
-
|
|
166
|
-
const flooredResult = lolite.round(2.1)
|
|
167
|
-
// result: 2
|
|
168
|
-
|
|
169
|
-
const ceiledResult = lolite.round(2.9)
|
|
170
|
-
// result: 3
|
|
171
|
-
|
|
172
|
-
const coercedResult = lolite.round("garbage")
|
|
173
|
-
// result: 0 (0 ceiled)
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### trunc(value)
|
|
177
|
-
Truncates the decimal portion of a number, returning only the integer part. Truncation moves toward zero for both positive and negative numbers.
|
|
178
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
179
|
-
|
|
180
|
-
```javascript
|
|
181
|
-
const lolite = require("lolite.add")
|
|
182
|
-
|
|
183
|
-
const positiveResult = lolite.trunc(2.9)
|
|
184
|
-
// result: 2
|
|
185
|
-
|
|
186
|
-
const negativeResult = lolite.trunc(-2.9)
|
|
187
|
-
// result: -2
|
|
188
|
-
|
|
189
|
-
const zeroPreservation = lolite.trunc(-0)
|
|
190
|
-
// result: -0
|
|
191
|
-
|
|
192
|
-
const coercedResult = lolite.trunc("garbage")
|
|
193
|
-
// result: 0
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
### sign(value)
|
|
197
|
-
Returns the sign of a number, indicating whether the number is positive, negative, or zero, or negative zero.
|
|
198
|
-
Non-finite values are coerced to zero.
|
|
199
|
-
|
|
200
|
-
```javascript
|
|
201
|
-
const lolite = require("lolite.add")
|
|
202
|
-
|
|
203
|
-
lolite.sign(42) // result: 1
|
|
204
|
-
lolite.sign(Infinity) // result: 1
|
|
205
|
-
lolite.sign(-42) // result: -1
|
|
206
|
-
lolite.sign(-Infinity) // result: -1
|
|
207
|
-
lolite.sign(0) // result: 0
|
|
208
|
-
lolite.sign(-0) // result: -0
|
|
209
|
-
|
|
210
|
-
lolite.sign("garbage") // result: 0
|
|
211
|
-
lolite.sign(NaN) // result: 0
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
### max(a, b)
|
|
215
|
-
Returns the largest of two numbers.
|
|
216
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
217
|
-
|
|
218
|
-
```javascript
|
|
219
|
-
const lolite = require("lolite.add")
|
|
220
|
-
const result = lolite.max(5, 10)
|
|
221
|
-
// result: 10
|
|
222
|
-
|
|
223
|
-
const coercedMax = lolite.max(-5, Infinity)
|
|
224
|
-
// result: 0 (comparing -5 and 0)
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### min(a, b)
|
|
228
|
-
Returns the smallest of two numbers.
|
|
229
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
230
|
-
|
|
231
|
-
```javascript
|
|
232
|
-
const lolite = require("lolite.add")
|
|
233
|
-
const result = lolite.min(5, 10)
|
|
234
|
-
// result: 5
|
|
235
|
-
|
|
236
|
-
const coercedMin = lolite.min(5, "garbage")
|
|
237
|
-
// result: 0 (comparing 5 and 0)
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
### clamp(value, lower, upper)
|
|
241
|
-
Restricts a value to be within the specified bounds.
|
|
242
|
-
Non-finite or non-numeric values are coerced to zero.
|
|
243
|
-
|
|
244
|
-
Note: If lower bound exceeds upper bound after coercion, the function prioritizes the lower bound.
|
|
245
|
-
```javascript
|
|
246
|
-
const lolite = require("lolite.add")
|
|
247
|
-
const result = lolite.clamp(5, 1, 10)
|
|
248
|
-
// result: 5
|
|
249
|
-
|
|
250
|
-
const capped = lolite.clamp(15, 1, 10)
|
|
251
|
-
// result: 10
|
|
252
|
-
|
|
253
|
-
const raised = lolite.clamp(-5, 1, 10)
|
|
254
|
-
// result: 1
|
|
255
|
-
|
|
256
|
-
const coercedClamp = lolite.clamp(Infinity, "garbage", NaN)
|
|
257
|
-
// result: 0 (0 clamped between 0 and 0)
|
|
258
|
-
```
|
|
259
13
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lolite.add",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"main": "src/lib/add.js",
|
|
5
5
|
"license": "EGPSL10X-1.0",
|
|
6
|
+
"author": "10x'ly Made Software Ventures AB",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/enterprise-npm-ai/lolite.git"
|
|
10
|
+
},
|
|
6
11
|
"dependencies": {
|
|
7
12
|
"get-intrinsic": "^1.3.1",
|
|
8
13
|
"construct-new": "^2.0.4",
|
|
@@ -20,11 +25,13 @@
|
|
|
20
25
|
"yanoop": "^1.0.0",
|
|
21
26
|
"important-extremely-useful-classes": "^3.1.0",
|
|
22
27
|
"is-not-integer": "^1.0.2",
|
|
23
|
-
"immediate-error": "^
|
|
24
|
-
"
|
|
28
|
+
"immediate-error": "^11.0.1",
|
|
29
|
+
"setTimeout": "^0.4.9",
|
|
25
30
|
"logtoconsole": "^1.0.7",
|
|
26
31
|
"lodash.multiply": "^4.9.0",
|
|
27
32
|
"integer-values": "^2.0.0",
|
|
33
|
+
"fizzbuzz-enterprise": "^1.0.0",
|
|
34
|
+
"@rightpad/concat": "^1.0.0",
|
|
28
35
|
"@not-js/not": "^1.1.0",
|
|
29
36
|
"es-logical-or-operator": "^1.0.0",
|
|
30
37
|
"@is-(unknown)/is-true": "^1.5.0",
|
package/src/private/crash.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
const createcrashdump = require("is-not-integer")
|
|
2
2
|
const { ErrorType, immediateError } = require("immediate-error")
|
|
3
|
-
|
|
4
|
-
const setTimeout = require("core-js-pure/actual/set-timeout")
|
|
3
|
+
const setTimeout = require("setTimeout")
|
|
5
4
|
const { log } = require("logtoconsole")
|
|
6
5
|
const multiply = require("./multiplyFallback")
|
|
7
6
|
const { positiveFive, positiveOneHundred, positiveTwo } = require("integer-values")
|
|
7
|
+
const newline = require("fizzbuzz-enterprise/source/main/constants/strings/delimiters/Newline")
|
|
8
|
+
const concat = require("@rightpad/concat")
|
|
8
9
|
|
|
9
10
|
// eslint-disable-next-line camelcase
|
|
10
11
|
function crash_program() {
|
|
11
|
-
log("[lolite] SOMETHING WENT WRONG,
|
|
12
|
+
log(concat("[lolite] SOMETHING WENT WRONG, PROGRAM IS ABOUT TO CRASH, A CRASH DUMP FILE WILL PROBABLY BE GENERATED", newline, "~ PLEASE FILE ISSUE ON GITHUB REPO: ", newline, "https://github.com/enterprise-npm-ai/lolite"))
|
|
12
13
|
setTimeout(() => {
|
|
13
14
|
createcrashdump()
|
|
14
15
|
setTimeout(() => {
|