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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@opsimathically/emptytools

v1.0.1

Published

Utilities for determining the emptiness of values.

Readme

emptytools

This package provides utility functions for determining the "emptiness" of values wherein "empty" is defined below. The purpose of this is for runtime validation of data to quickly determine if a value falls outside of expected "presentness." This is a basic, but foundationally useful bit of code that can be utilized to quickly determine the present/empty state of a value.

/*
  Definition of "empty":
    zero length buffer
    undefined
    null
    zero length array
    zero length string
    object with no keys
    set with no entries
    map with no entries
    date with invalid/unparsable date

  Empty is NOT 0 or false, wherein these are both considered valid non-empty values.
*/

Install

npm install @opsimathically/emptytools

Building from source

This package is intended to be run via npm, but if you'd like to build from source, clone this repo, enter directory, and run npm install for dev dependencies, then run npm run build.

Usage

import {
  isEmpty,
  isNotEmpty,
  valuesAreEmpty,
  valuesAreNotEmpty
} from '@opsimathically/emptytools';

(async function () {
  // true
  isEmpty(undefined);
  isEmpty(null);
  isEmpty(new Date(''));
  isEmpty(new Set());
  isEmpty(new Map());
  isEmpty(Buffer.alloc(0));
  isEmpty([]);
  isEmpty('');
  isEmpty({});

  // false
  isEmpty({ a: 1 });
  isEmpty(0);
  isEmpty(false);
  isEmpty([1, 2, 3]);

  // false
  isNotEmpty({});

  // true
  valuesAreEmpty([
    undefined,
    null,
    new Date(''),
    new Set(),
    new Map(),
    Buffer.alloc(0),
    [],
    '',
    {}
  ]);

  // true
  valuesAreNotEmpty([
    undefined,
    null,
    new Date(''),
    new Set(),
    new Map(),
    Buffer.alloc(0),
    [],
    '',
    { a: 1 } // not empty val
  ]);
})();