array-tools
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -46,2 +46,3 @@ "use strict"; | ||
``` | ||
@alias module:array-tools.pluck | ||
*/ | ||
@@ -92,2 +93,3 @@ function pluck(arrayOfObjects, property, property2, property3){ | ||
``` | ||
@alias module:array-tools.arrayify | ||
*/ | ||
@@ -120,2 +122,3 @@ function arrayify(input){ | ||
``` | ||
@alias module:array-tools.exists | ||
*/ | ||
@@ -154,2 +157,3 @@ function exists(array, value){ | ||
``` | ||
@alias module:array-tools.where | ||
*/ | ||
@@ -177,2 +181,3 @@ function where(arrayOfObjects, query){ | ||
``` | ||
@alias module:array-tools.findWhere | ||
*/ | ||
@@ -197,2 +202,3 @@ function findWhere(arrayOfObjects, query){ | ||
``` | ||
@alias module:array-tools.without | ||
*/ | ||
@@ -232,2 +238,3 @@ function without(input, toRemove){ | ||
``` | ||
@alias module:array-tools.union | ||
*/ | ||
@@ -260,2 +267,3 @@ function union(array1, array2, idKey){ | ||
``` | ||
@alias module:array-tools.commonSequence | ||
*/ | ||
@@ -283,2 +291,3 @@ function commonSequence(a, b){ | ||
``` | ||
@alias module:array-tools.unique | ||
*/ | ||
@@ -308,2 +317,3 @@ function unique(array){ | ||
``` | ||
@alias module:array-tools.spliceWhile | ||
*/ | ||
@@ -324,2 +334,3 @@ function spliceWhile(array, index, test){ | ||
@returns {Array} the extracted items. | ||
@alias module:array-tools.extract | ||
*/ | ||
@@ -339,2 +350,2 @@ function extract(array, callback){ | ||
return result; | ||
} | ||
} |
{ | ||
"name": "array-tools", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Useful functions for working with arrays", | ||
@@ -23,7 +23,7 @@ "repository": "https://github.com/75lb/array-tools.git", | ||
"lint": "jshint lib/*.js test/*.js; echo", | ||
"docs": "jsdoc2md -t jsdoc2md/README.hbs lib/*.js > README.md; echo", | ||
"docs": "jsdoc2md -t jsdoc2md/README.hbs lib/*.js --index > README.md; echo", | ||
"watch": "baldrick --do 'npm run docs' --when lib/*.js --change" | ||
}, | ||
"devDependencies": { | ||
"jsdoc-to-markdown": "^0.1.1", | ||
"jsdoc-to-markdown": "^0.2.0", | ||
"tape": "^2.13.2" | ||
@@ -30,0 +30,0 @@ }, |
169
README.md
@@ -6,11 +6,7 @@ [![view on npm](http://img.shields.io/npm/v/array-tools.svg)](https://www.npmjs.org/package/array-tools) | ||
<a name="module_array-tools"></a> | ||
#array-tools | ||
Useful functions for working with arrays | ||
####Example | ||
@@ -20,5 +16,2 @@ ```js | ||
``` | ||
**Contents** | ||
@@ -37,19 +30,11 @@ * [pluck(arrayOfObjects, ...property)](#module_array-tools.pluck) | ||
<a name="module_array-tools.pluck"></a> | ||
###pluck(arrayOfObjects, ...property) | ||
###a.pluck(arrayOfObjects, ...property) | ||
Plucks the value of the specified property from each object in the input array | ||
- arrayOfObjects `Array.<Object>` the input array of objects | ||
- ...property `string` the property(s) to pluck | ||
- arrayOfObjects `Array.<Object>` - the input array of objects | ||
- ...property `string` - the property(s) to pluck | ||
**Returns**: `Array` | ||
**Returns**: `Array` | ||
####Example | ||
@@ -70,7 +55,4 @@ ```js | ||
``` | ||
<a name="module_array-tools.arrayify"></a> | ||
###arrayify(input) | ||
###a.arrayify(input) | ||
Takes input and guarantees an array back. Result can be one of three things: | ||
@@ -83,7 +65,5 @@ | ||
- input `*` the input value to convert to an array | ||
- input `*` - the input value to convert to an array | ||
**Returns**: `Array` | ||
**Returns**: `Array` | ||
####Example | ||
@@ -102,16 +82,11 @@ ```js | ||
``` | ||
<a name="module_array-tools.exists"></a> | ||
###exists(array, value) | ||
###a.exists(array, value) | ||
returns true if a value, or nested object value exists in an array | ||
- array `Array` the array to search | ||
- value `*` the value to search for | ||
- array `Array` - the array to search | ||
- value `*` - the value to search for | ||
**Returns**: `boolean` | ||
**Returns**: `boolean` | ||
####Example | ||
@@ -128,7 +103,4 @@ ```js | ||
``` | ||
<a name="module_array-tools.where"></a> | ||
###where(arrayOfObjects, query) | ||
###a.where(arrayOfObjects, query) | ||
returns an array containing items from `arrayOfObjects` where key/value pairs | ||
@@ -138,8 +110,6 @@ from `query` are matched identically | ||
- arrayOfObjects `Array` the array to search | ||
- query `query` an object containing the key/value pairs you want to match | ||
- arrayOfObjects `Array` - the array to search | ||
- query `query` - an object containing the key/value pairs you want to match | ||
**Returns**: `Array` | ||
**Returns**: `Array` | ||
####Example | ||
@@ -155,7 +125,4 @@ ```js | ||
``` | ||
<a name="module_array-tools.findWhere"></a> | ||
###findWhere(arrayOfObjects, query) | ||
###a.findWhere(arrayOfObjects, query) | ||
returns the first item from `arrayOfObjects` where key/value pairs | ||
@@ -165,8 +132,6 @@ from `query` are matched identically | ||
- arrayOfObjects `Array` the array to search | ||
- query `query` an object containing the key/value pairs you want to match | ||
- arrayOfObjects `Array` - the array to search | ||
- query `query` - an object containing the key/value pairs you want to match | ||
**Returns**: `Object` | ||
**Returns**: `Object` | ||
####Example | ||
@@ -181,16 +146,11 @@ ```js | ||
``` | ||
<a name="module_array-tools.without"></a> | ||
###without(input, toRemove) | ||
###a.without(input, toRemove) | ||
Returns the input minus the specified values. | ||
- input `Array` the input array | ||
- toRemove `*` a single, or array of values to omit | ||
- input `Array` - the input array | ||
- toRemove `*` - a single, or array of values to omit | ||
**Returns**: `Array` | ||
**Returns**: `Array` | ||
####Example | ||
@@ -203,17 +163,12 @@ ```js | ||
``` | ||
<a name="module_array-tools.union"></a> | ||
###union(array1, array2, idKey) | ||
###a.union(array1, array2, idKey) | ||
merge two arrays into a single array of unique values | ||
- array1 `Array` First array | ||
- array2 `Array` Second array | ||
- idKey `string` the unique ID property name | ||
- array1 `Array` - First array | ||
- array2 `Array` - Second array | ||
- idKey `string` - the unique ID property name | ||
**Returns**: `Array` | ||
**Returns**: `Array` | ||
####Example | ||
@@ -239,16 +194,11 @@ ```js | ||
``` | ||
<a name="module_array-tools.commonSequence"></a> | ||
###commonSequence(a, b) | ||
###a.commonSequence(a, b) | ||
Returns the initial elements which both input arrays have in common | ||
- a `Array` first array to compare | ||
- b `Array` second array to compare | ||
- a `Array` - first array to compare | ||
- b `Array` - second array to compare | ||
**Returns**: `Array` | ||
**Returns**: `Array` | ||
####Example | ||
@@ -259,15 +209,10 @@ ```js | ||
``` | ||
<a name="module_array-tools.unique"></a> | ||
###unique(array) | ||
###a.unique(array) | ||
reduces an array to unique values | ||
- array `Array` input array | ||
- array `Array` - input array | ||
**Returns**: `Array` | ||
**Returns**: `Array` | ||
####Example | ||
@@ -280,18 +225,13 @@ ```js | ||
``` | ||
<a name="module_array-tools.spliceWhile"></a> | ||
###spliceWhile(array, index, test, ...elementN) | ||
###a.spliceWhile(array, index, test, ...elementN) | ||
splice from `index` until `test` fails | ||
- array `Array` the input array | ||
- index `number` the position to begin splicing from | ||
- test `RegExp` the test to continue splicing while true | ||
- ...elementN `*` the elements to add to the array | ||
- array `Array` - the input array | ||
- index `number` - the position to begin splicing from | ||
- test `RegExp` - the test to continue splicing while true | ||
- ...elementN `*` - the elements to add to the array | ||
**Returns**: `Array` | ||
**Returns**: `Array` | ||
####Example | ||
@@ -306,25 +246,10 @@ ```js | ||
``` | ||
<a name="module_array-tools.extract"></a> | ||
###extract(array, callback) | ||
###a.extract(array, callback) | ||
Removes items from `array` which pass the `callback` test. Modifies the input array, returns the extracted. | ||
- array `Array` the input array, modified directly | ||
- callback `function` called on each item in `array`. Those which return a truthy value are extracted. | ||
- array `Array` - the input array, modified directly | ||
- callback `function` - called on each item in `array`. Those which return a truthy value are extracted. | ||
**Returns**: `Array` - the extracted items. | ||
**Returns**: `Array` - the extracted items. |
Sorry, the diff of this file is not supported yet
21040
450
240