function Binary(buffer$1, subType) {
        if (!(this instanceof Binary))
            return new Binary(buffer$1, subType);
        if (!(buffer$1 == null) &&
            !(typeof buffer$1 === 'string') &&
            !ArrayBuffer.isView(buffer$1) &&
            !(buffer$1 instanceof ArrayBuffer) &&
            !Array.isArray(buffer$1)) {
            throw new TypeError('Binary can only be constructed from string, Buffer, TypedArray, or Array<number>');
        }
        this.sub_type = subType !== null && subType !== void 0 ? subType : Binary.BSON_BINARY_SUBTYPE_DEFAULT;
        if (buffer$1 == null) {
            // create an empty binary buffer
            this.buffer = buffer.Buffer.alloc(Binary.BUFFER_SIZE);
            this.position = 0;
        }
        else {
            if (typeof buffer$1 === 'string') {
                // string
                this.buffer = buffer.Buffer.from(buffer$1, 'binary');
            }
            else if (Array.isArray(buffer$1)) {
                // number[]
                this.buffer = buffer.Buffer.from(buffer$1);
            }
            else {
                // Buffer | TypedArray | ArrayBuffer
                this.buffer = ensure_buffer.ensureBuffer(buffer$1);
            }
            this.position = this.buffer.byteLength;
        }
    }
/**
     * @param buffer - a buffer object containing the binary data.
     * @param subType - the option binary type.
     */
@param buffer - a buffer object containing the binary data.
@param subType - the option binary type.
@param buffer - a buffer object containing the binary data . @param subType - the option binary type .
function Binary(buffer$1, subType) {
        if (!(this instanceof Binary))
            return new Binary(buffer$1, subType);
        if (!(buffer$1 == null) &&
            !(typeof buffer$1 === 'string') &&
            !ArrayBuffer.isView(buffer$1) &&
            !(buffer$1 instanceof ArrayBuffer) &&
            !Array.isArray(buffer$1)) {
            throw new TypeError('Binary can only be constructed from string, Buffer, TypedArray, or Array<number>');
        }
        this.sub_type = subType !== null && subType !== void 0 ? subType : Binary.BSON_BINARY_SUBTYPE_DEFAULT;
        if (buffer$1 == null) {
            this.buffer = buffer.Buffer.alloc(Binary.BUFFER_SIZE);
            this.position = 0;
        }
        else {
            if (typeof buffer$1 === 'string') {
                this.buffer = buffer.Buffer.from(buffer$1, 'binary');
            }
            else if (Array.isArray(buffer$1)) {
                this.buffer = buffer.Buffer.from(buffer$1);
            }
            else {
                this.buffer = ensure_buffer.ensureBuffer(buffer$1);
            }
            this.position = this.buffer.byteLength;
        }
    }
function Binary ( buffer$1 , subType ) { if ( ! ( this instanceof Binary ) ) return new Binary ( buffer$1 , subType ) ; if ( ! ( buffer$1 == null ) && ! ( typeof buffer$1 === 'string' ) && ! ArrayBuffer . isView ( buffer$1 ) && ! ( buffer$1 instanceof ArrayBuffer ) && ! Array . isArray ( buffer$1 ) ) { throw new TypeError ( 'Binary can only be constructed from string, Buffer, TypedArray, or Array<number>' ) ; } this . sub_type = subType !== null && subType !== void 0 ? subType : Binary . BSON_BINARY_SUBTYPE_DEFAULT ; if ( buffer$1 == null ) { this . buffer = buffer . Buffer . alloc ( Binary . BUFFER_SIZE ) ; this . position = 0 ; } else { if ( typeof buffer$1 === 'string' ) { this . buffer = buffer . Buffer . from ( buffer$1 , 'binary' ) ; } else if ( Array . isArray ( buffer$1 ) ) { this . buffer = buffer . Buffer . from ( buffer$1 ) ; } else { this . buffer = ensure_buffer . ensureBuffer ( buffer$1 ) ; } this . position = this . buffer . byteLength ; } }
@param buffer - a buffer object containing the binary data.
@param buffer - a buffer object containing the binary data .
// create an empty binary buffer // string // number[] // Buffer | TypedArray | ArrayBuffer