@flemist/test-variants 0.0.7 → 0.0.8

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.
@@ -1,32 +1,33 @@
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=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)
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=r.logCompleted,l=void 0===v||v,s=Object.keys(t),p=Object.values(t),y=s.length,h={}
5
+ ;function b(e){var t=p[e]
6
+ ;return"function"==typeof t&&(t=t(h)),t}
7
+ for(var d=[],g=[],m=0;m<y;m++)d[m]=-1,g[m]=[]
8
+ ;function w(){for(var e=y-1;e>=0;e--){var t=d[e]+1
9
+ ;if(t<g[e].length){
10
+ for(d[e]=t,h[s[e]]=g[e][t],e++;e<y;e++){var n=b(e)
11
+ ;if(0===n.length)break;d[e]=0,g[e]=n,h[s[e]]=n[0]}
12
+ if(e>=y)return!0}}return!1}g[0]=b(0)
13
+ ;var j=0,D=!1,O=0;function P(e){
14
+ console.error(JSON.stringify(h,null,2)),console.error(e)
15
15
  ;var t=Date.now()
16
- ;throw Date.now()-t>50&&j<5&&(m=!0,P(0),j++),e}
17
- var O=Date.now();function P(t){
16
+ ;throw Date.now()-t>50&&O<5&&(D=!0,k(0),O++),e}
17
+ var T=Date.now();function k(t){
18
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)
19
+ ;n&&n-T>=c&&(console.log(j),T=n),j+="number"==typeof t?t:1
20
+ ;for(var r=u&&n,o=function(){try{var t=e(h)
21
21
  ;if("object"==typeof t&&t&&"function"==typeof t.then)return{
22
- value:t.then(P).catch(D)}
22
+ value:t.then(k).catch(P)}
23
23
  ;if(r&&Date.now()-r>=u)return{
24
24
  value:(i?new Promise((function(e){
25
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)}}
26
+ })):Promise.resolve(t)).then(k)}
27
+ ;j+="number"==typeof t?t:1}catch(e){P(e)}
28
+ };D||w();){var a=o()
29
+ ;if("object"==typeof a)return a.value}
30
+ return l&&console.log("variants: "+j),j}
31
+ return k(0)}}
31
32
  },Object.defineProperty(e,"__esModule",{value:!0})
32
33
  }({});
@@ -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 = 1000, pauseTime = 10, logInterval = 10000, } = {}) {
6
+ return function testVariantsCall({ pauseInterval = 1000, pauseTime = 10, logInterval = 10000, logCompleted = true, } = {}) {
7
7
  const argsKeys = Object.keys(args);
8
8
  const argsValues = Object.values(args);
9
9
  const argsLength = argsKeys.length;
@@ -61,6 +61,11 @@ function createTestVariants(test) {
61
61
  }
62
62
  throw err;
63
63
  }
64
+ function onCompleted() {
65
+ if (logCompleted) {
66
+ console.log('variants: ' + iterations);
67
+ }
68
+ }
64
69
  let prevLogTime = Date.now();
65
70
  function next(value) {
66
71
  const now = (logInterval || pauseInterval) && Date.now();
@@ -97,6 +102,7 @@ function createTestVariants(test) {
97
102
  onError(err);
98
103
  }
99
104
  }
105
+ onCompleted();
100
106
  return iterations;
101
107
  }
102
108
  return next(0);
@@ -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 = 1000, pauseTime = 10, logInterval = 10000, } = {}) {
4
+ return function testVariantsCall({ pauseInterval = 1000, pauseTime = 10, logInterval = 10000, logCompleted = true, } = {}) {
5
5
  const argsKeys = Object.keys(args);
6
6
  const argsValues = Object.values(args);
7
7
  const argsLength = argsKeys.length;
@@ -59,6 +59,11 @@ function createTestVariants(test) {
59
59
  }
60
60
  throw err;
61
61
  }
62
+ function onCompleted() {
63
+ if (logCompleted) {
64
+ console.log('variants: ' + iterations);
65
+ }
66
+ }
62
67
  let prevLogTime = Date.now();
63
68
  function next(value) {
64
69
  const now = (logInterval || pauseInterval) && Date.now();
@@ -95,6 +100,7 @@ function createTestVariants(test) {
95
100
  onError(err);
96
101
  }
97
102
  }
103
+ onCompleted();
98
104
  return iterations;
99
105
  }
100
106
  return next(0);
@@ -12,6 +12,8 @@ export declare type TestVariantsCallParams = {
12
12
  pauseTime?: number;
13
13
  /** console log current iterations, required to prevent the karma browserNoActivityTimeout */
14
14
  logInterval?: number;
15
+ /** console log iterations on test completed */
16
+ logCompleted?: boolean;
15
17
  };
16
18
  export declare function createTestVariants<TArgs extends object>(test: (args: TArgs) => Promise<number | void> | number | void): TestVariantsSetArgs<TArgs>;
17
19
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flemist/test-variants",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Runs a test function with all possible combinations of its parameters.",
5
5
  "main": "dist/lib/index.cjs",
6
6
  "module": "dist/lib/index.mjs",