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

lukinto-utils-type-checking

v1.0.0

Published

A library of type checking utilities.

Downloads

3

Readme

A library of type checking utilities.

Description

This is a library of utilities for checking the types of input values of variables.

Each utility returns a value of the "boolean" type: "true" or "false".

The checks are based on the "isNotExists()" function, which returns "true" if it received one of three values as input, namely "undefined", "null" or "NaN". In this case, it is assumed that the input received "nothing" or something that does not exist. When any other value is received as input, it is assumed that something existing has been received. To invert its result, the "isExists()" function is used, which returns "true" when receiving a value that is considered to exist.

In all other functions, the "isExists()" function is applied first, and only after that the operation of checking the type of this input value is performed.

Installation

$ npm install lukinto-utils-type-checking

Usage

const {
  isString,
  isStringEmpty,
  isStringNotEmpty,
} = require('lukinto-utils-type-checking')

const input = ''

if (isString(input)) { // => true
  // your code
}
if (isStringEmpty(input)) { // => true
  // your code
}
if (isStringNotEmpty(input)) { // => false
  // your code
}

API

isNotExists(input) ⇒ boolean

  • When the input value is "undefined", "null" or "NaN" returns "true".
  • Returns "false" in all other cases!

isExists(input) ⇒ boolean

  • When the input value is "undefined", "null" or "NaN" returns "false".
  • Returns "true" in all other cases!

isBoolean(input) ⇒ boolean

  • When the input value is of type "boolean", returns "true".
  • Returns "false" in all other cases!

isBooleanObject(input) ⇒ boolean

  • When the input value is the "Boolean" object, returns "true".
  • Returns "false" in all other cases!

isBooleanAny(input) ⇒ boolean

  • When the input value of type "boolean" or is the "Boolean" object, returns "true".
  • Returns "false" in all other cases!

isNumber(input) ⇒ boolean

  • When the input value is of type "number", returns "true".
  • Returns "false" in all other cases!

isNumberZero(input) ⇒ boolean

  • When the input value is of type "number" and is equal to 0, returns "true".
  • Returns "false" in all other cases!

isNumberNotZero(input) ⇒ boolean

  • When the input value is of type "number" and is not equal to 0, returns "true".
  • Returns "false" in all other cases!

isNumberObject(input) ⇒ boolean

  • When the input value is the "Number" object, returns "true".
  • Returns "false" in all other cases!

isNumberAny(input) ⇒ boolean

  • When the input value of type "number" or is the "Number" object, returns "true".
  • Returns "false" in all other cases!

isBigInt(input) ⇒ boolean

  • When the input value of type "bigint", returns "true".
  • Returns "false" in all other cases!

isString(input) ⇒ boolean

  • When the input value is of type "string", returns "true".
  • Returns "false" in all other cases!

isStringEmpty(input) ⇒ boolean

  • When the input value is of type "string" and is equal to '' (empty string), returns "true".
  • Returns "false" in all other cases!

isStringNotEmpty(input) ⇒ boolean

  • When the input value is of type "string" and is not equal to '' (empty string), returns "true".
  • Returns "false" in all other cases!

isStringObject(input) ⇒ boolean

  • When the input value is the "String" object, returns "true".
  • Returns "false" in all other cases!

isStringAny(input) ⇒ boolean

  • When the input value of type "string" or is the "String" object, returns "true".
  • Returns "false" in all other cases!

isRegExp(input) ⇒ boolean

  • When the input value is the "RegExp" object, returns "true".
  • Returns "false" in all other cases!

isArray(input) ⇒ boolean

  • When the input value is the "Array" object, returns "true".
  • Returns "false" in all other cases!

isArrayEmpty(input) ⇒ boolean

  • When the input value is the "Array" object and its length is 0, returns "true".
  • Returns "false" in all other cases!

isArrayNotEmpty(input) ⇒ boolean

  • When the input value is the "Array" object and its length is greater than 0, returns "true".
  • Returns "false" in all other cases!

isSet(input) ⇒ boolean

  • When the input value is the "Set" object, returns "true".
  • Returns "false" in all other cases!

isSetEmpty(input) ⇒ boolean

  • When the input value is the "Set" object and its size is 0, returns "true".
  • Returns "false" in all other cases!

isSetNotEmpty(input) ⇒ boolean

  • When the input value is the "Set" object and its size is greater than 0, returns "true".
  • Returns "false" in all other cases!

isMap(input) ⇒ boolean

  • When the input value is the "Map" object, returns "true".
  • Returns "false" in all other cases!

isMapEmpty(input) ⇒ boolean

  • When the input value is the "Map" object and its size is 0, returns "true".
  • Returns "false" in all other cases!

isMapNotEmpty(input) ⇒ boolean

  • When the input value is the "Map" object and its size is greater than 0, returns "true".
  • Returns "false" in all other cases!

isDate(input) ⇒ boolean

  • When the input value is the "Date" object, returns "true".
  • Returns "false" in all other cases!

isPromise(input) ⇒ boolean

  • When the input value is the "Promise" object, returns "true".
  • Returns "false" in all other cases!

isObjectAny(input) ⇒ boolean

  • When the input value is of type "object", returns "true".
  • Returns "false" in all other cases!

isObject(input) ⇒ boolean

  • When the input value is of type "object" and is not one of the objects from the following list: "Boolean", "Number", "String", "RegExp", "Array", "Set", "Map", "Date" or "Promise", returns "true".
  • Returns "false" in all other cases!

isObjectEmpty(input) ⇒ boolean

  • When the input value is of type "object", satisfies the conditions for checking the function "isObject()", and is also empty, returns "true".
  • Returns "false" in all other cases!

isObjectNotEmpty(input) ⇒ boolean

  • When the input value is of type "object", satisfies the conditions for checking the function "isObject()", and is also not empty, returns "true".
  • Returns "false" in all other cases!

isSymbol(input) ⇒ boolean

  • When the input value is of type "symbol", returns "true".
  • Returns "false" in all other cases!