expf-sigma-node.js 3.2.0 → 3.2.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.
- package/package.json +1 -1
- package/public/sigma.js +66 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expf-sigma-node.js",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.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": [
|
package/public/sigma.js
CHANGED
|
@@ -902,6 +902,70 @@ function compareVersions(versionA, versionB, strict = true) {
|
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
904
|
|
|
905
|
+
// src/helpers/conditionOperation.js
|
|
906
|
+
function conditionOperation(userValue, conditionValues, operation) {
|
|
907
|
+
!operation ? operation = "=" : operation;
|
|
908
|
+
if (userValue === null || typeof userValue === "undefined" || !conditionValues)
|
|
909
|
+
return false;
|
|
910
|
+
userValue = String(userValue);
|
|
911
|
+
if (!Array.isArray(conditionValues))
|
|
912
|
+
conditionValues = String(conditionValues);
|
|
913
|
+
switch (operation.trim()) {
|
|
914
|
+
case "equal":
|
|
915
|
+
return userValue.toLowerCase().trim() == conditionValues.toLowerCase().trim();
|
|
916
|
+
case "not equal":
|
|
917
|
+
return userValue.toLowerCase().trim() != conditionValues.toLowerCase().trim();
|
|
918
|
+
case "greater":
|
|
919
|
+
return compareVersions(userValue.trim(), conditionValues.trim());
|
|
920
|
+
case "less":
|
|
921
|
+
return compareVersions(conditionValues.trim(), userValue.trim());
|
|
922
|
+
case "greater equal":
|
|
923
|
+
return compareVersions(userValue.trim(), conditionValues.trim(), false);
|
|
924
|
+
case "less equal":
|
|
925
|
+
return compareVersions(conditionValues.trim(), userValue.trim(), false);
|
|
926
|
+
case "any of":
|
|
927
|
+
return conditionValues.includes(userValue);
|
|
928
|
+
case "none of":
|
|
929
|
+
return !conditionValues.includes(userValue);
|
|
930
|
+
case "contains any of":
|
|
931
|
+
for (let i = 0; i < conditionValues.length; i++) {
|
|
932
|
+
if (userValue.includes(conditionValues[i])) {
|
|
933
|
+
return true;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
return false;
|
|
937
|
+
case "contains none of":
|
|
938
|
+
for (let i = 0; i < conditionValues.length; i++) {
|
|
939
|
+
if (userValue.includes(conditionValues[i])) {
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return true;
|
|
944
|
+
case "on date":
|
|
945
|
+
return Math.floor(
|
|
946
|
+
new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60 * 24)
|
|
947
|
+
) == this.sigmaUserData.user.date;
|
|
948
|
+
case "after time":
|
|
949
|
+
return new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60) < this.sigmaUserData.user.time;
|
|
950
|
+
case "before time":
|
|
951
|
+
return new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60) > this.sigmaUserData.user.time;
|
|
952
|
+
case "starts with":
|
|
953
|
+
return userValue.startsWith(conditionValues);
|
|
954
|
+
case "not starts with":
|
|
955
|
+
return !userValue.startsWith(conditionValues);
|
|
956
|
+
case "ends with":
|
|
957
|
+
return userValue.endsWith(conditionValues);
|
|
958
|
+
case "not ends with":
|
|
959
|
+
return !userValue.endsWith(conditionValues);
|
|
960
|
+
case "contains":
|
|
961
|
+
return userValue.includes(conditionValues);
|
|
962
|
+
case "not contains":
|
|
963
|
+
return !userValue.includes(conditionValues);
|
|
964
|
+
default:
|
|
965
|
+
return false;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
905
969
|
// src/helpers/delay.js
|
|
906
970
|
function delay(ms) {
|
|
907
971
|
return new Promise((resolve) => setTimeout(() => resolve(void 0), ms));
|
|
@@ -1242,56 +1306,6 @@ var Sigma = class {
|
|
|
1242
1306
|
}
|
|
1243
1307
|
return flagValue;
|
|
1244
1308
|
}
|
|
1245
|
-
conditionOperation(userValue, conditionValues, operation) {
|
|
1246
|
-
!operation ? operation = "=" : operation;
|
|
1247
|
-
if (userValue === null || typeof userValue === "undefined" || !conditionValues)
|
|
1248
|
-
return false;
|
|
1249
|
-
userValue = String(userValue);
|
|
1250
|
-
if (!Array.isArray(conditionValues))
|
|
1251
|
-
conditionValues = String(conditionValues);
|
|
1252
|
-
switch (operation.trim()) {
|
|
1253
|
-
case "equal":
|
|
1254
|
-
return userValue.toLowerCase().trim() == conditionValues.toLowerCase().trim();
|
|
1255
|
-
case "not equal":
|
|
1256
|
-
return userValue.toLowerCase().trim() != conditionValues.toLowerCase().trim();
|
|
1257
|
-
case "greater":
|
|
1258
|
-
return compareVersions(userValue.trim(), conditionValues.trim());
|
|
1259
|
-
case "less":
|
|
1260
|
-
return compareVersions(conditionValues.trim(), userValue.trim());
|
|
1261
|
-
case "greater equal":
|
|
1262
|
-
return compareVersions(userValue.trim(), conditionValues.trim(), false);
|
|
1263
|
-
case "less equal":
|
|
1264
|
-
return compareVersions(conditionValues.trim(), userValue.trim(), false);
|
|
1265
|
-
case "any of":
|
|
1266
|
-
return conditionValues.includes(userValue);
|
|
1267
|
-
case "none of":
|
|
1268
|
-
return !conditionValues.includes(userValue);
|
|
1269
|
-
case "contains any of":
|
|
1270
|
-
for (let i = 0; i < conditionValues.length; i++) {
|
|
1271
|
-
if (userValue.includes(conditionValues[i])) {
|
|
1272
|
-
return true;
|
|
1273
|
-
}
|
|
1274
|
-
}
|
|
1275
|
-
return false;
|
|
1276
|
-
case "contains none of":
|
|
1277
|
-
for (let i = 0; i < conditionValues.length; i++) {
|
|
1278
|
-
if (userValue.includes(conditionValues[i])) {
|
|
1279
|
-
return false;
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
return true;
|
|
1283
|
-
case "on date":
|
|
1284
|
-
return Math.floor(
|
|
1285
|
-
new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60 * 24)
|
|
1286
|
-
) == this.sigmaUserData.user.date;
|
|
1287
|
-
case "after time":
|
|
1288
|
-
return new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60) < this.sigmaUserData.user.time;
|
|
1289
|
-
case "before time":
|
|
1290
|
-
return new Date(conditionValues.trim()).getTime() / (1e3 * 60 * 60) > this.sigmaUserData.user.time;
|
|
1291
|
-
default:
|
|
1292
|
-
return false;
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
1309
|
getUserParamValue(paramKey, privateFlag = null, isConditionSignForHash = false) {
|
|
1296
1310
|
if (!paramKey)
|
|
1297
1311
|
return false;
|
|
@@ -1385,7 +1399,7 @@ var Sigma = class {
|
|
|
1385
1399
|
this.checkConditionSignForHash(targets.conditions[index].condition_sign)
|
|
1386
1400
|
);
|
|
1387
1401
|
results.push(
|
|
1388
|
-
|
|
1402
|
+
conditionOperation(
|
|
1389
1403
|
userValue,
|
|
1390
1404
|
targets.conditions[index].value,
|
|
1391
1405
|
targets.conditions[index].condition_sign
|
|
@@ -1597,7 +1611,7 @@ var Sigma = class {
|
|
|
1597
1611
|
this.checkConditionSignForHash(conditions[i].condition_sign)
|
|
1598
1612
|
);
|
|
1599
1613
|
results.push(
|
|
1600
|
-
|
|
1614
|
+
conditionOperation(
|
|
1601
1615
|
userValue,
|
|
1602
1616
|
conditions[i].value,
|
|
1603
1617
|
conditions[i].condition_sign
|