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

the.js

v0.3.8

Published

Type-checking library for Javascript

Downloads

23

Readme

the.js

A type checking library for Javascript.

Installation and setup

$ npm install the.js

For Node.js:

const the = require('./path/to/the.js');

For browser environments:

<script src='./path/to/dist/the.min.js'></script>
<script>
	the(42).isNumber();
</script>

Usage

const the = require('./path/to/the.js');

let thing = 42;

console.log(the(thing).isNumber()); // true
console.log(the(thing).isString()); // false, outputs the explanation and stack trace to the console
console.log(the(thing).isString(true)); // still false, but no console output

Methods

.isNumber([isSilent]);

Checks if the value is a finite number.

the(42).isNumber(); // true
the(1e0).isNumber(); // true
the(0xff).isNumber(); // true
the('42').isNumber(); // false
the(null).isNumber(); // false
the(NaN).isNumber(); // false
the(Infinity).isNumber(); // false

.isDefined([isSilent]);

Checks if the value is not undefined.

the(42).isDefined(); // true
the(null).isDefined(); // true
the('').isDefined(); // true
the({}).isDefined(); // true
the().isDefined(); // false

.isNull([isSilent]);

Checks if the value is null.

the(null).isNull(); // true
the(0).isNull(); // false
the().isNull(); // false

.isString([isSilent]);

Checks if the value is a string.

the('').isString(); // true
the('42').isString(); // true
the([]).isString(); // false
the({}).isString(); // false

.isHexString([isSilent]);

Checks if the value is a hex string.

the('000000').isHexString(); // true
the('abcdef').isHexString(); // true
the('42').isHexString(); // true
the(' 0 0 ').isHexString(); // false
the('ghijklmnopqrstuvwxyz').isHexString(); // false
the('').isHexString(); // false

.isEmptyString([isSilent]);

Checks if the value is an empty string.

the('').isEmptyString(); // true
the('42').isEmptyString(); // false
the([]).isEmptyString(); // false
the({}).isEmptyString(); // false

.isBoolean([isSilent]);

Checks if the value is boolean.

the(true).isBoolean(); // true
the(false).isBoolean(); // true
the(!0).isBoolean(); // true
the(new Boolean()).isBoolean(); // false
the(0).isBoolean(); // false

.isFunction([isSilent]);

Checks if the value is a function.

the(function () { return 42; }).isFunction(); // true
the(console.log).isFunction(); // true
the(isNaN).isFunction(); // true
the(new Function()).isFunction(); // true
the(null).isFunction(); // false

let Thing = function () {};
the(new Thing()).isFunction(); // false

.isObject([isSilent]);

Checks if the value is an object literal.

the({}).isObject(); // true
the(console).isObject(); // true

let Thing = function () {};
the(new Thing()).isObject(); // true

the(NaN).isObject(); // false
the(null).isObject(); // false

.isArray([isSilent]);

Checks if the value is an array.

the([]).isArray(); // true
the({}).isArray(); // false
the('').isArray(); // false

function fn(arg1, arg2) {
	return the(arguments).isArray(); // false
}

.isDate([isSilent]);

Checks if the value is a date.

the(new Date()).isDate(); // true
the(new Date(9000)).isDate(); // true
the(Date.parse('1980-01-01 00:00')).isDate(); // false

let timeDiff = (new Date('1970-01-01 00:10')) - (new Date('1970-01-01 00:05'));
the(timeDiff).isDate(); // false

.isRegExp([isSilent]);

Checks if the value is a regular expression.

the(/^.+$/ig).isRegExp(); // true
the(new RegExp('/^.+$/', 'ig')).isRegExp(); // true
the('/^.+$/').isRegExp(); // false

.isInstanceOf(constructor[, isSilent]);

Checks if the value is an instance of a class (constructor).

let num = new Number(42);
the(num).isInstanceOf(Number); // true

let Thing = function () {};
the(new Thing()).isInstanceOf(Thing); // true
the(new Thing()).isInstanceOf(Object); // false
the(new Thing()).isInstanceOf(Function); // false
the({}).isInstanceOf(Object); // true
the([]).isInstanceOf(Array); // true
the(function () {}).isInstanceOf(Function); // true
the(42).isInstanceOf(Number); // false
the('42').isInstanceOf(String); // false

.hasPrototypeOf(constructor[, isSilent]);

Checks if the value has a prototype of a class (constructor).

let num = new Number(42);
the(num).hasPrototypeOf(Number); // true
the(42).hasPrototypeOf(Number); // true
the(NaN).hasPrototypeOf(Number); // true
the(Infinity).hasPrototypeOf(Number); // true
the('42').hasPrototypeOf(String); // true
the(null).hasPrototypeOf(Number); // false

let Thing = function () {};
the(new Thing()).hasPrototypeOf(Thing); // true
the(new Thing()).hasPrototypeOf(Object); // false
the(new Thing()).hasPrototypeOf(Function); // false

.isFrozen([isSilent]);

Checks if the value is a frozen object.

let object = { value: 42 };
let frozenObject = Object.freeze({ value: 42 });
the(frozenObject).isFrozen(); // true
the(object).isFrozen(); // false