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

isnot

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isnot

All imaginable type checking utils with negation

  • 0.9.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by60%
Maintainers
1
Weekly downloads
 
Created
Source

isnot

Beautifully documented type checking package for JavaScript.

Usage

Use any of the functions as named exports:

const {isString, isArray} = require('isnot')
//or
import {isObject} from 'isnot'

Functions

Strings

String

Corresponds to the js string primitive

isString
isString('') //true
isNotString
isNotString(()=>{}) //true
Empty String

An empty string is only ''

isEmptyString

Purely checks if the string is empty

isEmptyString({}) //false

isEmptyString('') //true

isEmptyString(' ') //false

isEmptyString
isNotEmptyString('') //false
Name

A name is a string that is just not empty space.

isName
isName('') //false

isName(' ') //false

isName('\r') //false

isName(123) //false

isName('hey') //true
isNotName
isNotName('') //true

isNotName(' ') //true

isNotName('\n') //true

isNotName([]) //true

isNotName({}.toString()) //false
Email
isEmail
isEmail('a@b.c') //true
isNotEmail
isNotEmail('missing@dot') //true

isNotEmail('missing.domain') //true
Variable Name
isVariableName

isVariableName('var') //true (technically not, but it can be a property of an object accessed without ['...'])

isVariableName('oh dear') //false

isVariableName('0rel') //false cannot start with number

isVariableName('var0') //true
isNotVariableName
isNotVariableName('a@a') //true

isNotVariableName('--var--') //true
URL
isURL
isURL('https://localhost') //true

isURL('www.site.com') //true
isNotURL
isNotURL('a@a') //true

isNotURL('site.com') //false
ISO String

Checks only if string it's in a ISO format, not if the date is actually a valid date. Useful to check date properties stored in a database.

isISOString
isISOString(new Date().toISOString()) //true

isISOString('2017-06-01T18:43:26.000-02:00') //true

isISOString('2017-06-01T18:43:26.000Z') //true
isNotISOString
isNotISOString('2017-06-01') //true

isNotISOString('2017/06/01') //true

isNotISOString('2017/06/01T18:43:26.000-02:00') //true

isNotISOString(new Date().toString()) //true
UUID

Tests any version of UUID from 1 to 5.

isUUID
isUUID(uuidv1()) //true

isUUID(uuidv2()) //true

isUUID(uuidv3()) //true

isUUID(uuidv4()) //true

isUUID(uuidv5()) //true

isUUID('5a2de30a-a736-5aea-8f7f-ad0f019cdc00') //true
isNotUUID
isNotUUID('2017-06-01') //true

Arrays

isArray/isNotArray
isArray([]) // true

isArray({}) // false

isNotArray() // true

isNotArray(['hey']) // false
isEmptyArray/isNotEmptyArray
isEmptyArray([]) // true

isEmptyArray({}) // false

isNotEmptyArray([]) // false

isNotEmptyArray([1]) // true

isNotEmptyArray({}) // false
isArrayOfNames
isArrayOfNames([]) // false

isArrayOfNames([' ', '']) // false

isArrayOfNames(['1', 'foo']) // true

Objects

Object
isObject()
isObject([]) // FALSE, arrays are not objects for this library

isObject({}) // true
isNotObject()
isNotObject('') //true
isEmptyObject()
isEmptyObject({}) //true
isNotEmptyObject()
isNotEmptyObject({a: 1}) //true

Numbers

isNumber(1) //true

isNotNumber(NaN) //true

isInt(0) //true

isNotInt(1.2) //true

Bool

isBool(1) //false

isNotBool(NaN) //true

isBool(0) //false

isBool(true) //true

Generic

isEmpty([]) //true

isEmpty('') //true

isEmpty(' ') //true

isEmpty({}) //true

isEmpty(null) //true

isEmpty(undefined) //true

isEmpty(0) //false

isNotEmpty('hey') //true

Dates

isDate('') //false

isNotDate('') //true

isDate(new Date()) //true

isDate('1970-01-01T00:00:00.000Z') //true

isDate('1970-01-01T00:00:00') //true

isDate('1970-01-01T00:00') //true

isDate('1970-01-01') //true

isDate('0000-00-00') //false

isDate('1970-13-01') //false (bad month)

isDate('1970-01-32') //false (bad day)

isDate('2017-02-29') //false (not leap year)

undefined

isUndefined('') //false

isUndefined(false) //false

isUndefined(undefined) //true

isUndefined(typeof undefined) //false

isUndefined({}.inventedProp) //true

Keywords

FAQs

Package last updated on 23 Nov 2019

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