Current Folder
This commit is contained in:
1 parent
8b3382289b
commit
cfcada880d
4379 files changed
No files matched your search
+13
@@ -0,0 +1,13 @@
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
|
||||
module.exports = function (thing, encoding, name) {
|
||||
if (Buffer.isBuffer(thing)) {
|
||||
return thing
|
||||
} else if (typeof thing === 'string') {
|
||||
return Buffer.from(thing, encoding)
|
||||
} else if (ArrayBuffer.isView(thing)) {
|
||||
return Buffer.from(thing.buffer)
|
||||
} else {
|
||||
throw new TypeError(name + ' must be a string, a Buffer, a typed array or a DataView')
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user