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.9.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by400%
Maintainers
1
Weekly downloads
 
Created
Source

attodom

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

ExampleWhyAPILicense

Examples

import {Store} from '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'}])
store.set(['a', 'b'], data:'world')

supports different environments

  • CJS: var create = require('attostore').createStore
  • ES modules: import {createStore} from 'attostore'

Features, Limitations, Gotcha

  • available in CommonJS and ES6 modules
  • 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 are equivalent
  • a/b, ["a", "b"] are equivalent

License

MIT © Hugo Villeneuve

Keywords

FAQs

Package last updated on 24 Jul 2017

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