# simply-is

> An expressive type testing library

Latest version **2.5.8** (published 2016-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install simply-is
pnpm add simply-is
yarn add simply-is
bun add simply-is
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.5.8 |
| Published | 2016-07-08 |
| First published | 2015-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Michelle Liu |
| Maintainers | anonmily |
| Keywords | type, utility, util, boolean, typing, type testing, type check |

## Links

- npm: https://www.npmjs.com/package/simply-is
- Repository: https://github.com/anonmily/simply-is
- Homepage: https://github.com/anonmily/simply-is#readme
- Issues: https://github.com/anonmily/simply-is/issues
- npm.io page: https://npm.io/package/simply-is

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 2.5.8 (latest) — 2016-07-08
- 2.5.7 — 2016-05-26
- 2.5.6 — 2016-03-31
- 2.5.5 — 2015-12-20
- 2.5.4 — 2015-12-20
- 2.5.3 — 2015-12-20
- 2.5.2 — 2015-12-20
- 2.5.1 — 2015-12-20
- 2.5.0 — 2015-12-20
- 2.4.7 — 2015-12-20
- 2.4.6 — 2015-11-08
- 2.4.5 — 2015-11-08
- 2.4.4 — 2015-11-08
- 2.4.3 — 2015-11-08
- 2.4.2 — 2015-11-08
- … 16 more at https://npm.io/package/simply-is/versions

## README

Simply Is
====================
![Simply Is Dependency badge](https://david-dm.org/anonmily/simply-is.svg)

An expressive type testing utility library.

[GITHUB:	https://github.com/anonmily/simply-is](https://github.com/anonmily/simply-is)

[NPM:		https://www.npmjs.com/package/simply-is](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](https://raw.githubusercontent.com/anonmily/simply-is/master/simplyis.js) 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 		('test@test.com')
	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                                                                                                                                             |

---
_Source: https://npm.io/package/simply-is · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
