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

jis

v2.2.0

Published

When you need validate the variable data type

Readme

Jis

jis is a lightweight runtime data type verifier designed for browsers and environments where static typing or modern language features may not be reliable or available.

Based on Object.prototype.toString.call, the library provides a set of methods to perform reliable runtime data type checks.

Why jis?

jis comes from is, the core of the library, prefixed with j (my initial). Phonetically, it sounds like “ji-is”, a subtle nod to JS itself.

In the browser, everything runs as JavaScript at runtime. Static types disappear after transpilation, and runtime type checks are often limited, inconsistent, or dependent on modern language features that are not always available.

jis focuses on providing simple, reliable runtime is checks using the most stable and widely supported mechanisms in JavaScript.

Installation

You can install this library with npm or yarn.

npm install jis

Usage

Import in ES5 or higher

const jis = require('jis')

Import in TS

import jis from 'jis'

On browser

<script src="https://unpkg.com/jis@latest"></script>

<!-- or
    <script src="https://cdn.jsdelivr.net/npm/jis@latest"></script>
-->

<script>
    // jis is exposed globally as window.jis
    var is = jis.types.is;
    console.log(is(new Date(), 'Date'))
</script>

You can also pin a specific version (≥2.2.0-preview.1), e.g.:

⚠️ Backward compatibility

In v2.x, legacy access via jis.is and jis.$* still works for compatibility reasons, but it is deprecated and will be removed in v3.0.0.

If you are starting a new project or updating existing code, use the new namespaces shown below.

// Deprecated
jis.is(arg, type);
jis.$object(arg);
jis.$array(arg);
jis.$number(arg);
jis.$string(arg);
jis.$boolean(arg);
jis.$undefined(arg);
jis.$function(arg);
jis.$null(arg);

jis.$empty(arg);
jis.$numeric(arg);
jis.$primitive(arg);

Use the new namespaces instead:

jis.types.is(arg, type);
jis.types.$object(arg);
jis.types.$array(arg);
jis.types.$number(arg);
jis.types.$string(arg);
jis.types.$boolean(arg);
jis.types.$undefined(arg);
jis.types.$function(arg);
jis.types.$null(arg);

jis.semantic.$empty(arg);
jis.semantic.$numeric(arg);
jis.semantic.$primitive(arg);

API

Type checks (jis.types)

$array

const { $array } = jis.types // jis.types.$array

$array( [] ) // true

$array( true ) // false
$array( function() {} ) // false
$array( null ) // false
$array( 12 ) // false
$array( {} ) // false
$array( '' ) // false
$array( undefined ) // false

$boolean

const { $boolean } = jis.types

$boolean( true ) // true
$boolean( false ) // true

$boolean( [] ) // false
$boolean( function() {} ) // false

// ...

$function

const { $function } = jis.types

$function( function() {} ) // true

$function( 12 ) // false
$function( {} ) // false
$function( '' ) // false

// ...

$null

const { $null } = jis.types

$null( null ) // true

$null( {} ) // false
$null( '' ) // false
$null( undefined ) // false

// ...

$number

const { $number } = jis.types

$number( 12 ) // true

$number( function() {} ) // false
$number( null ) // false
$number( undefined ) // false

// ...

$object

const { $object } = jis.types

$object( {} ) // true

$object( [] ) // false
$object( true ) // false
$object( 12 ) // false

// ...

$string

const { $string } = jis.types

$string( 'Some text' ) // true

$string( [] ) // false
$string( true ) // false
$string( undefined ) // false

// ...

$undefined

const { $undefined } = jis.types

$undefined( undefined ) // true

$undefined( [] ) // false
$undefined( {} ) // false
$undefined( '' ) // false

// ...

is

This method is the core of the library and provides more flexible and advanced type checks.

const { is } = jis.types

is( [], 'Array' ) // true
is( false, 'Boolean' ) // true
is( true, 'Boolean' ) // true
is( function(){}, 'Function' ) // true
is( null, 'Null' ) // true
is( 12, 'Number' ) // true
is( {}, 'Object' ) // true
is( 'Text', 'String' ) // true
is( undefined, 'Undefined' ) // true

let date = new Date();
is(date, Date) // true

is(/^$/g, RegExp) // true
is(/^$/g, 'RegExp') // true

is(12, 12) // true
is(12, 13) // false

// ... experiment with this method :D

Semantic checks (jis.semantic)

$numeric

Check if the argument is a number or number string (including exponential)

const { $numeric } = jis.semantic // jis.semantic.$numeric

$numeric( 12 ) // true
$numeric( '12' ) // true
$numeric( '-12' ) // true
$numeric( '+12' ) // true
$numeric( '12.' ) // true
$numeric( '12.e5' ) // true
$numeric( '12.E5' ) // true
$numeric( '12.E-5' ) // true
$numeric( '-12.E-5' ) // true
$numeric( '+12.E-5' ) // true

$numeric( '12.E-' ) // false
$numeric( 'A3B' ) // false
$numeric( undefined ) // false
$numeric( null ) // false

$primitive

Check if the argument is a primitive value

const { $primitive } = jis.semantic

$primitive(undefined) // true
$primitive(null) // true
$primitive("something") // true
$primitive(true) // true
$primitive(false) // true
$primitive(12) // true
$primitive(Symbol()) // true

$primitive({}) // false
$primitive([]) // false
$primitive(new Date()) // false

$empty

$empty follows a semantic definition of emptiness, where certain falsy or zero-like values are intentionally considered empty.

const { $empty } = jis.semantic

$empty(null) // true
$empty(undefined) // true
$empty(false) // true
$empty(0) // true
$empty(0.0) // true
$empty("") // true
$empty("0") // true
$empty([]) // true

$empty(true) // false
$empty(12) // false
$empty(12.0) // false
$empty("something") // false
$empty("012") // false
$empty([1, 2, 3]) // false

Changelog

See CHANGELOG.md for version history and breaking changes.