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

useful-library

v1.3.3

Published

A set of helper functions.

Readme

containsOnly()

/**
 * Return true if an array contains only certain elements.
 *
 * @param  {object} arr An array object to check
 * @param  {function} func A function that performs the check
 */

dateAsISO()

/**
 * Returns the date portion of Date, e.g. "2022-06-12"
 *
 * @param  {Date} date
 */

first()

/**
 * Return the first element of an array.
 *
 * @param  {object} arr
 */

formatDay()

/**
 * Return day formatted as DD.
 *
 * @param  {object} day Date object.
 */

formatMonth()

/**
 * Return MM indexed from 1 as string.
 *
 * @param  {object} month Date object.
 */

formatString()

/**
 * Return a formatted string.
 *
 * @param  {object} configObj Three properties are mandatory:
 *  string       - an input string;
 *  positions    - an array of numbers that represent indices;
 *  insertedChar - a characted to insert at positions
 */

getConnectionString()

/**
 * Return connection string for MSSQL DB.
 *
 * @param  {object} infoObj Object with user, password, server, and database
 *  properties.
 */

getEnv()

/**
 * Return value from an env variable.
 *
 * @param  {string} envVarName Env variable name.
 */

getEnvWithoutLang()

/**
 * Return environment part of a string ('dev-cz' => 'dev').
 *
 * @param  {string} envVarName Env variable name.
 */

getLang()

/**
 * Return language part of a string ('dev-cz' => 'cz').
 *
 * @param  {string} envVarName Env variable name.
 */

isEqual()

/**
 * Return true if given arrays are equal, e.i. have the same members in the
 * same order.
 *
 * @param  {object} arr
 * @param  {object} arr1
 */

isStrictlyEqual()

/**
 * Return true if given arrays are strictly equal, e.i. have the same members
 * in the same order.
 * @param  {object} arr
 * @param  {object} arr1
 */

last()

/**
 * Return the last element of an array.
 *
 * @param  {object} arr
 */

loadJsonFile()

/**
 * Synchronously reads and parses a JSON file.
 *
 * @param  {string} filename
 * @return {object} Parsed JSON file as an object literal.
 */

loadYamlFile()

/**
 * Synchronously reads and parses a YAML file.
 *
 * @param  {string} filename
 * @return {object} Parsed YAML file as an object literal.
 */

max()

/**
 * Return maximum value from an array.
 *
 * @param  {object} arr
 */

merge()

/**
 * Merge two objects.
 *
 * @param  {object} obj
 * @param  {object} obj1
 */

min()

/**
 * Return minimum value from an array.
 *
 * @param  {object} arr
 */

nth()

/**
 * Return nth element of an array.
 *
 * @param  {object} arr
 * @param  {number} nthEl Default to 0.
 * @param  {number} indexStyle Indexing, either start with 0 or 1. Default to 0.
 */

pastYyyyMmDd()

/**
 * Return past date in YYYY{{separator}}MM{{separator}}DD.
 *
 * @param  {string} separator Default '/'.
 * @param  {number} daysAgo Default 1.
 */

randInt()

/**
 * Return a random integer between min and max inclusive.
 *
 * @param  {number} min
 * @param  {number} max
 */

randomEmail()

/**
 * Generate random email. If len is 0, the part before '@' will be
 * missing. If domainStr is '', no domain will be included.
 *
 * @param  {number} len Default 10.
 * @param  {string} domainStr Default USEFUL_DEFAULT_DOMAIN env variable
 *  or "inveo.cz".
 */

randomNumberString()

/**
 * Generate random number string. If alphabetString is not passed,
 * only [0-9] is a considered alphabet.
 *
 * @param  {number} len Default 10.
 * @param  {string} alphabetString Default [0-9].
 */

randomString()

/**
 * Generate random string. If alphabetString is not passed,
 * only [a-zA-Z] is a considered alphabet.
 *
 * @param  {number} len Default 10.
 * @param  {string} alphabetString Default [a-zA-Z].
 */

sortAsc()

/**
 * Return a sorted (asc) array clone.
 *
 * Sorting does not happen in place. Numeric sorting is performed.
 *
 * @param  {object} arr
 */

sortDesc()

/**
 * Return a sorted (desc) array clone.
 *
 * Sorting does not happen in place. Numeric sorting is performed.
 *
 * @param  {object} arr
 */

unix()

/**
 * Return unit timestamp.
 *
 */

yyyyMmDd()

/**
 * Return current date in YYYY{{separator}}MM{{separator}}DD.
 *
 * @param  {string} separator Default '/'.
 */