@statsig/on-device-eval-core 3.25.4 → 3.25.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/on-device-eval-core",
3
- "version": "3.25.4",
3
+ "version": "3.25.6",
4
4
  "license": "ISC",
5
5
  "homepage": "https://github.com/statsig-io/js-client-monorepo",
6
6
  "repository": {
@@ -9,8 +9,8 @@
9
9
  "directory": "packages/on-device-eval-core"
10
10
  },
11
11
  "dependencies": {
12
- "@statsig/client-core": "3.25.4",
13
- "@statsig/sha256": "3.25.4"
12
+ "@statsig/client-core": "3.25.6",
13
+ "@statsig/sha256": "3.25.6"
14
14
  },
15
15
  "type": "commonjs",
16
16
  "main": "./src/index.js",
@@ -123,20 +123,15 @@ exports.default = {
123
123
  return false;
124
124
  }
125
125
  try {
126
- // Try to parse into date as a string first, if not, try unixtime
127
- let dateLeft = new Date(String(left));
128
- if (isNaN(dateLeft.getTime())) {
129
- dateLeft = new Date(Number(left));
130
- }
131
- let dateRight = new Date(String(right));
132
- if (isNaN(dateRight.getTime())) {
133
- dateRight = new Date(Number(right));
126
+ //convert to normalized date
127
+ const dateLeft = _toNormalizedDate(left);
128
+ const dateRight = _toNormalizedDate(right);
129
+ if (dateLeft === null || dateRight === null) {
130
+ return false;
134
131
  }
132
+ //convert to milliseconds
135
133
  const timeLeft = dateLeft.getTime();
136
134
  const timeRight = dateRight.getTime();
137
- if (isNaN(timeLeft) || isNaN(timeRight)) {
138
- return false;
139
- }
140
135
  switch (operator) {
141
136
  case 'before':
142
137
  return timeLeft < timeRight;
@@ -178,3 +173,13 @@ function _startOfDay(date) {
178
173
  date.setUTCHours(0, 0, 0, 0);
179
174
  return date.getTime();
180
175
  }
176
+ function _toNormalizedDate(value) {
177
+ // If it's a valid number (including numeric strings)
178
+ const num = Number(value);
179
+ if (!isNaN(num)) {
180
+ return num < 1e10 ? new Date(num * 1000) : new Date(num);
181
+ }
182
+ // Check if its a date
183
+ const date = new Date(String(value));
184
+ return isNaN(date.getTime()) ? null : date;
185
+ }
package/src/SpecStore.js CHANGED
@@ -24,7 +24,7 @@ class SpecStore {
24
24
  return this._defaultEnvironment;
25
25
  }
26
26
  setValuesFromDataAdapter(result) {
27
- var _a;
27
+ var _a, _b;
28
28
  if (!result) {
29
29
  return;
30
30
  }
@@ -32,12 +32,16 @@ class SpecStore {
32
32
  if ((values === null || values === void 0 ? void 0 : values.has_updates) !== true) {
33
33
  return;
34
34
  }
35
+ const updatedLcut = (_a = values.time) !== null && _a !== void 0 ? _a : 0;
36
+ if (updatedLcut < this._lcut) {
37
+ return;
38
+ }
35
39
  this._lcut = values.time;
36
40
  this._receivedAt = result.receivedAt;
37
41
  this._source = result.source;
38
42
  this._values = values;
39
43
  this._rawValues = result.data;
40
- this._defaultEnvironment = (_a = values.default_environment) !== null && _a !== void 0 ? _a : null;
44
+ this._defaultEnvironment = (_b = values.default_environment) !== null && _b !== void 0 ? _b : null;
41
45
  }
42
46
  reset() {
43
47
  this._values = null;