mirror of
https://github.com/cderche/greenlock-storage-s3
synced 2025-05-13 16:16:32 +00:00
14 lines
351 B
JavaScript
14 lines
351 B
JavaScript
/**
|
|
* Converts a UTF8 string into a Buffer.
|
|
* @param {string} data Some string to convert to a Buffer
|
|
* @returns {Buffer}
|
|
*/
|
|
function stringToBuffer(data) {
|
|
return (typeof Buffer.from === 'function' && Buffer.from !== Uint8Array.from) ?
|
|
Buffer.from(data) : new Buffer(data);
|
|
}
|
|
|
|
module.exports = {
|
|
stringToBuffer: stringToBuffer
|
|
};
|