An open API service indexing awesome lists of open source software.

https://github.com/toxic-johann/toxic-predicate-functions

predicate functions collection
https://github.com/toxic-johann/toxic-predicate-functions

predicate-functions utils

Last synced: 4 months ago
JSON representation

predicate functions collection

Awesome Lists containing this project

README

          

# toxic-predicate-functions

[![Build Status](https://img.shields.io/travis/toxic-johann/toxic-predicate-functions/master.svg?style=flat-square)](https://travis-ci.org/toxic-johann/toxic-predicate-functions.svg?branch=master)
[![Coverage Status](https://img.shields.io/coveralls/toxic-johann/toxic-predicate-functions/master.svg?style=flat-square)](https://coveralls.io/github/toxic-johann/toxic-predicate-functions?branch=master)
[![npm](https://img.shields.io/npm/v/toxic-predicate-functions.svg?colorB=brightgreen&style=flat-square)](https://www.npmjs.com/package/toxic-predicate-functions)
[![dependency Status](https://david-dm.org/toxic-johann/toxic-predicate-functions.svg)](https://david-dm.org/toxic-johann/toxic-predicate-functions)
[![devDependency Status](https://david-dm.org/toxic-johann/toxic-predicate-functions/dev-status.svg)](https://david-dm.org/toxic-johann/toxic-predicate-functions?type=dev) [![Greenkeeper badge](https://badges.greenkeeper.io/toxic-johann/toxic-predicate-functions.svg)](https://greenkeeper.io/)

predicate functions collection

## get started

```shell
npm install toxic-predicate-functions --save
```

if you are using `flow`, you should import our flow defination, by adding this to your `.flowconfig`.

```ya
[ignore]

[include]

[libs]
./node_modules/toxic-predicate-functions/lib/index.flow.js
[options]

[lints]
```

## doc

### defined

[src/index.js:5-7](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L5-L7 "Source code on GitHub")

to check whether the object is defined or not

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isVoid

[src/index.js:11-13](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L11-L13 "Source code on GitHub")

is void element or not ? Means it will return true when val is undefined or null

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isArray

[src/index.js:17-19](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L17-L19 "Source code on GitHub")

to check whether a variable is array

**Parameters**

- `arr` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isFunction

[src/index.js:24-26](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L24-L26 "Source code on GitHub")

is it a function or not

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isObject

[src/index.js:31-34](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L31-L34 "Source code on GitHub")

is it an object or not

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isNumber

[src/index.js:38-40](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L38-L40 "Source code on GitHub")

to tell you if it's a real number

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isNumeric

[src/index.js:44-46](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L44-L46 "Source code on GitHub")

to tell you if the val can be transfer into number

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isInteger

[src/index.js:50-52](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L50-L52 "Source code on GitHub")

is it an interget or not

**Parameters**

- `num` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isEmpty

[src/index.js:57-65](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L57-L65 "Source code on GitHub")

return true when the value is "", {}, \[], 0, null, undefined, false.

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isEvent

[src/index.js:69-71](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L69-L71 "Source code on GitHub")

is it an event or not

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isBlob

[src/index.js:75-77](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L75-L77 "Source code on GitHub")

is it a blob

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isFile

[src/index.js:81-83](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L81-L83 "Source code on GitHub")

is it a file uploaded by user through file inpue

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isDate

[src/index.js:87-89](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L87-L89 "Source code on GitHub")

is it a date

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isString

[src/index.js:93-96](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L93-L96 "Source code on GitHub")

is it a string

**Parameters**

- `str` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isBoolean

[src/index.js:100-102](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L100-L102 "Source code on GitHub")

is Boolean or not

**Parameters**

- `bool` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isPromise

[src/index.js:106-108](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L106-L108 "Source code on GitHub")

is a promise or not

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isPrimitive

[src/index.js:112-114](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L112-L114 "Source code on GitHub")

is Primitive type or not, whick means it will return true when data is number/string/boolean/undefined/null

**Parameters**

- `val` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isUrl

[src/index.js:118-120](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L118-L120 "Source code on GitHub")

is it an url, but this test require the url to have an protocol

**Parameters**

- `str` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isNode

[src/index.js:124-131](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L124-L131 "Source code on GitHub")

to test if a HTML node

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isElement

[src/index.js:135-143](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L135-L143 "Source code on GitHub")

to test if a HTML element

**Parameters**

- `obj` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isChildNode

[src/index.js:147-152](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L147-L152 "Source code on GitHub")

check if node A is node B's parent or not

**Parameters**

- `parent` **[Node](https://developer.mozilla.org/en-US/docs/Web/API/Node/nextSibling)**
- `child` **[Node](https://developer.mozilla.org/en-US/docs/Web/API/Node/nextSibling)**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isPosterityNode

[src/index.js:156-167](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L156-L167 "Source code on GitHub")

check if node B is node A's posterrity or not

**Parameters**

- `parent` **[Node](https://developer.mozilla.org/en-US/docs/Web/API/Node/nextSibling)**
- `child` **[Node](https://developer.mozilla.org/en-US/docs/Web/API/Node/nextSibling)**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isHTMLString

[src/index.js:171-173](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L171-L173 "Source code on GitHub")

check if the string is an HTMLString

**Parameters**

- `str` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isError

[src/index.js:177-179](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L177-L179 "Source code on GitHub")

check if is an error

**Parameters**

- `val` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**

### isRegExp

[src/index.js:183-185](https://github.com/toxic-johann/toxic-predicate-functions/blob/126adb1bdf2ab98826e10aa1b465209accb97197/src/index.js#L183-L185 "Source code on GitHub")

check if is an RegExp

**Parameters**

- `val` **any**

Returns **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**