Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

generics-storage

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generics-storage

local storage for any implementation or cookie with immutable-helper

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

generics-storage

local storage for any implementation or cookie with immutable-helper update

npm version Coverage Status Build Status

Installation

yarn add immutable-helper generics-storage

or

npm install immutable-helper generics-storage --save

Simple usage

import {GenericsStorage} from 'generics-storage';

const storage = new GenericsStorage(); // default storage is cookie
const query = {$push: [1, 2, "test"]}; // immutable-helper query

storage.update("some-field", query);

storage.getValue("some-field");
// should be an array [1, 2, "test"]

storage.remove("some-field");
// undefined

API

MethodArgument(Type)Return TypeDescription
updatekey: string, query: objectvoidupdate current object or array to key by query
getValuekey: stringobject or ArrayGet value (object or array) from key
removekey: stringvoidClean data of key

Custom your storage (optional)

import * as Cookies from 'js-cookie';
import {Storage, GenericsStorage} from 'generics-storage';

export class CookieStorage implements Storage {
    setItem(key, value) {
        Cookies.set(key, value);
    }

    getItem(key) {
        return Cookies.get(key);
    }

    removeItem(key) {
        Cookies.remove(key);
    }
}

const cookie = new CookieStorage();
export const storage = new GenericsStorage(cookie);

Contributing

npm test

Keywords

FAQs

Package last updated on 17 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc