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

is-lite

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-lite

A tiny javascript type testing tool

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
556K
decreased by-13.52%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 12 Aug 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