Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilianoSanchez committed Oct 1, 2024
1 parent 5f865f3 commit 6ab2bc8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-commons",
"version": "1.17.1-rc.1",
"version": "1.17.1-rc.2",
"description": "Split JavaScript SDK common components",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down
4 changes: 1 addition & 3 deletions src/storages/__tests__/dataLoader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ test('loadData & getSnapshot', () => {
expect(dataLoader.getSnapshot(clientStorage, [fullSettings.core.key as string])).toEqual(preloadedData);
expect(preloadedData).toEqual({
since: 123,
splitsData: {
split1: { name: 'split1' }
},
splitsData: [{ name: 'split1' }],
mySegmentsData: { [fullSettings.core.key as string]: ['segment1'] },
segmentsData: undefined
});
Expand Down
8 changes: 4 additions & 4 deletions src/storages/dataLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function loadData(preloadedData: SplitIO.PreloadedData, storage: { splits
// Do not load data if current preloadedData is empty
if (Object.keys(preloadedData).length === 0) return;

const { segmentsData = {}, since = -1, splitsData = {} } = preloadedData;
const { segmentsData = {}, since = -1, splitsData = [] } = preloadedData;

if (storage.splits) {
const storedSince = storage.splits.getChangeNumber();
Expand All @@ -32,7 +32,7 @@ export function loadData(preloadedData: SplitIO.PreloadedData, storage: { splits
storage.splits.setChangeNumber(since);

// splitsData in an object where the property is the split name and the pertaining value is a stringified json of its data
storage.splits.addSplits(Object.keys(splitsData).map(splitName => ([splitName, splitsData[splitName]])));
storage.splits.addSplits(splitsData.map(split => ([split.name, split])));
}

if (userKey) { // add mySegments data (client-side)
Expand All @@ -57,8 +57,8 @@ export function getSnapshot(storage: IStorageSync, userKeys?: string[]): SplitIO
return {
// lastUpdated: Date.now(),
// @ts-ignore accessing private prop
since: storage.splits.changeNumber, // @ts-ignore accessing private prop
splitsData: storage.splits.splitsCache,
since: storage.splits.changeNumber,
splitsData: storage.splits.getAll(),
segmentsData: userKeys ?
undefined : // @ts-ignore accessing private prop
Object.keys(storage.segments.segmentCache).reduce((prev, cur) => { // @ts-ignore accessing private prop
Expand Down
6 changes: 2 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,12 +779,10 @@ export namespace SplitIO {
*/
since: number,
/**
* Map of feature flags to their stringified definitions.
* List of feature flag definitions.
* @TODO rename to flags
*/
splitsData: {
[splitName: string]: ISplit
},
splitsData: ISplit[],
/**
* Optional map of user keys to their list of segments.
* @TODO rename to memberships
Expand Down

0 comments on commit 6ab2bc8

Please sign in to comment.