expf-sigma-node.js 0.1.4 → 0.1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/sigma.js +22 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expf-sigma-node.js",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
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": [
package/public/sigma.js CHANGED
@@ -6095,10 +6095,28 @@ var Sigma = class {
6095
6095
  break;
6096
6096
  }
6097
6097
  }
6098
+ if (!flag) {
6099
+ let expName = this.getExperimentByFeatureFlag(cacheKey, flagName);
6100
+ if (!expName)
6101
+ return flag;
6102
+ return await this.getExperiment(expName).then((res) => res.getFeatureValue(flagName));
6103
+ }
6098
6104
  if (!flag)
6099
6105
  return null;
6100
6106
  return this.findingSpotCondition(flag, this.sigmaUserData);
6101
6107
  }
6108
+ getExperimentByFeatureFlag(cache, flagName) {
6109
+ for (let i = 0; i < cache.experiments.length; i++) {
6110
+ if (cache.experiments[i].feature_flags.length) {
6111
+ for (let j in cache.experiments[i].feature_flags) {
6112
+ if (cache.experiments[i].feature_flags[j].name === flagName) {
6113
+ return cache.experiments[i].name;
6114
+ }
6115
+ }
6116
+ }
6117
+ }
6118
+ return null;
6119
+ }
6102
6120
  getFlag(key) {
6103
6121
  if (!key) {
6104
6122
  return false;
@@ -6126,21 +6144,13 @@ var Sigma = class {
6126
6144
  case "not equal":
6127
6145
  return userValue.toLowerCase().trim() != conditionValues.toLowerCase().trim();
6128
6146
  case "greater":
6129
- return compareVersions(conditionValues.trim(), userValue.trim());
6130
- case "less":
6131
6147
  return compareVersions(userValue.trim(), conditionValues.trim());
6148
+ case "less":
6149
+ return compareVersions(conditionValues.trim(), userValue.trim());
6132
6150
  case "greater equal":
6133
- return compareVersions(
6134
- conditionValues.trim(),
6135
- userValue.trim(),
6136
- false
6137
- );
6151
+ return compareVersions(userValue.trim(), conditionValues.trim(), false);
6138
6152
  case "less equal":
6139
- return compareVersions(
6140
- userValue.trim(),
6141
- conditionValues.trim(),
6142
- false
6143
- );
6153
+ return compareVersions(conditionValues.trim(), userValue.trim(), false);
6144
6154
  case "any of":
6145
6155
  return conditionValues.includes(userValue);
6146
6156
  case "none of":