@featurevisor/sdk 0.35.0 → 0.37.0
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/CHANGELOG.md +19 -0
- package/README.md +14 -14
- package/coverage/clover.xml +224 -224
- package/coverage/coverage-final.json +4 -4
- package/coverage/lcov-report/bucket.ts.html +1 -1
- package/coverage/lcov-report/conditions.ts.html +38 -38
- package/coverage/lcov-report/datafileReader.ts.html +1 -1
- package/coverage/lcov-report/emitter.ts.html +1 -1
- package/coverage/lcov-report/feature.ts.html +7 -7
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/instance.ts.html +74 -113
- package/coverage/lcov-report/logger.ts.html +1 -1
- package/coverage/lcov-report/segments.ts.html +10 -10
- package/coverage/lcov.info +391 -391
- package/dist/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/lib/conditions.d.ts +3 -3
- package/lib/conditions.js +35 -35
- package/lib/conditions.js.map +1 -1
- package/lib/feature.d.ts +3 -3
- package/lib/feature.js +5 -5
- package/lib/feature.js.map +1 -1
- package/lib/instance.d.ts +27 -26
- package/lib/instance.js +80 -86
- package/lib/instance.js.map +1 -1
- package/lib/segments.d.ts +3 -3
- package/lib/segments.js +8 -8
- package/lib/segments.js.map +1 -1
- package/package.json +3 -3
- package/src/conditions.ts +37 -37
- package/src/feature.ts +6 -6
- package/src/instance.spec.ts +6 -6
- package/src/instance.ts +70 -83
- package/src/segments.ts +9 -9
package/src/segments.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Context, GroupSegment, Segment, Condition } from "@featurevisor/types";
|
|
2
2
|
import { allConditionsAreMatched } from "./conditions";
|
|
3
3
|
import { DatafileReader } from "./datafileReader";
|
|
4
4
|
|
|
5
|
-
export function segmentIsMatched(segment: Segment,
|
|
6
|
-
return allConditionsAreMatched(segment.conditions as Condition | Condition[],
|
|
5
|
+
export function segmentIsMatched(segment: Segment, context: Context): boolean {
|
|
6
|
+
return allConditionsAreMatched(segment.conditions as Condition | Condition[], context);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function allGroupSegmentsAreMatched(
|
|
10
10
|
groupSegments: GroupSegment | GroupSegment[] | "*",
|
|
11
|
-
|
|
11
|
+
context: Context,
|
|
12
12
|
datafileReader: DatafileReader,
|
|
13
13
|
): boolean {
|
|
14
14
|
if (groupSegments === "*") {
|
|
@@ -19,7 +19,7 @@ export function allGroupSegmentsAreMatched(
|
|
|
19
19
|
const segment = datafileReader.getSegment(groupSegments);
|
|
20
20
|
|
|
21
21
|
if (segment) {
|
|
22
|
-
return segmentIsMatched(segment,
|
|
22
|
+
return segmentIsMatched(segment, context);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
return false;
|
|
@@ -28,27 +28,27 @@ export function allGroupSegmentsAreMatched(
|
|
|
28
28
|
if (typeof groupSegments === "object") {
|
|
29
29
|
if ("and" in groupSegments && Array.isArray(groupSegments.and)) {
|
|
30
30
|
return groupSegments.and.every((groupSegment) =>
|
|
31
|
-
allGroupSegmentsAreMatched(groupSegment,
|
|
31
|
+
allGroupSegmentsAreMatched(groupSegment, context, datafileReader),
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
if ("or" in groupSegments && Array.isArray(groupSegments.or)) {
|
|
36
36
|
return groupSegments.or.some((groupSegment) =>
|
|
37
|
-
allGroupSegmentsAreMatched(groupSegment,
|
|
37
|
+
allGroupSegmentsAreMatched(groupSegment, context, datafileReader),
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if ("not" in groupSegments && Array.isArray(groupSegments.not)) {
|
|
42
42
|
return groupSegments.not.every(
|
|
43
43
|
(groupSegment) =>
|
|
44
|
-
allGroupSegmentsAreMatched(groupSegment,
|
|
44
|
+
allGroupSegmentsAreMatched(groupSegment, context, datafileReader) === false,
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (Array.isArray(groupSegments)) {
|
|
50
50
|
return groupSegments.every((groupSegment) =>
|
|
51
|
-
allGroupSegmentsAreMatched(groupSegment,
|
|
51
|
+
allGroupSegmentsAreMatched(groupSegment, context, datafileReader),
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
|