npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

redistimeseries-js

v2.3.1

Published

JavaScript client for RedisTimeSeries

Downloads

120

Readme

Tests npm version

redistimeseries-js

JavaScript client for RedisTimeSeries

npm install redistimeseries-js

Example

const RedisTimeSeries = require('redistimeseries-js');


// check base redis client for options
// https://github.com/NodeRedis/node_redis
const options = {
  host: 'localhost',
  port: 6379
}

const rtsClient = new RedisTimeSeries(options);
const key = 'temperature';

const updateTemperature = async () => {
  await rtsClient.add(key, Date.now(), Math.floor(Math.random()*30)).send();
}

const start = async () => {
  await rtsClient.connect();
  await rtsClient.create(key).retention(60000).send();
  setInterval(updateTemperature, 1000);
}

start();

Filtering

Filters are represented as array of conditions

const { Filter } = require('redistimeseries-js');

const myFilter = [
  Filter.equal('area_id', 32),
  Filter.notEqual('sensor_id', 1),
  Filter.exists('sub_area_id'),
  Filter.notExists('outdoor'),
  Filter.in('secitons', [2, 3, 4]),
  Filter.notIn('secitons', [5, 6])
];

Aggregation

Possible aggregation values

const { Aggregation } = require('redistimeseries-js');

// Aggregation.AVG
// Aggregation.SUM
// Aggregation.MIN
// Aggregation.MAX
// Aggregation.RANGE
// Aggregation.COUNT
// Aggregation.FIRST
// Aggregation.LAST
// Aggregation.STDP
// Aggregation.STDS
// Aggregation.VARP
// Aggregation.VARS

Duplicate Policy

Possible duplicate policy values

const { DuplicatePolicy } = require('redistimeseries-js');

// DuplicatePolicy.BLOCK
// DuplicatePolicy.FIRST
// DuplicatePolicy.LAST
// DuplicatePolicy.MIN
// DuplicatePolicy.MAX
// DuplicatePolicy.SUM

Methods

Examples for each method are shown below, notice that optional parameters are always represented as object which is the last argument in the methods.

create

// TS.CREATE temperature:2:32 RETENTION 60000 LABELS sensor_id 2 area_id 32 UNCOMPRESSED

const RedisTimeSeries = require('redistimeseries-js');
const { DuplicatePolicy } = RedisTimeSeries;

client
  .create('temperature:2:32')
  .retention(60000)
  .labels({ sensor_id: 2, area_id: 32 })
  .duplicatePolicy(DuplicatePolicy.LAST)
  .uncompressed()
  .send();

alter

// TS.ALTER temperature:2:32 LABELS sensor_id 2 area_id 32 sub_area_id 15

client
  .alter('temperature:2:32')
  .labels({ sensor_id: 2, area_id: 32, sub_area_id: 15 })
  .send();

add

// TS.ADD temperature:2:32 1548149180000 26 LABELS sensor_id 2 area_id 32

const RedisTimeSeries = require('redistimeseries-js');
const { DuplicatePolicy } = RedisTimeSeries;

client
  .add('temperature:2:32', 1548149180000, 26)
  .onDuplicate(DuplicatePolicy.SUM)
  .labels({ sensor_id: 2, area_id: 32 })
  .send();
// TS.ADD temperature:3:11 1548149183000 27 RETENTION 3600

client
  .add('temperature:2:32', 1548149180000, 26)
  .retention(3600)
  .send();

madd

// TS.MADD temperature:2:32 1548149180000 26 cpu:2:32 1548149183000 54

client
  .madd([
    { key: 'temperature:2:32', timestamp: 1548149180000, value: 26 },
    { key: 'cpu:2:32', timestamp: 1548149183000, value: 54 }
  ]);
  .send();

incrBy

// TS.INCRBY temperature:2:32 3 RETENTION 30000

client
  .incrBy('temperature:2:32', 3)
  .retention(30000)
  .send();

decrBy

// TS.DECRBY temperature:2:32 5 RETENTION 30000 UNCOMPRESSED

client
  .decrBy('temperature:2:32', 5)
  .retention(30000)
  .uncompressed()
  .send();

createRule

// TS.CREATERULE temperature:2:32 temperature:avg AGGREGATION avg 60000

const RedisTimeSeries = require('redistimeseries-js');
const { Aggregation } = RedisTimeSeries;

// ...

client
  .createRule('temperature:2:32', 'temperature:avg')
  .aggregation(Aggregation.AVG, 60000)
  .send();

deleteRule

// TS.DELETE temperature:2:32 temperature:avg

client.deleteRule('temperature:2:32', 'temperature:avg').send();

range

// TS.RANGE temperature:3:32 1548149180000 1548149210000 AGGREGATION avg 5000
// TS.REVRANGE temperature:3:32 1548149180000 1548149210000 AGGREGATION avg 5000

const RedisTimeSeries = require('redistimeseries-js');
const { Aggregation } = RedisTimeSeries;

// ...

client
  .range('temperature:2:32', 1548149180000, 1548149210000)
  .aggregation(Aggregation.AVG, 5000)
  .send();

mrange

// TS.MRANGE 1548149180000 1548149210000 AGGREGATION avg 5000 FILTER area_id=32 sensor_id!=1
// TS.MREVRANGE 1548149180000 1548149210000 AGGREGATION avg 5000 FILTER area_id=32 sensor_id!=1

const RedisTimeSeries = require('redistimeseries-js');
const { Aggregation, Filter } = RedisTimeSeries;

// ...

client
  .mrange('temperature:2:32', 1548149180000, 1548149210000)
  .filter([
    Filter.equal('area_id', 32),
    Filter.notEqual('sensor_id', 1)
  ])
  .aggregation(Aggregation.AVG, 5000)
  .send();
// TS.MRANGE 1548149180000 1548149210000 AGGREGATION avg 5000 WITHLABELS FILTER area_id=32 sensor_id!=1
// TS.MREVRANGE 1548149180000 1548149210000 AGGREGATION avg 5000 WITHLABELS FILTER area_id=32 sensor_id!=1

const RedisTimeSeries = require('redistimeseries-js');
const { Aggregation, Filter } = RedisTimeSeries;

// ...

client
  .mrevrange('temperature:2:32', 1548149180000, 1548149210000)
  .aggregation(Aggregation.AVG, 5000)
  .withLabels()
  .filter([
    Filter.equal('area_id', 32),
    Filter.notEqual('sensor_id', 1)
  ])
  .send();

get

// TS.GET temperature:2:32

client
  .get('temperature:2:32')
  .send();

mget

// TS.MGET FILTER area_id=32

const RedisTimeSeries = require('redistimeseries-js');
const { Filter } = RedisTimeSeries;

// ...

client
  .mget()
  .filter([ Filter.equal('area_id', 32) ])
  .send();

info

// TS.INFO temperature:2:32

client
  .info('temperature:2:32')
  .send();

queryIndex

// TS.QUERYINDEX sensor_id=2

client
  .queryIndex([ Filter.equal('sensor_id', 2) ])
  .send();