Changed syntax in hope of IE fix
This commit is contained in:
parent
db4784520b
commit
3262a76cfd
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "webstorage-decorators",
|
"name": "webstorage-decorators",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"description": "Decorators to sync variable to Local/Session storage",
|
"description": "Decorators to sync variable to Local/Session storage",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"typings": "./lib/index.d.ts",
|
"typings": "./lib/index.d.ts",
|
||||||
|
@ -6,15 +6,17 @@ export interface WebStorageOptions {
|
|||||||
defaultValue?: any;
|
defaultValue?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LocalStorage(opts: WebStorageOptions = {}) {
|
export function LocalStorage(opts: WebStorageOptions) {
|
||||||
|
if(!opts) opts = {};
|
||||||
return storage(localStorage, opts);
|
return storage(localStorage, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SessionStorage(opts: WebStorageOptions = {}) {
|
export function SessionStorage(opts: WebStorageOptions) {
|
||||||
|
if(!opts) opts = {};
|
||||||
return storage(sessionStorage, opts);
|
return storage(sessionStorage, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
function storage(storageType: Storage, opts: WebStorageOptions = {}) {
|
function storage(storageType: Storage, opts: WebStorageOptions) {
|
||||||
return function(target: object, key: string) {
|
return function(target: object, key: string) {
|
||||||
if(!opts.fieldName) opts.fieldName = key;
|
if(!opts.fieldName) opts.fieldName = key;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user