New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

iftype

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iftype

Check types

1.1.1
Source
npm
Version published
Weekly downloads
5.4K
-48.18%
Maintainers
1
Weekly downloads
 
Created
Source

iftype

Build Status Code Climate Code Coverage npm Version

Check types

Installation

$ npm install iftype --save

Usage

var iftype = require('iftype');

//----------------------------
// Check if type is string
//----------------------------
iftype(123).is('string'); // => false
iftype(function foo(){}).is('string'); // => false
iftype(["foo", "bar"]).is('string'); // => false
iftype("bar").is('string'); // => true
iftype(null).is('string'); // => false
iftype(undefined).is('string'); // => false


//----------------------------
// Check if type is number
//----------------------------
iftype(123).is('number'); // => true
iftype(function foo(){}).is('number'); // => false
iftype(["foo", "bar"]).is('number'); // => false
iftype("bar").is('number'); // => false
iftype(null).is('number'); // => false
iftype(undefined).is('number'); // => false


//----------------------------
// Check if type is object
//----------------------------
iftype(123).is('object'); // => false
iftype(function foo(){}).is('object'); // => false
iftype(["foo", "bar"]).is('object'); // => true
iftype("bar").is('object'); // => false
iftype(null).is('object'); // => false
iftype(undefined).is('object'); // => false


//----------------------------
// Check if type is array
//----------------------------
iftype(123).is('array'); // => false
iftype(function foo(){}).is('array'); // => false
iftype(["foo", "bar"]).is('array'); // => true
iftype("bar").is('array'); // => false
iftype(null).is('array'); // => false
iftype(undefined).is('array'); // => false


//----------------------------
// Check if type is function
//----------------------------
iftype(123).is('function'); // => false
iftype(function foo(){}).is('function'); // => true
iftype(["foo", "bar"]).is('function'); // => false
iftype("bar").is('function'); // => false
iftype(null).is('function'); // => false
iftype(undefined).is('function'); // => false



API

SignatureDescription
iftype(val).is(type)Check if type match.
iftype(val).isString()Check if string.
iftype(val).isNumber()Check if number.
iftype(val).isObject()Check if object.
iftype(val).isArray()Check if array.
iftype.is(type, val)Check if type match.
iftype.isString(val)Check if string.
iftype.isNumber(val)Check if number.
iftype.isObject(val)Check if object.
iftype.isArray(val)Check if array.

License

This software is released under the MIT License.

Keywords

type

FAQs

Package last updated on 04 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts