ts-storages
v0.2.3
Published
The package for save data to storages in typescript.
Downloads
2
Maintainers
Readme
ts-storages
Installation
$ npm install ts-storages
Interface of item
interface LocalStorageInterface {
current?: string;
previous?: string[]; // Write full name of key (like in localStorage: 0.0{Unicard-Impero360} or [1.0.0]1.1{Unicard-Impero360})
checked?: boolean;
withApplicationName?: boolean;
withUserId?: boolean;
dontCheckVersion?: boolean;
encryption?: EncryptionEnum;
json?: boolean; // default true
}
Example of state
const state = { [key: string]: { [key: string]: LocalStorageInterface } } {
APPLICATION: {
VERSION: {
current: `A.0`, // A - Application
previous: [],
checked: false,
dontCheckVersion: true,
},
PREV_VERSION: {
current: `A.1`, // A - Application
previous: [],
checked: false,
dontCheckVersion: true,
},
},
USER: {
ID: {
current: `U.0`, // U - User
previous: [],
checked: false,
},
TOKEN: {
current: `U.1`, // U - User
previous: [],
checked: false,
encryption: EncryptionEnum.BASE64,
},
},
};
Examples
LocalStorage.setApplicationName(applicationName);
LocalStorage.applicationName;
LocalStorage.applicationVersion;
LocalStorage.userId;
LocalStorage.prevVersionList;
LocalStorage.deleteUserData();
LocalStorage.deleteApplicationData();
LocalStorage.get(state.USER.TOKEN);
LocalStorage.set(state.USER.TOKEN, $veriable);
LocalStorage.remove(state.USER.TOKEN);