Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juliangruber/buffer-replace
Like String#replace(), except for buffers
https://github.com/juliangruber/buffer-replace
Last synced: 4 days ago
JSON representation
Like String#replace(), except for buffers
- Host: GitHub
- URL: https://github.com/juliangruber/buffer-replace
- Owner: juliangruber
- Created: 2016-06-10T12:13:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-02T03:50:27.000Z (almost 8 years ago)
- Last Synced: 2024-10-17T07:07:29.695Z (3 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 25
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# buffer-replace
Like `String#replace`, but for buffers.
## Usage
```js
const replace = require('buffer-replace');replace(Buffer('foo:bar'), ':', '-')
// Buffer('foo-bar')replace(Buffer('foo-beep-bar'), '-beep-', '-');
// Buffer('foo-bar')replace('foo-beep-bar', '-beep-', '-');
// Buffer('foo-bar')
```## Installation
```bash
$ npm install buffer-replace
```## API
### replace(buf, a, b)
Replace all occurences of `a` in `buf` with `b`. All arguments can be either buffers or strings, but the return value is always a buffer.
## License
MIT