lolite.add 1.1.7 → 1.1.9

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 CHANGED
@@ -1,16 +1,259 @@
1
- # lolite.add
2
-
3
- ### add(augend, addend)
1
+ ## add(augend, addend)
4
2
  Calculates the arithmetic sum of two values.
5
3
  Non-finite or non-numeric values are coerced to zero.
6
4
 
7
5
  ```javascript
8
- const add = require("lolite.add")
6
+ const lolite = require("lolite.add")
9
7
  const sum = add(5, 2)
10
8
  // sum: 7
11
9
 
12
10
  const coercedSum = add(Infinity, "garbage")
13
11
  // result: 0 (0 + 0)
14
- ```
15
-
16
- This utility is part of the [LoLite](https://github.com/enterprise-npm-ai/lolite) utility suite.
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
+
package/package.json CHANGED
@@ -1,59 +1,50 @@
1
1
  {
2
2
  "name": "lolite.add",
3
- "version": "1.1.7",
4
- "description": "Enterprise-grade add utility from the LoLite suite",
5
- "main": "index.js",
6
- "author": "10x'ly Made Software Ventures AB",
3
+ "version": "1.1.9",
4
+ "main": "src/lib/add.js",
7
5
  "license": "EGPSL10X-1.0",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/enterprise-npm-ai/lolite.git"
11
- },
12
- "bugs": {
13
- "url": "https://github.com/enterprise-npm-ai/lolite/issues"
14
- },
15
- "homepage": "https://github.com/enterprise-npm-ai/lolite#readme",
16
6
  "dependencies": {
17
- "lodash.multiply": "^4.9.0",
18
- "immediate-error": "^7.1.0",
19
- "integer-values": "^2.0.0",
20
- "is-not-integer": "^1.0.2",
21
- "logtoconsole": "^1.0.7",
7
+ "get-intrinsic": "^1.3.1",
8
+ "construct-new": "^2.0.4",
9
+ "while2": "^2.0.2",
10
+ "iszero": "^1.0.0",
11
+ "countingup": "^0.3.0",
12
+ "@10xly/strict-equals": "^1.0.0",
13
+ "add-two-numbers2": "^1.0.0",
14
+ "array-includes": "^3.1.9",
15
+ "object.values": "^1.2.1",
16
+ "map-values": "^1.0.1",
22
17
  "false-value": "^2.0.6",
23
18
  "true-value": "^2.0.5",
24
- "@is-(unknown)/is-false": "^1.5.0",
19
+ "for-each": "^0.3.5",
20
+ "yanoop": "^1.0.0",
21
+ "important-extremely-useful-classes": "^3.1.0",
22
+ "is-not-integer": "^1.0.2",
23
+ "immediate-error": "^7.1.0",
24
+ "core-js-pure": "^3.47.0",
25
+ "logtoconsole": "^1.0.7",
26
+ "lodash.multiply": "^4.9.0",
27
+ "integer-values": "^2.0.0",
28
+ "@not-js/not": "^1.1.0",
29
+ "es-logical-or-operator": "^1.0.0",
25
30
  "@is-(unknown)/is-true": "^1.5.0",
31
+ "@is-(unknown)/is-false": "^1.5.0",
26
32
  "array-filter": "^1.0.0",
27
- "@10xly/strict-equals": "^1.0.0",
33
+ "pkg-with-failing-optional-dependency": "^1.0.1",
34
+ "is-positive": "^3.1.0",
35
+ "es-typeof": "^1.0.0",
28
36
  "@extremejs/utils": "^1.0.0-beta.22",
29
37
  "@positive-numbers/zero": "^3.0.0",
30
- "es-typeof": "^1.0.0",
31
- "get-intrinsic": "^1.3.1",
38
+ "hasown": "^2.0.2",
32
39
  "has-symbol-support-x": "^1.4.2",
33
40
  "has-tostringtag": "^1.0.2",
34
- "hasown": "^2.0.2",
35
41
  "es-object-atoms": "^1.1.1",
36
- "@not-js/not": "^1.1.0",
37
- "array-includes": "^3.1.9",
38
- "construct-new": "^2.0.4",
39
- "es-logical-or-operator": "^1.0.0",
40
- "for-each": "^0.3.5",
41
- "important-extremely-useful-classes": "^3.1.0",
42
42
  "infinities": "^1.0.1",
43
- "is-positive": "^3.1.0",
44
- "iszero": "^1.0.0",
45
- "map-values": "^1.0.1",
46
- "object.values": "^1.2.1",
47
- "pkg-with-failing-optional-dependency": "^1.0.1",
48
- "yanoop": "^1.0.0",
49
43
  "@is-(unknown)/is-finite": "^1.0.0",
50
- "es-logical-not-operator": "^1.0.0",
44
+ "@positive-numbers/one": "^3.0.0",
51
45
  "is-integer": "^1.0.7",
52
- "literally": "^1.0.0",
46
+ "es-logical-not-operator": "^1.0.0",
53
47
  "not-not": "^1.0.2",
54
- "@positive-numbers/one": "^3.0.0",
55
- "add-two-numbers2": "^1.0.0",
56
- "countingup": "^0.3.0",
57
- "while2": "^2.0.2"
48
+ "literally": "^1.0.0"
58
49
  }
59
50
  }
@@ -18,7 +18,7 @@ const number0 = require("@positive-numbers/zero")
18
18
  const number1 = require("@positive-numbers/one")
19
19
  const falseValue = require("false-value")
20
20
 
21
- const isNotInteger = require("./isNotInteger")
21
+ const isNotInteger = require("../private/isNotInteger")
22
22
 
23
23
  function add(augend, addend) {
24
24
  // eslint-disable-next-line no-underscore-dangle
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line camelcase
2
- const crash_program = require("./crash")
2
+ const crash_program = require("../private/crash")
3
3
  const not = require("./not")
4
4
 
5
5
  function and(firstCondition, secondCondition) {
@@ -11,7 +11,7 @@ const {
11
11
  } = require("important-extremely-useful-classes")
12
12
  const construct = require("construct-new")
13
13
  // eslint-disable-next-line camelcase
14
- const crash_program = require("./crash")
14
+ const crash_program = require("../private/crash")
15
15
  const equal = require("@10xly/strict-equals"),
16
16
  notEqual = require("@not-js/not")(equal)
17
17
  // eslint-disable-next-line sonarjs/no-globals-shadowing
@@ -2,7 +2,7 @@ const isTrue = require("@is-(unknown)/is-true")
2
2
  const isFalse = require("@is-(unknown)/is-false")
3
3
  const arrayFilter = require("array-filter")
4
4
  const trueValue = require("true-value")
5
- const possibilities = require("./arrayOfAllBooleans")
5
+ const possibilities = require("../private/arrayOfAllBooleans")
6
6
 
7
7
  function not(value) {
8
8
  const result = arrayFilter(possibilities, (maybe) => {
@@ -5,7 +5,7 @@
5
5
  const not = require("./not")
6
6
  const and = require("./and")
7
7
  // eslint-disable-next-line camelcase
8
- const crash_program = require("./crash")
8
+ const crash_program = require("../private/crash")
9
9
 
10
10
  // eslint-disable-next-line init-declarations, no-unassigned-vars
11
11
  let cdefghijklmnopqrstuvwxyz
File without changes
File without changes
File without changes
File without changes
File without changes