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

antiflux

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

antiflux

A lightweight, zero-dependency, observable state manager, exclusively for Node.js, for when reactive stage managers and their attendant boilerplate are extreme overkill.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
increased by185.71%
Maintainers
1
Weekly downloads
 
Created
Source

Antiflux

A lightweight, zero-dependency, observable state manager, exclusively for Node.js, for when reactive stage managers and their attendant boilerplate are extreme overkill.

Installation

npm install antiflux || yarn add antiflux

Usage

import { Antiflux } from 'antiflux'

const store = new Antiflux([initialState], [options], [getters])

Set key

Add or update a key.

store.set('myKey', 'myValue')

Has key

Check if a key exists. Responds with a boolean.

store.has('myKey')

Get key

Responds with the key value.

const myValue = store.get('myKey')

Deep-get with dot notation.

const myValue = store.get('deep.deeper.deepest')

Delete key

Delete a key from the state.

store.delete('myKey')

Dump data

Dump all state data. Specify true to decrypt encrypted data. False by default.

store.dump()

Clear all

Clear all entries from the state.

store.clear()

Options

Initialize state

Initialize the store with a predefined state.

const initialState = {
  foo: 'bar',
  baz: 'qux'
}

const store = new Antiflux(initialState)

Encrypt data

Encrypt data at rest with AES-256-GCM encryption. Use the encryptKey option to specify a 32-character encryption key.

const options = {
  encryptKey: 'bWDlfrMxr1cnl4F4sdOvoKEOO9WY628a'
}

const store = new Antiflux({}, options)

Persist data

Use the persist option to specify a path at which to write data. Data will be reloaded from disk at runtime.

const options = {
  persist: '/tmp/antiflux.db'
}

const store = new Antiflux({}, options)

Custom getters

Create custom getters to return modified data.

const getters = {
  getLower(state) {
    return state.get('foo.bar.baz').toLowerCase()
  },
  getUpper(state) {
    return state.get('foo.bar.baz').toUpperCase()
  }
}

const store = new Antiflux({}, {}, getters)

FAQs

Package last updated on 01 Jan 2022

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