@flemist/test-variants 2.0.3 → 2.0.4

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.
@@ -448,65 +448,67 @@ setTimeout(function(){e(t)},1)})
448
448
  var r,s,d,v,_,y,b,p,m
449
449
  ;return void 0===n&&(n={}),c(this,void 0,void 0,function(){
450
450
  function w(){
451
- return null!=U&&null!=L?Math.min(U,L.index):null!=U?U:null!=L?L.index:null
451
+ return null!=U&&null!=Q?Math.min(U,Q.index):null!=U?U:null!=Q?Q.index:null
452
452
  }function j(){
453
453
  return c(this,void 0,void 0,function(){
454
454
  var n,r=this;return l(this,function(s){
455
455
  switch(s.label){case 0:n=function(){
456
456
  var e,n,s,i,a,u,h,d,v;return l(this,function(_){
457
- switch(_.label){case 0:return e=Q,n=o(o({},K),{
458
- seed:B
459
- }),s=(R||V)&&Date.now(),R&&s-it>=R&&(i="",$?(i+="cycle: ".concat(W,", variant: ").concat(Q),
460
- null!=(a=w())&&(i+="/".concat(a))):i+="variant: ".concat(Q),
461
- i+=", total: ".concat(rt),
462
- console.log(i),it=s),D&&rt-ct>=D||C&&st-lt>=C||V&&s-ot>=V?(ct=rt,
463
- lt=st,ot=s,[4,Y(1)]):[3,2];case 1:
457
+ switch(_.label){case 0:return e=K,n=o(o({},H),{
458
+ seed:L
459
+ }),s=(R||V)&&Date.now(),R&&s-ot>=R&&(i="",$?(i+="cycle: ".concat(q,", variant: ").concat(K),
460
+ q>0&&null!=(a=w())&&(null!=W&&W<a&&(a=W),
461
+ i+="/".concat(a))):i+="variant: ".concat(K),
462
+ i+=", total: ".concat(st),console.log(i),
463
+ ot=s),D&&st-lt>=D||C&&it-at>=C||V&&s-ct>=V?(lt=st,
464
+ at=it,ct=s,[4,Y(1)]):[3,2];case 1:
464
465
  _.sent(),_.label=2;case 2:
465
466
  if(null==N?void 0:N.aborted)return[2,"continue"]
466
- ;if(at&&!tt.aborted)return[3,10];_.label=3;case 3:
467
- return _.trys.push([3,6,,9]),g(u=t(n,e,tt))?[4,u]:[3,5]
467
+ ;if(ut&&!et.aborted)return[3,10];_.label=3;case 3:
468
+ return _.trys.push([3,6,,9]),g(u=t(n,e,et))?[4,u]:[3,5]
468
469
  ;case 4:u=_.sent(),_.label=5;case 5:
469
470
  return u?(h=u.iterationsAsync,d=u.iterationsSync,
470
- st+=h,rt+=d+h,[3,9]):(nt=!0,Z.abort(),
471
+ it+=h,st+=d+h,[3,9]):(rt=!0,tt.abort(),
471
472
  [2,"continue"]);case 6:
472
473
  return v=_.sent(),P?[4,f(n,P,S.argsToJson)]:[3,8]
473
474
  ;case 7:_.sent(),_.label=8;case 8:if(!$)throw v
474
- ;return L={error:v,args:n,index:e},nt=!1,[3,9]
475
+ ;return Q={error:v,args:n,index:e},rt=!1,[3,9]
475
476
  ;case 9:return[3,13];case 10:
476
- return at.hold(1)?[3,12]:[4,at.holdWait(1)]
477
+ return ut.hold(1)?[3,12]:[4,ut.holdWait(1)]
477
478
  ;case 11:_.sent(),_.label=12;case 12:
478
479
  c(r,void 0,void 0,function(){var r,s,i,o
479
480
  ;return l(this,function(c){switch(c.label){case 0:
480
481
  return c.trys.push([0,3,6,7]),
481
- (null==tt?void 0:tt.aborted)?[2]:g(r=t(n,e,tt))?[4,r]:[3,2]
482
+ (null==et?void 0:et.aborted)?[2]:g(r=t(n,e,et))?[4,r]:[3,2]
482
483
  ;case 1:r=c.sent(),c.label=2;case 2:
483
484
  return r?(s=r.iterationsAsync,i=r.iterationsSync,
484
- st+=s,rt+=i+s,[3,7]):(nt=!0,Z.abort(),[2]);case 3:
485
+ it+=s,st+=i+s,[3,7]):(rt=!0,tt.abort(),[2])
486
+ ;case 3:
485
487
  return o=c.sent(),P?[4,f(n,P,S.argsToJson)]:[3,5]
486
488
  ;case 4:c.sent(),c.label=5;case 5:if(!$)throw o
487
- ;return L={error:o,args:n,index:e},nt=!1,[3,7]
488
- ;case 6:return at.release(1),[7];case 7:return[2]}
489
+ ;return Q={error:o,args:n,index:e},rt=!1,[3,7]
490
+ ;case 6:return ut.release(1),[7];case 7:return[2]}
489
491
  })}),_.label=13;case 13:return[2]}})},s.label=1
490
492
  ;case 1:
491
- return(null==N?void 0:N.aborted)||!nt&&!function(){
493
+ return(null==N?void 0:N.aborted)||!rt&&!function(){
492
494
  for(;;){
493
- if($&&Q>=0&&(null==L||Q<L.index)&&++q<$.repeatsPerVariant)return B=$.getSeed({
494
- variantIndex:Q,cycleIndex:W,repeatIndex:q,
495
- totalIndex:W*$.repeatsPerVariant+q}),!0
496
- ;if(q=0,Q++,$&&W>=$.cycles)return!1;var t=w()
497
- ;if(null==t||Q<t){var n=H.next()
498
- ;if(!n.done)return K=n.value,$&&(B=$.getSeed({
499
- variantIndex:Q,cycleIndex:W,repeatIndex:q,
500
- totalIndex:W*$.repeatsPerVariant+q})),!0}
501
- if(!$)return!1;if(++W>=$.cycles)return!1
502
- ;Q=-1,H=e[Symbol.iterator]()}}()?[3,3]:[5,n()]
495
+ if($&&K>=0&&(null==Q||K<Q.index)&&++B<$.repeatsPerVariant)return L=$.getSeed({
496
+ variantIndex:K,cycleIndex:q,repeatIndex:B,
497
+ totalIndex:q*$.repeatsPerVariant+B}),!0
498
+ ;if(B=0,K++,$&&q>=$.cycles)return!1;var t=w()
499
+ ;if(null==t||K<t){var n=Z.next()
500
+ ;if(!n.done)return H=n.value,$&&(L=$.getSeed({
501
+ variantIndex:K,cycleIndex:q,repeatIndex:B,
502
+ totalIndex:q*$.repeatsPerVariant+B})),!0}
503
+ if(!$)return!1;if(W=K,++q>=$.cycles)return!1
504
+ ;K=-1,Z=e[Symbol.iterator]()}}()?[3,3]:[5,n()]
503
505
  ;case 2:return s.sent(),[3,1];case 3:
504
- return at?[4,at.holdWait(G)]:[3,5];case 4:
505
- s.sent(),at.release(G),s.label=5;case 5:
506
- if(null==et?void 0:et.aborted)throw et.reason
507
- ;return J&&console.log("[test-variants] variants: ".concat(Q,", iterations: ").concat(rt,", async: ").concat(st)),
508
- [4,Y(1)];case 6:return s.sent(),[2,rt]}})})}
509
- var S,x,E,P,A,k,T,z,O,M,F,D,C,V,R,J,N,$,G,U,W,q,B,L,Q,K,H,Z,tt,et,nt,rt,st,it,ot,ct,lt,at,ut,ht
506
+ return ut?[4,ut.holdWait(G)]:[3,5];case 4:
507
+ s.sent(),ut.release(G),s.label=5;case 5:
508
+ if(null==nt?void 0:nt.aborted)throw nt.reason
509
+ ;return J&&console.log("[test-variants] variants: ".concat(K,", iterations: ").concat(st,", async: ").concat(it)),
510
+ [4,Y(1)];case 6:return s.sent(),[2,st]}})})}
511
+ var S,x,E,P,A,k,T,z,O,M,F,D,C,V,R,J,N,$,G,U,W,q,B,L,Q,K,H,Z,tt,et,nt,rt,st,it,ot,ct,lt,at,ut,ht,ft
510
512
  ;return l(this,function(o){switch(o.label){case 0:
511
513
  return S=n.saveErrorVariants,x=null!==(r=null==S?void 0:S.retriesPerVariant)&&void 0!==r?r:1,
512
514
  E=new Date,
@@ -528,10 +530,10 @@ return T.done?[3,9]:[4,u(T.value,S.jsonToArgs)]
528
530
  return O<x?g(M=t(z,-1,null))?[4,M]:[3,7]:[3,8]
529
531
  ;case 6:o.sent(),o.label=7;case 7:return O++,[3,5]
530
532
  ;case 8:return T=k.next(),[3,3];case 9:
531
- return[3,12];case 10:return F=o.sent(),ut={error:F
533
+ return[3,12];case 10:return F=o.sent(),ht={error:F
532
534
  },[3,12];case 11:try{
533
- T&&!T.done&&(ht=k.return)&&ht.call(k)}finally{
534
- if(ut)throw ut.error}return[7];case 12:
535
+ T&&!T.done&&(ft=k.return)&&ft.call(k)}finally{
536
+ if(ht)throw ht.error}return[7];case 12:
535
537
  return D=null!==(v=n.GC_Iterations)&&void 0!==v?v:1e6,
536
538
  C=null!==(_=n.GC_IterationsAsync)&&void 0!==_?_:1e4,
537
539
  V=null!==(y=n.GC_Interval)&&void 0!==y?y:1e3,
@@ -539,16 +541,16 @@ R=null!==(b=n.logInterval)&&void 0!==b?b:5e3,
539
541
  J=null===(p=n.logCompleted)||void 0===p||p,
540
542
  N=n.abortSignal,$=n.findBestError,G=!0===n.parallel?Math.pow(2,31):!n.parallel||n.parallel<=0?1:n.parallel,
541
543
  U=null!==(m=n.limitVariantsCount)&&void 0!==m?m:null,
542
- W=0,q=0,B=void 0,L=null,Q=-1,
543
- K={},H=e[Symbol.iterator](),Z=new I,tt=function(...t){
544
+ W=null,q=0,B=0,L=void 0,Q=null,
545
+ K=-1,H={},Z=e[Symbol.iterator](),tt=new I,et=function(...t){
544
546
  let e,n;function r(t){e.abort(t)}
545
547
  for(let s=0;s<t.length;s++){const i=t[s];if(i){
546
548
  if(i.aborted)return i
547
549
  ;n?(e||(e=new I,n.subscribe(r)),i.subscribe(r)):n=i
548
550
  }}return e?e.signal:n||(new I).signal
549
- }(N,Z.signal),et=tt,nt=!1,rt=0,st=0,it=Date.now(),
550
- ot=it,ct=rt,lt=st,at=G<=1?null:new X(G),[4,j()]
551
- ;case 13:return[2,{iterations:o.sent(),bestError:L
551
+ }(N,tt.signal),nt=et,rt=!1,st=0,it=0,ot=Date.now(),
552
+ ct=ot,lt=st,at=it,ut=G<=1?null:new X(G),[4,j()]
553
+ ;case 13:return[2,{iterations:o.sent(),bestError:Q
552
554
  }]}})})}t.createTestVariants=function(t){
553
555
  return function(e){return function(n){
554
556
  return c(this,void 0,void 0,function(){var r,s
@@ -66,6 +66,7 @@ function testVariantsRun(testRun, variants, options = {}) {
66
66
  ? 1
67
67
  : options.parallel;
68
68
  const limitVariantsCount = (_j = options.limitVariantsCount) !== null && _j !== void 0 ? _j : null;
69
+ let prevCycleVariantsCount = null;
69
70
  let cycleIndex = 0;
70
71
  let repeatIndex = 0;
71
72
  let seed = void 0;
@@ -124,6 +125,7 @@ function testVariantsRun(testRun, variants, options = {}) {
124
125
  if (!findBestError) {
125
126
  return false;
126
127
  }
128
+ prevCycleVariantsCount = index;
127
129
  cycleIndex++;
128
130
  if (cycleIndex >= findBestError.cycles) {
129
131
  return false;
@@ -161,9 +163,14 @@ function testVariantsRun(testRun, variants, options = {}) {
161
163
  let log = '';
162
164
  if (findBestError) {
163
165
  log += `cycle: ${cycleIndex}, variant: ${index}`;
164
- const _limitVariantsCount = getLimitVariantsCount();
165
- if (_limitVariantsCount != null) {
166
- log += `/${_limitVariantsCount}`;
166
+ if (cycleIndex > 0) {
167
+ let max = getLimitVariantsCount();
168
+ if (max != null) {
169
+ if (prevCycleVariantsCount != null && prevCycleVariantsCount < max) {
170
+ max = prevCycleVariantsCount;
171
+ }
172
+ log += `/${max}`;
173
+ }
167
174
  }
168
175
  }
169
176
  else {
@@ -42,6 +42,7 @@ function testVariantsRun(testRun, variants, options = {}) {
42
42
  ? 1
43
43
  : options.parallel;
44
44
  const limitVariantsCount = (_j = options.limitVariantsCount) !== null && _j !== void 0 ? _j : null;
45
+ let prevCycleVariantsCount = null;
45
46
  let cycleIndex = 0;
46
47
  let repeatIndex = 0;
47
48
  let seed = void 0;
@@ -100,6 +101,7 @@ function testVariantsRun(testRun, variants, options = {}) {
100
101
  if (!findBestError) {
101
102
  return false;
102
103
  }
104
+ prevCycleVariantsCount = index;
103
105
  cycleIndex++;
104
106
  if (cycleIndex >= findBestError.cycles) {
105
107
  return false;
@@ -137,9 +139,14 @@ function testVariantsRun(testRun, variants, options = {}) {
137
139
  let log = '';
138
140
  if (findBestError) {
139
141
  log += `cycle: ${cycleIndex}, variant: ${index}`;
140
- const _limitVariantsCount = getLimitVariantsCount();
141
- if (_limitVariantsCount != null) {
142
- log += `/${_limitVariantsCount}`;
142
+ if (cycleIndex > 0) {
143
+ let max = getLimitVariantsCount();
144
+ if (max != null) {
145
+ if (prevCycleVariantsCount != null && prevCycleVariantsCount < max) {
146
+ max = prevCycleVariantsCount;
147
+ }
148
+ log += `/${max}`;
149
+ }
143
150
  }
144
151
  }
145
152
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flemist/test-variants",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
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",