JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1152360
  • Score
    100M100P100Q184623F
  • License MIT

A tiny javascript type testing tool

Package Exports

  • is-lite

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (is-lite) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

is-lite

NPM version build status Maintainability Test Coverage

Type check tool (just 0.6k minified+gzipped)

Setup

npm install is-lite

Usage

import is from 'is-lite';

const value = '';

is.string(value) // true;

API

is(value)

Returns the type of the value.

Primitives are lowercase: bigint, boolean, null, number, string, symbol, undefined
The rest are camelcase: Array, Function, GeneratorFunction, Object, ...

####is.array(value)

####is.asyncFunction(value)

Check if value is an async function that can be called with await

is.asyncFunction(async () => {}); // => true
is.asyncFunction(() => {}); // => false

####is.boolean(value)

####is.date(value)

####is.domElement(value)
Check if value is a DOM Element.

####is.error(value)

####is.function(value)

####is.generator(value)
Check for an object that has its own .next() and .throw() methods and has a function definition for Symbol.iterator

####is.generatorFunction(value)

####is.instanceOf(value, class) Check if value is a direct instance of class

class APIError extends Error {}

const error = new APIError('Fail');

is.instanceOf(error, APIError); // true 
is.instanceOf(error, Error); // false 

####is.iterable(value)

####is.map(value)

####is.nan(value)

####is.null(value)

####is.nullOrUndefined(value)

####is.number(value)
Note: is.number(NaN) returns false

####is.numericString(value) Check for a string that represents a number. For example, '42' and '-8'. Note: 'NaN' returns false, but 'Infinity' and '-Infinity' return true

####is.object(value) Remember that functions and arrays are objects too.

####is.plainObject(value) Check if the object is created by either {}, new Object(), or Object.create(null).

####is.promise(value)

####is.regexp(value)

####is.set(value)

####is.string(value)

####is.symbol(value)

####is.undefined(value)

####is.weakMap(value)

####is.weakSet(value)

FAQ

@sindresorhus/is is amazing but I needed something even smaller (and simpler). This package cover the basics and is only 0.6k minified+gzipped.