Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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