Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-is

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-is

maximally minimal type-testing library

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
239K
decreased by-21.69%
Maintainers
1
Weekly downloads
 
Created
Source

simple-is.js

A maximally minimal type-testing library. Use it to make your code more readable. Works in node and browsers.

Usage

var is = require("simple-is");

Use is.number(x) instead of typeof x === "number" (also is.boolean, is.string, is.fn).

Use is.nan(x) instead of typeof x === "number" && isNaN(x), x !== x or ES6 Number.isNaN(x).

Use is.object(x) instead of x !== null && typeof x === "object".

Use is.primitive(x) instead of x === null || x === undefined || typeof x === "boolean" || typeof x === "number" || typeof x === "string" (verbose on purpose).

Use is.array(x) instead of ES5 Array.isArray.

Use is.finitenumber(x) instead of typeof x === "number" && isFinite(x) or ES6 Number.isFinite(x).

Use is.someof(x, ["first", 2, obj]) instead of (usually) x === "first" || x === 2 || x === obj or (alternatively) ["first", 2, obj].indexOf(x) >= 0. Great for reducing copy and paste mistake in if-conditions and for making them more readable.

Use is.noneof(x, ["first", 2, obj]) instead of (usually) x !== "first" && x !== 2 && x !== obj or (alternatively) ["first", 2, obj].indexOf(x) === -1.

Use is.own(x, "name") instead of Object.prototype.hasOwnProperty.call(x, "name").

That's it.

Installation

Node

Install using npm

npm install simple-is
var is = require("simple-is");

Browser

Clone the repo and include it in a script tag

git clone https://github.com/olov/simple-is.git
<script src="simple-is/simple-is.js"></script>

Keywords

FAQs

Package last updated on 21 Apr 2013

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