0.2.0 • Published 12 years ago

simple-is v0.2.0

Weekly downloads
289,844
License
-
Repository
github
Last release
12 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-ozturksheyda-sultaneren-karakocburkan-akyurekst-pakettest-packet-hwhalil-ibrahim-baykan@infinitebrahmanuniverse/nolb-simple-i@everything-registry/sub-chunk-2763gokhyildiztaylan-talusumeyra-bayrakserkanovski@camptocamp/babel-plugin-angularjs-annotate@rstacruz/pnpmkaan-yar-dimcikirk2-checkvariableslast-try-1523435sunny-diego-boitypographic-orphan@cdevine49/react-numeric-input@boundless-inc/mobiledoc-dom-rendereryasar-emre-dogruyusuf-ziya-cakmak@pioug/ng-annotatemurat-avciminnodeprojectorhan-kalkanozer-caykaranpm-kurulumuomowaleprovedpasamlkshpaket-olusturma-denemeseda-demirserhat-dalcicekserhat-denizsado_test_packagesadaasgang-di-annotateng-annotate-flaming-cloudng-annotateplatin01uniquepss2soft-engin37react-websocketsilk-paketim-omerhello_world_founderhakan-geyik99halil-toprakhaya-rafeegurkan-bilgic-npmmakepackgekubilay-bayindirmdgucdemir-testing2melih-canaz@wesleysilva6112/babel-plugin-angularjs-annotate@vendhq/babel-plugin-angularjs-annotate@stone-payments/ng-annotatealper-seyman-fbangular-extenderahmet-ali-hasboyaciahmet-faruk-karacaahmet-orman-packetanil-gunduzatilla-onderaycan-akinbabel-plugin-angularjs-annotateazz-elicaner2canimpaketimcenk-buse-favoricucu-pack
0.2.0

12 years ago

0.1.0

12 years ago