Skip to content

Commit 70cebe1

Browse files
committed
Renamed context attribute name to match effect (freeze)
1 parent 1b95deb commit 70cebe1

File tree

9 files changed

+20
-22
lines changed

9 files changed

+20
-22
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ You can also activate features such as local and silent mode:
6060

6161
```js
6262
const local = true;
63-
const static = true;
63+
const freeze = true;
6464
const logger = true;
6565
const snapshotLocation = './snapshot/';
6666
const snapshotAutoUpdateInterval = 3;
@@ -70,15 +70,15 @@ const restrictRelay = true;
7070
const certPath = './certs/ca.pem';
7171

7272
Client.buildContext({ url, apiKey, domain, component, environment }, {
73-
local, static, logger, snapshotLocation, snapshotAutoUpdateInterval,
73+
local, freeze, logger, snapshotLocation, snapshotAutoUpdateInterval,
7474
snapshotWatcher, silentMode, restrictRelay, certPath
7575
});
7676

7777
const switcher = Client.getSwitcher();
7878
```
7979

8080
- **local**: If activated, the client will only fetch the configuration inside your snapshot file. The default value is 'false'
81-
- **static**: If activated, the client will not perform any API calls and will only use the in-memory snapshot. The default value is 'false'
81+
- **freeze**: If activated, prevents the execution of background cache update when using throttle. The default value is 'false'
8282
- **logger**: If activated, it is possible to retrieve the last results from a given Switcher key using Client.getLogger('KEY')
8383
- **snapshotLocation**: Location of snapshot files
8484
- **snapshotAutoUpdateInterval**: Enable Snapshot Auto Update given an interval in seconds (default: 0 disabled)

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "switcher-client",
3-
"version": "4.4.0",
3+
"version": "4.4.1",
44
"description": "Client JS SDK for working with Switcher-API",
55
"main": "./switcher-client.js",
66
"type": "module",
@@ -32,10 +32,10 @@
3232
],
3333
"devDependencies": {
3434
"@babel/eslint-parser": "^7.28.0",
35-
"@typescript-eslint/eslint-plugin": "^8.35.1",
36-
"@typescript-eslint/parser": "^8.35.1",
35+
"@typescript-eslint/eslint-plugin": "^8.36.0",
36+
"@typescript-eslint/parser": "^8.36.0",
3737
"c8": "^10.1.3",
38-
"chai": "^5.2.0",
38+
"chai": "^5.2.1",
3939
"env-cmd": "^10.1.0",
4040
"eslint": "^9.30.1",
4141
"mocha": "^11.7.1",

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
sonar.projectKey=switcherapi_switcher-client-master
22
sonar.projectName=switcher-client-js
33
sonar.organization=switcherapi
4-
sonar.projectVersion=4.4.0
4+
sonar.projectVersion=4.4.1
55
sonar.links.homepage=https://github.com/switcherapi/switcher-client-js
66

77
sonar.javascript.lcov.reportPaths=coverage/lcov.info

src/client.d.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export type LoggerRecord = {
150150
}
151151

152152
/**
153-
* SwitcherContext is required to build the context to communicate with the API.
153+
* SwitcherContext is required to build the context to communicate with the API
154154
*/
155155
export type SwitcherContext = {
156156
/**
@@ -180,7 +180,7 @@ export type SwitcherContext = {
180180
}
181181

182182
/**
183-
* SwitcherOptions is optional to build the context to communicate with the API.
183+
* SwitcherOptions is optional to build the context to communicate with the API
184184
*/
185185
export type SwitcherOptions = {
186186
/**
@@ -191,13 +191,11 @@ export type SwitcherOptions = {
191191
local?: boolean;
192192

193193
/**
194-
* When enabled it will always use in-memory cached results
195-
*
196-
* This option prevents the scheduling of background updates to improve overall performance
194+
* This option prevents the execution of background cache update when using throttle
197195
*
198196
* Use Client.clearLogger() to reset the in-memory cache if snapshot are renewed
199197
*/
200-
static?: boolean;
198+
freeze?: boolean;
201199

202200
/**
203201
* When enabled it allows inspecting the result details with Client.getLogger(key)

src/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
DEFAULT_LOGGER,
1010
DEFAULT_REGEX_MAX_BLACKLISTED,
1111
DEFAULT_REGEX_MAX_TIME_LIMIT,
12-
DEFAULT_STATIC,
12+
DEFAULT_FREEZE,
1313
DEFAULT_TEST_MODE,
1414
SWITCHER_OPTIONS
1515
} from './lib/constants.js';
@@ -40,7 +40,7 @@ export class Client {
4040
snapshotAutoUpdateInterval: 0,
4141
snapshotLocation: options?.snapshotLocation,
4242
local: util.get(options?.local, DEFAULT_LOCAL),
43-
static: util.get(options?.static, DEFAULT_STATIC),
43+
freeze: util.get(options?.freeze, DEFAULT_FREEZE),
4444
logger: util.get(options?.logger, DEFAULT_LOGGER)
4545
});
4646

src/lib/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const DEFAULT_ENVIRONMENT = 'default';
22
export const DEFAULT_LOCAL = false;
3-
export const DEFAULT_STATIC = false;
3+
export const DEFAULT_FREEZE = false;
44
export const DEFAULT_LOGGER = false;
55
export const DEFAULT_TEST_MODE = false;
66
export const DEFAULT_REGEX_MAX_BLACKLISTED = 50;

src/lib/globals/globalOptions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export class GlobalOptions {
1818
return this.#options.local;
1919
}
2020

21-
static get static() {
22-
return this.#options.static;
21+
static get freeze() {
22+
return this.#options.freeze;
2323
}
2424

2525
static get logger() {

src/switcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export class Switcher extends SwitcherRequest {
168168

169169
#tryCachedResult() {
170170
if (this.#hasThrottle()) {
171-
if (!GlobalOptions.static) {
171+
if (!GlobalOptions.freeze) {
172172
this.scheduleBackgroundRefresh();
173173
}
174174

tests/switcher-client.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,12 @@ describe('E2E test - Client local from cache:', function () {
340340
assert.deepEqual(result.metadata || {}, {});
341341
});
342342

343-
it('should get response from cache when static mode is enabled', async function () {
343+
it('should get response from cache when freeze mode is enabled', async function () {
344344
// given
345345
Client.buildContext(contextSettings, {
346346
snapshotLocation: options.snapshotLocation,
347347
local: true,
348-
static: true
348+
freeze: true
349349
});
350350

351351
await Client.loadSnapshot();

0 commit comments

Comments
 (0)