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

is-type-of

v2.1.0

Published

complete type checking for node

Downloads

1,764,595

Readme

is-type-of

Complete type checking for Node

Features

  • 🔒 Usefull Type Checking,including Primitive, Standard Object, Node Object
  • ✨ Typescript Support
  • 🚪 Typescript Type Guard Support

Install

npm install is-type-of

Usage

Use ES Module import

import is from 'is-type-of';
import { isArray } from 'is-type-of';

isArray([]); // => true
is.array(); // => true

Compatible With

const is = require('is-type-of');

is.array([1]); // => true
is.primitive(true); // => true
is.primitive({}); // => false
is.generatorFunction(function * () {}); // => true
is.long(Math.pow(2, 33)); // => true
is.double(0); // => false

Use Type Guard

import { isArray } from 'is-type-of';

function checkArray(arr: string[] | string) {
  // => parameter) arr: string | string[]
  if (isArray(arr)) {
    // => (parameter) arr: string[]
    arr.forEach(console.log);
  }
}

API Document

Primitive

isString

Returns true if val is string, not String object.

See Also is.string

isNumber

Returns true if val is number, not Number object.

See Also is.number

isBoolean

Returns true if val is boolean, not Boolean object.

See Also is.boolean

isBigInt

Returns true if val is bigint.

See Also is.bigInt

isSymbol

Returns true if val is symbol.

See Also is.symbol

isUndefined

Returns true if val is undefined.

See Also is.undefined

isNull

Returns true if val is null.

See Also is.null

isNullable

Returns true if val is null or undefined.

See Also is.nullable

isPrimitive

Returns true if val is primitive.

See Also is.primitive

isInteger

Returns true if val is integer.

See Also is.integer

isInteger32

Returns true if val is integer, and between -2 ** 31 and 2 ** 31 - 1.

See Also is.integer32

isLong

Returns true if val is integer, and < -2 ** 31, and > 2 ** 31 - 1.

See Also is.long

isSafeInteger

Returns true if val is integer, and between -(2 ** 53 - 1) and 2 ** 53 - 1.

See Also is.safeInteger

isDouble

Returns true if val is Double.

See Also is.double

isNaN

Returns true if val is NaN.

See Also is.NaN

isFinite

Returns true if val is finite.

See Also is.finite

Standard Object

API Documentation

isArray

Returns true if val is array, it won't check items of array.

See Also is.array

isFunction

Returns true if val is function.

See Also is.function

isGeneratorFunction

Returns true if val is generator function.

See Also is.generatorFunction

isAsyncFunction

Returns true if val is async function.

See Also is.asyncFunction

isAsyncGeneratorFunction

Returns true if val is async generator function.

See Also is.asyncGeneratorFunction

isObject

Returns true if val is object.

See Also is.object

isClass

Returns true if val is class.

Note: "class" is supported in ECMAScript 6, and if the code is using some compiler or transpiler, the checking might fail.

See Also is.class

isRegExp

Returns true if val is regular expression.

See Also is.regExp

isDate

Returns true if val is instance of Date.

See Also is.date

isError

Returns true if val is instance of Error.

See Also is.error

isGenerator

Returns true if val is generator.

See Also is.generator

isPromise

Returns true if val is promise.

See Also is.promise

isPromiseLike

Returns true if val is like promise, if the object has then property, the checking will pass.

See Also is.promiseLike

Node Object

isBuffer

Returns true if val is buffer.

See Also is.buffer

isStream

Returns true if val is stream.

See Also is.stream

isReadable

Returns true if val is readable stream.

See Also is.readable

isWritable

Returns true if val is write stream.

See Also is.writable

isDuplex

Returns true if val is duplex stream.

See Also is.duplex

External Object

isLongObject

returns true if val is LongObject

LongObject is from npm package long

See Also is.longObject

Thanks

License

MIT