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

array-to-events

v1.0.0

Published

Push a series of events to an emitter. Useful for testing.

Downloads

14

Readme

array-to-events Build Status

Push a series of events to an emitter. Useful for testing.

Install

$ npm install --save array-to-events

Usage

import arrayToEvents from 'array-to-events';

arrayToEvents(targetEmitter, [
  ['foo', 'fooArg1', 'fooArg2'],
  ['bar', 'barArg1', 'barArg2']
]);

// pushes both a 'foo' and 'bar' event (with specified arguments) to the emitter.

API

arrayToEvents(targetEmitter, eventArray, [options])

Returns: stop callback

Emit a series of events on targetEmitter. Depending on the specified options, events will be emitted synchronously or at specified intervals. In async mode, a stop callback is returned that, when called, will prevent further events from being emitted.

targetEmitter

Required Type: EventEmitter

The emitter where events will be pushed

eventArray

Required Type: two dimensional array

An array of event argument arrays. Must be a two dimensional array. The first value of each child array must be a string value with the event name. Additional array members will be passed as arguments when the array is triggered.

[
  ['foo', 1],
  ['bar', 2]
]

The above defines two events. First a foo event will be emitted with argument 1. Then a bar event will be emitted with argument 2.

options

sync

Type: boolean Default: it depends

If true, all events will be emitted immediately and synchronously, one right after the other. It defaults to true unless the delay option or done callback are specified (in which case it defaults to false). Explicitly setting it to true will cause the delay option to be ignored.

delay

Type: a number or the string "immediate" Default: "immediate"

If set to "immediate", events fire asynchronously with a minimal delay in between (setImmediate is used to schedule the next event).

If set to a number, events are scheduled every delay milliseconds (via setTimeout(nextEvent, opts.delay)).

done

Type: callback(error, finished)

An optional callback to be executed when all events have finished. The first argument will contain any error thrown during execution (not currently implemented). The second argument (finished) will be true if every event was emitted, false if the event stream was stopped prematurely using the stop function.

See Also

License

MIT © James Talmage