0.2.0 • Published 11 years ago

simple-is v0.2.0

Weekly downloads
289,844
License
-
Repository
github
Last release
11 years ago

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.function).

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.in(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>
asdasd-paketmahmut-aktasmustafa-murat-coskun-yusufmuhammet-deregozu-testtugrul-arslancelalettinayvaci-paketrchntestvolkan-altugmehmetkablanugur-volkan-golrahman-niftaliyevkutlu-ersoyturgut-acarbu-benim-denemememir-onanhs2-denememeherremovemek-sedar-cicekkubilay-uysal-paketmido_packageridvan-denemetolga-kaya-testtolga-kaya-test-retestjavids-new-packetherina-ibosahinelikhasangeorge13ayhan-karaman-gss-kdrozgun-sefa-ozturkyakupsheyda-sultaneren-karakocburkan-akyurekst-pakettest-packet-hwhalil-ibrahim-baykan@infinitebrahmanuniverse/nolb-simple-i@everything-registry/sub-chunk-2763@vendhq/babel-plugin-angularjs-annotateesma-puremre-curekenes-senemirali-gungor-nodejs-firsttrydursun-kokturkequrbanoveren-karaes6-transpileregemen-jsahmet-ali-hasboyaciahmet-faruk-karacaahmet-orman-packetalper-seyman-fb@wesleysilva6112/babel-plugin-angularjs-annotatefatih-emre-akyuzdefslast-try-1523435ilk-paketim-omerburak-cengizcaner2canimpaketimmdgucdemir-testing2makepackgeminnodeprojectgokhyildizangular-extenderanil-gunduz@boundless-inc/mobiledoc-dom-rendereraycan-akinmurat-avci@camptocamp/babel-plugin-angularjs-annotatehaya-rafeehello_world_founderbetul-karadumanbootmarkcbtnodeexcucu-packkubilay-bayindirazz-eli@cdevine49/react-numeric-inputgurkan-bilgic-npmbabel-plugin-angularjs-annotatehalil-toprakhakan-geyik99berke-erdogancenk-buse-favorikirk2-checkvariableskaan-yar-dimcing-di-annotateng-annotateng-annotate-flaming-cloudomowaleprovedpaket-olusturma-denemepasamlkshozer-caykaranpm-kurulumuorhan-kalkanplatin01uniquereact-websocketspss2@rstacruz/pnpm
0.2.0

11 years ago

0.1.0

11 years ago