node_modules/bson/dist/bson.esm.js
/**
     * @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, subType) {
        if (!(this instanceof Binary))
            return new Binary(buffer, subType);
        if (!(buffer == null) &&
            !(typeof buffer === 'string') &&
            !ArrayBuffer.isView(buffer) &&
            !(buffer instanceof ArrayBuffer) &&
            !Array.isArray(buffer)) {
            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 == null) {
            this.buffer = Buffer.alloc(Binary.BUFFER_SIZE);
            this.position = 0;
        }
        else {
            if (typeof buffer === 'string') {
                this.buffer = Buffer.from(buffer, 'binary');
            }
            else if (Array.isArray(buffer)) {
                this.buffer = Buffer.from(buffer);
            }
            else {
                this.buffer = ensureBuffer(buffer);
            }
            this.position = this.buffer.byteLength;
        }
    }
function Binary ( buffer , subType ) { if ( ! ( this instanceof Binary ) ) return new Binary ( buffer , subType ) ; if ( ! ( buffer == null ) && ! ( typeof buffer === 'string' ) && ! ArrayBuffer . isView ( buffer ) && ! ( buffer instanceof ArrayBuffer ) && ! Array . isArray ( buffer ) ) { 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 == null ) { this . buffer = Buffer . alloc ( Binary . BUFFER_SIZE ) ; this . position = 0 ; } else { if ( typeof buffer === 'string' ) { this . buffer = Buffer . from ( buffer , 'binary' ) ; } else if ( Array . isArray ( buffer ) ) { this . buffer = Buffer . from ( buffer ) ; } else { this . buffer = ensureBuffer ( buffer ) ; } 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