state.js/README.md

55 lines
1.3 KiB
Markdown
Raw Permalink Normal View History

2019-06-24 19:45:14 +00:00
# State JS
> simple spa state managment utility
**WIP**
Simple state managment utility for single-page-applications w/ optional localStorage caching with a tiny footprint
> ALL values are JSONified
**Features**
- Tiny ~100 lines of JS
- Support both browser and NodeJS environments
- `.get` can be used as expression, `false` returned for all empty datatypes -- yes even `{}` & `[]`
## Quick Start
include the library *ONLY ONCE*
const state = require('state.js');
or in browser
<script src="state.js"></script>
### Options
`state` is a funciton that you can optionally pass in an `options` object
| Option | Descption |
| cache | enable localStorage |
| debug | display various console messages |
### API
from there you have access to a simple api, `get`, `set`, `remove`, and `clear`
| Method | Description |
| get(key) | get value by key |
| set(key, val) | set value by key |
| remove(key) | remove key |
| clear() | destories all state data |
## Support
Please open [an issue](http://code.negative9.net/geoff/state.js/issues/new) for support.
## Contributing
Anyone is welcome to contribute, however, if you decide to get involved, please take a moment to review the [guidelines](CONTRIBUTING.md), there minimalistic;)
## License
[MIT](LICENSE)