random-weighted-pick 1.0.12 → 2.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/.circleci/config.yml +1 -1
- package/.eslintrc.json +7 -0
- package/.prettierrc +4 -0
- package/CONTRIBUTING.md +9 -0
- package/README.md +144 -45
- package/dist/cjs/index.js +43 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/weightList.js +166 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/weightList.d.ts +36 -0
- package/dist/esm/weightList.js +161 -0
- package/jest.config.cjs +5 -0
- package/package.json +22 -32
- package/tsconfig.cjs.json +8 -0
- package/tsconfig.esm.json +8 -0
- package/tsconfig.json +20 -0
- package/.eslintrc +0 -27
- package/coverage/clover.xml +0 -54
- package/coverage/coverage-final.json +0 -3
- package/coverage/lcov-report/base.css +0 -212
- package/coverage/lcov-report/index.html +0 -106
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -1
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -158
- package/coverage/lcov-report/src/index.html +0 -93
- package/coverage/lcov-report/src/utils/index.html +0 -93
- package/coverage/lcov-report/src/utils/tests.utils.js.html +0 -128
- package/coverage/lcov-report/src/weightList.js.html +0 -194
- package/coverage/lcov.info +0 -106
- package/dist/index.js +0 -1
- package/scripts/emptyFolder.js +0 -18
- package/webpack.config.js +0 -46
- package/webpack.prod.config.js +0 -31
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const throwTypeError = (msg) => {
|
|
2
|
+
throw new TypeError(msg);
|
|
3
|
+
};
|
|
4
|
+
const defaultRNG = () => {
|
|
5
|
+
if (typeof globalThis !== 'undefined' && globalThis.crypto?.getRandomValues) {
|
|
6
|
+
const arr = new Uint32Array(1);
|
|
7
|
+
globalThis.crypto.getRandomValues(arr);
|
|
8
|
+
return arr[0] / 0x100000000;
|
|
9
|
+
}
|
|
10
|
+
return Math.random();
|
|
11
|
+
};
|
|
12
|
+
const validateOptions = (options) => {
|
|
13
|
+
if (!Array.isArray(options)) {
|
|
14
|
+
return throwTypeError('Weighted List expect Array of Objects as argument');
|
|
15
|
+
}
|
|
16
|
+
return options.map((opt, i) => {
|
|
17
|
+
if (!('weight' in opt))
|
|
18
|
+
throwTypeError('Every list item should have [weight] property');
|
|
19
|
+
if (!('item' in opt))
|
|
20
|
+
throwTypeError('Every list item should have [item] property');
|
|
21
|
+
const w = opt.weight;
|
|
22
|
+
if (typeof w !== 'number' || Number.isNaN(w) || !Number.isFinite(w) || w < 0) {
|
|
23
|
+
throwTypeError('Weights should be finite numbers >= 0');
|
|
24
|
+
}
|
|
25
|
+
return { id: opt.id ?? i, item: opt.item, weight: w };
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const normalize = (weights, { normalize, epsilon }) => {
|
|
29
|
+
const total = weights.reduce((a, b) => a + b, 0);
|
|
30
|
+
if (normalize) {
|
|
31
|
+
if (total <= epsilon)
|
|
32
|
+
throwTypeError("Sum of 'weights' should be greater than 0");
|
|
33
|
+
return weights.map((w) => w / total);
|
|
34
|
+
}
|
|
35
|
+
if (Math.abs(total - 1) > epsilon)
|
|
36
|
+
throwTypeError("Sum of 'weights' should be equal 1");
|
|
37
|
+
return weights;
|
|
38
|
+
};
|
|
39
|
+
/** Pick a single item based on its weight */
|
|
40
|
+
export function weightedPick(options, cfg = {}) {
|
|
41
|
+
const config = { normalize: true, epsilon: 1e-12, rng: defaultRNG, ...cfg };
|
|
42
|
+
const opts = validateOptions(options);
|
|
43
|
+
const weights = opts.map(o => o.weight);
|
|
44
|
+
const normalized = normalize(weights, config);
|
|
45
|
+
const num = config.rng();
|
|
46
|
+
if (typeof num !== 'number' || Number.isNaN(num) || num < 0 || num >= 1) {
|
|
47
|
+
throwTypeError('RNG should return a number x where 0 <= x < 1');
|
|
48
|
+
}
|
|
49
|
+
let acc = 0;
|
|
50
|
+
for (let i = 0; i < normalized.length; i++) {
|
|
51
|
+
acc += normalized[i];
|
|
52
|
+
if (num < acc) {
|
|
53
|
+
return { id: opts[i].id, item: opts[i].item };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return { id: opts[opts.length - 1].id, item: opts[opts.length - 1].item };
|
|
57
|
+
}
|
|
58
|
+
/** Pick `k` items. When `replacement` is false sampling is without replacement */
|
|
59
|
+
export function pickMany(options, k, cfg = {}) {
|
|
60
|
+
const { replacement = true, ...rest } = cfg;
|
|
61
|
+
if (replacement) {
|
|
62
|
+
return Array.from({ length: k }, () => weightedPick(options, rest));
|
|
63
|
+
}
|
|
64
|
+
const config = { normalize: true, epsilon: 1e-12, rng: defaultRNG, ...rest };
|
|
65
|
+
const opts = validateOptions(options);
|
|
66
|
+
const res = [];
|
|
67
|
+
opts.forEach((o) => {
|
|
68
|
+
const r = config.rng();
|
|
69
|
+
if (typeof r !== 'number' || Number.isNaN(r) || r <= 0 || r >= 1) {
|
|
70
|
+
throwTypeError('RNG should return a number x where 0 < x < 1');
|
|
71
|
+
}
|
|
72
|
+
if (o.weight > 0) {
|
|
73
|
+
const key = Math.pow(r, 1 / o.weight);
|
|
74
|
+
res.push({ key, option: o });
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
res.sort((a, b) => b.key - a.key);
|
|
78
|
+
return res.slice(0, k).map(r => ({ id: r.option.id, item: r.option.item }));
|
|
79
|
+
}
|
|
80
|
+
/** Create a weighted picker for many fast selections */
|
|
81
|
+
export function createWeightedPicker(options, cfg = {}) {
|
|
82
|
+
const { method = 'alias', ...rest } = cfg;
|
|
83
|
+
const config = { normalize: true, epsilon: 1e-12, rng: defaultRNG, ...rest };
|
|
84
|
+
let opts = validateOptions(options);
|
|
85
|
+
let probs = [];
|
|
86
|
+
let alias = [];
|
|
87
|
+
let cdf = [];
|
|
88
|
+
const build = () => {
|
|
89
|
+
const weights = opts.map(o => o.weight);
|
|
90
|
+
const normalized = normalize(weights, config);
|
|
91
|
+
if (method === 'alias') {
|
|
92
|
+
const n = normalized.length;
|
|
93
|
+
const scaled = normalized.map(w => w * n);
|
|
94
|
+
const small = [];
|
|
95
|
+
const large = [];
|
|
96
|
+
probs = new Array(n).fill(0);
|
|
97
|
+
alias = new Array(n).fill(0);
|
|
98
|
+
scaled.forEach((w, i) => (w < 1 ? small : large).push(i));
|
|
99
|
+
while (small.length && large.length) {
|
|
100
|
+
const l = small.pop();
|
|
101
|
+
const g = large.pop();
|
|
102
|
+
probs[l] = scaled[l];
|
|
103
|
+
alias[l] = g;
|
|
104
|
+
scaled[g] = scaled[g] + scaled[l] - 1;
|
|
105
|
+
if (scaled[g] < 1)
|
|
106
|
+
small.push(g);
|
|
107
|
+
else
|
|
108
|
+
large.push(g);
|
|
109
|
+
}
|
|
110
|
+
;
|
|
111
|
+
[...large, ...small].forEach(i => (probs[i] = 1));
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
cdf = [];
|
|
115
|
+
let sum = 0;
|
|
116
|
+
normalized.forEach((w) => {
|
|
117
|
+
sum += w;
|
|
118
|
+
cdf.push(sum);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
build();
|
|
123
|
+
const pick = () => {
|
|
124
|
+
if (method === 'alias') {
|
|
125
|
+
const n = opts.length;
|
|
126
|
+
const i = Math.floor(config.rng() * n);
|
|
127
|
+
const r = config.rng();
|
|
128
|
+
const idx = r < probs[i] ? i : alias[i];
|
|
129
|
+
return { id: opts[idx].id, item: opts[idx].item };
|
|
130
|
+
}
|
|
131
|
+
const r = config.rng();
|
|
132
|
+
if (typeof r !== 'number' || Number.isNaN(r) || r < 0 || r >= 1) {
|
|
133
|
+
throwTypeError('RNG should return a number x where 0 <= x < 1');
|
|
134
|
+
}
|
|
135
|
+
let low = 0;
|
|
136
|
+
let high = cdf.length - 1;
|
|
137
|
+
while (low < high) {
|
|
138
|
+
const mid = Math.floor((low + high) / 2);
|
|
139
|
+
if (r < cdf[mid])
|
|
140
|
+
high = mid;
|
|
141
|
+
else
|
|
142
|
+
low = mid + 1;
|
|
143
|
+
}
|
|
144
|
+
return { id: opts[low].id, item: opts[low].item };
|
|
145
|
+
};
|
|
146
|
+
return {
|
|
147
|
+
pick,
|
|
148
|
+
pickMany: (k) => Array.from({ length: k }, () => pick()),
|
|
149
|
+
updateWeight: (id, weight) => {
|
|
150
|
+
const idx = opts.findIndex(o => o.id === id);
|
|
151
|
+
if (idx === -1)
|
|
152
|
+
throwTypeError('ID not found');
|
|
153
|
+
if (typeof weight !== 'number' || Number.isNaN(weight) || !Number.isFinite(weight) || weight < 0) {
|
|
154
|
+
throwTypeError('Weights should be finite numbers >= 0');
|
|
155
|
+
}
|
|
156
|
+
opts[idx].weight = weight;
|
|
157
|
+
build();
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export default weightedPick;
|
package/jest.config.cjs
ADDED
package/package.json
CHANGED
|
@@ -1,46 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "random-weighted-pick",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/cjs/index.js",
|
|
6
|
+
"types": "dist/esm/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/esm/index.d.ts",
|
|
10
|
+
"import": "./dist/esm/index.js",
|
|
11
|
+
"require": "./dist/cjs/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
5
14
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
15
|
+
"node": ">=16"
|
|
7
16
|
},
|
|
8
17
|
"scripts": {
|
|
9
|
-
"build": "
|
|
10
|
-
"dev": "webpack-dashboard -- webpack-dev-server --content-base src/index --hot --host 0.0.0.0 --config ./webpack.config.js",
|
|
11
|
-
"watch": "webpack-dashboard -- webpack --progress --colors --watch --config ./webpack.config.js",
|
|
18
|
+
"build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
|
|
12
19
|
"test": "jest",
|
|
13
20
|
"coverage": "npm test -- --coverage"
|
|
14
21
|
},
|
|
15
22
|
"license": "MIT",
|
|
16
23
|
"devDependencies": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"eslint": "^3.6.0",
|
|
27
|
-
"eslint-config-airbnb": "^11.2.0",
|
|
28
|
-
"eslint-plugin-import": "^1.16.0",
|
|
29
|
-
"eslint-plugin-jsx-a11y": "^2.2.2",
|
|
30
|
-
"eslint-plugin-react": "^6.3.0",
|
|
31
|
-
"fs-extra": "^0.30.0",
|
|
32
|
-
"jest": "^22.3.0",
|
|
33
|
-
"regenerator-runtime": "^0.11.1",
|
|
34
|
-
"webpack": "^1.13.2",
|
|
35
|
-
"webpack-bundle-analyzer": "^2.10.0",
|
|
36
|
-
"webpack-dashboard": "^1.1.1",
|
|
37
|
-
"webpack-dev-server": "^1.16.1",
|
|
38
|
-
"webpack-node-externals": "^1.6.0"
|
|
39
|
-
},
|
|
40
|
-
"directories": {
|
|
41
|
-
"test": "test"
|
|
24
|
+
"@types/jest": "^29.5.14",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
26
|
+
"@typescript-eslint/parser": "^7.18.0",
|
|
27
|
+
"eslint": "^8.56.0",
|
|
28
|
+
"jest": "^29.7.0",
|
|
29
|
+
"prettier": "^3.3.3",
|
|
30
|
+
"ts-jest": "^29.4.1",
|
|
31
|
+
"typescript": "^5.9.2",
|
|
32
|
+
"undici-types": "^7.16.0"
|
|
42
33
|
},
|
|
43
|
-
"dependencies": {},
|
|
44
34
|
"repository": {
|
|
45
35
|
"type": "git",
|
|
46
36
|
"url": "git+https://github.com/phellipeandrade/random-weighted-pick.git"
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"types": ["node"],
|
|
11
|
+
"moduleResolution": "node"
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"],
|
|
14
|
+
"exclude": [
|
|
15
|
+
"node_modules",
|
|
16
|
+
"dist",
|
|
17
|
+
"**/*.test.ts",
|
|
18
|
+
"src/utils/tests.utils.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
package/.eslintrc
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "eslint-config-airbnb",
|
|
3
|
-
"parserOptions": {
|
|
4
|
-
"ecmaFeatures": {
|
|
5
|
-
"experimentalObjectRestSpread": true
|
|
6
|
-
}
|
|
7
|
-
},
|
|
8
|
-
"globals": {
|
|
9
|
-
"document": true
|
|
10
|
-
},
|
|
11
|
-
"env":{
|
|
12
|
-
"jest": true
|
|
13
|
-
},
|
|
14
|
-
"rules": {
|
|
15
|
-
"func-names": "off",
|
|
16
|
-
"no-param-reassign": "off",
|
|
17
|
-
"arrow-body-style": "off",
|
|
18
|
-
"max-len": "off",
|
|
19
|
-
"new-cap": "off",
|
|
20
|
-
"global-require": "off",
|
|
21
|
-
"no-underscore-dangle": "off",
|
|
22
|
-
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
|
|
23
|
-
"no-trailing-spaces": 0,
|
|
24
|
-
"padded-blocks": 0,
|
|
25
|
-
"no-plusplus": 0
|
|
26
|
-
}
|
|
27
|
-
}
|
package/coverage/clover.xml
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="1519039562480" clover="3.2.0">
|
|
3
|
-
<project timestamp="1519039562480" name="All files">
|
|
4
|
-
<metrics statements="35" coveredstatements="35" conditionals="13" coveredconditionals="13" methods="20" coveredmethods="19" elements="68" coveredelements="67" complexity="0" loc="35" ncloc="35" packages="2" files="2" classes="2">
|
|
5
|
-
<package name="src">
|
|
6
|
-
<metrics statements="24" coveredstatements="24" conditionals="6" coveredconditionals="6" methods="12" coveredmethods="12"/>
|
|
7
|
-
<file name="weightList.js" path="/home/phellipe/Documents/GIT/personal/probabilities/src/weightList.js">
|
|
8
|
-
<metrics statements="24" coveredstatements="24" conditionals="6" coveredconditionals="6" methods="12" coveredmethods="12"/>
|
|
9
|
-
<line num="1" count="2140978" type="stmt"/>
|
|
10
|
-
<line num="3" count="3700401" type="stmt"/>
|
|
11
|
-
<line num="5" count="1" type="stmt"/>
|
|
12
|
-
<line num="6" count="7400805" type="stmt"/>
|
|
13
|
-
<line num="8" count="2" type="stmt"/>
|
|
14
|
-
<line num="10" count="500203" type="stmt"/>
|
|
15
|
-
<line num="11" count="1000405" type="cond" truecount="2" falsecount="0"/>
|
|
16
|
-
<line num="12" count="2" type="stmt"/>
|
|
17
|
-
<line num="14" count="1000403" type="stmt"/>
|
|
18
|
-
<line num="17" count="2" type="stmt"/>
|
|
19
|
-
<line num="19" count="1" type="stmt"/>
|
|
20
|
-
<line num="21" count="500204" type="cond" truecount="2" falsecount="0"/>
|
|
21
|
-
<line num="22" count="1" type="stmt"/>
|
|
22
|
-
<line num="25" count="500203" type="stmt"/>
|
|
23
|
-
<line num="27" count="500201" type="stmt"/>
|
|
24
|
-
<line num="28" count="3700401" type="stmt"/>
|
|
25
|
-
<line num="29" count="500201" type="stmt"/>
|
|
26
|
-
<line num="30" count="500201" type="stmt"/>
|
|
27
|
-
<line num="33" count="500201" type="cond" truecount="2" falsecount="0"/>
|
|
28
|
-
<line num="35" count="500200" type="stmt"/>
|
|
29
|
-
<line num="36" count="2140978" type="stmt"/>
|
|
30
|
-
<line num="37" count="2140978" type="stmt"/>
|
|
31
|
-
<line num="38" count="2140978" type="stmt"/>
|
|
32
|
-
<line num="40" count="500200" type="stmt"/>
|
|
33
|
-
</file>
|
|
34
|
-
</package>
|
|
35
|
-
<package name="src.utils">
|
|
36
|
-
<metrics statements="11" coveredstatements="11" conditionals="7" coveredconditionals="7" methods="8" coveredmethods="7"/>
|
|
37
|
-
<file name="tests.utils.js" path="/home/phellipe/Documents/GIT/personal/probabilities/src/utils/tests.utils.js">
|
|
38
|
-
<metrics statements="11" coveredstatements="11" conditionals="7" coveredconditionals="7" methods="8" coveredmethods="7"/>
|
|
39
|
-
<line num="3" count="1" type="stmt"/>
|
|
40
|
-
<line num="5" count="6" type="cond" truecount="2" falsecount="0"/>
|
|
41
|
-
<line num="7" count="1" type="stmt"/>
|
|
42
|
-
<line num="9" count="5" type="stmt"/>
|
|
43
|
-
<line num="10" count="500000" type="cond" truecount="2" falsecount="0"/>
|
|
44
|
-
<line num="11" count="500000" type="stmt"/>
|
|
45
|
-
<line num="14" count="5" type="cond" truecount="2" falsecount="0"/>
|
|
46
|
-
<line num="16" count="1" type="stmt"/>
|
|
47
|
-
<line num="18" count="1" type="cond" truecount="1" falsecount="0"/>
|
|
48
|
-
<line num="19" count="5" type="stmt"/>
|
|
49
|
-
<line num="21" count="500000" type="stmt"/>
|
|
50
|
-
</file>
|
|
51
|
-
</package>
|
|
52
|
-
</metrics>
|
|
53
|
-
</project>
|
|
54
|
-
</coverage>
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
{"/home/phellipe/Documents/GIT/personal/probabilities/src/weightList.js": {"path":"/home/phellipe/Documents/GIT/personal/probabilities/src/weightList.js","statementMap":{"0":{"start":{"line":1,"column":21},"end":{"line":1,"column":71}},"1":{"start":{"line":1,"column":34},"end":{"line":1,"column":70}},"2":{"start":{"line":3,"column":16},"end":{"line":3,"column":56}},"3":{"start":{"line":3,"column":31},"end":{"line":3,"column":56}},"4":{"start":{"line":3,"column":46},"end":{"line":3,"column":55}},"5":{"start":{"line":5,"column":22},"end":{"line":6,"column":69}},"6":{"start":{"line":6,"column":2},"end":{"line":6,"column":69}},"7":{"start":{"line":6,"column":20},"end":{"line":6,"column":68}},"8":{"start":{"line":8,"column":21},"end":{"line":8,"column":77}},"9":{"start":{"line":8,"column":29},"end":{"line":8,"column":77}},"10":{"start":{"line":10,"column":24},"end":{"line":15,"column":2}},"11":{"start":{"line":10,"column":44},"end":{"line":15,"column":2}},"12":{"start":{"line":11,"column":2},"end":{"line":13,"column":3}},"13":{"start":{"line":12,"column":4},"end":{"line":12,"column":44}},"14":{"start":{"line":14,"column":2},"end":{"line":14,"column":14}},"15":{"start":{"line":17,"column":23},"end":{"line":17,"column":61}},"16":{"start":{"line":17,"column":34},"end":{"line":17,"column":59}},"17":{"start":{"line":19,"column":21},"end":{"line":41,"column":1}},"18":{"start":{"line":21,"column":2},"end":{"line":23,"column":3}},"19":{"start":{"line":22,"column":4},"end":{"line":22,"column":79}},"20":{"start":{"line":25,"column":2},"end":{"line":25,"column":47}},"21":{"start":{"line":27,"column":18},"end":{"line":27,"column":44}},"22":{"start":{"line":28,"column":23},"end":{"line":28,"column":80}},"23":{"start":{"line":28,"column":55},"end":{"line":28,"column":60}},"24":{"start":{"line":29,"column":14},"end":{"line":29,"column":27}},"25":{"start":{"line":30,"column":12},"end":{"line":30,"column":13}},"26":{"start":{"line":33,"column":2},"end":{"line":33,"column":79}},"27":{"start":{"line":33,"column":26},"end":{"line":33,"column":79}},"28":{"start":{"line":35,"column":2},"end":{"line":39,"column":5}},"29":{"start":{"line":36,"column":4},"end":{"line":36,"column":18}},"30":{"start":{"line":37,"column":4},"end":{"line":37,"column":40}},"31":{"start":{"line":38,"column":4},"end":{"line":38,"column":21}},"32":{"start":{"line":40,"column":2},"end":{"line":40,"column":18}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":1,"column":21},"end":{"line":1,"column":22}},"loc":{"start":{"line":1,"column":34},"end":{"line":1,"column":70}},"line":1},"1":{"name":"(anonymous_1)","decl":{"start":{"line":3,"column":16},"end":{"line":3,"column":17}},"loc":{"start":{"line":3,"column":31},"end":{"line":3,"column":56}},"line":3},"2":{"name":"(anonymous_2)","decl":{"start":{"line":3,"column":39},"end":{"line":3,"column":40}},"loc":{"start":{"line":3,"column":46},"end":{"line":3,"column":55}},"line":3},"3":{"name":"(anonymous_3)","decl":{"start":{"line":5,"column":22},"end":{"line":5,"column":23}},"loc":{"start":{"line":6,"column":2},"end":{"line":6,"column":69}},"line":6},"4":{"name":"(anonymous_4)","decl":{"start":{"line":6,"column":12},"end":{"line":6,"column":13}},"loc":{"start":{"line":6,"column":20},"end":{"line":6,"column":68}},"line":6},"5":{"name":"(anonymous_5)","decl":{"start":{"line":8,"column":21},"end":{"line":8,"column":22}},"loc":{"start":{"line":8,"column":29},"end":{"line":8,"column":77}},"line":8},"6":{"name":"(anonymous_6)","decl":{"start":{"line":10,"column":24},"end":{"line":10,"column":25}},"loc":{"start":{"line":10,"column":44},"end":{"line":15,"column":2}},"line":10},"7":{"name":"(anonymous_7)","decl":{"start":{"line":10,"column":54},"end":{"line":10,"column":55}},"loc":{"start":{"line":10,"column":64},"end":{"line":15,"column":1}},"line":10},"8":{"name":"(anonymous_8)","decl":{"start":{"line":17,"column":23},"end":{"line":17,"column":24}},"loc":{"start":{"line":17,"column":32},"end":{"line":17,"column":61}},"line":17},"9":{"name":"(anonymous_9)","decl":{"start":{"line":19,"column":21},"end":{"line":19,"column":22}},"loc":{"start":{"line":19,"column":34},"end":{"line":41,"column":1}},"line":19},"10":{"name":"(anonymous_10)","decl":{"start":{"line":28,"column":45},"end":{"line":28,"column":46}},"loc":{"start":{"line":28,"column":55},"end":{"line":28,"column":60}},"line":28},"11":{"name":"(anonymous_11)","decl":{"start":{"line":35,"column":15},"end":{"line":35,"column":16}},"loc":{"start":{"line":35,"column":30},"end":{"line":39,"column":3}},"line":35}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":2},"end":{"line":13,"column":3}},"type":"if","locations":[{"start":{"line":11,"column":2},"end":{"line":13,"column":3}},{"start":{"line":11,"column":2},"end":{"line":13,"column":3}}],"line":11},"1":{"loc":{"start":{"line":21,"column":2},"end":{"line":23,"column":3}},"type":"if","locations":[{"start":{"line":21,"column":2},"end":{"line":23,"column":3}},{"start":{"line":21,"column":2},"end":{"line":23,"column":3}}],"line":21},"2":{"loc":{"start":{"line":33,"column":2},"end":{"line":33,"column":79}},"type":"if","locations":[{"start":{"line":33,"column":2},"end":{"line":33,"column":79}},{"start":{"line":33,"column":2},"end":{"line":33,"column":79}}],"line":33}},"s":{"0":1,"1":2140978,"2":1,"3":500201,"4":3700401,"5":1,"6":1000405,"7":7400805,"8":1,"9":2,"10":1,"11":500203,"12":1000405,"13":2,"14":1000403,"15":1,"16":2,"17":1,"18":500204,"19":1,"20":500203,"21":500201,"22":500201,"23":3700401,"24":500201,"25":500201,"26":500201,"27":1,"28":500200,"29":2140978,"30":2140978,"31":2140978,"32":500200},"f":{"0":2140978,"1":500201,"2":3700401,"3":1000405,"4":7400805,"5":2,"6":500203,"7":1000405,"8":2,"9":500204,"10":3700401,"11":2140978},"b":{"0":[2,1000403],"1":[1,500203],"2":[1,500200]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"de63f9a5672735a15d704945f20b1b9961a80947"}
|
|
2
|
-
,"/home/phellipe/Documents/GIT/personal/probabilities/src/utils/tests.utils.js": {"path":"/home/phellipe/Documents/GIT/personal/probabilities/src/utils/tests.utils.js","statementMap":{"0":{"start":{"line":3,"column":28},"end":{"line":3,"column":31}},"1":{"start":{"line":5,"column":23},"end":{"line":5,"column":69}},"2":{"start":{"line":5,"column":33},"end":{"line":5,"column":69}},"3":{"start":{"line":7,"column":27},"end":{"line":7,"column":36}},"4":{"start":{"line":9,"column":33},"end":{"line":12,"column":6}},"5":{"start":{"line":9,"column":40},"end":{"line":12,"column":6}},"6":{"start":{"line":10,"column":2},"end":{"line":10,"column":31}},"7":{"start":{"line":11,"column":2},"end":{"line":11,"column":13}},"8":{"start":{"line":14,"column":23},"end":{"line":14,"column":60}},"9":{"start":{"line":14,"column":40},"end":{"line":14,"column":60}},"10":{"start":{"line":16,"column":20},"end":{"line":16,"column":45}},"11":{"start":{"line":16,"column":30},"end":{"line":16,"column":45}},"12":{"start":{"line":18,"column":32},"end":{"line":19,"column":54}},"13":{"start":{"line":19,"column":2},"end":{"line":19,"column":54}},"14":{"start":{"line":21,"column":29},"end":{"line":21,"column":94}},"15":{"start":{"line":21,"column":49},"end":{"line":21,"column":94}},"16":{"start":{"line":21,"column":74},"end":{"line":21,"column":93}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":5,"column":23},"end":{"line":5,"column":24}},"loc":{"start":{"line":5,"column":33},"end":{"line":5,"column":69}},"line":5},"1":{"name":"(anonymous_1)","decl":{"start":{"line":9,"column":33},"end":{"line":9,"column":34}},"loc":{"start":{"line":9,"column":40},"end":{"line":12,"column":6}},"line":9},"2":{"name":"(anonymous_2)","decl":{"start":{"line":9,"column":51},"end":{"line":9,"column":52}},"loc":{"start":{"line":9,"column":63},"end":{"line":12,"column":1}},"line":9},"3":{"name":"(anonymous_3)","decl":{"start":{"line":14,"column":23},"end":{"line":14,"column":24}},"loc":{"start":{"line":14,"column":40},"end":{"line":14,"column":60}},"line":14},"4":{"name":"(anonymous_4)","decl":{"start":{"line":16,"column":20},"end":{"line":16,"column":21}},"loc":{"start":{"line":16,"column":30},"end":{"line":16,"column":45}},"line":16},"5":{"name":"(anonymous_5)","decl":{"start":{"line":18,"column":32},"end":{"line":18,"column":33}},"loc":{"start":{"line":19,"column":2},"end":{"line":19,"column":54}},"line":19},"6":{"name":"(anonymous_6)","decl":{"start":{"line":21,"column":29},"end":{"line":21,"column":30}},"loc":{"start":{"line":21,"column":49},"end":{"line":21,"column":94}},"line":21},"7":{"name":"(anonymous_7)","decl":{"start":{"line":21,"column":68},"end":{"line":21,"column":69}},"loc":{"start":{"line":21,"column":74},"end":{"line":21,"column":93}},"line":21}},"branchMap":{"0":{"loc":{"start":{"line":5,"column":39},"end":{"line":5,"column":61}},"type":"binary-expr","locations":[{"start":{"line":5,"column":39},"end":{"line":5,"column":45}},{"start":{"line":5,"column":49},"end":{"line":5,"column":61}}],"line":5},"1":{"loc":{"start":{"line":10,"column":14},"end":{"line":10,"column":30}},"type":"binary-expr","locations":[{"start":{"line":10,"column":14},"end":{"line":10,"column":25}},{"start":{"line":10,"column":29},"end":{"line":10,"column":30}}],"line":10},"2":{"loc":{"start":{"line":14,"column":40},"end":{"line":14,"column":60}},"type":"binary-expr","locations":[{"start":{"line":14,"column":40},"end":{"line":14,"column":48}},{"start":{"line":14,"column":52},"end":{"line":14,"column":60}}],"line":14},"3":{"loc":{"start":{"line":18,"column":49},"end":{"line":18,"column":62}},"type":"default-arg","locations":[{"start":{"line":18,"column":61},"end":{"line":18,"column":62}}],"line":18}},"s":{"0":1,"1":1,"2":6,"3":1,"4":1,"5":5,"6":500000,"7":500000,"8":1,"9":5,"10":1,"11":0,"12":1,"13":5,"14":1,"15":5,"16":500000},"f":{"0":6,"1":5,"2":500000,"3":5,"4":0,"5":5,"6":5,"7":500000},"b":{"0":[6,1],"1":[500000,36],"2":[5,5],"3":[5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"d64d74ebb268f8055d0bf64e48838bc99171ccac"}
|
|
3
|
-
}
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
body, html {
|
|
2
|
-
margin:0; padding: 0;
|
|
3
|
-
height: 100%;
|
|
4
|
-
}
|
|
5
|
-
body {
|
|
6
|
-
font-family: Helvetica Neue, Helvetica, Arial;
|
|
7
|
-
font-size: 14px;
|
|
8
|
-
color:#333;
|
|
9
|
-
}
|
|
10
|
-
.small { font-size: 12px; }
|
|
11
|
-
*, *:after, *:before {
|
|
12
|
-
-webkit-box-sizing:border-box;
|
|
13
|
-
-moz-box-sizing:border-box;
|
|
14
|
-
box-sizing:border-box;
|
|
15
|
-
}
|
|
16
|
-
h1 { font-size: 20px; margin: 0;}
|
|
17
|
-
h2 { font-size: 14px; }
|
|
18
|
-
pre {
|
|
19
|
-
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
20
|
-
margin: 0;
|
|
21
|
-
padding: 0;
|
|
22
|
-
-moz-tab-size: 2;
|
|
23
|
-
-o-tab-size: 2;
|
|
24
|
-
tab-size: 2;
|
|
25
|
-
}
|
|
26
|
-
a { color:#0074D9; text-decoration:none; }
|
|
27
|
-
a:hover { text-decoration:underline; }
|
|
28
|
-
.strong { font-weight: bold; }
|
|
29
|
-
.space-top1 { padding: 10px 0 0 0; }
|
|
30
|
-
.pad2y { padding: 20px 0; }
|
|
31
|
-
.pad1y { padding: 10px 0; }
|
|
32
|
-
.pad2x { padding: 0 20px; }
|
|
33
|
-
.pad2 { padding: 20px; }
|
|
34
|
-
.pad1 { padding: 10px; }
|
|
35
|
-
.space-left2 { padding-left:55px; }
|
|
36
|
-
.space-right2 { padding-right:20px; }
|
|
37
|
-
.center { text-align:center; }
|
|
38
|
-
.clearfix { display:block; }
|
|
39
|
-
.clearfix:after {
|
|
40
|
-
content:'';
|
|
41
|
-
display:block;
|
|
42
|
-
height:0;
|
|
43
|
-
clear:both;
|
|
44
|
-
visibility:hidden;
|
|
45
|
-
}
|
|
46
|
-
.fl { float: left; }
|
|
47
|
-
@media only screen and (max-width:640px) {
|
|
48
|
-
.col3 { width:100%; max-width:100%; }
|
|
49
|
-
.hide-mobile { display:none!important; }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.quiet {
|
|
53
|
-
color: #7f7f7f;
|
|
54
|
-
color: rgba(0,0,0,0.5);
|
|
55
|
-
}
|
|
56
|
-
.quiet a { opacity: 0.7; }
|
|
57
|
-
|
|
58
|
-
.fraction {
|
|
59
|
-
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
|
60
|
-
font-size: 10px;
|
|
61
|
-
color: #555;
|
|
62
|
-
background: #E8E8E8;
|
|
63
|
-
padding: 4px 5px;
|
|
64
|
-
border-radius: 3px;
|
|
65
|
-
vertical-align: middle;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
div.path a:link, div.path a:visited { color: #333; }
|
|
69
|
-
table.coverage {
|
|
70
|
-
border-collapse: collapse;
|
|
71
|
-
margin: 10px 0 0 0;
|
|
72
|
-
padding: 0;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
table.coverage td {
|
|
76
|
-
margin: 0;
|
|
77
|
-
padding: 0;
|
|
78
|
-
vertical-align: top;
|
|
79
|
-
}
|
|
80
|
-
table.coverage td.line-count {
|
|
81
|
-
text-align: right;
|
|
82
|
-
padding: 0 5px 0 20px;
|
|
83
|
-
}
|
|
84
|
-
table.coverage td.line-coverage {
|
|
85
|
-
text-align: right;
|
|
86
|
-
padding-right: 10px;
|
|
87
|
-
min-width:20px;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
table.coverage td span.cline-any {
|
|
91
|
-
display: inline-block;
|
|
92
|
-
padding: 0 5px;
|
|
93
|
-
width: 100%;
|
|
94
|
-
}
|
|
95
|
-
.missing-if-branch {
|
|
96
|
-
display: inline-block;
|
|
97
|
-
margin-right: 5px;
|
|
98
|
-
border-radius: 3px;
|
|
99
|
-
position: relative;
|
|
100
|
-
padding: 0 4px;
|
|
101
|
-
background: #333;
|
|
102
|
-
color: yellow;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.skip-if-branch {
|
|
106
|
-
display: none;
|
|
107
|
-
margin-right: 10px;
|
|
108
|
-
position: relative;
|
|
109
|
-
padding: 0 4px;
|
|
110
|
-
background: #ccc;
|
|
111
|
-
color: white;
|
|
112
|
-
}
|
|
113
|
-
.missing-if-branch .typ, .skip-if-branch .typ {
|
|
114
|
-
color: inherit !important;
|
|
115
|
-
}
|
|
116
|
-
.coverage-summary {
|
|
117
|
-
border-collapse: collapse;
|
|
118
|
-
width: 100%;
|
|
119
|
-
}
|
|
120
|
-
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
|
121
|
-
.keyline-all { border: 1px solid #ddd; }
|
|
122
|
-
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
|
123
|
-
.coverage-summary tbody { border: 1px solid #bbb; }
|
|
124
|
-
.coverage-summary td { border-right: 1px solid #bbb; }
|
|
125
|
-
.coverage-summary td:last-child { border-right: none; }
|
|
126
|
-
.coverage-summary th {
|
|
127
|
-
text-align: left;
|
|
128
|
-
font-weight: normal;
|
|
129
|
-
white-space: nowrap;
|
|
130
|
-
}
|
|
131
|
-
.coverage-summary th.file { border-right: none !important; }
|
|
132
|
-
.coverage-summary th.pct { }
|
|
133
|
-
.coverage-summary th.pic,
|
|
134
|
-
.coverage-summary th.abs,
|
|
135
|
-
.coverage-summary td.pct,
|
|
136
|
-
.coverage-summary td.abs { text-align: right; }
|
|
137
|
-
.coverage-summary td.file { white-space: nowrap; }
|
|
138
|
-
.coverage-summary td.pic { min-width: 120px !important; }
|
|
139
|
-
.coverage-summary tfoot td { }
|
|
140
|
-
|
|
141
|
-
.coverage-summary .sorter {
|
|
142
|
-
height: 10px;
|
|
143
|
-
width: 7px;
|
|
144
|
-
display: inline-block;
|
|
145
|
-
margin-left: 0.5em;
|
|
146
|
-
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
|
147
|
-
}
|
|
148
|
-
.coverage-summary .sorted .sorter {
|
|
149
|
-
background-position: 0 -20px;
|
|
150
|
-
}
|
|
151
|
-
.coverage-summary .sorted-desc .sorter {
|
|
152
|
-
background-position: 0 -10px;
|
|
153
|
-
}
|
|
154
|
-
.status-line { height: 10px; }
|
|
155
|
-
/* dark red */
|
|
156
|
-
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
|
157
|
-
.low .chart { border:1px solid #C21F39 }
|
|
158
|
-
/* medium red */
|
|
159
|
-
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
|
160
|
-
/* light red */
|
|
161
|
-
.low, .cline-no { background:#FCE1E5 }
|
|
162
|
-
/* light green */
|
|
163
|
-
.high, .cline-yes { background:rgb(230,245,208) }
|
|
164
|
-
/* medium green */
|
|
165
|
-
.cstat-yes { background:rgb(161,215,106) }
|
|
166
|
-
/* dark green */
|
|
167
|
-
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
|
168
|
-
.high .chart { border:1px solid rgb(77,146,33) }
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
.medium .chart { border:1px solid #666; }
|
|
172
|
-
.medium .cover-fill { background: #666; }
|
|
173
|
-
|
|
174
|
-
.cbranch-no { background: yellow !important; color: #111; }
|
|
175
|
-
|
|
176
|
-
.cstat-skip { background: #ddd; color: #111; }
|
|
177
|
-
.fstat-skip { background: #ddd; color: #111 !important; }
|
|
178
|
-
.cbranch-skip { background: #ddd !important; color: #111; }
|
|
179
|
-
|
|
180
|
-
span.cline-neutral { background: #eaeaea; }
|
|
181
|
-
.medium { background: #eaeaea; }
|
|
182
|
-
|
|
183
|
-
.cover-fill, .cover-empty {
|
|
184
|
-
display:inline-block;
|
|
185
|
-
height: 12px;
|
|
186
|
-
}
|
|
187
|
-
.chart {
|
|
188
|
-
line-height: 0;
|
|
189
|
-
}
|
|
190
|
-
.cover-empty {
|
|
191
|
-
background: white;
|
|
192
|
-
}
|
|
193
|
-
.cover-full {
|
|
194
|
-
border-right: none !important;
|
|
195
|
-
}
|
|
196
|
-
pre.prettyprint {
|
|
197
|
-
border: none !important;
|
|
198
|
-
padding: 0 !important;
|
|
199
|
-
margin: 0 !important;
|
|
200
|
-
}
|
|
201
|
-
.com { color: #999 !important; }
|
|
202
|
-
.ignore-none { color: #999; font-weight: normal; }
|
|
203
|
-
|
|
204
|
-
.wrapper {
|
|
205
|
-
min-height: 100%;
|
|
206
|
-
height: auto !important;
|
|
207
|
-
height: 100%;
|
|
208
|
-
margin: 0 auto -48px;
|
|
209
|
-
}
|
|
210
|
-
.footer, .push {
|
|
211
|
-
height: 48px;
|
|
212
|
-
}
|