2
0
mirror of https://github.com/cderche/greenlock-storage-s3 synced 2025-12-24 13:28:38 +00:00
2019-05-08 12:19:12 +01:00

19 lines
488 B
JavaScript

var Buffer = require('../core').util.Buffer;
/**
* Converts data into Buffer.
* @param {ArrayBuffer|string|number[]|Buffer} data Data to convert to a Buffer
* @param {string} [encoding] String encoding
* @returns {Buffer}
*/
function toBuffer(data, encoding) {
return (typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from) ?
Buffer.from(data, encoding) : new Buffer(data, encoding);
}
/**
* @api private
*/
module.exports = {
toBuffer: toBuffer
};