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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jis

v1.0.36

Published

When you need validate the variable data type

Downloads

9

Readme

Jis

jis is a data type verifier for older browsers. Based in Object.prototype.toString.call

The library has some methods to check the data type.

Installation

npm install jis

You can install this library with npm or yarn. And you can add in devDependecies with

npm install jis --dev

Usage

Import in ES5 or higher
let jis = require('jis')
Import in TS
import jis from 'jis'

Methods

$array

jis.$array( [] ) // true

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

jis.$boolean( true ) // true
jis.$boolean( false ) // true

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

// ...
$function

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

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

// ...
$null

jis.$null( null ) // true

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

// ...
$number

jis.$number( 12 ) // true

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

// ...
$object

jis.$object( {} ) // true

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

// ...
$string

jis.$string( 'Some text' ) // true

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

// ...
$undefined

jis.$undefined( undefined ) // true

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

// ...
$numeric

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


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

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

Check if the argument is primitive type


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

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

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

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

This method is the library core. Have more options.


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

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

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

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

// ... experiment with this method :D