12 lines
294 B
JavaScript
12 lines
294 B
JavaScript
// @flow
|
|
|
|
export const toBuffer = (arr: Buffer | Uint8Array | Array<number>): Buffer => {
|
|
if (arr instanceof Buffer) {
|
|
return arr;
|
|
} else if (arr instanceof Uint8Array) {
|
|
return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
} else {
|
|
return Buffer.from(arr);
|
|
}
|
|
};
|