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

simpler-types

v1.1.6

Published

A simplified way of verifying variable types.

Downloads

285

Readme

Simpler Types

A simplified way of verifying variable types.

Installation

	$ npm install simpler-types

Whats new?

1.1.5 - Fixed NaN arrays not working.

Methods

Type.assert()

Throws an exception anytime the input does not match the type. The input and type can objects or arrays with embedded types within them or a single type.

	Type.assert(input, type);

Type.get()

Returns the name of the type provided.

	Type.get(input);

Type.getType()

Returns the class type of a provided variable.

	Type.getType(input);

Type.is()

Returns true/false based on if input matches the type. The input and type can objects or arrays with embedded types within them or a single type.

	Type.is(input, type);

Examples

	const Type = require('simpler-types');

	class MyClass {}

	const myInstance = new MyClass();

	Type.get(myInstance); // "MyClass"
	Type.get(0); // "Number"
	Type.get(''); // "String"
	Type.get(false); // "Boolean"
	Type.get(() => {}); // "Function"
	Type.get([]); // "Array"
	Type.get({}); // "Object"
	Type.get(NaN); // "NaN"
	Type.get(null); // "null"
	Type.get(undefined); // "undefined"
	Type.get(Symbol('id')); // "Symbol"

	Type.getType(myInstance); // MyClass
	Type.getType(0); // Number
	Type.getType(''); // String
	Type.getType(false); // Boolean
	Type.getType(() => {}); // Function
	Type.getType([]); // Array
	Type.getType({}); // Object
	Type.getType(NaN); // NaN
	Type.getType(null); // null
	Type.getType(undefined); // undefined
	Type.getType(Symbol('id')); // Symbol

	Type.assert(myInstance, MyClass);
	Type.assert(0, Number);
	Type.assert('', String);
	Type.assert(false, Boolean);
	Type.assert(() => {}, Function);
	Type.assert([], Array);
	Type.assert({}, Object);
	Type.assert(NaN, NaN);
	Type.assert('', NaN);
	Type.assert(null, null);
	Type.assert(undefined, undefined);
	Type.assert(Symbol('id'), Symbol);

	Type.is(myInstance, MyClass); // true
	Type.is(0, Number); // true
	Type.is('', String); // true
	Type.is(false, Boolean); // true
	Type.is(() => {}, Function); // true
	Type.is([], Array); // true
	Type.is({}, Object); // true
	Type.is(NaN, NaN); // true
	Type.is('', NaN); // true
	Type.is(null, null); // true
	Type.is(undefined, undefined); // true
	Type.is(Symbol('id'), Symbol); // true

Layered Checks

Type.assert(input, {
	name : String,
	age  : Number,
	address : {
		street  : String,
		zipcode : Number,
		state   : String,
		country : String
	}
});

Type.is(input, {
	name : String,
	age  : Number,
	address : {
		street  : String,
		zipcode : Number,
		state   : String,
		country : String
	}
});

License

Simpler Types is freely distributable under the terms of the MIT license.