Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianoSanchez committed Nov 28, 2023
1 parent 89e980b commit f61b65a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"build": "npm run build:cjs && npm run build:esm",
"build:esm": "rimraf esm && tsc -m es2015 --outDir esm -d true --declarationDir types",
"build:cjs": "rimraf cjs && tsc -m CommonJS --outDir cjs",
"test": "jest --runInBand",
"test": "jest",
"test:coverage": "jest --coverage",
"all": "npm run check && npm run build && npm run test",
"publish:rc": "npm run check && npm run test && npm run build && npm publish --tag rc",
Expand Down
9 changes: 4 additions & 5 deletions src/storages/inLocalStorage/SplitsCacheInLocal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
getNamesByFlagSets(flagSets: string[]): ISet<string>[] {
return flagSets.map(flagSet => {
const flagSetKey = this.keys.buildFlagSetKey(flagSet);
let flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
const flagSetFromLocalStorage = localStorage.getItem(flagSetKey);

return new _Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
});
Expand All @@ -275,10 +275,9 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {

const flagSetKey = this.keys.buildFlagSetKey(featureFlagSet);

let flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
if (!flagSetFromLocalStorage) flagSetFromLocalStorage = '[]';
const flagSetFromLocalStorage = localStorage.getItem(flagSetKey);

const flagSetCache = new _Set(JSON.parse(flagSetFromLocalStorage));
const flagSetCache = new _Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
flagSetCache.add(featureFlag.name);

localStorage.setItem(flagSetKey, JSON.stringify(setToArray(flagSetCache)));
Expand All @@ -296,7 +295,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
private removeNames(flagSetName: string, featureFlagName: string) {
const flagSetKey = this.keys.buildFlagSetKey(flagSetName);

let flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
const flagSetFromLocalStorage = localStorage.getItem(flagSetKey);

if (!flagSetFromLocalStorage) return;

Expand Down

0 comments on commit f61b65a

Please sign in to comment.