Takes in a value and encodes it as a `sInt64` stored in a [ByteBuffer]{@link https://www.npmjs.com/package/bytebuffer} object for use with the protobufjs library.
@param value - The value to encode.
@return {ByteBuffer|void}
161190
function encodeSInt64(value) {
    let buffer = new ByteBuffer();
    if (value === null) {
        return buffer;
    }
    return buffer.writeVarint64ZigZag(value);
}
754088
public static String compressStringToBase64String(String value) throws IOException {
        return new String(Base64.encode(compressString(value)), StandardCharsets.UTF_8);
    }
831440
public static byte[] getFiveBytes(long value) {
        if (value < 0) {
            throw new IllegalArgumentException("negative value not allowed: " + value);
        } else if (value > 1099511627775L) {
            throw new IllegalArgumentException("value out of range: " + value);
        }
        return new byte[]{(byte) (value >> 32), (byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8),
                (byte) value};
    }
1081345
@Override
    public byte[] convertTo(final Object value) {
        if (value == null) {
            final BsonWriter out = writerPool.get().tiny(tiny);
            out.writeNull();
            byte[] result = out.toArray();
            writerPool.accept(out);
            return result;
        }
        return convertTo(value.getClass(), value);
    }
725784
public static void writeInt64LE(final long value, final byte[] buffer, int offset)
    {
        buffer[offset++] = (byte) (value >>> 0);
        buffer[offset++] = (byte) (value >>> 8);
        buffer[offset++] = (byte) (value >>> 16);
        buffer[offset++] = (byte) (value >>> 24);
        buffer[offset++] = (byte) (value >>> 32);
        buffer[offset++] = (byte) (value >>> 40);
        buffer[offset++] = (byte) (value >>> 48);
        buffer[offset] = (byte) (value >>> 56);
    }
143530
private static StringBuilder toBase64(long value) {
		StringBuilder result = new StringBuilder(23); // Initialize with the size of ID if using Base64
		for(int shift=60; shift>=0; shift-=6) {
			result.append(Base64[(int)((value >> shift) & 0x3F)]);
		}
		return result;
	}
588192
public static SerializedObjectValueBuilder serializedObjectValue(String value, boolean isTransient) {
    return (SerializedObjectValueBuilder) serializedObjectValue().serializedValue(value).setTransient(isTransient);
  }
1016523
public static String encodeBase64(String value) {
        return new String(Base64.encode(value.getBytes(Charsets.UTF_8)));
    }
407337
function encodeString(value) {
    let buffer = new ByteBuffer();
    if (value === null) {
        return buffer;
    }
    return buffer.writeVString(value);
}
36261
def encode(self, value):
        
        if type(value) == str and self.enum and value in self.enum:
            value = self.enum[value]
        return self.type.encode(value) if self.type else bytearray()
1232169
public static byte[] toBytes(int value) {
		final byte[] result = new byte[4];

		result[0] = (byte) (value >> 24);
		result[1] = (byte) (value >> 16);
		result[2] = (byte) (value >> 8);
		result[3] = (byte) (value /* >> 0 */);

		return result;
	}
1105865
public static byte[] toByteArray(String value) {
        if (value == null) {
            return null;
        }
        try {
            CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder().onMalformedInput(CodingErrorAction.REPORT)
                    .onUnmappableCharacter(CodingErrorAction.REPORT);
            ByteBuffer buf = encoder.encode(CharBuffer.wrap(value));
            // don't use ByteBuffer.array(), as it returns internal, and
            // possibly larger, byte array
            byte[] res = new byte[buf.remaining()];
            buf.get(res);
            return res;
        } catch (CharacterCodingException e) {
            throw new RuntimeException("Unexpected exception", e);
        }
    }
383508
function encodeFloat(value) {
    let buffer = new ByteBuffer();
    buffer.littleEndian = true;
    buffer.limit = 8;
    if (value === null) {
        return buffer;
    }
    return buffer.writeFloat(value);
}
506745
function (value, length, offset) {

                length = length || value.byteLength || value.length;
                var i;

                if (!length) {
                    return this;
                }

                if (undefined === offset) {
                    offset = this.offset;
                }

                if (length < 0 || offset + length > this.length) {
                    error.raise(10002, this.length, offset + length);
                }

                if (value instanceof ArrayBuffer) {
                    var view = new DataView(value, 0, length);
                    var littleEndian = this.littleEndian;

                    for (i = 0; i < length; ++i) {
                        this.view.setUint8(offset + i, view.getUint8(i, littleEndian), littleEndian);
                    }
                }
                else {
                    for (i = 0; i < length; ++i) {
                        this.view.setUint8(offset + i, value[i], littleEndian);
                    }
                }

                this.offset = offset + length;

                return this;
            }
652253
static void putInt(ByteBuffer buffer, int value) {
        value = (value << 1) ^ (value >> 31);
        if (value >>> 7 == 0) {
            buffer.put((byte) value);
        } else {
            buffer.put((byte) ((value & 0x7F) | 0x80));
            if (value >>> 14 == 0) {
                buffer.put((byte) (value >>> 7));
            } else {
                buffer.put((byte) (value >>> 7 | 0x80));
                if (value >>> 21 == 0) {
                    buffer.put((byte) (value >>> 14));
                } else {
                    buffer.put((byte) (value >>> 14 | 0x80));
                    if (value >>> 28 == 0) {
                        buffer.put((byte) (value >>> 21));
                    } else {
                        buffer.put((byte) (value >>> 21 | 0x80));
                        buffer.put((byte) (value >>> 28));
                    }
                }
            }
        }
    }
882586
@Deprecated
    public static String encodeBASE64(String value) {
        return new String(Base64.encode(value.getBytes(Charsets.UTF_8)));
    }
769283
@SneakyThrows(IOException.class)
    public ByteBuffer toByteBuffer(ControllerEvent value) {
        ByteArraySegment s = serialize(value);
        return ByteBuffer.wrap(s.array(), s.arrayOffset(), s.getLength());
    }