normalizeStream = function (stream) {
        if (!stream) { return; }

        // create buffer from buffer's JSON representation
        if (stream.type === STREAM_TYPE_BUFFER && _.isArray(stream.data)) {
            // @todo Add tests for Browser environments, where ArrayBuffer is returned instead of Buffer
            return typeof Buffer === FUNCTION ? Buffer.from(stream.data) : new Uint8Array(stream.data).buffer;
        }

        // create buffer from base64 string
        if (stream.type === STREAM_TYPE_BASE64 && typeof stream.data === STRING) {
            return Buffer.from(stream.data, BASE64);
        }

        // probably it's already of type buffer
        return stream;
    }
Normalizes an input Buffer, Buffer.toJSON() or base64 string into a Buffer or ArrayBuffer.

@private
@param {Buffer|Object} stream - An instance of Buffer, Buffer.toJSON(), or Base64 string
@returns {Buffer|ArrayBuffer|undefined}