https://github.com/parro-it/iterable-transform-replace
An iterable transform that apply replace to all items
https://github.com/parro-it/iterable-transform-replace
Last synced: 7 months ago
JSON representation
An iterable transform that apply replace to all items
- Host: GitHub
- URL: https://github.com/parro-it/iterable-transform-replace
- Owner: parro-it
- License: mit
- Created: 2016-10-08T08:34:52.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:21:27.000Z (over 5 years ago)
- Last Synced: 2024-10-10T21:08:26.834Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 150 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# iterable-transform-replace
[](https://greenkeeper.io/)
> An iterable transform that apply replace to all items
## Usage
This example replace `response` with `42`:
```js
const replace = require('iterable-transform-replace');
const source = [1, 2, 'response', 3];
console.log(Array.from(replace('response', 42, source)));
```
This will output
```
[1, 2, 42, 3]
```
[](http://travis-ci.org/parro-it/iterable-transform-replace)
[](https://npmjs.org/package/iterable-transform-replace)
## API
```js
const iterableTransformReplace = (oldItem: any, newItem: any, source: Iterable): Iterable
```
Given an iterable source object, return another iterable with all items equal
to `oldItem` replaced with `newItem`.
## Install
With [npm](https://npmjs.org/) installed, run
```
$ npm install iterable-transform-replace
```
## See Also
- [`noffle/common-readme`](https://github.com/noffle/common-readme)
## License
MIT