Skip to content

rcpooley/time-state

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A node package for keeping track of some state across time

Resources

Stars

Watchers

Forks