summaryrefslogtreecommitdiffstats
path: root/node_modules/pbkdf2/lib/to-buffer.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/pbkdf2/lib/to-buffer.js')
-rw-r--r--node_modules/pbkdf2/lib/to-buffer.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/node_modules/pbkdf2/lib/to-buffer.js b/node_modules/pbkdf2/lib/to-buffer.js
new file mode 100644
index 0000000..ef0d4d4
--- /dev/null
+++ b/node_modules/pbkdf2/lib/to-buffer.js
@@ -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')
+ }
+}