New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

babystore

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babystore

Smallest LocalStorage wrapper

latest
Source
npmnpm
Version
0.5.1
Version published
Maintainers
1
Created
Source

Babystore

A tiny (330b gz) wrapper around localStorage with a familiar set of methods.

import { store } from 'babystore';

const s = store();
const p = store('prefixed:');

// automatically stringifies objects
s.add('itemName', { a: 1 });

// then parses them on the way out
s.find('itemName') // { a: 1 }

p.add('secondItemName', { b: 2 });

// check if the item exists
s.has('itemName') // true
s.has('doesntExist') // false

// prefixed stores are not accessible unless you use the
// prefixed store or include the prefix
s.find('secondItemName') // undefined
s.find('prefixed:secondItemName') // { b: 2 }

// use store.all to get all values in the storage
store.all() // [ { a: 1 }, { b: 2 } ]

// you can use .delete to remove single items
p.delete('secondItemName');
p.find('secondItemName') // undefined

// or use store.nuke to wipe the entire storage
store.nuke();
s.find('itemName') // undefined

TODO

  • keep trimming

Changelog

  • 0.5.1
    • Reduces package size by 11b gz
  • 0.5.0 (breaking)
    • the clear and all methods have been removed from babystore instances
    • nuke and all are the above methods on the store function
    import { store } from 'store';
    store.all() // returns all items in localStorage
    store.nuke() // removes all items in localStorage
    
  • 0.4.0 (breaking)
    • babystore is now async by default
    • the get handler now returns async (key, obj) => which makes then AsyncFunction's
  • 0.3.1
    • updates some of the content
    • removes references to async in tests and source code
  • 0.3.0 (breaking)
    • babystore no longer offers an async version the implementation meant that every method was async, even when there were ones that didn't need to be. May revisit later

Keywords

localStorage

FAQs

Package last updated on 02 Jan 2024

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