ts-storages
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

ts-storages

NPM Latest Version Downloads Count Bundle Size Test Status Last Update Date Project License

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);

My Social Network Links

Twitter Profile

LinkedIn Profile

GitHub Profile

medium.com Profile

Package Sidebar

Install

npm i ts-storages

Weekly Downloads

0

Version

0.2.3

License

MIT

Unpacked Size

22.5 kB

Total Files

12

Last publish

Collaborators

  • karbash