find-replace
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -6,26 +6,29 @@ 'use strict' | ||
/** | ||
* Find and replace items in an array. | ||
* | ||
* @module find-replace | ||
* @example | ||
* > findReplace = require('find-replace') | ||
* | ||
* > findReplace([ 1, 2, 3], 2, 'two') | ||
* [ 1, 'two', 3 ] | ||
* | ||
* > findReplace([ 1, 2, 3], 2, [ 'two', 'zwei' ]) | ||
* [ 1, [ 'two', 'zwei' ], 3 ] | ||
* | ||
* > findReplace([ 1, 2, 3], 2, 'two', 'zwei') | ||
* [ 1, 'two', 'zwei', 3 ] | ||
*/ | ||
* Find and either replace or remove items from an array. | ||
* | ||
* @module find-replace | ||
* @example | ||
* > findReplace = require('find-replace') | ||
* | ||
* > findReplace([ 1, 2, 3], 2, 'two') | ||
* [ 1, 'two', 3 ] | ||
* | ||
* > findReplace([ 1, 2, 3], 2, [ 'two', 'zwei' ]) | ||
* [ 1, [ 'two', 'zwei' ], 3 ] | ||
* | ||
* > findReplace([ 1, 2, 3], 2, 'two', 'zwei') | ||
* [ 1, 'two', 'zwei', 3 ] | ||
* | ||
* > findReplace([ 1, 2, 3], 2) // no replacement, so remove | ||
* [ 1, 3 ] | ||
*/ | ||
module.exports = findReplace | ||
/** | ||
* @param {array} - the input array | ||
* @param {valueTest} - a query to match the value you're looking for | ||
* @param [replaceWith] {...any} - optional replacement items | ||
* @returns {array} | ||
* @alias module:find-replace | ||
*/ | ||
* @param {array} - the input array | ||
* @param {valueTest} - a [test-value](https://github.com/75lb/test-value) query to match the value you're looking for | ||
* @param [replaceWith] {...any} - If specified, found values will be replaced with these values, else removed. | ||
* @returns {array} | ||
* @alias module:find-replace | ||
*/ | ||
function findReplace (array, valueTest) { | ||
@@ -32,0 +35,0 @@ var found = [] |
{ | ||
"name": "find-replace", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "1.0.1", | ||
"description": "Find and replace items of an array", | ||
"version": "1.0.2", | ||
"description": "Find and either replace or remove items from an array", | ||
"repository": "https://github.com/75lb/find-replace.git", | ||
@@ -12,3 +12,5 @@ "license": "MIT", | ||
"replace", | ||
"array" | ||
"array", | ||
"remove", | ||
"splice" | ||
], | ||
@@ -24,8 +26,8 @@ "engines": { | ||
"jsdoc-to-markdown": "^1.3.3", | ||
"tape": "^4.4.0" | ||
"tape": "^4.5.1" | ||
}, | ||
"dependencies": { | ||
"array-back": "^1.0.2", | ||
"test-value": "^1.0.1" | ||
"test-value": "^2.0.0" | ||
} | ||
} |
@@ -5,6 +5,8 @@ [![view on npm](http://img.shields.io/npm/v/find-replace.svg)](https://www.npmjs.org/package/find-replace) | ||
[![Dependency Status](https://david-dm.org/75lb/find-replace.svg)](https://david-dm.org/75lb/find-replace) | ||
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard) | ||
<a name="module_find-replace"></a> | ||
## find-replace | ||
Find and replace items in an array. | ||
Find and either replace or remove items from an array. | ||
@@ -23,4 +25,8 @@ **Example** | ||
[ 1, 'two', 'zwei', 3 ] | ||
> findReplace([ 1, 2, 3], 2) // no replacement, so remove | ||
[ 1, 3 ] | ||
``` | ||
<a name="exp_module_find-replace--findReplace"></a> | ||
### findReplace(array, valueTest, [...replaceWith]) ⇒ <code>array</code> ⏏ | ||
@@ -32,4 +38,4 @@ **Kind**: Exported function | ||
| array | <code>array</code> | the input array | | ||
| valueTest | <code>valueTest</code> | a query to match the value you're looking for | | ||
| [...replaceWith] | <code>any</code> | optional replacement items | | ||
| valueTest | <code>valueTest</code> | a [test-value](https://github.com/75lb/test-value) query to match the value you're looking for | | ||
| [...replaceWith] | <code>any</code> | If specified, found values will be replaced with these values, else removed. | | ||
@@ -39,2 +45,2 @@ | ||
© 2015 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown). | ||
© 2015-16 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7052
101
43
+ Addedtest-value@2.1.0(transitive)
- Removedtest-value@1.1.0(transitive)
Updatedtest-value@^2.0.0