Local Storage Programming Interface
Basic ORM for local storage that can save you time!
Super easy to use!
Store and retrieve valid JSON objects/arrays or simple strings 😄
Make sure to use polyfills for Array.from
and Object.assign
when bundling your application code! 🎉
Install
npm install lspi --save
Basics
const lspi = ; //= set string ->lspi;// Returns: undefined// Stores: "testing" //= get string ->lspi;// Returns: "testOne" //= set object literal ->lspi;// Returns: undefined// Stores: "{}" //= get object literal ->lspi;// Returns: {} //= set array ->lspi;// Returns: undefined// Stores: "[]" //= get array ->lspi;// Returns: [] //= set array of objects ->lspi;// Returns: undefined// Stores: "{"name": "test2"}" //= where query on array of objects ->lspi;// Returns: [{ name: 'test2' }] //= update state ->lspi; lspi;// Returns: undefined// Adds ok key and 'new stuff' value to the 'testOne' record lspi;// Returns: undefined// Updates hey value to 'hello' instead of 'hi' //= remove data (singular) ->lspi;// Returns: undefined// This will delete the 'testOne' record from localStorage //= remove all data ->lspi;// Returns: undefined// Drops ALL localStorage associated to your domain //= Mutiple set ->lspi;// Returns: undefined// Stores: {wow: 'wow1'} in mthe 'test' key// Stores: {wow: 'wow2'} in the 'test2' key const testDataOne = lspi;const testDataTwo = lspi; testDataOne; // => {wow: 'wow1'}testDataTwo; // => {wow: 'wow2'} //= Multiple get ->\lspi; const testData = lspi; testData; // => ['test', {wow: 'wow'}], ['test2', {wow: 'wow'}] //= Multiple drop ->lspi; lspi;// Returns: undefined// 'test3' -> {wow: 'wow3'} remains