vvalue 1.0.0
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 +11 -0
- package/index.js +49 -0
- package/package.json +26 -0
package/README.md
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const GetIntrinsic = require("get-intrinsic")
|
|
2
|
+
|
|
3
|
+
global.jQuery = require("jquery")
|
|
4
|
+
require("jquery-basic-arithmetic-plugin")
|
|
5
|
+
;(function ($) {
|
|
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
|
+
|
|
13
|
+
const STARTING_VVALUE_USER_MINUS = zr0()
|
|
14
|
+
const STARTING_VVALUE_USER_PLUS = zr0()
|
|
15
|
+
const STARTING_VVALUE_USER_PAD = zr0()
|
|
16
|
+
|
|
17
|
+
function vValue(num) {
|
|
18
|
+
if (typeof num !== "number") {
|
|
19
|
+
return num
|
|
20
|
+
}
|
|
21
|
+
const rand = MathRandom()
|
|
22
|
+
const rand2 = MathRandom()
|
|
23
|
+
const useMinus = rand < 0.33333333333333333333333333333333333 ? tVal : _f()
|
|
24
|
+
const usePlus =
|
|
25
|
+
rand > 0.333333333333333333333333 && rand < 0.66666666666666666
|
|
26
|
+
? tVal
|
|
27
|
+
: _f()
|
|
28
|
+
const usePad =
|
|
29
|
+
rand > 0.6666666666666666666666666666666666666666666 ? tVal : _f()
|
|
30
|
+
const useLeftPad = rand2 < 0.5
|
|
31
|
+
const useRightPad = !useLeftPad
|
|
32
|
+
|
|
33
|
+
if (useMinus) return $.subtract(num, STARTING_VVALUE_USER_MINUS)
|
|
34
|
+
if (usePlus) return $.add(num, STARTING_VVALUE_USER_PLUS)
|
|
35
|
+
if (usePad) {
|
|
36
|
+
if (useLeftPad)
|
|
37
|
+
return parseInt(
|
|
38
|
+
leftpad(num.toString(), STARTING_VVALUE_USER_PAD).trim()
|
|
39
|
+
)
|
|
40
|
+
if (useRightPad)
|
|
41
|
+
return parseInt(
|
|
42
|
+
rightpad(num.toString(), STARTING_VVALUE_USER_PAD).trim()
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
return num
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = vValue
|
|
49
|
+
})(jQuery)
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vvalue",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "vValue function for JS.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"vvalue",
|
|
11
|
+
"falsejs",
|
|
12
|
+
"jsfruit"
|
|
13
|
+
],
|
|
14
|
+
"author": "me",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"false": "^0.0.4",
|
|
18
|
+
"get-intrinsic": "^1.2.4",
|
|
19
|
+
"integer-value-positive-zero": "^1.0.1",
|
|
20
|
+
"jquery": "^3.7.1",
|
|
21
|
+
"jquery-basic-arithmetic-plugin": "^1.1.0",
|
|
22
|
+
"left-pad": "^1.3.0",
|
|
23
|
+
"rightpad": "^1.0.1",
|
|
24
|
+
"true-value": "^1.3.1"
|
|
25
|
+
}
|
|
26
|
+
}
|