The JavaScript Database, for Node.js, nw.js, electron and the browser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
nedb/docs/utils.md

67 lines
2.1 KiB

<a name="module_utils"></a>
## utils
<p>Utility functions for all environments.
This replaces the underscore dependency.</p>
* [utils](#module_utils)
* _static_
* [.uniq(array, [iteratee])](#module_utils.uniq) ⇒ <code>Array</code>
* [.isDate(d)](#module_utils.isDate) ⇒ <code>boolean</code>
* [.isRegExp(re)](#module_utils.isRegExp) ⇒ <code>boolean</code>
* _inner_
* [~isObject(arg)](#module_utils..isObject) ⇒ <code>boolean</code>
<a name="module_utils.uniq"></a>
### utils.uniq(array, [iteratee]) ⇒ <code>Array</code>
<p>Produces a duplicate-free version of the array, using === to test object equality. In particular only the first
occurrence of each value is kept. If you want to compute unique items based on a transformation, pass an iteratee
function.
Heavily inspired by https://underscorejs.org/#uniq</p>
**Kind**: static method of [<code>utils</code>](#module_utils)
| Param | Type | Description |
| --- | --- | --- |
| array | <code>Array</code> | |
| [iteratee] | <code>function</code> | <p>transformation applied to every element before checking for duplicates. This will not transform the items in the result.</p> |
<a name="module_utils.isDate"></a>
### utils.isDate(d) ⇒ <code>boolean</code>
<p>Returns true if d is a Date.
Heavily inspired by https://underscorejs.org/#isDate</p>
**Kind**: static method of [<code>utils</code>](#module_utils)
| Param | Type |
| --- | --- |
| d | <code>\*</code> |
<a name="module_utils.isRegExp"></a>
### utils.isRegExp(re) ⇒ <code>boolean</code>
<p>Returns true if re is a RegExp.
Heavily inspired by https://underscorejs.org/#isRegExp</p>
**Kind**: static method of [<code>utils</code>](#module_utils)
| Param | Type |
| --- | --- |
| re | <code>\*</code> |
<a name="module_utils..isObject"></a>
### utils~isObject(arg) ⇒ <code>boolean</code>
<p>Returns true if arg is an Object. Note that JavaScript arrays and functions are objects, while (normal) strings
and numbers are not.
Heavily inspired by https://underscorejs.org/#isObject</p>
**Kind**: inner method of [<code>utils</code>](#module_utils)
| Param | Type |
| --- | --- |
| arg | <code>\*</code> |