• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SAP / feature-toggle-node / 891991c4-7a14-4989-ac56-e39cc2abe6fb

10 Mar 2025 12:40PM UTC coverage: 100.0%. Remained the same
891991c4-7a14-4989-ac56-e39cc2abe6fb

Pull #244

circleci

i053322
docs:  update chanelog 2.0.3
Pull Request #244: docs: update chanelog 2.0.3

53 of 53 branches covered (100.0%)

Branch coverage included in aggregate %.

106 of 106 relevant lines covered (100.0%)

3.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/strategies.ts
1
import { ContextData, createContextEntity } from "./current_context";
1✔
2
import { convertPluralNameToSingular } from "./utils";
1✔
3
import { Toggle } from "./client";
4

5
export interface IterateableContext extends ContextData {
6
  [key: string]: string;
7
}
8

9
enum ParametersNames {
1✔
10
  environments = "environments",
1✔
11
  infrastructures = "infrastructures",
1✔
12
  landscapes = "landscapes",
1✔
13
  subaccounts = "subaccounts",
1✔
14
  users = "users",
1✔
15
  wss = "wss",
1✔
16
  tenantids = "tenantids",
1✔
17
}
18

19
/*
20
 * isMatchStrategies iterates over parameters in ParametersNames enum
21
 * takes value by parameter name of toggle and parameter from currentContext
22
 * return true if any of currentContext parameter presented in toggle
23
 * */
24
export function isMatchStrategies(toggle: Toggle): boolean {
1✔
25
  const currentContext: IterateableContext = createContextEntity();
8✔
26
  if (currentContext) {
8✔
27
    for (const parameterName of Object.values(ParametersNames)) {
7✔
28
      const parameterValue = toggle[parameterName];
34✔
29

30
      const singularParamName = convertPluralNameToSingular(parameterName);
34✔
31
      const currentContextParamValue = currentContext[singularParamName];
34✔
32

33
      if (currentContextParamValue && parameterValue?.length && parameterValue.includes(currentContextParamValue)) {
34✔
34
        return true;
3✔
35
      }
36
    }
37
  }
38

39
  return false;
5✔
40
}
41

42
export function isToggleEnabled(toggle: Toggle): boolean {
1✔
43
  return !toggle.disabled && toggle.strategies ? isMatchStrategies(toggle) : !toggle.disabled;
7✔
44
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc