import { Buffer } from "https://deno.land/x/canvaseno@v1.0.2/deps.ts";
Returns a new Buffer
that references the same memory as the original, but
offset and cropped by the start
and end
indices.
This is the same behavior as buf.subarray()
.
This method is not compatible with the Uint8Array.prototype.slice()
,
which is a superclass of Buffer
. To copy the slice, useUint8Array.prototype.slice()
.
import { Buffer } from 'buffer';
const buf = Buffer.from('buffer');
const copiedBuf = Uint8Array.prototype.slice.call(buf);
copiedBuf[0]++;
console.log(copiedBuf.toString());
// Prints: cuffer
console.log(buf.toString());
// Prints: buffer