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

sampler

v0.0.5

Published

Record things, play them back

Downloads

3

Readme

node-sampler

A library which record things and play them back

Overview

Record byte streams/events (eg. twitter, music, IRC, Apache logs..) and play them back (eg. to test or debug an app, reproduce errors, simulate events)

One the of main features is that you can control the rate speed, very useful to train machine learning algorithms on historic data (eg. Twitter streams)

Current status

This library is still in development so expect heavy refactoring and sparse documentation until I have more time to settle everything.

TODO / Wishlist

  • real support of stream/buffer API
  • insertion of event at arbitrary timesteps (eg. when working with incomplete time-series)
  • reverse playback!

License

BSD

Installation

For users

Install it as a dependency for your project

$ npm install sampler

Install it globally in your system

$ npm install sampler -g

Run the tests

$ npm run-script test

For developers

To install node-sampler in a development setup:

$ git clone http://github.com/daizoru/node-sampler.git
$ cd node-sampler
$ npm link
$ # optional:
$ # npm run-script test 

To build the coffee-script:

$ npm run-script build

Documentation

Example

# myapp.coffee
Sampler = require 'sampler'

sample = new Sampler()
sample.on 'event', (event) -> log "#{event.timestamp}: #{event.data}"

# coffee-style timeouts
delay = (t,f) -> setTimeout f, t

# sample some dummy events
log "sampling events.."
delay 100, -> sample.rec companyhelpdesk: "hi how can I help you"
delay 500, -> sample.rec facebook: "wow! this was a big earthquake"
delay 1000, -> sample.rec twitter: "just saw my dead neighbor walking in my street. It's weird. wait I'm gonna check it out"
delay 1500, -> sample.rec twitter: "ZOMBIE APOCALYPSE!!1!!"

delay 2000, -> 
  log "playing events back.."
  sample.play()

delay 5000, -> 
  log "playing events back. and faster."
  sample.play 5.0 # 2.0x

which should output something like:


10 Jun 14:57:49 - sampling events..
10 Jun 14:57:51 - playing events back..
10 Jun 14:57:51 - 1339333069383: { companyhelpdesk: 'hi how can I help you' }
10 Jun 14:57:51 - 1339333069783: { facebook: 'wow! this was a big earthquake' }
10 Jun 14:57:52 - 1339333070284: { twitter: 'just saw my dead neighbor walking in my street. It\'s weird. wait I\'m gonna check it out' }
10 Jun 14:57:52 - 1339333070784: { twitter: 'ZOMBIE APOCALYPSE!!1!!' }
10 Jun 14:57:54 - playing events back. and faster.
10 Jun 14:57:54 - 1339333069383: { companyhelpdesk: 'hi how can I help you' }
10 Jun 14:57:54 - 1339333069783: { facebook: 'wow! this was a big earthquake' }
10 Jun 14:57:54 - 1339333070284: { twitter: 'just saw my dead neighbor walking in my street. It\'s weird. wait I\'m gonna check it out' }
10 Jun 14:57:54 - 1339333070784: { twitter: 'ZOMBIE APOCALYPSE!!1!!' }

You can see it here but the second batch is two times faster