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

good-squeeze-bhawna

v1.0.1

Published

Collection of utility transform streams.

Downloads

6

Readme

good-squeeze

Simple transform streams useful in creating good data pipelines.

Build Status Current Version

Lead Maintainer: Open Position

Usage

good-squeeze is a collection of small transform streams. The Squeeze stream is useful for filtering events based on the good event options. The SafeJson stream is useful for stringifying objects to prevent circular object errors.

Methods

Squeeze(events, [options])

Creates a new Squeeze transform stream where:

  • events an object where each key is a valid good event and the value is one of the following:
    • string - a tag to include when filtering. '*' indicates no filtering.
    • array - array of tags to filter. [] indicates no filtering.
    • object - an object with the following values
      • include - string or array representing tag(s) to include when filtering
      • exclude - string or array representing tag(s) to exclude when filtering. exclude takes precedence over any include tags.
  • [options] configuration object that gets passed to the Node Stream.Transform constructor. Note objectMode is always true for all Squeeze objects.

The transform stream only passes on events that satisfy the event filtering based on event name and tags. If the upstream event doesn't satisfy the filter, it is not continued down the pipe line.

Squeeze.subscription(events)

A static method on Squeeze that creates a new event subscription map where:

  • events the same arguments used in the Squeeze constructor.
const Squeeze = require('good-squeeze');

Squeeze.subscription({ log: 'user', ops: '*', request: ['hapi', 'foo'] });

// Results in
// {
//  log: { include: [ 'user' ], exclude: [] },
//  ops: { include: [], exclude: [] },
//  request: { include: [ 'hapi', 'foo' ], exclude: [] } 
// }

Squeeze.subscription({ log: 'user', ops: { exclude: 'debug' }, request: { include: ['hapi', 'foo'], exclude: 'sensitive' } });

// Results in
// {
//  log: { include: [ 'user' ], exclude: [] },
//  ops: { include: [], exclude: [ 'debug' ] },
//  request: { include: [ 'hapi', 'foo' ], exclude: [ 'sensitive' ] }
// }

Useful for creating an event subscription to be used with Squeeze.filter if you do not plan on creating a pipeline coming from good and instead want to manage event filtering manually.

Squeeze.filter(subscription, data)

Returns true if the supplied data.event + data.tags should be reported based on subscription where:

  • subscription - a subscription map created by Squeeze.subscription().
  • data - event object emitted from good/hapi which should contain the following keys:
    • event - a string representing the event name of data
    • tags - an array of strings representing tags associated with this event.

SafeJson([options], [stringify])

Creates a new SafeJson transform stream where:

  • [options] configuration object that gets passed to the Node Stream.Transform constructor. Note objectMode is always true for all Squeeze objects.
  • [stringify] configuration object for controlling how stringify is handled.
    • separator - string to append to each message. Defaults to "\n".
    • space - number of spaces in pretty printed JSON. Doesn't pretty print when set to 0. Defaults to 0.

The transform stream stringifys the incoming data and pipes it forward. It will not crash in the cases of circular references and will instead include a "~Circular" string in the result.