npm.io
1.0.1 • Published 10 years ago

map-buffer

Licence
LSC
Version
1.0.1
Deps
0
Vulns
0
Weekly
0

map-buffer Build Status

Creates a new Buffer with the results of calling a provided function on every element in this Buffer (ie. like Array.prototype.map but for buffers).

Usage example

const mapBuffer = require('map-buffer');

const buf = new Buffer([0x62,0x75,0x66,0x66,0x65,0x72]);

const new_buf = mapBuffer(buf, (value, index, original_buffer) => {
  return value === 0x62 ? 0x75 : value;
});

console.log(new_buf); // <Buffer 75 75 66 66 65 72>