simple-is

WebJar for simple-is

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

simple-is
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

simple-is
WebJar for simple-is
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/olov/simple-is

Download simple-is

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/simple-is/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>simple-is</artifactId>
    <version>0.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/simple-is/
implementation 'org.webjars.npm:simple-is:0.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/simple-is/
implementation ("org.webjars.npm:simple-is:0.2.0")
'org.webjars.npm:simple-is:jar:0.2.0'
<dependency org="org.webjars.npm" name="simple-is" rev="0.2.0">
  <artifact name="simple-is" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='simple-is', version='0.2.0')
)
libraryDependencies += "org.webjars.npm" % "simple-is" % "0.2.0"
[org.webjars.npm/simple-is "0.2.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

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>

Versions

Version
0.2.0