GithubHelp home page GithubHelp logo

ls-manager's Introduction

ls-manager

ls stands for LocalStorage. It allows you to simply get and set objects, arrays etc. directly into the window.localStorage, without worrying about parsing / stringifying data.

How to use

"Simple" use (basic JSON encoding)

import lsManager from '@kebab-case/ls-manager'

const ls = lsManager()

const key = 'tralala'
const value = {a: 'tsoin-tsoin'}

ls.setItem(key, value)

let otherValue = ls.getItem(key)

// will display: Object { a: "tsoin-tsoin" } Object { a: "tsoin-tsoin" }
console.log(value, otherValue)

ls.update(key, {'testUpdate': 'tralala'})
otherValue = ls.getItem(key)

// will display: Object { a: "tsoin-tsoin", testUpdate: "tralala" }
console.log(otherValue)

N.B.: ls-manager also supports require syntax (which doesn't help since you don't have access to window with node).

Use your very own encoder / decoder

const ls = lsManager({
    parsingFunction: (string) => {
        // return parsed string
    },
    stringifyingFunction: (any) => {
        // return stringified any
    }
})

Well... that is all folks!


Powered by @kebab-case/npm-simple-publisher

This package has been brought to you by npm-simple-publisher

This little nodejs command-line script allows you to easily compile and publish node and es6 compliant code packages to npm. Init your project with minimal babel configuration for es6, compile to cjs and publish to npm with only two commands.

Try it now:

sudo apt install yarn
sudo npm install -g @kebab-case/npm-simple-publisher
mkdir my_project
cd my_project
# getting help about command
kc-nsp -h # list of command modules
kc-nsp init -h # and so on
# getting started
kc-nsp init -f # create project 
# ... do things in my_project/src, using proposed build or your own (not npm-friendly)
kc-nsp publish -t M|m|r # publish new Major / minor version or revision

Basically, that's all!

Find on npm: https://www.npmjs.com/package/@kebab-case/npm-simple-publisher

ls-manager's People

Contributors

flazzarotto avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.