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

random-signal

v0.0.2

Published

Generate a pseudo-random signal stream for mocking Sensor data

Readme

random-signal

Generate a pseudo-random signal for mocking Sensor data

var RandomSignal = require("../.")

var opt = {
  sep: "\n"     // seperator
, tdelta: 200   // milliseconds
}

var rs = RandomSignal(opt)

rs.pipe(process.stdout)

setTimeout( function () {
  rs.destroy()
}, 1000)

outputs

{"x":"2014-02-26 16:30:57.918","y":1.3151883383869654}
{"x":"2014-02-26 16:30:58.123","y":4.24176480313184}
{"x":"2014-02-26 16:30:58.328","y":3.719194025237043}
{"x":"2014-02-26 16:30:58.529","y":3.7442073803567077}

Options

Along with Readable stream options, (including object mode) you may pass in these options or use the defaults given below

  var tdelta = opt.tdelta || 50
    , hz = opt.hz || (1 / 20 * tdelta)
    , amp = opt.amp || 1
    , noiseHz = opt.noiseHz || 4 * hz
    , noiseAmp = opt.noiseAmp || 0.3 * amp
    , trendIV = opt.trendIV || (1000 * 1/hz)
    , lowtrend = opt.lowtrend || -amp
    , hightrend = opt.hightrend || amp
    , sep = opt.sep || ""
    , timeFormatter = opt.timeFormatter || getTimeString

tdelta (milliseconds)

The millisecond time that data will be produced. The default is 50ms.

hz (seconds)

The frequency of the underlying sine signal. The default frequency for the sine wave is 1 cycle per 20 tdelta's. This means that each cycle is fairly well sampled. It also means that setting tdelta = 50 will result in a default of a cycle per second.

amp

The amplitude of the underlying sine signal.

noizeHz (seconds)

The frequency of the applied noise signal

noiseAmp

The amplitude of the noise which will be randomly generated between 0 and noiseAmp

trendIV (milliseconds)

The millisecond interval in which to apply a random trend constant to the output data. The default is 1000 * 1/hz which provides a new trend every cycle of the underlying sine wave. If you want a longer trend, say applied every 5 cycles, set trendIV = 5000 * 1/hz. Remember the trendIV is in milliseconds, so the 1000 multiplication is necessary.

hightrend

The maximum amplitude of the randomly applied constant trend. The default is 1.

lowtrend

The minimum amplitude of the randomly applied constant trend. The default is -1.

sep

If the stream is not configured in objectMode this seperator will be applied to the end of the utf8 encoded string buffer. The default is set to empty string "".

timeFormatter

A function that takes a Javascript Date object as inputs and outputs a formatted date string. The default getTimeString function will output dates as "YYYY-MM-SS HH:MM:SS.f"

Install

npm install random-signal