ng2-webstorage
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -5,2 +5,3 @@ import { SessionStorageService } from './services/index'; | ||
export * from './services/index'; | ||
export * from './helpers/keyStorage'; | ||
export declare const NG2_WEBSTORAGE: typeof SessionStorageService[]; |
@@ -8,2 +8,3 @@ "use strict"; | ||
__export(require('./services/index')); | ||
__export(require('./helpers/keyStorage')); | ||
exports.NG2_WEBSTORAGE = [ | ||
@@ -10,0 +11,0 @@ index_1.SessionStorageService, |
@@ -5,2 +5,3 @@ import { IWebStorage } from '../interfaces/webStorage'; | ||
static genKey(raw: string): string; | ||
static setStorageKeyPrefix(key?: string): void; | ||
} |
"use strict"; | ||
var lib_1 = require('../constants/lib'); | ||
var CUSTOM_LIB_KEY = lib_1.LIB_KEY; | ||
var KeyStorageHelper = (function () { | ||
@@ -7,3 +8,3 @@ function KeyStorageHelper() { | ||
KeyStorageHelper.retrieveKeysFromStorage = function (storage) { | ||
return Object.keys(storage).filter(function (key) { return key.indexOf(lib_1.LIB_KEY) === 0; }); | ||
return Object.keys(storage).filter(function (key) { return key.indexOf(CUSTOM_LIB_KEY) === 0; }); | ||
}; | ||
@@ -13,4 +14,8 @@ KeyStorageHelper.genKey = function (raw) { | ||
throw Error('attempt to generate a storage key with a non string value'); | ||
return lib_1.LIB_KEY + "|" + raw.toString().toLowerCase(); | ||
return CUSTOM_LIB_KEY + "|" + raw.toString().toLowerCase(); | ||
}; | ||
KeyStorageHelper.setStorageKeyPrefix = function (key) { | ||
if (key === void 0) { key = lib_1.LIB_KEY; } | ||
CUSTOM_LIB_KEY = key; | ||
}; | ||
return KeyStorageHelper; | ||
@@ -17,0 +22,0 @@ }()); |
{ | ||
"name": "ng2-webstorage", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "angular2 webstorage manager", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,2 +18,4 @@ # ng2-webstorage | ||
* [@SessionStorage](#d_sessionStorage) | ||
* [Helpers](#helpers): | ||
* [@KeyStorageHelper](#h_keystorage) | ||
* [Modify and build](#modifBuild) | ||
@@ -169,3 +171,3 @@ | ||
import {Component} from '@angular/core'; | ||
import {LocalStorageService, localStorage} from 'ng2-webstorage'; | ||
import {LocalStorageService, LocalStorage} from 'ng2-webstorage'; | ||
@@ -207,3 +209,3 @@ @Component({ | ||
import {Component} from '@angular/core'; | ||
import {LocalStorageService, localStorage} from 'ng2-webstorage'; | ||
import {LocalStorageService, LocalStorage} from 'ng2-webstorage'; | ||
@@ -286,3 +288,22 @@ @Component({ | ||
### <a name="helpers">Helpers</a> | ||
-------------------- | ||
###<a name="h_keystorage">`KeyStorageHelper`</a> | ||
#### setStorageKeyPrefix( key:`string` ):`void` | ||
> set the string used as prefix in the storage's item names | ||
##### Params: | ||
- **key**: String. prefix. | ||
##### Usage: | ||
````typescript | ||
import {KeyStorageHelper} from 'ng2-webstorage'; | ||
KeyStorageHelper.setStorageKeyPrefix('foobar'); | ||
```` | ||
### <a name="modifBuild">Modify and build</a> | ||
@@ -289,0 +310,0 @@ -------------------- |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34335
355
316