ngrx-store-localstorage
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -68,3 +68,7 @@ "use strict"; | ||
} | ||
var raw = JSON.parse(stateSlice, reviver); | ||
var isObjectRegex = new RegExp('\{|\\['); | ||
var raw = stateSlice; | ||
if (isObjectRegex.test(stateSlice.charAt(0))) { | ||
raw = JSON.parse(stateSlice, reviver); | ||
} | ||
return Object.assign({}, acc, (_a = {}, _a[key] = deserialize ? deserialize(raw) : raw, _a)); | ||
@@ -71,0 +75,0 @@ } |
{ | ||
"name": "ngrx-store-localstorage", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "State and local storage syncing for @ngrx/store", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -18,3 +18,3 @@ # ngrx-store-localstorage | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { StoreModule, ActionReducerMap, ActionReducer } from '@ngrx/store'; | ||
import { StoreModule, ActionReducerMap, ActionReducer, MetaReducer } from '@ngrx/store'; | ||
import { localStorageSync } from 'ngrx-store-localstorage'; | ||
@@ -29,3 +29,3 @@ import { reducers } from './reducers'; | ||
} | ||
const metaReducers: Array<ActionReducer<any, any>> = [localStorageSyncReducer]; | ||
const metaReducers: Array<MetaReducer<any, any>> = [localStorageSyncReducer]; | ||
@@ -32,0 +32,0 @@ @NgModule({ |
@@ -109,2 +109,5 @@ declare var beforeEachProviders, it, describe, expect, inject; | ||
const primitiveStr = 'string is not an object'; | ||
const initialStatePrimitiveStr = { state: primitiveStr }; | ||
it('simple', () => { | ||
@@ -130,2 +133,15 @@ // This tests a very simple state object syncing to mock Storage | ||
it('simple string', () => { | ||
const s = new MockStorage(); | ||
const skr = mockStorageKeySerializer; | ||
syncStateUpdate(initialStatePrimitiveStr, ['state'], s, skr, false); | ||
const raw = s.getItem('state'); | ||
expect(raw).toEqual(primitiveStr); | ||
const finalState: any = rehydrateApplicationState(['state'], s, skr); | ||
expect(finalState.state).toEqual(primitiveStr); | ||
}); | ||
it('filtered', () => { | ||
@@ -132,0 +148,0 @@ // Use the filter by field option to round-trip an object while |
@@ -73,3 +73,10 @@ const INIT_ACTION = '@ngrx/store/init'; | ||
} | ||
let raw = JSON.parse(stateSlice, reviver); | ||
const isObjectRegex = new RegExp('\{|\\['); | ||
let raw = stateSlice; | ||
if (isObjectRegex.test(stateSlice.charAt(0))) { | ||
raw = JSON.parse(stateSlice, reviver); | ||
} | ||
return Object.assign({}, acc, { [key]: deserialize ? deserialize(raw) : raw }); | ||
@@ -76,0 +83,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51849
776