time-state

1.2.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i time-state

Weekly Downloads

2

Version

1.2.4

License

ISC

Unpacked Size

191 kB

Total Files

41

Last publish

Collaborators

  • rcpooley