vvalue 1.1.2 → 1.1.3
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/index.js +43 -41
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3,50 +3,52 @@ const GetIntrinsic = require("get-intrinsic")
|
|
|
3
3
|
global.jQuery = require("jquery")
|
|
4
4
|
require("jquery-basic-arithmetic-plugin")
|
|
5
5
|
;(function ($) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const zr0 = require("integer-value-positive-zero")
|
|
7
|
+
const leftpad = require("left-pad")
|
|
8
|
+
const rightpad = require("rightpad")
|
|
9
|
+
const tVal = require("true-value")
|
|
10
|
+
const _f = require("false")
|
|
11
|
+
const MathRandom = GetIntrinsic("%Math.random%")
|
|
12
|
+
const isFinite = require("@is-(unknown)/is-finite")
|
|
13
|
+
const not = require("es-logical-not-operator")
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const STARTING_VVALUE_USER_MINUS = zr0()
|
|
16
|
+
const STARTING_VVALUE_USER_PLUS = zr0()
|
|
17
|
+
const STARTING_VVALUE_USER_PAD = zr0()
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
function vValue(num) {
|
|
20
|
+
try {
|
|
21
|
+
if (require("is-float")(num)) return num
|
|
22
|
+
} catch {}
|
|
23
|
+
if (not(isFinite(num))) {
|
|
24
|
+
return num
|
|
25
|
+
}
|
|
26
|
+
const rand = MathRandom()
|
|
27
|
+
const rand2 = MathRandom()
|
|
28
|
+
const useMinus = rand < 0.33333333333333333333333333333333333 ? tVal : _f()
|
|
29
|
+
const usePlus =
|
|
30
|
+
rand > 0.333333333333333333333333 && rand < 0.66666666666666666
|
|
31
|
+
? tVal
|
|
32
|
+
: _f()
|
|
33
|
+
const usePad =
|
|
34
|
+
rand > 0.6666666666666666666666666666666666666666666 ? tVal : _f()
|
|
35
|
+
const useLeftPad = rand2 < 0.5
|
|
36
|
+
const useRightPad = !useLeftPad
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
if (useMinus) return $.subtract(num, STARTING_VVALUE_USER_MINUS)
|
|
39
|
+
if (usePlus) return $.add(num, STARTING_VVALUE_USER_PLUS)
|
|
40
|
+
if (usePad) {
|
|
41
|
+
if (useLeftPad)
|
|
42
|
+
return parseInt(
|
|
43
|
+
leftpad(num.toString(), STARTING_VVALUE_USER_PAD).trim()
|
|
44
|
+
)
|
|
45
|
+
if (useRightPad)
|
|
46
|
+
return parseInt(
|
|
47
|
+
rightpad(num.toString(), STARTING_VVALUE_USER_PAD).trim()
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
return num
|
|
51
|
+
}
|
|
50
52
|
|
|
51
53
|
module.exports = vValue
|
|
52
54
|
})(jQuery)
|