replace-buffer
Replace matches in a Buffer
Install
$ npm install replace-buffer
Usage
const replaceBuffer = ; const input = Buffer; ;//=> 'My friend has a unicorn. I want a unicorn too!'
API
replaceBuffer(input, needle, replacement, [options])
Returns a new Buffer
with all needle matches replaced with replacement.
input
Type: Buffer
Buffer
to work on.
needle
Type: string
String to match in input
.
replacement
Type: string
Function
Replacement for needle matches.
If a function, it receives the following arguments; the needle
, the match count, and the input
:
;//=> 'Foo Unicorn❤️ Bar'
options
Type: Object
fromIndex
Type: number
Default: 0
Index at which to start replacing.
License
MIT © Kevin Mårtensson