time-state
v1.2.4
Published
A node package for keeping track of some state across time
Downloads
5
Readme
Time State
Store and fetch historical values of a state (Flow friendly!)
Installation
$ npm install time-state
Usage
First import time-state
const TS = require('time-state');
Then create a factory (see FactoryOptions)
const factory = TS.factory({/* options */});
Storage
Each factory requires a StorageProvider. time-state provides three options:
MongoDB
time-state will create a timestate and block collection
const storage = await TS.Storage.mongo('mongodb://localhost:27017/testdb');
// OR provide collection names
const storage = await TS.Storage.mongo('mongodb://localhost:27017/testdb', 'timestates', 'blocks');
Memory
time-state will store everything in memory
const storage = TS.Storage.memory();
// Save and load storage.provider.timeStates for persistence
Create your own
Feel free to implement StorageProvider. See storage/mongo.js and storage/memory.js.
Examples
- See examples/tictactoe.js for basic factory usage.
- See examples/trading.js for usage of the sequence stepper and sync stepper.