npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simply-is

v2.5.8

Published

An expressive type testing library

Downloads

42

Readme

Simply Is

Simply Is Dependency badge

An expressive type testing utility library.

GITHUB: https://github.com/anonmily/simply-is

NPM: https://www.npmjs.com/package/simply-is

Installation - Node

To install as a Node package, simply install via npm:

npm install simply-is

Then, you can require and start using the package as you wish:

var is = require('simply-is');
console.log( is('300').a.number );

Installation - Bower/Frontend

The package can be installed via Bower:

bower install simply-is

SimplyIs can also be downloaded directly.

Note, for frontend use, the file that should be included is simplyis.js:

<script src='/bower_components/simplyis/simplyis.js'></script>

The script is available as a global module as well as an AMD module. As a global module, it can be accessed through window.simplyIs.

var is = window.simplyIs;
console.log( is('300').a.number );

Usage

Example

var is = require('simply-is');

is.object({}); 			//true
is.a.string('hello')	//chaining
is.not.an.array({})		//negation

//alternative syntax
is(3).even
is('hello').a.string
is('[{"key":"somevalue"}]').json

Basics

is.argument 	( (function(){ return arguments; })(1,2,3) )
is.array 		([1,2,3])
is.boolean 		(1==1)
is.date 		(new Date())
is.defined 		(1)
is.function 	(function(){return 'hi'})
is.json 		('[{"key":"somevalue"}]')
is.null 		(Null)
is.number 		(1)
is.object 		({})
is.regexp 		(/abc/)
is.string 		('hello world')
is.undefined 	(undefined)

Utility

is.empty		({}) 	//true for {}, [], 0, "", null, undefined, false
is.equal 		( {a: 1, b: "hello"}, {b:"hello", a:1} )
is.sameType 	({	a: 1, b: "hello" }, { a: "number", b: "string" })

is.inArray 		('a',['a','b','c'])

is.inObject 	('apple',{fruit: 'apple'})
is.inObject 	('fruit',{fruit: 'apple'})

is.instanceOf 	( doberman, DogConstructor )

Contains/inside

is.inside("fred", {"user": "fred", "age":40 })
is.inside("age", {"user": "fred", "age":40 })
is.inside("apple",["peach","apple","grapes"])
is.inside("cat","I love cats")

is("fred").inside({"user": "fred", "age":40 })
is("age").inside({"user": "fred", "age":40 })
is("apple").inside(["peach","apple","grapes"])
is("cat").inside("I love cats")

Numbers

is.number		(1)
is.nan			(NaN)
is.infinite		(Infinity)
is.even			(2)
is.odd			(3)
is.integer 		(10)
is.decimal 		(10.5)
is.numberValid 	(Infinity) //returns false for Infinity, -Infinity, NaN, and non-numbers
is.numberInvalid (NaN) //true. opposite of is.numberValid

Booleans

is.boolean  	(true)
is.true			(1==1)
is.false		(1==2)

Patterns

is.email 		('[email protected]')
is.phone 		('626-123-4567')
is.alpha 		('abcdefghij')
is.numeric 		('123455')
is.alphanumeric ('test12345')

TODO

  1. is.csv
  2. is.yaml
  3. is.xml
  4. is.deepEqual

Changelog

| Version | Notes | |---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 2.4.7 | Used getter functions for isfunc to improve performance. The result of the comparison will only run when the result is needed/requested rather than stored in a static property. | | 2.5.5 | Added in is.equal and is.sameType | | 2.5.6 | Added is.email, is.phone, is.alpha, is.numeric, is.alphanumeric | | 2.5.7 | Added is.numberValid and is.numberInvalid |