Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-tools

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-tools - npm Package Compare versions

Comparing version 1.5.3 to 1.6.0

test/chaining.js

120

lib/array-tools.js
"use strict";
var t = require("typical"),
o = require("object-tools");
var t = require("typical");
var o = require("object-tools");
var util = require("util");
/**
Useful functions for working with arrays
Lightweight tool-kit for working with arrays.
```js
> var a = require("array-tools");
> a.exists([ 1, 2, 3 ], 1)
true
```
You can also chain together operations. The process:
1. Pass your input array to array-tools as an argument.
2. Chain together your operations. From array-tools, you may use {@link module:array-tools.pluck}, {@link module:array-tools.pick}, {@link module:array-tools.arrayify}, {@link module:array-tools.where}, {@link module:array-tools.without}, {@link module:array-tools.unique}, {@link module:array-tools.spliceWhile}, {@link module:array-tools.extract}, {@link module:array-tools.flatten}, {@link module:array-tools.exists} and {@link module:array-tools.sortBy} in the chain. From core Array methods you may use `filter`, `reverse`, `sort`, `concat`, `slice`, `every`, `some` and `map`.
3. Finally, following all above methods except {@link module:array-tools.exists}, call `.val()` to extract the result.
```js
> var a = require("array-tools");
> a([ 1, 2, 2, 3 ]).exists(1)
true
> a([ 1, 2, 2, 3 ]).without(1).exists(1)
false
> a([ 1, 2, 2, 3 ]).without(1).unique().val()
[ 2, 3 ]
```
@module
@typicalname a
@example
var a = require("array-tools");
*/
exports.pluck = pluck;
exports.pick = pick;
exports.commonSequence = commonSequence;
exports.arrayify = arrayify;
exports.exists = exists;
exports.without = without;
exports.union = union;
exports.where = where;
exports.findWhere = findWhere;
exports.unique = unique;
exports.spliceWhile = spliceWhile;
exports.extract = extract;
exports.flatten = flatten;
exports.sortBy = sortBy;
module.exports = ArrayTools;
ArrayTools.pluck = pluck;
ArrayTools.pick = pick;
ArrayTools.commonSequence = commonSequence;
ArrayTools.arrayify = arrayify;
ArrayTools.exists = exists;
ArrayTools.without = without;
ArrayTools.union = union;
ArrayTools.where = where;
ArrayTools.findWhere = findWhere;
ArrayTools.unique = unique;
ArrayTools.spliceWhile = spliceWhile;
ArrayTools.extract = extract;
ArrayTools.flatten = flatten;
ArrayTools.sortBy = sortBy;
function ArrayTools(array){
if (!(this instanceof ArrayTools)) return new ArrayTools(array);
if (!Array.isArray(array)) throw new Error("must pass an array to array-tools");
this._array = array.slice(0);
}
ArrayTools.prototype.val = function(){
return this._array;
};
["filter", "reverse", "sort", "concat", "slice", "every", "some", "map"].forEach(function(method){
ArrayTools.prototype[method] = function(){
this._array = Array.prototype[method].apply(this._array, arguments);
return this;
};
});
["pluck", "pick", "arrayify", "where", "without", "unique", "spliceWhile", "extract", "flatten", "sortBy"].forEach(function(method){
ArrayTools.prototype[method] = function(){
var args = arrayify(arguments);
args.unshift(this._array);
this._array = ArrayTools[method].apply(null, args);
return this;
};
});
ArrayTools.prototype.exists = function(value){
return exists(this._array, value);
};
/**

@@ -32,3 +86,3 @@ Plucks the value of the specified property from each object in the input array

@returns {Array}
@category Record sets
@category record set in
@example

@@ -71,3 +125,3 @@ > var data = [

@return {object[]}
@category Record sets
@category record set in
@example

@@ -119,3 +173,3 @@ > data = [

@returns {Array}
@category General
@category any value in
@example

@@ -148,3 +202,3 @@ > a.arrayify(null)

@returns {boolean}
@category General
@category single array in
@example

@@ -183,3 +237,3 @@ > a.exists([ 1, 2, 3 ], 2)

@returns {Array}
@category Record sets
@category record set in
@example

@@ -207,3 +261,3 @@ > dudes = [{ name: "Jim", age: 8}, { name: "Clive", age: 8}, { name: "Hater", age: 9}]

@returns {object}
@category Record sets
@category record set in
@example

@@ -229,3 +283,3 @@ > dudes = [{ name: "Jim", age: 8}, { name: "Clive", age: 8}, { name: "Hater", age: 9}]

@returns {Array}
@category General
@category single array in
@example

@@ -251,3 +305,3 @@ > a.without([ 1, 2, 3 ], 2)

@returns {Array}
@category General
@category multiple arrays in
@example

@@ -291,3 +345,3 @@ > var array1 = [ 1, 2 ], array2 = [ 2, 3 ];

@returns {Array}
@category General
@category multiple arrays in
@example

@@ -314,3 +368,3 @@ > a.commonSequence([1,2,3], [1,2,4])

@returns {Array}
@category General
@category single array in
@example

@@ -337,3 +391,3 @@ > n = [1,6,6,7,1]

@returns {Array}
@category General
@category single array in
@example

@@ -362,3 +416,3 @@ > letters = ["a", "a", "b"]

@returns {Array} the extracted items.
@category General
@category single array in
@alias module:array-tools.extract

@@ -394,3 +448,3 @@ */

@returns {Array}
@category General
@category single array in
@example

@@ -414,3 +468,3 @@ > numbers = [ 1, 2, [ 3, 4 ], 5 ]

@returns {Array}
@category Record sets
@category record set in
@since 1.5.0

@@ -417,0 +471,0 @@ @example

{
"name": "array-tools",
"author": "Lloyd Brookes <75pound@gmail.com>",
"version": "1.5.3",
"description": "Useful functions for working with arrays",
"version": "1.6.0",
"description": "Lightweight tool-kit for working with arrays",
"repository": "https://github.com/75lb/array-tools.git",

@@ -12,11 +12,15 @@ "main": "./lib/array-tools.js",

"pluck",
"pick",
"extract",
"flatten",
"sort by",
"arrayify",
"exists",
"where",
"findWhere",
"find where",
"without",
"union",
"commonSequence",
"common sequence",
"unique",
"spliceWhile"
"splice while"
],

@@ -23,0 +27,0 @@ "scripts": {

@@ -8,21 +8,34 @@ [![view on npm](http://img.shields.io/npm/v/array-tools.svg)](https://www.npmjs.org/package/array-tools)

# array-tools
Useful functions for working with arrays
Lightweight tool-kit for working with arrays.
**Example**
```js
var a = require("array-tools");
> var a = require("array-tools");
> a.exists([ 1, 2, 3 ], 1)
true
```
You can also chain together operations. The process:
1. Pass your input array to array-tools as an argument.
2. Chain together your operations. From array-tools, you may use [pluck](#module_array-tools.pluck), [pick](#module_array-tools.pick), [arrayify](#module_array-tools.arrayify), [where](#module_array-tools.where), [without](#module_array-tools.without), [unique](#module_array-tools.unique), [spliceWhile](#module_array-tools.spliceWhile), [extract](#module_array-tools.extract), [flatten](#module_array-tools.flatten), [exists](#module_array-tools.exists) and [sortBy](#module_array-tools.sortBy) in the chain. From core Array methods you may use `filter`, `reverse`, `sort`, `concat`, `slice`, `every`, `some` and `map`.
3. Finally, following all above methods except [exists](#module_array-tools.exists), call `.val()` to extract the result.
```js
> var a = require("array-tools");
> a([ 1, 2, 2, 3 ]).exists(1)
true
> a([ 1, 2, 2, 3 ]).without(1).exists(1)
false
> a([ 1, 2, 2, 3 ]).without(1).unique().val()
[ 2, 3 ]
```
* [array-tools](#module_array-tools)
* _General_
* _any value in_
* [.arrayify(any)](#module_array-tools.arrayify) ⇒ <code>Array</code>
* [.exists(array, value)](#module_array-tools.exists) ⇒ <code>boolean</code>
* [.without(array, toRemove)](#module_array-tools.without) ⇒ <code>Array</code>
* _multiple arrays in_
* [.union(array1, array2, idKey)](#module_array-tools.union) ⇒ <code>Array</code>
* [.commonSequence(a, b)](#module_array-tools.commonSequence) ⇒ <code>Array</code>
* [.unique(array)](#module_array-tools.unique) ⇒ <code>Array</code>
* [.spliceWhile(array, index, test, ...elementN)](#module_array-tools.spliceWhile) ⇒ <code>Array</code>
* [.extract(array, query)](#module_array-tools.extract) ⇒ <code>Array</code>
* [.flatten()](#module_array-tools.flatten) ⇒ <code>Array</code>
* _Record sets_
* _record set in_
* [.pluck(arrayOfObjects, ...property)](#module_array-tools.pluck) ⇒ <code>Array</code>

@@ -33,2 +46,9 @@ * [.pick(arrayOfObjects, ...property)](#module_array-tools.pick) ⇒ <code>Array.&lt;object&gt;</code>

* [.sortBy(arrayOfObjects, columns, customOrder)](#module_array-tools.sortBy) ⇒ <code>Array</code>
* _single array in_
* [.exists(array, value)](#module_array-tools.exists) ⇒ <code>boolean</code>
* [.without(array, toRemove)](#module_array-tools.without) ⇒ <code>Array</code>
* [.unique(array)](#module_array-tools.unique) ⇒ <code>Array</code>
* [.spliceWhile(array, index, test, ...elementN)](#module_array-tools.spliceWhile) ⇒ <code>Array</code>
* [.extract(array, query)](#module_array-tools.extract) ⇒ <code>Array</code>
* [.flatten()](#module_array-tools.flatten) ⇒ <code>Array</code>

@@ -43,4 +63,4 @@ <a name="module_array-tools.arrayify"></a>

**Category**: General
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: any value in
<table>

@@ -53,6 +73,6 @@ <thead>

<tbody>
<tr>
<td>any</td><td><code>*</code></td><td>the input value to convert to an array</td>
</tr>
</tbody>
<tr>
<td>any</td><td><code>*</code></td><td><p>the input value to convert to an array</p>
</td>
</tr> </tbody>
</table>

@@ -72,62 +92,2 @@

```
<a name="module_array-tools.exists"></a>
## a.exists(array, value) ⇒ <code>boolean</code>
returns true if a value, or nested object value exists in an array
**Category**: General
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>array</td><td><code>Array</code></td><td>the array to search</td>
</tr><tr>
<td>value</td><td><code>*</code></td><td>the value to search for</td>
</tr>
</tbody>
</table>
**Example**
```js
> a.exists([ 1, 2, 3 ], 2)
true
> a.exists([ { result: false }, { result: false } ], { result: true })
false
> a.exists([ { result: true }, { result: false } ], { result: true })
true
> a.exists([ { result: true }, { result: true } ], { result: true })
true
```
<a name="module_array-tools.without"></a>
## a.without(array, toRemove) ⇒ <code>Array</code>
Returns the input minus the specified values.
**Category**: General
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>array</td><td><code>Array</code></td><td>the input array</td>
</tr><tr>
<td>toRemove</td><td><code>*</code></td><td>a single, or array of values to omit</td>
</tr>
</tbody>
</table>
**Example**
```js
> a.without([ 1, 2, 3 ], 2)
[ 1, 3 ]
> a.without([ 1, 2, 3 ], [ 2, 3 ])
[ 1 ]
```
<a name="module_array-tools.union"></a>

@@ -137,4 +97,4 @@ ## a.union(array1, array2, idKey) ⇒ <code>Array</code>

**Category**: General
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: multiple arrays in
<table>

@@ -147,10 +107,12 @@ <thead>

<tbody>
<tr>
<td>array1</td><td><code>Array</code></td><td>First array</td>
<tr>
<td>array1</td><td><code>Array</code></td><td><p>First array</p>
</td>
</tr><tr>
<td>array2</td><td><code>Array</code></td><td>Second array</td>
<td>array2</td><td><code>Array</code></td><td><p>Second array</p>
</td>
</tr><tr>
<td>idKey</td><td><code>string</code></td><td>the unique ID property name</td>
</tr>
</tbody>
<td>idKey</td><td><code>string</code></td><td><p>the unique ID property name</p>
</td>
</tr> </tbody>
</table>

@@ -179,4 +141,4 @@

**Category**: General
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: multiple arrays in
<table>

@@ -189,8 +151,9 @@ <thead>

<tbody>
<tr>
<td>a</td><td><code>Array</code></td><td>first array to compare</td>
<tr>
<td>a</td><td><code>Array</code></td><td><p>first array to compare</p>
</td>
</tr><tr>
<td>b</td><td><code>Array</code></td><td>second array to compare</td>
</tr>
</tbody>
<td>b</td><td><code>Array</code></td><td><p>second array to compare</p>
</td>
</tr> </tbody>
</table>

@@ -203,100 +166,2 @@

```
<a name="module_array-tools.unique"></a>
## a.unique(array) ⇒ <code>Array</code>
returns an array of unique values
**Category**: General
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>array</td><td><code>Array</code></td><td>input array</td>
</tr>
</tbody>
</table>
**Example**
```js
> n = [1,6,6,7,1]
[ 1, 6, 6, 7, 1 ]
> a.unique(n)
[ 1, 6, 7 ]
```
<a name="module_array-tools.spliceWhile"></a>
## a.spliceWhile(array, index, test, ...elementN) ⇒ <code>Array</code>
splice from `index` until `test` fails
**Category**: General
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>array</td><td><code>Array</code></td><td>the input array</td>
</tr><tr>
<td>index</td><td><code>number</code></td><td>the position to begin splicing from</td>
</tr><tr>
<td>test</td><td><code>RegExp</code></td><td>the test to continue splicing while true</td>
</tr><tr>
<td>...elementN</td><td><code>*</code></td><td>the elements to add to the array</td>
</tr>
</tbody>
</table>
**Example**
```js
> letters = ["a", "a", "b"]
[ 'a', 'a', 'b' ]
> a.spliceWhile(letters, 0, /a/, "x")
[ 'a', 'a' ]
> letters
[ 'x', 'b' ]
```
<a name="module_array-tools.extract"></a>
## a.extract(array, query) ⇒ <code>Array</code>
Removes items from `array` which satisfy the query. Modifies the input array, returns the extracted.
**Returns**: <code>Array</code> - the extracted items.
**Category**: General
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>array</td><td><code>Array</code></td><td>the input array, modified directly</td>
</tr><tr>
<td>query</td><td><code>function</code> | <code>object</code></td><td>Per item in the array, if either the function returns truthy or the exists query is satisfied, the item is extracted</td>
</tr>
</tbody>
</table>
<a name="module_array-tools.flatten"></a>
## a.flatten() ⇒ <code>Array</code>
flatten an array of arrays into a single array
**Category**: General
**Since**: 1.4.0
**Todo**
- document
**Example**
```js
> numbers = [ 1, 2, [ 3, 4 ], 5 ]
> a.flatten(numbers)
[ 1, 2, 3, 4, 5 ]
```
<a name="module_array-tools.pluck"></a>

@@ -306,4 +171,4 @@ ## a.pluck(arrayOfObjects, ...property) ⇒ <code>Array</code>

**Category**: Record sets
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: record set in
<table>

@@ -316,8 +181,9 @@ <thead>

<tbody>
<tr>
<td>arrayOfObjects</td><td><code>Array.&lt;object&gt;</code></td><td>the input array of objects</td>
<tr>
<td>arrayOfObjects</td><td><code>Array.&lt;object&gt;</code></td><td><p>the input array of objects</p>
</td>
</tr><tr>
<td>...property</td><td><code>string</code></td><td>the property(s) to pluck</td>
</tr>
</tbody>
<td>...property</td><td><code>string</code></td><td><p>the property(s) to pluck</p>
</td>
</tr> </tbody>
</table>

@@ -343,4 +209,4 @@

**Category**: Record sets
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: record set in
<table>

@@ -353,8 +219,9 @@ <thead>

<tbody>
<tr>
<td>arrayOfObjects</td><td><code>Array.&lt;object&gt;</code></td><td>the input</td>
<tr>
<td>arrayOfObjects</td><td><code>Array.&lt;object&gt;</code></td><td><p>the input</p>
</td>
</tr><tr>
<td>...property</td><td><code>string</code></td><td>the properties to include in the result</td>
</tr>
</tbody>
<td>...property</td><td><code>string</code></td><td><p>the properties to include in the result</p>
</td>
</tr> </tbody>
</table>

@@ -380,4 +247,4 @@

**Category**: Record sets
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: record set in
<table>

@@ -390,8 +257,9 @@ <thead>

<tbody>
<tr>
<td>arrayOfObjects</td><td><code>Array.&lt;object&gt;</code></td><td>the array to search</td>
<tr>
<td>arrayOfObjects</td><td><code>Array.&lt;object&gt;</code></td><td><p>the array to search</p>
</td>
</tr><tr>
<td>query</td><td><code>query</code></td><td>an object containing the key/value pairs you want to match</td>
</tr>
</tbody>
<td>query</td><td><code>query</code></td><td><p>an object containing the key/value pairs you want to match</p>
</td>
</tr> </tbody>
</table>

@@ -414,4 +282,4 @@

**Category**: Record sets
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: record set in
<table>

@@ -424,8 +292,9 @@ <thead>

<tbody>
<tr>
<td>arrayOfObjects</td><td><code>Array.&lt;object&gt;</code></td><td>the array to search</td>
<tr>
<td>arrayOfObjects</td><td><code>Array.&lt;object&gt;</code></td><td><p>the array to search</p>
</td>
</tr><tr>
<td>query</td><td><code>object</code></td><td>an object containing the key/value pairs you want to match</td>
</tr>
</tbody>
<td>query</td><td><code>object</code></td><td><p>an object containing the key/value pairs you want to match</p>
</td>
</tr> </tbody>
</table>

@@ -446,5 +315,5 @@

**Category**: Record sets
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: record set in
**Since**: 1.5.0
<table>

@@ -457,10 +326,12 @@ <thead>

<tbody>
<tr>
<td>arrayOfObjects</td><td><code>Array.&lt;object&gt;</code></td><td>input array</td>
<tr>
<td>arrayOfObjects</td><td><code>Array.&lt;object&gt;</code></td><td><p>input array</p>
</td>
</tr><tr>
<td>columns</td><td><code>string</code> | <code>Array.&lt;string&gt;</code></td><td>column name(s) to sort by</td>
<td>columns</td><td><code>string</code> | <code>Array.&lt;string&gt;</code></td><td><p>column name(s) to sort by</p>
</td>
</tr><tr>
<td>customOrder</td><td><code>object</code></td><td>specific sort orders, per columns</td>
</tr>
</tbody>
<td>customOrder</td><td><code>object</code></td><td><p>specific sort orders, per columns</p>
</td>
</tr> </tbody>
</table>

@@ -492,8 +363,170 @@

```
<a name="module_array-tools.exists"></a>
## a.exists(array, value) ⇒ <code>boolean</code>
returns true if a value, or nested object value exists in an array
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: single array in
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>array</td><td><code>Array</code></td><td><p>the array to search</p>
</td>
</tr><tr>
<td>value</td><td><code>*</code></td><td><p>the value to search for</p>
</td>
</tr> </tbody>
</table>
--
**Example**
```js
> a.exists([ 1, 2, 3 ], 2)
true
> a.exists([ { result: false }, { result: false } ], { result: true })
false
> a.exists([ { result: true }, { result: false } ], { result: true })
true
> a.exists([ { result: true }, { result: true } ], { result: true })
true
```
<a name="module_array-tools.without"></a>
## a.without(array, toRemove) ⇒ <code>Array</code>
Returns the input minus the specified values.
*documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown)*.
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: single array in
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>array</td><td><code>Array</code></td><td><p>the input array</p>
</td>
</tr><tr>
<td>toRemove</td><td><code>*</code></td><td><p>a single, or array of values to omit</p>
</td>
</tr> </tbody>
</table>
&copy; 2015 Lloyd Brookes <75pound@gmail.com>
**Example**
```js
> a.without([ 1, 2, 3 ], 2)
[ 1, 3 ]
> a.without([ 1, 2, 3 ], [ 2, 3 ])
[ 1 ]
```
<a name="module_array-tools.unique"></a>
## a.unique(array) ⇒ <code>Array</code>
returns an array of unique values
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: single array in
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>array</td><td><code>Array</code></td><td><p>input array</p>
</td>
</tr> </tbody>
</table>
**Example**
```js
> n = [1,6,6,7,1]
[ 1, 6, 6, 7, 1 ]
> a.unique(n)
[ 1, 6, 7 ]
```
<a name="module_array-tools.spliceWhile"></a>
## a.spliceWhile(array, index, test, ...elementN) ⇒ <code>Array</code>
splice from `index` until `test` fails
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: single array in
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>array</td><td><code>Array</code></td><td><p>the input array</p>
</td>
</tr><tr>
<td>index</td><td><code>number</code></td><td><p>the position to begin splicing from</p>
</td>
</tr><tr>
<td>test</td><td><code>RegExp</code></td><td><p>the test to continue splicing while true</p>
</td>
</tr><tr>
<td>...elementN</td><td><code>*</code></td><td><p>the elements to add to the array</p>
</td>
</tr> </tbody>
</table>
**Example**
```js
> letters = ["a", "a", "b"]
[ 'a', 'a', 'b' ]
> a.spliceWhile(letters, 0, /a/, "x")
[ 'a', 'a' ]
> letters
[ 'x', 'b' ]
```
<a name="module_array-tools.extract"></a>
## a.extract(array, query) ⇒ <code>Array</code>
Removes items from `array` which satisfy the query. Modifies the input array, returns the extracted.
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Returns**: <code>Array</code> - the extracted items.
**Category**: single array in
<table>
<thead>
<tr>
<th>Param</th><th>Type</th><th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>array</td><td><code>Array</code></td><td><p>the input array, modified directly</p>
</td>
</tr><tr>
<td>query</td><td><code>function</code> | <code>object</code></td><td><p>Per item in the array, if either the function returns truthy or the exists query is satisfied, the item is extracted</p>
</td>
</tr> </tbody>
</table>
<a name="module_array-tools.flatten"></a>
## a.flatten() ⇒ <code>Array</code>
flatten an array of arrays into a single array
**Kind**: static method of <code>[array-tools](#module_array-tools)</code>
**Category**: single array in
**Since**: 1.4.0
**Todo**
- document
**Example**
```js
> numbers = [ 1, 2, [ 3, 4 ], 5 ]
> a.flatten(numbers)
[ 1, 2, 3, 4, 5 ]
```
* * *
&copy; 2015 Lloyd Brookes <75pound@gmail.com>. Documented by [jsdoc-to-markdown](https://github.com/75lb/jsdoc-to-markdown).

@@ -1,3 +0,3 @@

var test = require("tape"),
a = require("../");
var test = require("tape");
var a = require("../");

@@ -4,0 +4,0 @@ test(".pluck", function(t){

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc