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 🙏

© 2024 – Pkg Stats / Ryan Hefner

time-series-data-generator

v0.1.5

Published

[![Build Status](https://travis-ci.org/ttokutake/time-series-data-generator.svg?branch=master)](https://travis-ci.org/ttokutake/time-series-data-generator) [![Coverage Status](https://coveralls.io/repos/github/ttokutake/time-series-data-generator/badge.sv

Downloads

1,062

Readme

time-series-data-generator

Build Status Coverage Status Greenkeeper badge MIT License

Generate time series data for development!

Installation

$ npm install --save time-series-data-generator

Getting started

  1. Use simply. This generator outputs sine curve values with timestamps from "now - 1 hour" until now at 5 min interval.
const Series = require("time-series-data-generator");

const series = new Series();
console.log(series.sin());
// => [{timestamp: '2017-05-28T03:34:31.000Z', value: -0.46}, {timestamp: '2017-05-28T03:39:31.000Z', value: -0.84}, ...]
  1. Use with options.
const Series = require("time-series-data-generator");

const from = "2016-01-01T00:00:00Z";
const until = "2016-01-01T01:00:00Z";
const interval = 5 * 60; // seconds
const keyName = "key-name-of-value";
const series = new Series({ from, until, interval, keyName });
console.log(series.sin());
// => [{timestamp: '2016-01-01T00:00:00.000Z', 'key-name-of-value': 0}, {timestamp: '2016-01-01T00:05:00.000Z', 'key-name-of-value': 0.5}, ...]
  1. Output data with "random" timestamps.
const Series = require("time-series-data-generator");

const from = "2016-01-01T00:00:00Z";
const until = "2016-01-01T01:00:00Z";
const numOfData = 10;
const series = new Series({ type: "random", from, until, numOfData });
console.log(series.sin());
// => [{timestamp: '2016-01-01T00:01:43.000Z', value: 0.18}, {timestamp: '2016-01-01T00:02:19.000Z', value: 0.24}, ...]

Examples for each APIs

  • sin(): Describing sine curve.

    const Series = require("time-series-data-generator");
    
    const series = new Series();
    console.log(series.sin());
    // => [{timestamp: '2017-05-31T02:17:23.000Z', value: 0.97}, {imestamp: '2017-05-31T02:22:23.000Z', value: 0.72}, ...]
    
    const coefficient = 1;
    const constant = 1;
    const decimalDigits = 3;
    const period = 1 * 60 * 60; // seconds
    console.log(series.sin({ coefficient, constant, decimalDigits, period }));
    // => [{timestamp: '2017-05-31T02:17:23.000Z', value: 1.969}, {timestamp: '2017-05-31T02:22:23.000Z', value: 1.716}, ...]
  • cos(): Describing cosine curve.

    const Series = require("time-series-data-generator");
    
    const series = new Series();
    console.log(series.cos());
    // => [{timestamp: '2017-05-31T02:20:48.000Z', value: -0.57}, {timestamp: '2017-05-31T02:25:48.000Z', value: -0.9}, ...]
    
    const coefficient = 1;
    const constant = 1;
    const decimalDigits = 3;
    const period = 1 * 60 * 60; // seconds
    console.log(series.cos({ coefficient, constant, decimalDigits, period }));
    // => [{timestamp: '2017-05-31T02:20:48.000Z', value: 0.429}, {timestamp: '2017-05-31T02:25:48.000Z', value: 0.095}, ...]
  • gaussian(): Plotting numbers with normal distribution.

    const Series = require("time-series-data-generator");
    
    const series = new Series();
    console.log(sereis.gaussian());
    // => [{timestamp: '2017-05-31T02:25:38.000Z', value: 10.15}, {timestamp: '2017-05-31T02:30:38.000Z', value: 9.68}, ...]
    
    const mean = 5;
    const variance = 1.5;
    const decimalDigits = 3;
    console.log(series.gaussian({ mean, variance, decimalDigits }));
    // => [{timestamp: '2017-05-31T02:25:38.000Z', value: 2.56}, {timestamp: '2017-05-31T02:30:38.000Z', value: 5.924}, ...]
  • ratio(): Sampling strings following theirs weights.

    const Series = require("time-series-data-generator");
    
    const series = new Series({ type: "random" });
    const weights = {
      rock: 1,
      scissors: 2,
      paper: 1
    };
    console.log(series.ratio(weights));
    // => [{timestamp: '2017-05-31T02:30:25.000Z', value: 'rock'}, {timestamp: '2017-05-31T02:37:31.000Z', value: 'scissors'}, ...]
  • generate(): General function.

    const Series = require("time-series-data-generator");
    
    const series = new Series({ type: "random" });
    console.log(series.generate(unix => unix));
    // => [{timestamp: '2017-05-31T02:43:57.000Z', value: 1496198637}, {timestamp: '2017-05-31T02:53:07.000Z', value: 1496199187}, ...]

API document

https://ttokutake.github.io/time-series-data-generator/