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

tartaros

v3.0.0

Published

A single function for typechecks at runtime

Readme

tartaros

Runtime type checks made easy.

How to

tartaros only exports a single function.

var tartaros = require('tartaros');

var validate = tartaros({
  username: 'String',
  password: 'String',
  rememberMe: 'Bool'
});

validate('foo');
// false

validate({
  foo: 'bar'
});
// false

validate({
  username: 'Arthur',
  password: 'secret',
  rememberMe: true
});
// true

validate({
  username: 'Zaphod',
  password: 'BB 4ever',
  rememberMe: false,
  thisIsOnePropertyTooMuch: 'foo'
});
// false

That function takes a schema as it's only argument and returns a function that validates its input according to that schema. A schema is either a String, an Array or an Object.

If the schema is a String, it must be on of String, Number, Bool, Null, Undefined. It resolves accordingly.

var validate = tartaros('Bool');

validate(true);
// true

validate(false);
// false

validate(/* anything else */);
// true

If the schema is an Object, tartaros first of all checks if the passed data is an object. Then it checks the types of all given keys.

var validate = tartaros({
  msg: 'String',
  nested: {
    foo: 'String'
  }
});

validate({
  msg: 42,
  nested: {
    foo: 'bar'
  }
});
// false

validate({
  msg: 'hello',
  nested: {
    foo: 'bar'
  }
});
// true

If the schema is an **Array**, `tartaros` first checks if the corresponding data is an `instanceof Array`.
Then it validates every item of that array with the schema given as the first element of the schema array.

```js
var validate = tartaros([ 'String' ]);

validate('foo');
// false
validate([ 'foo', 'bar' ]);
// true
validate([]);
// true