@splitsoftware/splitio-commons 1.17.1-rc.5 → 1.17.2-rc.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.
@@ -95,9 +95,8 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
95
95
  localStorage.setItem(splitKey, JSON.stringify(split));
96
96
  this._incrementCounts(split);
97
97
  this._decrementCounts(previousSplit);
98
- if (previousSplit)
99
- this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
100
- this.addToFlagSets(split);
98
+ // if (previousSplit) this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
99
+ // this.addToFlagSets(split);
101
100
  return true;
102
101
  }
103
102
  catch (e) {
@@ -110,8 +109,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
110
109
  var split = this.getSplit(name);
111
110
  localStorage.removeItem(this.keys.buildSplitKey(name));
112
111
  this._decrementCounts(split);
113
- if (split)
114
- this.removeFromFlagSets(split.name, split.sets);
112
+ // if (split) this.removeFromFlagSets(split.name, split.sets);
115
113
  return true;
116
114
  }
117
115
  catch (e) {
@@ -233,41 +231,6 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
233
231
  return new sets_1._Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
234
232
  });
235
233
  };
236
- SplitsCacheInLocal.prototype.addToFlagSets = function (featureFlag) {
237
- var _this = this;
238
- if (!featureFlag.sets)
239
- return;
240
- featureFlag.sets.forEach(function (featureFlagSet) {
241
- if (_this.flagSetsFilter.length > 0 && !_this.flagSetsFilter.some(function (filterFlagSet) { return filterFlagSet === featureFlagSet; }))
242
- return;
243
- var flagSetKey = _this.keys.buildFlagSetKey(featureFlagSet);
244
- var flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
245
- var flagSetCache = new sets_1._Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
246
- flagSetCache.add(featureFlag.name);
247
- localStorage.setItem(flagSetKey, JSON.stringify((0, sets_1.setToArray)(flagSetCache)));
248
- });
249
- };
250
- SplitsCacheInLocal.prototype.removeFromFlagSets = function (featureFlagName, flagSets) {
251
- var _this = this;
252
- if (!flagSets)
253
- return;
254
- flagSets.forEach(function (flagSet) {
255
- _this.removeNames(flagSet, featureFlagName);
256
- });
257
- };
258
- SplitsCacheInLocal.prototype.removeNames = function (flagSetName, featureFlagName) {
259
- var flagSetKey = this.keys.buildFlagSetKey(flagSetName);
260
- var flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
261
- if (!flagSetFromLocalStorage)
262
- return;
263
- var flagSetCache = new sets_1._Set(JSON.parse(flagSetFromLocalStorage));
264
- flagSetCache.delete(featureFlagName);
265
- if (flagSetCache.size === 0) {
266
- localStorage.removeItem(flagSetKey);
267
- return;
268
- }
269
- localStorage.setItem(flagSetKey, JSON.stringify((0, sets_1.setToArray)(flagSetCache)));
270
- };
271
234
  return SplitsCacheInLocal;
272
235
  }(AbstractSplitsCacheSync_1.AbstractSplitsCacheSync));
273
236
  exports.SplitsCacheInLocal = SplitsCacheInLocal;
@@ -2,7 +2,7 @@ import { __extends } from "tslib";
2
2
  import { AbstractSplitsCacheSync, usesSegments } from '../AbstractSplitsCacheSync';
3
3
  import { isFiniteNumber, toNumber, isNaNNumber } from '../../utils/lang';
4
4
  import { LOG_PREFIX } from './constants';
5
- import { _Set, setToArray } from '../../utils/lang/sets';
5
+ import { _Set } from '../../utils/lang/sets';
6
6
  import { getStorageHash } from '../KeyBuilder';
7
7
  /**
8
8
  * ISplitsCacheSync implementation that stores split definitions in browser LocalStorage.
@@ -92,9 +92,8 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
92
92
  localStorage.setItem(splitKey, JSON.stringify(split));
93
93
  this._incrementCounts(split);
94
94
  this._decrementCounts(previousSplit);
95
- if (previousSplit)
96
- this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
97
- this.addToFlagSets(split);
95
+ // if (previousSplit) this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
96
+ // this.addToFlagSets(split);
98
97
  return true;
99
98
  }
100
99
  catch (e) {
@@ -107,8 +106,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
107
106
  var split = this.getSplit(name);
108
107
  localStorage.removeItem(this.keys.buildSplitKey(name));
109
108
  this._decrementCounts(split);
110
- if (split)
111
- this.removeFromFlagSets(split.name, split.sets);
109
+ // if (split) this.removeFromFlagSets(split.name, split.sets);
112
110
  return true;
113
111
  }
114
112
  catch (e) {
@@ -230,41 +228,6 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
230
228
  return new _Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
231
229
  });
232
230
  };
233
- SplitsCacheInLocal.prototype.addToFlagSets = function (featureFlag) {
234
- var _this = this;
235
- if (!featureFlag.sets)
236
- return;
237
- featureFlag.sets.forEach(function (featureFlagSet) {
238
- if (_this.flagSetsFilter.length > 0 && !_this.flagSetsFilter.some(function (filterFlagSet) { return filterFlagSet === featureFlagSet; }))
239
- return;
240
- var flagSetKey = _this.keys.buildFlagSetKey(featureFlagSet);
241
- var flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
242
- var flagSetCache = new _Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
243
- flagSetCache.add(featureFlag.name);
244
- localStorage.setItem(flagSetKey, JSON.stringify(setToArray(flagSetCache)));
245
- });
246
- };
247
- SplitsCacheInLocal.prototype.removeFromFlagSets = function (featureFlagName, flagSets) {
248
- var _this = this;
249
- if (!flagSets)
250
- return;
251
- flagSets.forEach(function (flagSet) {
252
- _this.removeNames(flagSet, featureFlagName);
253
- });
254
- };
255
- SplitsCacheInLocal.prototype.removeNames = function (flagSetName, featureFlagName) {
256
- var flagSetKey = this.keys.buildFlagSetKey(flagSetName);
257
- var flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
258
- if (!flagSetFromLocalStorage)
259
- return;
260
- var flagSetCache = new _Set(JSON.parse(flagSetFromLocalStorage));
261
- flagSetCache.delete(featureFlagName);
262
- if (flagSetCache.size === 0) {
263
- localStorage.removeItem(flagSetKey);
264
- return;
265
- }
266
- localStorage.setItem(flagSetKey, JSON.stringify(setToArray(flagSetCache)));
267
- };
268
231
  return SplitsCacheInLocal;
269
232
  }(AbstractSplitsCacheSync));
270
233
  export { SplitsCacheInLocal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.17.1-rc.5",
3
+ "version": "1.17.2-rc.0",
4
4
  "description": "Split JavaScript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -26,7 +26,7 @@
26
26
  "test:coverage": "jest --coverage",
27
27
  "all": "npm run check && npm run build && npm run test",
28
28
  "publish:rc": "npm run check && npm run test && npm run build && npm publish --tag rc",
29
- "publish:stable": "npm run check && npm run test && npm run build && npm publish"
29
+ "publish:stable": "npm run check && npm run test && npm run build && npm publish --tag release-1.x"
30
30
  },
31
31
  "repository": {
32
32
  "type": "git",
@@ -4,7 +4,7 @@ import { isFiniteNumber, toNumber, isNaNNumber } from '../../utils/lang';
4
4
  import { KeyBuilderCS } from '../KeyBuilderCS';
5
5
  import { ILogger } from '../../logger/types';
6
6
  import { LOG_PREFIX } from './constants';
7
- import { ISet, _Set, setToArray } from '../../utils/lang/sets';
7
+ import { ISet, _Set } from '../../utils/lang/sets';
8
8
  import { ISettings } from '../../types';
9
9
  import { getStorageHash } from '../KeyBuilder';
10
10
 
@@ -112,8 +112,8 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
112
112
  this._incrementCounts(split);
113
113
  this._decrementCounts(previousSplit);
114
114
 
115
- if (previousSplit) this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
116
- this.addToFlagSets(split);
115
+ // if (previousSplit) this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
116
+ // this.addToFlagSets(split);
117
117
 
118
118
  return true;
119
119
  } catch (e) {
@@ -128,7 +128,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
128
128
  localStorage.removeItem(this.keys.buildSplitKey(name));
129
129
 
130
130
  this._decrementCounts(split);
131
- if (split) this.removeFromFlagSets(split.name, split.sets);
131
+ // if (split) this.removeFromFlagSets(split.name, split.sets);
132
132
 
133
133
  return true;
134
134
  } catch (e) {
@@ -268,48 +268,48 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
268
268
  });
269
269
  }
270
270
 
271
- private addToFlagSets(featureFlag: ISplit) {
272
- if (!featureFlag.sets) return;
271
+ // private addToFlagSets(featureFlag: ISplit) {
272
+ // if (!featureFlag.sets) return;
273
273
 
274
- featureFlag.sets.forEach(featureFlagSet => {
274
+ // featureFlag.sets.forEach(featureFlagSet => {
275
275
 
276
- if (this.flagSetsFilter.length > 0 && !this.flagSetsFilter.some(filterFlagSet => filterFlagSet === featureFlagSet)) return;
276
+ // if (this.flagSetsFilter.length > 0 && !this.flagSetsFilter.some(filterFlagSet => filterFlagSet === featureFlagSet)) return;
277
277
 
278
- const flagSetKey = this.keys.buildFlagSetKey(featureFlagSet);
278
+ // const flagSetKey = this.keys.buildFlagSetKey(featureFlagSet);
279
279
 
280
- const flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
280
+ // const flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
281
281
 
282
- const flagSetCache = new _Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
283
- flagSetCache.add(featureFlag.name);
282
+ // const flagSetCache = new _Set(flagSetFromLocalStorage ? JSON.parse(flagSetFromLocalStorage) : []);
283
+ // flagSetCache.add(featureFlag.name);
284
284
 
285
- localStorage.setItem(flagSetKey, JSON.stringify(setToArray(flagSetCache)));
286
- });
287
- }
285
+ // localStorage.setItem(flagSetKey, JSON.stringify(setToArray(flagSetCache)));
286
+ // });
287
+ // }
288
288
 
289
- private removeFromFlagSets(featureFlagName: string, flagSets?: string[]) {
290
- if (!flagSets) return;
289
+ // private removeFromFlagSets(featureFlagName: string, flagSets?: string[]) {
290
+ // if (!flagSets) return;
291
291
 
292
- flagSets.forEach(flagSet => {
293
- this.removeNames(flagSet, featureFlagName);
294
- });
295
- }
292
+ // flagSets.forEach(flagSet => {
293
+ // this.removeNames(flagSet, featureFlagName);
294
+ // });
295
+ // }
296
296
 
297
- private removeNames(flagSetName: string, featureFlagName: string) {
298
- const flagSetKey = this.keys.buildFlagSetKey(flagSetName);
297
+ // private removeNames(flagSetName: string, featureFlagName: string) {
298
+ // const flagSetKey = this.keys.buildFlagSetKey(flagSetName);
299
299
 
300
- const flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
300
+ // const flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
301
301
 
302
- if (!flagSetFromLocalStorage) return;
302
+ // if (!flagSetFromLocalStorage) return;
303
303
 
304
- const flagSetCache = new _Set(JSON.parse(flagSetFromLocalStorage));
305
- flagSetCache.delete(featureFlagName);
304
+ // const flagSetCache = new _Set(JSON.parse(flagSetFromLocalStorage));
305
+ // flagSetCache.delete(featureFlagName);
306
306
 
307
- if (flagSetCache.size === 0) {
308
- localStorage.removeItem(flagSetKey);
309
- return;
310
- }
307
+ // if (flagSetCache.size === 0) {
308
+ // localStorage.removeItem(flagSetKey);
309
+ // return;
310
+ // }
311
311
 
312
- localStorage.setItem(flagSetKey, JSON.stringify(setToArray(flagSetCache)));
313
- }
312
+ // localStorage.setItem(flagSetKey, JSON.stringify(setToArray(flagSetCache)));
313
+ // }
314
314
 
315
315
  }
@@ -49,7 +49,4 @@ export declare class SplitsCacheInLocal extends AbstractSplitsCacheSync {
49
49
  private _checkExpiration;
50
50
  private _checkFilterQuery;
51
51
  getNamesByFlagSets(flagSets: string[]): ISet<string>[];
52
- private addToFlagSets;
53
- private removeFromFlagSets;
54
- private removeNames;
55
52
  }