lolite.divide 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,11 +1,9 @@
1
- # lolite.divide
2
-
3
- ### divide(dividend, divisor)
1
+ ## divide(dividend, divisor)
4
2
  Calculates the quotient of two values.
5
3
  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.
6
4
 
7
5
  ```javascript
8
- const divide = require("lolite.divide")
6
+ const lolite = require("lolite.divide")
9
7
  const quotient = divide(20, 5)
10
8
  // quotient: 4
11
9
 
@@ -14,6 +12,209 @@ const divisonByZero = divide(10, 0)
14
12
 
15
13
  const coercedDivide = divide("garbage", Infinity)
16
14
  // result: NaN (0 / 0)
17
- ```
18
-
19
- This utility is part of the [LoLite](https://github.com/enterprise-npm-ai/lolite) utility suite.
15
+ ```
16
+
17
+ ### power(base, exponent)
18
+ Calculates the exponentiation of a base to a power. Non-finite or non-numeric values are coerced to zero.
19
+
20
+ ```javascript
21
+ const lolite = require("lolite.divide")
22
+ const result = lolite.power(2, 3)
23
+ // result: 8
24
+
25
+ const fractional = lolite.power(2, -1)
26
+ // result: 0.5
27
+
28
+ const zeroPower = lolite.power(10, 0)
29
+ // result: 1
30
+
31
+ const coercedPower = lolite.power(Infinity, "garbage")
32
+ // result: 1 (0^0)
33
+ ```
34
+
35
+ ### modulo(dividend, divisor)
36
+ Calculates the remainder of division.
37
+ Non-finite or non-numeric values are coerced to zero.
38
+
39
+ 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.
40
+
41
+ If the divisor is zero, it will return `NaN`.
42
+
43
+ ```javascript
44
+ const lolite = require("lolite.divide")
45
+ const remainder = lolite.modulo(10, 3)
46
+ // remainder: 1
47
+
48
+ const negativeModuloResult = lolite.modulo(10, 3)
49
+ // result: 2
50
+
51
+ const coercedModulo = lolite.modulo(Infinity, "garbage")
52
+ // result: NaN (0 % 0)
53
+ ```
54
+
55
+ ### abs(value)
56
+ Gets the absolute value of a number.
57
+ Non-finite or non-numeric values are coerced to zero.
58
+
59
+ ```javascript
60
+ const lolite = require("lolite.divide")
61
+ const result = lolite.abs(-42)
62
+ // result: 42
63
+
64
+ const coercedAbs = lolite.abs("garbage")
65
+ // result: 0
66
+ ```
67
+
68
+ ### invert(value)
69
+ Inverts the sign of a value. Zero becomes negative zero.
70
+ Non-numeric values are coerced to zero.
71
+ Infinity is negated to -Infinity, and vice versa.
72
+
73
+ ```javascript
74
+ const lolite = require("lolite.divide")
75
+ const inverted = lolite.invert(10)
76
+ // inverted: -10
77
+
78
+ const doubleNegative = lolite.invert(-5)
79
+ // result: 5
80
+
81
+ const negativeInfinity = lolite.invert(Infinity)
82
+ // result: -Infinity
83
+
84
+ const coercedNegative = lolite.invert("garbage")
85
+ // result: -0 (0 inverted)
86
+ ```
87
+
88
+ ### floor(value)
89
+ Round a number down to the nearest whole integer.
90
+ Non-finite or non-numeric values are coerced to zero.
91
+
92
+ ```javascript
93
+ const lolite = require("lolite.divide")
94
+ const positiveResult = lolite.floor(2.1)
95
+ // result: 2
96
+
97
+ const negativeResult = lolite.floor(-2.1)
98
+ // result: 3
99
+
100
+ const coercedResult = lolite.floor("garbage")
101
+ // result: 0 (0 floored)
102
+ ```
103
+
104
+ ### ceil(value)
105
+ Round a number up to the nearest whole integer.
106
+ Non-finite or non-numeric values are coerced to zero.
107
+
108
+ ```javascript
109
+ const lolite = require("lolite.divide")
110
+ const positiveResult = lolite.ceil(2.1)
111
+ // result: 3
112
+
113
+ const negativeResult = lolite.ceil(-2.1)
114
+ // result: 2
115
+
116
+ const coercedResult = lolite.ceil("garbage")
117
+ // result: 0 (0 ceiled)
118
+ ```
119
+
120
+ ### round(value)
121
+ Round a number either up to the nearest whole integer, unless the number is less than `0.5`, then it rounds down.
122
+ Non-finite or non-numeric values are coerced to zero.
123
+
124
+ ```javascript
125
+ const lolite = require("lolite.divide")
126
+
127
+ const flooredResult = lolite.round(2.1)
128
+ // result: 2
129
+
130
+ const ceiledResult = lolite.round(2.9)
131
+ // result: 3
132
+
133
+ const coercedResult = lolite.round("garbage")
134
+ // result: 0 (0 ceiled)
135
+ ```
136
+
137
+ ### trunc(value)
138
+ Truncates the decimal portion of a number, returning only the integer part. Truncation moves toward zero for both positive and negative numbers.
139
+ Non-finite or non-numeric values are coerced to zero.
140
+
141
+ ```javascript
142
+ const lolite = require("lolite.divide")
143
+
144
+ const positiveResult = lolite.trunc(2.9)
145
+ // result: 2
146
+
147
+ const negativeResult = lolite.trunc(-2.9)
148
+ // result: -2
149
+
150
+ const zeroPreservation = lolite.trunc(-0)
151
+ // result: -0
152
+
153
+ const coercedResult = lolite.trunc("garbage")
154
+ // result: 0
155
+ ```
156
+
157
+ ### sign(value)
158
+ Returns the sign of a number, indicating whether the number is positive, negative, or zero, or negative zero.
159
+ Non-finite values are coerced to zero.
160
+
161
+ ```javascript
162
+ const lolite = require("lolite.divide")
163
+
164
+ lolite.sign(42) // result: 1
165
+ lolite.sign(Infinity) // result: 1
166
+ lolite.sign(-42) // result: -1
167
+ lolite.sign(-Infinity) // result: -1
168
+ lolite.sign(0) // result: 0
169
+ lolite.sign(-0) // result: -0
170
+
171
+ lolite.sign("garbage") // result: 0
172
+ lolite.sign(NaN) // result: 0
173
+ ```
174
+
175
+ ### max(a, b)
176
+ Returns the largest of two numbers.
177
+ Non-finite or non-numeric values are coerced to zero.
178
+
179
+ ```javascript
180
+ const lolite = require("lolite.divide")
181
+ const result = lolite.max(5, 10)
182
+ // result: 10
183
+
184
+ const coercedMax = lolite.max(-5, Infinity)
185
+ // result: 0 (comparing -5 and 0)
186
+ ```
187
+
188
+ ### min(a, b)
189
+ Returns the smallest of two numbers.
190
+ Non-finite or non-numeric values are coerced to zero.
191
+
192
+ ```javascript
193
+ const lolite = require("lolite.divide")
194
+ const result = lolite.min(5, 10)
195
+ // result: 5
196
+
197
+ const coercedMin = lolite.min(5, "garbage")
198
+ // result: 0 (comparing 5 and 0)
199
+ ```
200
+
201
+ ### clamp(value, lower, upper)
202
+ Restricts a value to be within the specified bounds.
203
+ Non-finite or non-numeric values are coerced to zero.
204
+
205
+ Note: If lower bound exceeds upper bound after coercion, the function prioritizes the lower bound.
206
+ ```javascript
207
+ const lolite = require("lolite.divide")
208
+ const result = lolite.clamp(5, 1, 10)
209
+ // result: 5
210
+
211
+ const capped = lolite.clamp(15, 1, 10)
212
+ // result: 10
213
+
214
+ const raised = lolite.clamp(-5, 1, 10)
215
+ // result: 1
216
+
217
+ const coercedClamp = lolite.clamp(Infinity, "garbage", NaN)
218
+ // result: 0 (0 clamped between 0 and 0)
219
+ ```
220
+
package/package.json CHANGED
@@ -1,30 +1,20 @@
1
1
  {
2
2
  "name": "lolite.divide",
3
- "version": "1.1.7",
4
- "description": "Enterprise-grade divide 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/divide.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
- "@10xly/strict-equals": "^1.0.0",
18
- "@is-(unknown)/is-finite": "^1.0.0",
19
7
  "@positive-numbers/zero": "^3.0.0",
20
- "array-includes": "^3.1.9",
21
- "const": "^1.0.0",
22
8
  "false-value": "^2.0.6",
23
- "infinities": "^1.0.1",
24
- "is-negative-zero": "^2.0.3",
9
+ "@10xly/strict-equals": "^1.0.0",
10
+ "@is-(unknown)/is-finite": "^1.0.0",
25
11
  "iszero": "^1.0.0",
26
- "map-values": "^1.0.1",
12
+ "is-negative-zero": "^2.0.3",
27
13
  "nan-is-a-function": "^67.67.67",
28
- "object.values": "^1.2.1"
14
+ "array-includes": "^3.1.9",
15
+ "object.values": "^1.2.1",
16
+ "map-values": "^1.0.1",
17
+ "const": "^1.0.0",
18
+ "infinities": "^1.0.1"
29
19
  }
30
20
  }
File without changes