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

javascript-type-checker

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

javascript-type-checker

Utility to validate or fetch type of given argument in javascript.

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

javascript-type-checker

A NPM module to validate or fetch type of given argument in javascript.

Table of Contents

  • Installation
  • Available Methods

Installation

npm install javascript-type-checker --save

Available Methods

isArray(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isArray(['A','B',3])); // true
console.log(javascriptTypeChecker.isArray('A')); // false

isObject(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isObject({'key':'value'})); // true
console.log(javascriptTypeChecker.isObject(['A','B',3])); // false

isNumber(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isNumber(123)); // true
console.log(javascriptTypeChecker.isNumber('123')); // false
console.log(javascriptTypeChecker.isNumber(NaN)); // false

isError(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isError(new Error('Test Error'))); // true
console.log(javascriptTypeChecker.isError('Test Error')); // false

isString(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isString('123')); // true
console.log(javascriptTypeChecker.isString(123)); // false

isBoolean(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isBoolean(false)); // true
console.log(javascriptTypeChecker.isBoolean('false')); // false

isNull(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isNull(null)); // true
console.log(javascriptTypeChecker.isNull('ABC')); // false

isUndefined(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isUndefined({}.testKey)); // true
console.log(javascriptTypeChecker.isUndefined({})); // false

isEmptyObject(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isEmptyObject({})); // true
console.log(javascriptTypeChecker.isEmptyObject({'key':'value'})); // false

isEmptyArray(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isEmptyArray([])); // true
console.log(javascriptTypeChecker.isEmptyArray(['A'])); // false

isArrayOfEmptyArrays(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.isArrayOfEmptyArrays([[[[]], [[]]], [])); // true
console.log(javascriptTypeChecker.isArrayOfEmptyArrays([[[[[]]]], 'A'])); // false

getType(argument)

const javascriptTypeChecker = require('javascript-type-checker');
console.log(javascriptTypeChecker.getType('123')); // string
console.log(javascriptTypeChecker.getType(123)); // number
console.log(javascriptTypeChecker.getType(true)); // boolean
console.log(javascriptTypeChecker.getType(NaN)); // NaN
console.log(javascriptTypeChecker.getType(null)); // null
console.log(javascriptTypeChecker.getType(undefined)); // undefined
console.log(javascriptTypeChecker.getType({})); // object
console.log(javascriptTypeChecker.getType([])); // array
console.log(javascriptTypeChecker.getType(new Error('test'))); // error

Keywords

FAQs

Package last updated on 04 Jul 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc