@flemist/test-variants 0.0.6 → 0.0.7
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/dist/bundle/browser.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
!function(e){"use strict"
|
|
2
2
|
;e.createTestVariants=function(e){
|
|
3
3
|
return function(t){return function(n){
|
|
4
|
-
var r=void 0===n?{}:n,o=r.pauseInterval,u=r.pauseTime,
|
|
5
|
-
;function
|
|
6
|
-
;return"function"==typeof t&&(t=t(
|
|
7
|
-
for(var
|
|
8
|
-
;function
|
|
9
|
-
;if(t<
|
|
10
|
-
for(
|
|
11
|
-
;if(0===n.length)break;
|
|
12
|
-
if(e>=
|
|
13
|
-
;var
|
|
14
|
-
console.error(JSON.stringify(
|
|
4
|
+
var r=void 0===n?{}:n,o=r.pauseInterval,u=void 0===o?1e3:o,a=r.pauseTime,i=void 0===a?10:a,f=r.logInterval,c=void 0===f?1e4:f,v=Object.keys(t),l=Object.values(t),s=v.length,y={}
|
|
5
|
+
;function h(e){var t=l[e]
|
|
6
|
+
;return"function"==typeof t&&(t=t(y)),t}
|
|
7
|
+
for(var p=[],b=[],w=0;w<s;w++)p[w]=-1,b[w]=[]
|
|
8
|
+
;function d(){for(var e=s-1;e>=0;e--){var t=p[e]+1
|
|
9
|
+
;if(t<b[e].length){
|
|
10
|
+
for(p[e]=t,y[v[e]]=b[e][t],e++;e<s;e++){var n=h(e)
|
|
11
|
+
;if(0===n.length)break;p[e]=0,b[e]=n,y[v[e]]=n[0]}
|
|
12
|
+
if(e>=s)return!0}}return!1}b[0]=h(0)
|
|
13
|
+
;var g=0,m=!1,j=0;function D(e){
|
|
14
|
+
console.error(JSON.stringify(y,null,2)),console.error(e)
|
|
15
15
|
;var t=Date.now()
|
|
16
|
-
;throw Date.now()-t>50&&
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
;for(var r=n,
|
|
16
|
+
;throw Date.now()-t>50&&j<5&&(m=!0,P(0),j++),e}
|
|
17
|
+
var O=Date.now();function P(t){
|
|
18
|
+
var n=(c||u)&&Date.now()
|
|
19
|
+
;n&&n-O>=c&&(console.log(g),O=n),g+="number"==typeof t?t:1
|
|
20
|
+
;for(var r=u&&n,o=function(){try{var t=e(y)
|
|
21
21
|
;if("object"==typeof t&&t&&"function"==typeof t.then)return{
|
|
22
|
-
value:t.then(
|
|
23
|
-
;if(r&&Date.now()-r>=
|
|
24
|
-
value:(
|
|
25
|
-
setTimeout((function(){e(t)}),
|
|
26
|
-
})):Promise.resolve(t)).then(
|
|
27
|
-
;
|
|
28
|
-
};
|
|
29
|
-
;if("object"==typeof
|
|
30
|
-
return
|
|
22
|
+
value:t.then(P).catch(D)}
|
|
23
|
+
;if(r&&Date.now()-r>=u)return{
|
|
24
|
+
value:(i?new Promise((function(e){
|
|
25
|
+
setTimeout((function(){e(t)}),i)
|
|
26
|
+
})):Promise.resolve(t)).then(P)}
|
|
27
|
+
;g+="number"==typeof t?t:1}catch(e){D(e)}
|
|
28
|
+
};m||d();){var a=o()
|
|
29
|
+
;if("object"==typeof a)return a.value}return g}
|
|
30
|
+
return P(0)}}
|
|
31
31
|
},Object.defineProperty(e,"__esModule",{value:!0})
|
|
32
32
|
}({});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
4
4
|
function createTestVariants(test) {
|
|
5
5
|
return function testVariantsArgs(args) {
|
|
6
|
-
return function testVariantsCall({ pauseInterval, pauseTime = 10, } = {}) {
|
|
6
|
+
return function testVariantsCall({ pauseInterval = 1000, pauseTime = 10, logInterval = 10000, } = {}) {
|
|
7
7
|
const argsKeys = Object.keys(args);
|
|
8
8
|
const argsValues = Object.values(args);
|
|
9
9
|
const argsLength = argsKeys.length;
|
|
@@ -63,16 +63,16 @@ function createTestVariants(test) {
|
|
|
63
63
|
}
|
|
64
64
|
let prevLogTime = Date.now();
|
|
65
65
|
function next(value) {
|
|
66
|
-
const now = pauseInterval && Date.now();
|
|
66
|
+
const now = (logInterval || pauseInterval) && Date.now();
|
|
67
67
|
if (now) {
|
|
68
|
-
if (now - prevLogTime >=
|
|
68
|
+
if (now - prevLogTime >= logInterval) {
|
|
69
69
|
// the log is required to prevent the karma browserNoActivityTimeout
|
|
70
70
|
console.log(iterations);
|
|
71
71
|
prevLogTime = now;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
iterations += typeof value === 'number' ? value : 1;
|
|
75
|
-
const syncCallStartTime = now;
|
|
75
|
+
const syncCallStartTime = pauseInterval && now;
|
|
76
76
|
while (debug || nextVariant()) {
|
|
77
77
|
try {
|
|
78
78
|
const promiseOrIterations = test(variantArgs);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
2
2
|
function createTestVariants(test) {
|
|
3
3
|
return function testVariantsArgs(args) {
|
|
4
|
-
return function testVariantsCall({ pauseInterval, pauseTime = 10, } = {}) {
|
|
4
|
+
return function testVariantsCall({ pauseInterval = 1000, pauseTime = 10, logInterval = 10000, } = {}) {
|
|
5
5
|
const argsKeys = Object.keys(args);
|
|
6
6
|
const argsValues = Object.values(args);
|
|
7
7
|
const argsLength = argsKeys.length;
|
|
@@ -61,16 +61,16 @@ function createTestVariants(test) {
|
|
|
61
61
|
}
|
|
62
62
|
let prevLogTime = Date.now();
|
|
63
63
|
function next(value) {
|
|
64
|
-
const now = pauseInterval && Date.now();
|
|
64
|
+
const now = (logInterval || pauseInterval) && Date.now();
|
|
65
65
|
if (now) {
|
|
66
|
-
if (now - prevLogTime >=
|
|
66
|
+
if (now - prevLogTime >= logInterval) {
|
|
67
67
|
// the log is required to prevent the karma browserNoActivityTimeout
|
|
68
68
|
console.log(iterations);
|
|
69
69
|
prevLogTime = now;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
iterations += typeof value === 'number' ? value : 1;
|
|
73
|
-
const syncCallStartTime = now;
|
|
73
|
+
const syncCallStartTime = pauseInterval && now;
|
|
74
74
|
while (debug || nextVariant()) {
|
|
75
75
|
try {
|
|
76
76
|
const promiseOrIterations = test(variantArgs);
|
|
@@ -7,9 +7,11 @@ declare type TestVariantsSetArgs<TArgs> = <TAdditionalArgs>(args: VariantsArgs<{
|
|
|
7
7
|
[key in (keyof TAdditionalArgs | keyof TArgs)]: key extends keyof TArgs ? TArgs[key] : key extends keyof TAdditionalArgs ? TAdditionalArgs[key] : never;
|
|
8
8
|
}>) => TestVariantsCall;
|
|
9
9
|
export declare type TestVariantsCallParams = {
|
|
10
|
-
/** pause test
|
|
10
|
+
/** pause test, required to prevent the karma browserDisconnectTimeout */
|
|
11
11
|
pauseInterval?: number;
|
|
12
12
|
pauseTime?: number;
|
|
13
|
+
/** console log current iterations, required to prevent the karma browserNoActivityTimeout */
|
|
14
|
+
logInterval?: number;
|
|
13
15
|
};
|
|
14
16
|
export declare function createTestVariants<TArgs extends object>(test: (args: TArgs) => Promise<number | void> | number | void): TestVariantsSetArgs<TArgs>;
|
|
15
17
|
export {};
|