state-holder
Basic getter and setter for arbitrary data
source code
I think the best way to describe this module is to show you its source code:
module { return { return thing } { return thing = x } }
That's it! Short and sweet!
example
And a quick example of how to use it:
var StateHolder = var state = state // => 'hello' state // => undefinedstate // => undefined state // => 'world'state // => 'world'
api
var StateHolder =
var state = StateHolder( [thing] )
Can be called with or without new
.
The state is be set to the value of thing
. If thing
is omitted, the state is set to undefined
.
var thing = state.get()
Returns the state.
state.set( [thing] )
The state is be set to the value thing
. If thing
is omitted, the state is be set to undefined
. Whatever the state ends up being set to is returned.
install
npm install state-holder