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

attostore

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attostore

json data store

  • 0.10.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

attostore

small json in-memory store with path events, ~3kb min, ~1kb gz

ExampleWhyAPILicense

Examples

var Store = require('attostore')
var store = new Store({})

store.on('a/b', function(val, key, old) {
  console.log('changed', key, 'from', old, 'to', val)
})

store.run([{path:'a/b', data:'hello'}]) //runs a series of patches
store.set(['a', 'b'], 'world') //directly sets a value

Features, Limitations, Gotcha

  • only the last item of an Array can be deleted to avoid shifting of keys
  • No Array splicing to keep the keys unchanged. additions and removals from the end only (eg. push pop)
  • only JSON types supported (Array, Object, string, number, boolean, null)
  • set triggers a deletion if the value is undefined and/or absent

API

new Store(initValue: any): Store

Store

.on(path: Path, handler: (val, key, old, key)=>void, [, context: any]): Ref .once(path: Path, handler: (val, key, old, key)=>void, [, context: any]): Ref .off(path: Path, handler: (val, key, old, key)=>void, [, context: any]): Ref .run(commandName: string, ...args: any): Error|void .get(path: Path): any .run(command[]): Error|void .set(path: Path [, data: any]): Error|void

Command

{path: Path, data: any}

Path

Array|string|number

  • 0, "0", [0], ["0"] are equivalent
  • '', null, undefined, [] all point to the root
  • a/b, ["a", "b"] are equivalent

License

MIT © Hugo Villeneuve

Keywords

FAQs

Package last updated on 04 Feb 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