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

nestate

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestate

A simple state observing mechanism that only fires when the stored value is compared to true.

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

Nestate

A simple state observing mechanism that only fires when the stored value is compared to true.

Components

State

Contains a callback function that fires depending on the truthfulness of validFn.

Action

Contains a callback function that fires depending on the truthfulness of the parent state.

Usage

var states = new Nestate()

Creates a new group of State and Action.

Nestate.addState(key, value, options:{callbackFn?, validFn?})

Adds a new state into the group. Throws new Error when the key already exists.

key

The key of the state

value

The value of the state

options

Contains callbackFn and validFn. Defaults to:

options = {
    callbackFn: (val)=>{}, 
    validFn: (val)=>true
}
options.callbackFn

The callback function when validFn returns true.

options.validFn

State validity check function.

Nestate.updateState(key, value)

Updates the value of the state by the key. Throws new Error when key is not found.

Nestate.setStateCallback(key, callbackFn)

To be developed.

Nestate.setStateValidFunction(key, validFn)

To be developed.

Nestate.getState(key)

Returns the value of the state by key. Throws new Error when key is not found.

Nestate.addAction(key, fn, dependsOn=[], options={})

Adds a new action depeding on the dependsOn array of states.

options.type

"AND" or "OR".

FlagEffect
"AND"All parents' validity must be true to fire the action
"OR"Only requires one of the parents' validity to be true to fire the action

Keywords

state

FAQs

Package last updated on 08 Oct 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