lolite.floor 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.floor
2
-
3
- ### floor(value)
1
+ ## floor(value)
4
2
  Round a number down to the nearest whole integer.
5
3
  Non-finite or non-numeric values are coerced to zero.
6
4
 
7
5
  ```javascript
8
- const floor = require("lolite.floor")
6
+ const lolite = require("lolite.floor")
9
7
  const positiveResult = floor(2.1)
10
8
  // result: 2
11
9
 
@@ -14,6 +12,122 @@ const negativeResult = floor(-2.1)
14
12
 
15
13
  const coercedResult = floor("garbage")
16
14
  // result: 0 (0 floored)
17
- ```
18
-
19
- This utility is part of the [LoLite](https://github.com/enterprise-npm-ai/lolite) utility suite.
15
+ ```
16
+
17
+ ### ceil(value)
18
+ Round a number up to the nearest whole integer.
19
+ Non-finite or non-numeric values are coerced to zero.
20
+
21
+ ```javascript
22
+ const lolite = require("lolite.floor")
23
+ const positiveResult = lolite.ceil(2.1)
24
+ // result: 3
25
+
26
+ const negativeResult = lolite.ceil(-2.1)
27
+ // result: 2
28
+
29
+ const coercedResult = lolite.ceil("garbage")
30
+ // result: 0 (0 ceiled)
31
+ ```
32
+
33
+ ### round(value)
34
+ Round a number either up to the nearest whole integer, unless the number is less than `0.5`, then it rounds down.
35
+ Non-finite or non-numeric values are coerced to zero.
36
+
37
+ ```javascript
38
+ const lolite = require("lolite.floor")
39
+
40
+ const flooredResult = lolite.round(2.1)
41
+ // result: 2
42
+
43
+ const ceiledResult = lolite.round(2.9)
44
+ // result: 3
45
+
46
+ const coercedResult = lolite.round("garbage")
47
+ // result: 0 (0 ceiled)
48
+ ```
49
+
50
+ ### trunc(value)
51
+ Truncates the decimal portion of a number, returning only the integer part. Truncation moves toward zero for both positive and negative numbers.
52
+ Non-finite or non-numeric values are coerced to zero.
53
+
54
+ ```javascript
55
+ const lolite = require("lolite.floor")
56
+
57
+ const positiveResult = lolite.trunc(2.9)
58
+ // result: 2
59
+
60
+ const negativeResult = lolite.trunc(-2.9)
61
+ // result: -2
62
+
63
+ const zeroPreservation = lolite.trunc(-0)
64
+ // result: -0
65
+
66
+ const coercedResult = lolite.trunc("garbage")
67
+ // result: 0
68
+ ```
69
+
70
+ ### sign(value)
71
+ Returns the sign of a number, indicating whether the number is positive, negative, or zero, or negative zero.
72
+ Non-finite values are coerced to zero.
73
+
74
+ ```javascript
75
+ const lolite = require("lolite.floor")
76
+
77
+ lolite.sign(42) // result: 1
78
+ lolite.sign(Infinity) // result: 1
79
+ lolite.sign(-42) // result: -1
80
+ lolite.sign(-Infinity) // result: -1
81
+ lolite.sign(0) // result: 0
82
+ lolite.sign(-0) // result: -0
83
+
84
+ lolite.sign("garbage") // result: 0
85
+ lolite.sign(NaN) // result: 0
86
+ ```
87
+
88
+ ### max(a, b)
89
+ Returns the largest of two numbers.
90
+ Non-finite or non-numeric values are coerced to zero.
91
+
92
+ ```javascript
93
+ const lolite = require("lolite.floor")
94
+ const result = lolite.max(5, 10)
95
+ // result: 10
96
+
97
+ const coercedMax = lolite.max(-5, Infinity)
98
+ // result: 0 (comparing -5 and 0)
99
+ ```
100
+
101
+ ### min(a, b)
102
+ Returns the smallest of two numbers.
103
+ Non-finite or non-numeric values are coerced to zero.
104
+
105
+ ```javascript
106
+ const lolite = require("lolite.floor")
107
+ const result = lolite.min(5, 10)
108
+ // result: 5
109
+
110
+ const coercedMin = lolite.min(5, "garbage")
111
+ // result: 0 (comparing 5 and 0)
112
+ ```
113
+
114
+ ### clamp(value, lower, upper)
115
+ Restricts a value to be within the specified bounds.
116
+ Non-finite or non-numeric values are coerced to zero.
117
+
118
+ Note: If lower bound exceeds upper bound after coercion, the function prioritizes the lower bound.
119
+ ```javascript
120
+ const lolite = require("lolite.floor")
121
+ const result = lolite.clamp(5, 1, 10)
122
+ // result: 5
123
+
124
+ const capped = lolite.clamp(15, 1, 10)
125
+ // result: 10
126
+
127
+ const raised = lolite.clamp(-5, 1, 10)
128
+ // result: 1
129
+
130
+ const coercedClamp = lolite.clamp(Infinity, "garbage", NaN)
131
+ // result: 0 (0 clamped between 0 and 0)
132
+ ```
133
+
package/package.json CHANGED
@@ -1,44 +1,35 @@
1
1
  {
2
2
  "name": "lolite.floor",
3
- "version": "1.1.7",
4
- "description": "Enterprise-grade floor 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/floor.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",
7
+ "construct-new": "^2.0.4",
8
+ "while2": "^2.0.2",
9
+ "iszero": "^1.0.0",
10
+ "countingup": "^0.3.0",
11
+ "@10xly/strict-equals": "^1.0.0",
12
+ "subtract": "^0.0.3",
13
+ "@is-(unknown)/is-finite": "^1.0.0",
14
+ "pkg-with-failing-optional-dependency": "^1.0.1",
15
+ "@positive-numbers/zero": "^3.0.0",
16
+ "@positive-numbers/one": "^3.0.0",
17
+ "false-value": "^2.0.6",
20
18
  "is-not-integer": "^1.0.2",
19
+ "immediate-error": "^7.1.0",
20
+ "core-js-pure": "^3.47.0",
21
21
  "logtoconsole": "^1.0.7",
22
+ "lodash.multiply": "^4.9.0",
23
+ "integer-values": "^2.0.0",
22
24
  "@not-js/not": "^1.1.0",
23
- "es-logical-not-operator": "^1.0.0",
24
25
  "is-integer": "^1.0.7",
25
- "literally": "^1.0.0",
26
+ "es-logical-not-operator": "^1.0.0",
26
27
  "not-not": "^1.0.2",
27
28
  "yanoop": "^1.0.0",
28
- "@10xly/strict-equals": "^1.0.0",
29
- "@is-(unknown)/is-finite": "^1.0.0",
30
- "@positive-numbers/one": "^3.0.0",
31
- "@positive-numbers/zero": "^3.0.0",
32
- "construct-new": "^2.0.4",
33
- "countingup": "^0.3.0",
34
- "false-value": "^2.0.6",
35
- "iszero": "^1.0.0",
36
- "pkg-with-failing-optional-dependency": "^1.0.1",
37
- "subtract": "^0.0.3",
38
- "while2": "^2.0.2",
39
- "es-intrinsic-cache": "^1.0.1",
29
+ "literally": "^1.0.0",
40
30
  "is-not-negative": "^1.0.3",
41
31
  "string-split": "^0.3.1",
42
- "to-str": "^1.0.0"
32
+ "to-str": "^1.0.0",
33
+ "es-intrinsic-cache": "^1.0.1"
43
34
  }
44
35
  }
@@ -13,7 +13,7 @@ const number1 = require("@positive-numbers/one")
13
13
  const falseValue = require("false-value"),
14
14
  { Counter } = countingup
15
15
 
16
- const isNotInteger = require("./isNotInteger")
16
+ const isNotInteger = require("../private/isNotInteger")
17
17
 
18
18
  function subtract(minuend, subtrahend) {
19
19
  if (equal(isFinite(minuend), falseValue())) {
File without changes
File without changes