@rh-support/utils 2.1.11-beta.0 → 2.1.11-beta.1

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 +1 @@
1
- {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC;AAEF,aAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC;AAOF,eAAO,MAAM,YAAY,wBAAyB,MAAM,cAAc,MAAM,cAkB3E,CAAC"}
1
+ {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,eAAO,MAAM,UAAU,wCAGX,KAAK,qBAAqB,WASrC,CAAC;AAEF,eAAO,MAAM,cAAc,wCAGf,KAAK,qBAAqB,WAerC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAU,MAAM,KAAG,MAAmC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,WAAY,MAAM,WAEzD,CAAC;AAEF,eAAO,MAAM,qBAAqB,aAAc,MAAM,KAAG,MAExD,CAAC;AAEF,eAAO,MAAM,+BAA+B,SAClC,MAAM,gBACC,OAAO,UAAU,CAAC,OAAO,KACvC,OAEF,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,gBAAe,OAAO,UAAU,CAAC,OAAO,YAEhF,CAAC;AAEF,aAAK,SAAS,GAAG;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC;AAOF,eAAO,MAAM,YAAY,wBAAyB,MAAM,cAAc,MAAM,cAe3E,CAAC"}
@@ -55,7 +55,7 @@ const addDaysToDate = (params) => {
55
55
  };
56
56
  exports.addDaysToDate = addDaysToDate;
57
57
  // split traffic based on time and weight
58
- // for example, if testVariationWeight is 2 and the current time in milliseconds modulo 10 is less than 2,
58
+ // for example, if testVariationWeight is 2 and the current time in seconds modulo 10 is less than 2,
59
59
  // redirect to test version (20% of the time), else redirect to control version (80% of the time)
60
60
  // @wieght: a number between 0 and 10
61
61
  // @dateString: date string
@@ -65,11 +65,9 @@ const trafficSplit = (testVariationWeight, dateString) => {
65
65
  if (testVariationWeight === 0 || !testVariationWeight || isNaN(testVariationWeight))
66
66
  return 'B'; // control
67
67
  const date = new Date(dateString);
68
- const milliseconds = date.getTime();
68
+ const seconds = date.getSeconds();
69
69
  const totalWeight = 10;
70
- // calculate the modulo based on the total weight
71
- const moduloResult = milliseconds % totalWeight;
72
- // redirect traffic based on the calculated modulo
70
+ const moduloResult = seconds % totalWeight;
73
71
  if (moduloResult < testVariationWeight) {
74
72
  return 'A';
75
73
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dateUtils.d.ts","sourceRoot":"","sources":["../../src/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,eAAO,MAAM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G;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,aAAa,WAAY,SAAS,kBAG9C,CAAC;AAOF,eAAO,MAAM,YAAY,wBAAyB,MAAM,cAAc,MAAM,cAe3E,CAAC"}
@@ -41,7 +41,7 @@ export const addDaysToDate = (params) => {
41
41
  return moment(date).add(days, 'days');
42
42
  };
43
43
  // split traffic based on time and weight
44
- // for example, if testVariationWeight is 2 and the current time in milliseconds modulo 10 is less than 2,
44
+ // for example, if testVariationWeight is 2 and the current time in seconds modulo 10 is less than 2,
45
45
  // redirect to test version (20% of the time), else redirect to control version (80% of the time)
46
46
  // @wieght: a number between 0 and 10
47
47
  // @dateString: date string
@@ -51,11 +51,9 @@ export const trafficSplit = (testVariationWeight, dateString) => {
51
51
  if (testVariationWeight === 0 || !testVariationWeight || isNaN(testVariationWeight))
52
52
  return 'B'; // control
53
53
  const date = new Date(dateString);
54
- const milliseconds = date.getTime();
54
+ const seconds = date.getSeconds();
55
55
  const totalWeight = 10;
56
- // calculate the modulo based on the total weight
57
- const moduloResult = milliseconds % totalWeight;
58
- // redirect traffic based on the calculated modulo
56
+ const moduloResult = seconds % totalWeight;
59
57
  if (moduloResult < testVariationWeight) {
60
58
  return 'A';
61
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/utils",
3
- "version": "2.1.11-beta.0",
3
+ "version": "2.1.11-beta.1",
4
4
  "description": "> TODO: description",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -88,5 +88,5 @@
88
88
  "defaults and supports es6-module",
89
89
  "maintained node versions"
90
90
  ],
91
- "gitHead": "3d67f1bfd743fabfd0a606cf56ea4bf48d91daa2"
91
+ "gitHead": "8c179f70b71ca5a120cf3c379daef67435e24533"
92
92
  }