Returns data as buffer.

@param {any} data The input data.
@param {string} [encoding] The custom encoding to use if 'data' is NOT a buffer.

@return {Buffer} The output data.
544340
function asBuffer(data, encoding) {
    let result = data;
    if (!isNullOrUndefined(result)) {
        if ('object' !== typeof result) {
            // handle as string
            encoding = normalizeString(encoding);
            if (!encoding) {
                encoding = 'utf8';
            }
            result = new Buffer(toStringSafe(result), encoding);
        }
    }
    return result;
}
332018
function encode(data) {
	const bytes = buffer.Buffer.from(data, 'utf8');
	const pixelData = prependLength(bytes);

	return createPng(pixelData);
}
1374586
function bufferFrom(data, enc) {
  if (typeof Buffer.from == 'function') {
    return Buffer.from(data, enc);
  } else {
    return new Buffer(data, enc);
  }
}
39143
function encodeBuffer(packet, supportsBinary, callback) {
  if (!supportsBinary) {
    return exports.encodeBase64Packet(packet, callback);
  }

  var data = packet.data;
  var typeBuffer = new Buffer(1);
  typeBuffer[0] = packets[packet.type];
  return callback(Buffer.concat([typeBuffer, data]));
}
185836
def outputdata(self, data):
        
        if not isinstance(data, bytes):
            data = str(data).encode(self.encoding)
        self.output(MemoryStream(data))
177499
function stringToArrayBuffer(string) {
            var
                buffer = new ArrayBuffer(string.length),
                int8Array = new Uint8Array(buffer);
            
            for (var i = 0; i < string.length; i++) {
                int8Array[i] = string.charCodeAt(i);
            }
            
            return buffer;
        }
895777
function decode (data, start, end, encoding) {
  if (data == null || data.length === 0) {
    return null
  }

  if (typeof start !== 'number' && encoding == null) {
    encoding = start
    start = undefined
  }

  if (typeof end !== 'number' && encoding == null) {
    encoding = end
    end = undefined
  }

  decode.position = 0
  decode.encoding = encoding || null

  decode.data = !(Buffer.isBuffer(data))
    ? Buffer.from(data)
    : data.slice(start, end)

  decode.bytes = decode.data.length

  return decode.next()
}
737159
function __serializeArrayBuffer(data) {
	let length = data.byteLength;
	let lengthData = new Uint32Array([length]);
	return [lengthData.buffer, data];
}
820146
function (data) {
            const _mode = QRMode.MODE_8BIT_BYTE;
            const _bytes = qrcode.stringToBytes(data);
            const _this = {};

            _this.getMode = function () {
                return _mode;
            };

            _this.getLength = function () {
                return _bytes.length;
            };

            /**
             * @param {QrBitBuffer} buffer
             */
            _this.write = function (buffer) {
                for (let i = 0; i < _bytes.length; i += 1) {
                    buffer.put(_bytes[i], 8);
                }
            };

            return _this;
        }
1269552
def encode(char_data, encoding='utf-8'):
    
    if type(char_data) is unicode:
        return char_data.encode(encoding, 'replace')
    else:
        return char_data
396659
function toBuffer (object) {
  if (Buffer.isBuffer(object)) return object
  if (object.buffer) return object.buffer
  throw new TypeError('Could not output buffer type.')
}
818701
function encodeData (data) {
    // json encode data
    data = jsonStableStringify(data)
    // compress if compression in use
    if (this.compression) {
        data = snappy.compressSync(data).toString('base64')
    }
    // return encoded data
    return data
}
874833
public static String deflate(final String data) {
        val deflater = new Deflater();
        deflater.setInput(data.getBytes(StandardCharsets.UTF_8));
        deflater.finish();
        val buffer = new byte[data.length()];
        val resultSize = deflater.deflate(buffer);
        val output = new byte[resultSize];
        System.arraycopy(buffer, 0, output, 0, resultSize);
        return EncodingUtils.encodeBase64(output);
    }
632892
function (value, encoding) {
    encoding = (typeof encoding === 'undefined') ? 'utf8' : encoding
    if (Buffer.isBuffer(value)) {
      value = value.toString(encoding)
    }
    return value
  }
23156
function _data(data) {
  if(this.tcp) {
    this.decoder.write(data);
  // connected to an in-process server,
  // emit the reply from the server socket
  }else{
    if(data instanceof Error) {
      this.emit('reply', data, null);
    }else{
      this.emit('reply', null, data);
    }
  }
}
712911
function toBuffer (typed) {
        var ab = typed.buffer;
        var buffer = new Buffer(ab.byteLength);
        var view = new Uint8Array(ab);
        for (var i = 0; i < buffer.length; ++i) {
            buffer[i] = view[i];
        }
        return buffer;
    }
695443
function(data) {
		if( typeof data == "string" ) {
			var transformed = {};
			$.each(data.split(/\s/), function() {
				transformed[this] = true;
			});
			data = transformed;
		}
		return data;
	}