You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
344 B
12 lines
344 B
4 years ago
|
module.exports = function (buf) {
|
||
|
if (!buf) return undefined;
|
||
|
if (buf.constructor.name === 'Uint8Array'
|
||
|
|| buf.constructor === Uint8Array) {
|
||
|
return buf;
|
||
|
}
|
||
|
if (typeof buf === 'string') buf = Buffer(buf);
|
||
|
var a = new Uint8Array(buf.length);
|
||
|
for (var i = 0; i < buf.length; i++) a[i] = buf[i];
|
||
|
return a;
|
||
|
};
|