expf-sigma-node.js 0.0.8 → 0.1.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.
Files changed (2) hide show
  1. package/package.json +8 -2
  2. package/public/sigma.js +184 -137
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expf-sigma-node.js",
3
- "version": "0.0.8",
3
+ "version": "0.1.1",
4
4
  "description": "expf-sigma-node.js lets you manage features flags and remote config across web, server side applications. Deliver true Continuous Integration. Get builds out faster. Control who has access to new features.",
5
5
  "main": "public/sigma.js",
6
6
  "keywords": [
@@ -17,7 +17,10 @@
17
17
  "scripts": {
18
18
  "release": "np",
19
19
  "build": "esbuild --bundle ./src/sigma.js --platform=node --format=cjs --outdir=public",
20
- "dev": "esbuild --bundle ./src/sigma.js --platform=node --format=cjs --outdir=public --watch"
20
+ "dev": "esbuild --bundle ./src/sigma.js --platform=node --format=cjs --outdir=public --watch",
21
+ "lint": "eslint ./src/sigma.js",
22
+ "lint:all": "eslint \"**/*.js\"",
23
+ "test": "jest"
21
24
  },
22
25
  "dependencies": {
23
26
  "node-fetch": "^2.1.2"
@@ -27,6 +30,7 @@
27
30
  "@babel/plugin-proposal-class-properties": "^7.18.6",
28
31
  "@babel/preset-env": "^7.16.4",
29
32
  "babel-eslint": "^10.1.0",
33
+ "babel-jest": "^29.2.2",
30
34
  "babel-loader": "^8.2.3",
31
35
  "babel-plugin-add-module-exports": "^1.0.4",
32
36
  "clean-webpack-plugin": "^4.0.0",
@@ -36,6 +40,8 @@
36
40
  "eslint-plugin-jest": "^23.8.2",
37
41
  "eslint-plugin-node": "^11.1.0",
38
42
  "eslint-plugin-prettier": "^3.1.3",
43
+ "jest": "^29.2.2",
44
+ "jest-environment-jsdom": "^29.2.1",
39
45
  "js-cookie": "^3.0.1",
40
46
  "jshashes": "^1.0.8",
41
47
  "node-cache": "^5.1.2",
package/public/sigma.js CHANGED
@@ -5620,11 +5620,14 @@ var SigmaUserData = class {
5620
5620
  getUserNavigator() {
5621
5621
  const userNavigator = browser_detect_es5_default();
5622
5622
  const { user } = this;
5623
- const userOs = userNavigator.os.split(" ");
5624
- user.browser.name = userNavigator.name;
5625
- user.browser.version = userNavigator.version;
5626
- user.os.name = userOs[0];
5627
- user.os.version = userOs[1];
5623
+ let userOs;
5624
+ if (userNavigator.os) {
5625
+ userOs = userNavigator.os.split(" ");
5626
+ }
5627
+ user.browser.name = userNavigator.name ? userNavigator.name : void 0;
5628
+ user.browser.version = userNavigator.version ? userNavigator.version : void 0;
5629
+ user.os.name = userOs ? userOs[0] : void 0;
5630
+ user.os.version = userOs ? userOs[1] : void 0;
5628
5631
  }
5629
5632
  setUserId(userId) {
5630
5633
  this.user.userId = userId;
@@ -5780,6 +5783,109 @@ var js_cookie_default = api;
5780
5783
 
5781
5784
  // src/sigma.js
5782
5785
  var import_jshashes = __toESM(require_hashes());
5786
+
5787
+ // src/helpers/checkBoolValue.js
5788
+ function checkBoolValue(value) {
5789
+ if (value)
5790
+ return true;
5791
+ return false;
5792
+ }
5793
+
5794
+ // src/helpers/checkForcedList.js
5795
+ function checkForcedList(usersList, data) {
5796
+ if (usersList.length) {
5797
+ for (let id2 in usersList) {
5798
+ if (usersList[id2] == data) {
5799
+ return true;
5800
+ }
5801
+ }
5802
+ }
5803
+ return false;
5804
+ }
5805
+
5806
+ // src/helpers/compareVersions.js
5807
+ function compareVersions(versionA, versionB, strict = true) {
5808
+ let resultCompare;
5809
+ const versionsLength = Math.max(versionA.length, versionB.length);
5810
+ versionA = (versionA + "").split(".");
5811
+ versionB = (versionB + "").split(".");
5812
+ for (let i = 0; i < versionsLength; i++) {
5813
+ if (versionA[i] === void 0) {
5814
+ versionA[i] = "0";
5815
+ }
5816
+ if (versionB[i] === void 0) {
5817
+ versionB[i] = "0";
5818
+ }
5819
+ resultCompare = parseInt(versionA[i], 10) - parseInt(versionB[i], 10);
5820
+ if (resultCompare !== 0) {
5821
+ return resultCompare < 0 ? false : true;
5822
+ }
5823
+ }
5824
+ if (strict) {
5825
+ return false;
5826
+ }
5827
+ if (!strict) {
5828
+ return true;
5829
+ }
5830
+ }
5831
+
5832
+ // src/helpers/delay.js
5833
+ function delay(ms) {
5834
+ new Promise((resolve) => setTimeout(() => resolve(void 0), ms));
5835
+ }
5836
+
5837
+ // src/helpers/digestHash.js
5838
+ function digestHash(string) {
5839
+ let hash = 0, i, chr;
5840
+ if (string.length === 0)
5841
+ return hash;
5842
+ for (i = 0; i < string.length; i++) {
5843
+ chr = string.charCodeAt(i);
5844
+ hash = (hash << 5) - hash + chr;
5845
+ hash |= 0;
5846
+ }
5847
+ return hash;
5848
+ }
5849
+
5850
+ // src/helpers/doTypeConversion.js
5851
+ function doTypeConversion(type, value) {
5852
+ if (type === "string")
5853
+ return value;
5854
+ if (type === "bool") {
5855
+ return value === "true" ? true : false;
5856
+ }
5857
+ if (type === "integer" || type === "number")
5858
+ return parseFloat(value);
5859
+ return value;
5860
+ }
5861
+
5862
+ // src/helpers/makeIdCookie.js
5863
+ function makeIdCookie() {
5864
+ let text = "";
5865
+ let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
5866
+ for (let i = 0; i < 80; i++)
5867
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
5868
+ return text;
5869
+ }
5870
+
5871
+ // src/helpers/getUserGroup.js
5872
+ function getUserGroup(salt, exposureRate, controlBucketPerc, forcedExp) {
5873
+ let userInGroup = "a";
5874
+ let currentDiapason = 0;
5875
+ if (Math.abs(salt) / 100 <= parseFloat(exposureRate) * 100 || forcedExp) {
5876
+ let bucket = Math.abs(salt) % 100;
5877
+ for (let i = 0; i < controlBucketPerc.length; i++) {
5878
+ currentDiapason += controlBucketPerc[i].weight * 100;
5879
+ if (bucket <= currentDiapason) {
5880
+ return userInGroup = controlBucketPerc[i].name;
5881
+ }
5882
+ }
5883
+ return userInGroup;
5884
+ }
5885
+ return false;
5886
+ }
5887
+
5888
+ // src/sigma.js
5783
5889
  if (typeof import_node_fetch.default.default !== "undefined")
5784
5890
  import_node_fetch.default.default;
5785
5891
  var defaultApi = "https://api.expf.ru/api/v1";
@@ -5830,13 +5936,10 @@ var Sigma = class {
5830
5936
  if (hasMakeId && this.cache.get(sigmaUserId)) {
5831
5937
  userId = this.cache.get(sigmaUserId);
5832
5938
  } else if (hasMakeId) {
5833
- userId = this.makeIdCookie();
5939
+ userId = makeIdCookie();
5834
5940
  }
5835
5941
  return userId;
5836
5942
  }
5837
- delay(ms) {
5838
- new Promise((resolve) => setTimeout(() => resolve(void 0), ms));
5839
- }
5840
5943
  retryFetch(url, fetchOptions, retries = 3, timeout) {
5841
5944
  return new Promise((resolve, reject) => {
5842
5945
  if (timeout)
@@ -5844,7 +5947,7 @@ var Sigma = class {
5844
5947
  const wrapper = (n) => {
5845
5948
  (0, import_node_fetch.default)(url, fetchOptions).then((res) => resolve(res)).catch((err) => {
5846
5949
  if (n > 0) {
5847
- this.delay(1e3);
5950
+ delay(1e3);
5848
5951
  wrapper(--n);
5849
5952
  } else {
5850
5953
  reject(err);
@@ -5880,6 +5983,7 @@ var Sigma = class {
5880
5983
  async getUserGeoData() {
5881
5984
  try {
5882
5985
  const data = await this.getDataFile(`${defaultApi}/geo`);
5986
+ this.sigmaUserData.setIp(data.ip);
5883
5987
  return data;
5884
5988
  } catch (error) {
5885
5989
  throw new Error(error);
@@ -5945,19 +6049,12 @@ var Sigma = class {
5945
6049
  js_cookie_default.set(sigmaUserId, uin);
5946
6050
  }
5947
6051
  if (!uin) {
5948
- uin = this.makeIdCookie();
6052
+ uin = makeIdCookie();
5949
6053
  js_cookie_default.set(sigmaUserId, uin);
5950
6054
  this.cache.set(sigmaUserId, uin);
5951
6055
  }
5952
6056
  return;
5953
6057
  }
5954
- makeIdCookie() {
5955
- let text = "";
5956
- let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
5957
- for (let i = 0; i < 80; i++)
5958
- text += possible.charAt(Math.floor(Math.random() * possible.length));
5959
- return text;
5960
- }
5961
6058
  hasExpireCache() {
5962
6059
  const lastUpdate = parseInt(
5963
6060
  this.cache.get("sigmaDataFileLastUpdate")
@@ -5993,8 +6090,6 @@ var Sigma = class {
5993
6090
  this.sigmaUserData.setGeo(geoData);
5994
6091
  let flag = null;
5995
6092
  for (let i = 0; i < cacheKey.feature_flags.length; i++) {
5996
- if (cacheKey.feature_flags[i]["is_active"] == "false")
5997
- continue;
5998
6093
  if (cacheKey.feature_flags[i]["name"] === flagName) {
5999
6094
  flag = cacheKey.feature_flags[i];
6000
6095
  break;
@@ -6021,30 +6116,6 @@ var Sigma = class {
6021
6116
  }
6022
6117
  return flagValue;
6023
6118
  }
6024
- compareVersions(versionA, versionB, strict = true) {
6025
- let resultCompare;
6026
- const versionsLength = Math.max(versionA.length, versionB.length);
6027
- versionA = (versionA + "").split(".");
6028
- versionB = (versionB + "").split(".");
6029
- for (let i = 0; i < versionsLength; i++) {
6030
- if (versionA[i] === void 0) {
6031
- versionA[i] = "0";
6032
- }
6033
- if (versionB[i] === void 0) {
6034
- versionB[i] = "0";
6035
- }
6036
- resultCompare = parseInt(versionA[i], 10) - parseInt(versionB[i], 10);
6037
- if (resultCompare !== 0) {
6038
- return resultCompare < 0 ? false : true;
6039
- }
6040
- }
6041
- if (strict) {
6042
- return false;
6043
- }
6044
- if (!strict) {
6045
- return true;
6046
- }
6047
- }
6048
6119
  conditionOperation(userValue, conditionValues, operation) {
6049
6120
  !operation ? operation = "=" : operation;
6050
6121
  if (!userValue || typeof userValue === "undefined")
@@ -6055,17 +6126,17 @@ var Sigma = class {
6055
6126
  case "not equal":
6056
6127
  return userValue.toLowerCase().trim() != conditionValues.toLowerCase().trim();
6057
6128
  case "greater":
6058
- return this.compareVersions(conditionValues.trim(), userValue.trim());
6129
+ return compareVersions(conditionValues.trim(), userValue.trim());
6059
6130
  case "less":
6060
- return this.compareVersions(userValue.trim(), conditionValues.trim());
6131
+ return compareVersions(userValue.trim(), conditionValues.trim());
6061
6132
  case "greater equal":
6062
- return this.compareVersions(
6133
+ return compareVersions(
6063
6134
  conditionValues.trim(),
6064
6135
  userValue.trim(),
6065
6136
  false
6066
6137
  );
6067
6138
  case "less equal":
6068
- return this.compareVersions(
6139
+ return compareVersions(
6069
6140
  userValue.trim(),
6070
6141
  conditionValues.trim(),
6071
6142
  false
@@ -6076,14 +6147,14 @@ var Sigma = class {
6076
6147
  return !conditionValues.includes(userValue);
6077
6148
  case "contains any of":
6078
6149
  for (let i = 0; i < conditionValues.length; i++) {
6079
- if (String(conditionValues[i]).includes(userValue)) {
6150
+ if (String(userValue).includes(conditionValues[i])) {
6080
6151
  return true;
6081
6152
  }
6082
6153
  }
6083
6154
  return false;
6084
6155
  case "contains none of":
6085
6156
  for (let i = 0; i < conditionValues.length; i++) {
6086
- if (String(conditionValues[i]).includes(userValue)) {
6157
+ if (String(userValue).includes(conditionValues[i])) {
6087
6158
  return false;
6088
6159
  }
6089
6160
  }
@@ -6104,10 +6175,11 @@ var Sigma = class {
6104
6175
  return false;
6105
6176
  }
6106
6177
  }
6107
- getUserParamValue(paramKey) {
6178
+ getUserParamValue(paramKey, privateFlag = null) {
6108
6179
  if (!paramKey)
6109
6180
  return false;
6110
6181
  const user = this.sigmaUserData.user;
6182
+ let defaultValue = null;
6111
6183
  if (paramKey.includes(".")) {
6112
6184
  const paramsArray = paramKey.split(".");
6113
6185
  const parent = paramsArray[0];
@@ -6115,67 +6187,46 @@ var Sigma = class {
6115
6187
  if (!child)
6116
6188
  return false;
6117
6189
  const isSetParentInUserData = Object.keys(user).find((i) => i === parent);
6118
- if (!user[isSetParentInUserData])
6190
+ if (!user[isSetParentInUserData]) {
6119
6191
  return false;
6192
+ }
6120
6193
  const userObject = Object.entries(user[isSetParentInUserData]);
6121
6194
  for (let [userParamKey, userParamValue] of userObject) {
6122
6195
  if (userParamKey == child) {
6123
- return userParamValue;
6196
+ defaultValue = userParamValue;
6197
+ break;
6124
6198
  }
6125
6199
  }
6126
6200
  } else {
6127
6201
  for (let [key, value] of Object.entries(user)) {
6128
6202
  if (key == paramKey) {
6129
- return value;
6203
+ defaultValue = value;
6204
+ break;
6130
6205
  }
6131
6206
  }
6132
6207
  }
6133
- return false;
6134
- }
6135
- digestHash(string) {
6136
- let hash = 0, i, chr;
6137
- if (string.length === 0)
6138
- return hash;
6139
- for (i = 0; i < string.length; i++) {
6140
- chr = string.charCodeAt(i);
6141
- hash = (hash << 5) - hash + chr;
6142
- hash |= 0;
6143
- }
6144
- return hash;
6208
+ if (privateFlag && defaultValue)
6209
+ return MD5.hex(defaultValue);
6210
+ return defaultValue;
6145
6211
  }
6146
6212
  calcUserInGroup(salt, exposureRate, controlBucketPerc, forcedExp = false, layer = null, layerBounds = []) {
6147
6213
  const userId = this.sigmaUserData.user.userId ? this.sigmaUserData.user.userId : this.cache.get(sigmaUserId);
6148
6214
  const md5R = MD5.hex(String(userId) + salt);
6149
- const R = this.digestHash(md5R) * zeta / max_decimal_64;
6215
+ const R = digestHash(md5R) * zeta / max_decimal_64;
6150
6216
  let md5L = null;
6151
6217
  if (!layer && !layerBounds.length || forcedExp) {
6152
- return this.getUserGroup(R, exposureRate, controlBucketPerc, forcedExp);
6218
+ return getUserGroup(R, exposureRate, controlBucketPerc, forcedExp);
6153
6219
  } else {
6154
6220
  md5L = MD5.hex(String(userId) + layer);
6155
- const L = this.digestHash(md5L) * zeta / max_decimal_64;
6221
+ const L = digestHash(md5L) * zeta / max_decimal_64;
6156
6222
  for (let i in layerBounds) {
6157
6223
  const result = Math.abs(L / 10);
6158
6224
  if (result <= layerBounds[i].lower_bound || layerBounds[i].upper_bound <= result) {
6159
6225
  continue;
6160
6226
  } else {
6161
- return this.getUserGroup(R, exposureRate, controlBucketPerc, forcedExp);
6162
- }
6163
- }
6164
- }
6165
- return false;
6166
- }
6167
- getUserGroup(salt, exposureRate, controlBucketPerc, forcedExp) {
6168
- let userInGroup = "a";
6169
- let currentDiaposon = 0;
6170
- if (Math.abs(salt) / 100 <= parseFloat(exposureRate) * 100 || forcedExp) {
6171
- let bucket = Math.abs(salt) % 100;
6172
- for (let i = 0; i < controlBucketPerc.length; i++) {
6173
- currentDiaposon += controlBucketPerc[i].weight * 100;
6174
- if (bucket <= currentDiaposon) {
6175
- return userInGroup = controlBucketPerc[i].name;
6227
+ return getUserGroup(R, exposureRate, controlBucketPerc, forcedExp);
6176
6228
  }
6177
6229
  }
6178
- return userInGroup;
6179
6230
  }
6180
6231
  return false;
6181
6232
  }
@@ -6184,38 +6235,39 @@ var Sigma = class {
6184
6235
  return false;
6185
6236
  }
6186
6237
  await this.updateCache();
6187
- const sigmaDataLs = this.cache.parse(sigmaDataFile);
6238
+ const sigmaDataLs = await this.cache.parse(sigmaDataFile);
6239
+ if (!sigmaDataLs.experiments) {
6240
+ throw new Error("Experiments not found in cache");
6241
+ }
6188
6242
  let experiment = null;
6189
6243
  let layer = null;
6190
6244
  let bounds = [];
6191
6245
  let userInGroupExperiment = null;
6192
6246
  let forcedUser = false;
6193
- if (!sigmaDataLs.experiments) {
6194
- throw new Error("experiments in cache not found");
6195
- }
6196
6247
  for (let i = 0; i < sigmaDataLs.experiments.length; i++) {
6197
- if (sigmaDataLs.experiments[i]["is_active"] == "false")
6198
- continue;
6199
- if (sigmaDataLs.experiments[i]["name"] === experimentName && this.checkBoolValue(sigmaDataLs.experiments[i]["layer_id"])) {
6248
+ if (sigmaDataLs.experiments[i]["name"] === experimentName && checkBoolValue(sigmaDataLs.experiments[i]["layer_id"])) {
6200
6249
  layer = sigmaDataLs.experiments[i]["layer_id"];
6201
6250
  bounds = sigmaDataLs.experiments[i]["layer_bounds"];
6202
6251
  }
6203
6252
  if (sigmaDataLs.experiments[i]["name"] === experimentName && !experiment) {
6204
- forcedUser = this.checkForcedList(sigmaDataLs.experiments[i].forced_user_list, this.sigmaUserData.user.userId);
6253
+ forcedUser = checkForcedList(sigmaDataLs.experiments[i].forced_user_list, this.sigmaUserData.user.userId);
6205
6254
  experiment = sigmaDataLs.experiments[i];
6206
6255
  break;
6207
6256
  }
6208
6257
  }
6209
6258
  const localStorageGroupName = `sigma_group_${experimentName}`;
6210
6259
  if (experiment) {
6211
- userInGroupExperiment = this.calcUserInGroup(
6212
- experiment.salt,
6213
- experiment.allocation,
6214
- experiment.groups,
6215
- forcedUser,
6216
- layer,
6217
- bounds
6218
- );
6260
+ userInGroupExperiment = this.findUserInForcedGroup(experiment);
6261
+ if (!userInGroupExperiment) {
6262
+ userInGroupExperiment = this.calcUserInGroup(
6263
+ experiment.salt,
6264
+ experiment.allocation,
6265
+ experiment.groups,
6266
+ forcedUser,
6267
+ layer,
6268
+ bounds
6269
+ );
6270
+ }
6219
6271
  this.cache.set(localStorageGroupName, userInGroupExperiment);
6220
6272
  }
6221
6273
  const getParamValue = (paramName) => {
@@ -6236,7 +6288,7 @@ var Sigma = class {
6236
6288
  let paramValue = null;
6237
6289
  for (let item in params.values) {
6238
6290
  if (params.values[item].group === groupName) {
6239
- paramValue = this.doTypeConversion(params.type, params.values[item].value);
6291
+ paramValue = doTypeConversion(params.type, params.values[item].value);
6240
6292
  }
6241
6293
  }
6242
6294
  if (!paramValue) {
@@ -6267,7 +6319,7 @@ var Sigma = class {
6267
6319
  }
6268
6320
  if (!flag)
6269
6321
  return false;
6270
- return this.findingSpotCondition(flag);
6322
+ return this.findingSpotCondition(flag, false, experiment);
6271
6323
  };
6272
6324
  return {
6273
6325
  getParamValue,
@@ -6284,18 +6336,21 @@ var Sigma = class {
6284
6336
  const experiment = sigmaDataLs.experiments[i];
6285
6337
  let layer = null;
6286
6338
  let bounds = [];
6287
- if (this.checkBoolValue(experiment["layer_id"])) {
6339
+ let group = this.findUserInForcedGroup(experiment);
6340
+ if (checkBoolValue(experiment["layer_id"]) && !group) {
6288
6341
  layer = experiment["layer_id"];
6289
6342
  bounds = experiment["layer_bounds"];
6290
6343
  }
6291
- const group = this.calcUserInGroup(
6292
- experiment.salt,
6293
- experiment.allocation,
6294
- experiment.groups,
6295
- this.checkForcedList(experiment.forced_user_list, this.sigmaUserData.user.userId),
6296
- layer,
6297
- bounds
6298
- );
6344
+ if (!group) {
6345
+ group = this.calcUserInGroup(
6346
+ experiment.salt,
6347
+ experiment.allocation,
6348
+ experiment.groups,
6349
+ checkForcedList(experiment.forced_user_list, this.sigmaUserData.user.userId),
6350
+ layer,
6351
+ bounds
6352
+ );
6353
+ }
6299
6354
  if (group) {
6300
6355
  const groupIndex = experiment.groups.findIndex((i2) => i2.name == group);
6301
6356
  result = result.concat(experiment.name).concat(".").concat(groupIndex).concat("|");
@@ -6307,22 +6362,21 @@ var Sigma = class {
6307
6362
  }
6308
6363
  return false;
6309
6364
  }
6310
- checkForcedList(usersList, data) {
6311
- if (usersList.length) {
6312
- for (let id2 in usersList) {
6313
- if (usersList[id2] == data) {
6314
- return true;
6365
+ findUserInForcedGroup(experiment) {
6366
+ let groupName = false;
6367
+ for (const groupItem in experiment.groups) {
6368
+ const forcedList = experiment.groups[groupItem].forced_user_list;
6369
+ if (forcedList && forcedList.length) {
6370
+ for (const item in forcedList) {
6371
+ if (forcedList[item] === this.sigmaUserData.user.userId) {
6372
+ return groupName = experiment.groups[groupItem].name;
6373
+ }
6315
6374
  }
6316
6375
  }
6317
6376
  }
6318
- return false;
6377
+ return groupName;
6319
6378
  }
6320
- checkBoolValue(value) {
6321
- if (value)
6322
- return true;
6323
- return false;
6324
- }
6325
- findingSpotCondition(flag, saveToUser) {
6379
+ findingSpotCondition(flag, saveToUser = false, exp = null) {
6326
6380
  let flagRules = flag.rules;
6327
6381
  let flagDefaultResult = null;
6328
6382
  for (let defaultRule in flagRules) {
@@ -6347,7 +6401,10 @@ var Sigma = class {
6347
6401
  const conditions = flagRules[rule].conditions;
6348
6402
  let results = [];
6349
6403
  for (let i in conditions) {
6350
- let userValue = this.getUserParamValue(conditions[i].name);
6404
+ let userValue = this.getUserParamValue(
6405
+ conditions[i].name,
6406
+ exp ? exp.is_private : flag.is_private
6407
+ );
6351
6408
  results.push(
6352
6409
  this.conditionOperation(
6353
6410
  userValue,
@@ -6365,7 +6422,7 @@ var Sigma = class {
6365
6422
  const findingItem = results.find((item) => item === false);
6366
6423
  findingItem === false ? isSuccessRule : isSuccessRule = true;
6367
6424
  }
6368
- let ruleValue = this.doTypeConversion(flag.type, flagRules[rule].value);
6425
+ let ruleValue = doTypeConversion(flag.type, flagRules[rule].value);
6369
6426
  if (isSuccessRule) {
6370
6427
  if (saveToUser) {
6371
6428
  saveToUser.addFlag(flag.name, {
@@ -6377,7 +6434,7 @@ var Sigma = class {
6377
6434
  return ruleValue;
6378
6435
  }
6379
6436
  }
6380
- let defaultValue = this.doTypeConversion(flagDefaultResult.type, flagDefaultResult.value);
6437
+ let defaultValue = doTypeConversion(flagDefaultResult.type, flagDefaultResult.value);
6381
6438
  if (saveToUser) {
6382
6439
  flagDefaultResult.value = defaultValue;
6383
6440
  saveToUser.addFlag(flag.name, flagDefaultResult);
@@ -6385,16 +6442,6 @@ var Sigma = class {
6385
6442
  return defaultValue;
6386
6443
  }
6387
6444
  }
6388
- doTypeConversion(type, value) {
6389
- if (type === "string")
6390
- return value;
6391
- if (type === "bool") {
6392
- return value === "true" ? true : false;
6393
- }
6394
- if (type === "integer" || type === "number")
6395
- return parseFloat(value);
6396
- return value;
6397
- }
6398
6445
  async getCacheDataFile() {
6399
6446
  const data = await this.cache.get(sigmaDataFile);
6400
6447
  return data;