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

bp-utilities

v1.6.0

Published

Basic utilities used across modules

Downloads

4

Readme

Utilities

Basic utilities used across modules

This module provides a number of reusable utilites that help with tasks such as printing coloured text to the console and debugging. It can be installed easily through npm:

npm install bp-utilities

Any of the utilities can be required individually, or they can be used from the bp-utilities object:

var util = require('bp-utilities');
var ansi = require('bp-utilities').ansi;

console.log(util.ansi.red("This is just as valid"));
console.log(ansi.red("as this is"));

Current Modules

ansi

The ANSI module is used to wrap a string in ANSI codes to change the text display in terminals. This is useful for making things a bit easier to read when, for example, you're printing out all of the requests to the server to the console for debugging. Each code has its own self-named method in the ANSI object, or they can be invoked manually with the core(property, text) method.

Currently supported ANSI codes:

codes: {
  black: "\x1B[30m",
  red: "\x1B[31m",
  green: "\x1B[32m",
  yellow: "\x1B[33m",
  blue: "\x1B[34m",
  magenta: "\x1B[35m",
  cyan: "\x1B[36m",
  white: "\x1B[37m",
  bold: "\x1B[1m"
}

Sequence

The Sequence object is used to create a sequence of values from a given starting value, using a specified method to generate the next value. It can be thought of as a very simple implementation of a generator.

The contructor is of the form NumericStream([initial] [, transform]) where initial is the first value in the sequence (default 0) and transform is a function of the form transform(n) where n is the current value of the sequence. transform should return the next value in the sequence, and defaults to n + 1.

By providing both a non-numeric initial value and a custom transform function, Sequence can generate any sort of data sequence to be consumed at the pace of the calling program.

Access is provided by two methods; the first (Sequence.get()) returns the current value and is analogous to simply accessing the Sequence.current property, and the second (Sequence.next()) generates and returns the next value in the sequence.

JSN

The JSN module provides functions for manipulating JSON objects. It currently contains functions for:

  • Creating shallow copies of objects
  • Merging the properties of a second json object into another
  • Getting the property names of an object as an array
  • Filtering the properties of an object based on an array of property names