CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
bson.d.ts1724 linesDownload Raw Back to bson
1/**2 * A class representation of the BSON Binary type.3 * @public4 * @category BSONType5 */6export declare class Binary extends BSONValue {7    get _bsontype(): 'Binary';8    /* Excluded from this release type: BSON_BINARY_SUBTYPE_DEFAULT */9    /** Initial buffer default size */10    static readonly BUFFER_SIZE = 256;11    /** Default BSON type */12    static readonly SUBTYPE_DEFAULT = 0;13    /** Function BSON type */14    static readonly SUBTYPE_FUNCTION = 1;15    /** Byte Array BSON type */16    static readonly SUBTYPE_BYTE_ARRAY = 2;17    /** Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID */18    static readonly SUBTYPE_UUID_OLD = 3;19    /** UUID BSON type */20    static readonly SUBTYPE_UUID = 4;21    /** MD5 BSON type */22    static readonly SUBTYPE_MD5 = 5;23    /** Encrypted BSON type */24    static readonly SUBTYPE_ENCRYPTED = 6;25    /** Column BSON type */26    static readonly SUBTYPE_COLUMN = 7;27    /** Sensitive BSON type */28    static readonly SUBTYPE_SENSITIVE = 8;29    /** Vector BSON type */30    static readonly SUBTYPE_VECTOR = 9;31    /** User BSON type */32    static readonly SUBTYPE_USER_DEFINED = 128;33    /** datatype of a Binary Vector (subtype: 9) */34    static readonly VECTOR_TYPE: Readonly<{35        readonly Int8: 3;36        readonly Float32: 39;37        readonly PackedBit: 16;38    }>;39    /**40     * The bytes of the Binary value.41     *42     * The format of a Binary value in BSON is defined as:43     * ```txt44     * binary	::= int32 subtype (byte*)45     * ```46     *47     * This `buffer` is the "(byte*)" segment.48     *49     * Unless the value is subtype 2, then deserialize will read the first 4 bytes as an int32 and set this to the remaining bytes.50     *51     * ```txt52     * binary	::= int32 unsigned_byte(2) int32 (byte*)53     * ```54     *55     * @see https://bsonspec.org/spec.html56     */57    buffer: Uint8Array;58    /**59     * The binary subtype.60     *61     * Current defined values are:62     *63     * - `unsigned_byte(0)` Generic binary subtype64     * - `unsigned_byte(1)` Function65     * - `unsigned_byte(2)` Binary (Deprecated)66     * - `unsigned_byte(3)` UUID (Deprecated)67     * - `unsigned_byte(4)` UUID68     * - `unsigned_byte(5)` MD569     * - `unsigned_byte(6)` Encrypted BSON value70     * - `unsigned_byte(7)` Compressed BSON column71     * - `unsigned_byte(8)` Sensitive72     * - `unsigned_byte(9)` Vector73     * - `unsigned_byte(128)` - `unsigned_byte(255)` User defined74     */75    sub_type: number;76    /**77     * The Binary's `buffer` can be larger than the Binary's content.78     * This property is used to determine where the content ends in the buffer.79     */80    position: number;81    /**82     * Create a new Binary instance.83     * @param buffer - a buffer object containing the binary data.84     * @param subType - the option binary type.85     */86    constructor(buffer?: BinarySequence, subType?: number);87    /**88     * Updates this binary with byte_value.89     *90     * @param byteValue - a single byte we wish to write.91     */92    put(byteValue: string | number | Uint8Array | number[]): void;93    /**94     * Writes a buffer to the binary.95     *96     * @param sequence - a string or buffer to be written to the Binary BSON object.97     * @param offset - specify the binary of where to write the content.98     */99    write(sequence: BinarySequence, offset: number): void;100    /**101     * Returns a view of **length** bytes starting at **position**.102     *103     * @param position - read from the given position in the Binary.104     * @param length - the number of bytes to read.105     */106    read(position: number, length: number): Uint8Array;107    /** returns a view of the binary value as a Uint8Array */108    value(): Uint8Array;109    /** the length of the binary sequence */110    length(): number;111    toJSON(): string;112    toString(encoding?: 'hex' | 'base64' | 'utf8' | 'utf-8'): string;113    /* Excluded from this release type: toExtendedJSON */114    toUUID(): UUID;115    /** Creates an Binary instance from a hex digit string */116    static createFromHexString(hex: string, subType?: number): Binary;117    /** Creates an Binary instance from a base64 string */118    static createFromBase64(base64: string, subType?: number): Binary;119    /* Excluded from this release type: fromExtendedJSON */120    inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;121    /**122     * If this Binary represents a Int8 Vector (`binary.buffer[0] === Binary.VECTOR_TYPE.Int8`),123     * returns a copy of the bytes in a new Int8Array.124     *125     * If the Binary is not a Vector, or the datatype is not Int8, an error is thrown.126     */127    toInt8Array(): Int8Array;128    /**129     * If this Binary represents a Float32 Vector (`binary.buffer[0] === Binary.VECTOR_TYPE.Float32`),130     * returns a copy of the bytes in a new Float32Array.131     *132     * If the Binary is not a Vector, or the datatype is not Float32, an error is thrown.133     */134    toFloat32Array(): Float32Array;135    /**136     * If this Binary represents packed bit Vector (`binary.buffer[0] === Binary.VECTOR_TYPE.PackedBit`),137     * returns a copy of the bytes that are packed bits.138     *139     * Use `toBits` to get the unpacked bits.140     *141     * If the Binary is not a Vector, or the datatype is not PackedBit, an error is thrown.142     */143    toPackedBits(): Uint8Array;144    /**145     * If this Binary represents a Packed bit Vector (`binary.buffer[0] === Binary.VECTOR_TYPE.PackedBit`),146     * returns a copy of the bit unpacked into a new Int8Array.147     *148     * Use `toPackedBits` to get the bits still in packed form.149     *150     * If the Binary is not a Vector, or the datatype is not PackedBit, an error is thrown.151     */152    toBits(): Int8Array;153    /**154     * Constructs a Binary representing an Int8 Vector.155     * @param array - The array to store as a view on the Binary class156     */157    static fromInt8Array(array: Int8Array): Binary;158    /** Constructs a Binary representing an Float32 Vector. */159    static fromFloat32Array(array: Float32Array): Binary;160    /**161     * Constructs a Binary representing a packed bit Vector.162     *163     * Use `fromBits` to pack an array of 1s and 0s.164     */165    static fromPackedBits(array: Uint8Array, padding?: number): Binary;166    /**167     * Constructs a Binary representing an Packed Bit Vector.168     * @param array - The array of 1s and 0s to pack into the Binary instance169     */170    static fromBits(bits: ArrayLike<number>): Binary;171}172 173/** @public */174export declare interface BinaryExtended {175    $binary: {176        subType: string;177        base64: string;178    };179}180 181/** @public */182export declare interface BinaryExtendedLegacy {183    $type: string;184    $binary: string;185}186 187/** @public */188export declare type BinarySequence = Uint8Array | number[];189 190declare namespace BSON {191    export {192        setInternalBufferSize,193        serialize,194        serializeWithBufferAndIndex,195        deserialize,196        calculateObjectSize,197        deserializeStream,198        UUIDExtended,199        BinaryExtended,200        BinaryExtendedLegacy,201        BinarySequence,202        CodeExtended,203        DBRefLike,204        Decimal128Extended,205        DoubleExtended,206        EJSONOptions,207        Int32Extended,208        LongExtended,209        MaxKeyExtended,210        MinKeyExtended,211        ObjectIdExtended,212        ObjectIdLike,213        BSONRegExpExtended,214        BSONRegExpExtendedLegacy,215        BSONSymbolExtended,216        LongWithoutOverrides,217        TimestampExtended,218        TimestampOverrides,219        LongWithoutOverridesClass,220        SerializeOptions,221        DeserializeOptions,222        Code,223        BSONSymbol,224        DBRef,225        Binary,226        ObjectId,227        UUID,228        Long,229        Timestamp,230        Double,231        Int32,232        MinKey,233        MaxKey,234        BSONRegExp,235        Decimal128,236        BSONValue,237        BSONError,238        BSONVersionError,239        BSONRuntimeError,240        BSONOffsetError,241        BSONType,242        EJSON,243        onDemand,244        OnDemand,245        Document,246        CalculateObjectSizeOptions247    }248}249export { BSON }250 251/* Excluded from this release type: BSON_MAJOR_VERSION */252 253/* Excluded from this release type: BSON_VERSION_SYMBOL */254 255/**256 * @public257 * @experimental258 */259declare type BSONElement = [260type: number,261nameOffset: number,262nameLength: number,263offset: number,264length: number265];266 267/**268 * @public269 * @category Error270 *271 * `BSONError` objects are thrown when BSON encounters an error.272 *273 * This is the parent class for all the other errors thrown by this library.274 */275export declare class BSONError extends Error {276    /* Excluded from this release type: bsonError */277    get name(): string;278    constructor(message: string, options?: {279        cause?: unknown;280    });281    /**282     * @public283     *284     * All errors thrown from the BSON library inherit from `BSONError`.285     * This method can assist with determining if an error originates from the BSON library286     * even if it does not pass an `instanceof` check against this class' constructor.287     *288     * @param value - any javascript value that needs type checking289     */290    static isBSONError(value: unknown): value is BSONError;291}292 293/**294 * @public295 * @category Error296 *297 * @experimental298 *299 * An error generated when BSON bytes are invalid.300 * Reports the offset the parser was able to reach before encountering the error.301 */302export declare class BSONOffsetError extends BSONError {303    get name(): 'BSONOffsetError';304    offset: number;305    constructor(message: string, offset: number, options?: {306        cause?: unknown;307    });308}309 310/**311 * A class representation of the BSON RegExp type.312 * @public313 * @category BSONType314 */315export declare class BSONRegExp extends BSONValue {316    get _bsontype(): 'BSONRegExp';317    pattern: string;318    options: string;319    /**320     * @param pattern - The regular expression pattern to match321     * @param options - The regular expression options322     */323    constructor(pattern: string, options?: string);324    static parseOptions(options?: string): string;325    /* Excluded from this release type: toExtendedJSON */326    /* Excluded from this release type: fromExtendedJSON */327    inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;328}329 330/** @public */331export declare interface BSONRegExpExtended {332    $regularExpression: {333        pattern: string;334        options: string;335    };336}337 338/** @public */339export declare interface BSONRegExpExtendedLegacy {340    $regex: string | BSONRegExp;341    $options: string;342}343 344/**345 * @public346 * @category Error347 *348 * An error generated when BSON functions encounter an unexpected input349 * or reaches an unexpected/invalid internal state350 *351 */352export declare class BSONRuntimeError extends BSONError {353    get name(): 'BSONRuntimeError';354    constructor(message: string);355}356 357/**358 * A class representation of the BSON Symbol type.359 * @public360 * @category BSONType361 */362export declare class BSONSymbol extends BSONValue {363    get _bsontype(): 'BSONSymbol';364    value: string;365    /**366     * @param value - the string representing the symbol.367     */368    constructor(value: string);369    /** Access the wrapped string value. */370    valueOf(): string;371    toString(): string;372    toJSON(): string;373    /* Excluded from this release type: toExtendedJSON */374    /* Excluded from this release type: fromExtendedJSON */375    inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;376}377 378/** @public */379export declare interface BSONSymbolExtended {380    $symbol: string;381}382 383/** @public */384export declare const BSONType: Readonly<{385    readonly double: 1;386    readonly string: 2;387    readonly object: 3;388    readonly array: 4;389    readonly binData: 5;390    readonly undefined: 6;391    readonly objectId: 7;392    readonly bool: 8;393    readonly date: 9;394    readonly null: 10;395    readonly regex: 11;396    readonly dbPointer: 12;397    readonly javascript: 13;398    readonly symbol: 14;399    readonly javascriptWithScope: 15;400    readonly int: 16;401    readonly timestamp: 17;402    readonly long: 18;403    readonly decimal: 19;404    readonly minKey: -1;405    readonly maxKey: 127;406}>;407 408/** @public */409export declare type BSONType = (typeof BSONType)[keyof typeof BSONType];410 411/** @public */412export declare abstract class BSONValue {413    /** @public */414    abstract get _bsontype(): string;415    /* Excluded from this release type: [BSON_VERSION_SYMBOL] */416    /**417     * @public418     * Prints a human-readable string of BSON value information419     * If invoked manually without node.js.inspect function, this will default to a modified JSON.stringify420     */421    abstract inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;422    /* Excluded from this release type: toExtendedJSON */423}424 425/**426 * @public427 * @category Error428 */429export declare class BSONVersionError extends BSONError {430    get name(): 'BSONVersionError';431    constructor();432}433 434/**435 * @public436 * @experimental437 *438 * A collection of functions that help work with data in a Uint8Array.439 * ByteUtils is configured at load time to use Node.js or Web based APIs for the internal implementations.440 */441declare type ByteUtils = {442    /** Transforms the input to an instance of Buffer if running on node, otherwise Uint8Array */443    toLocalBufferType: (buffer: Uint8Array | ArrayBufferView | ArrayBuffer) => Uint8Array;444    /** Create empty space of size */445    allocate: (size: number) => Uint8Array;446    /** Create empty space of size, use pooled memory when available */447    allocateUnsafe: (size: number) => Uint8Array;448    /** Check if two Uint8Arrays are deep equal */449    equals: (a: Uint8Array, b: Uint8Array) => boolean;450    /** Check if two Uint8Arrays are deep equal */451    fromNumberArray: (array: number[]) => Uint8Array;452    /** Create a Uint8Array from a base64 string */453    fromBase64: (base64: string) => Uint8Array;454    /** Create a base64 string from bytes */455    toBase64: (buffer: Uint8Array) => string;456    /** **Legacy** binary strings are an outdated method of data transfer. Do not add public API support for interpreting this format */457    fromISO88591: (codePoints: string) => Uint8Array;458    /** **Legacy** binary strings are an outdated method of data transfer. Do not add public API support for interpreting this format */459    toISO88591: (buffer: Uint8Array) => string;460    /** Create a Uint8Array from a hex string */461    fromHex: (hex: string) => Uint8Array;462    /** Create a lowercase hex string from bytes */463    toHex: (buffer: Uint8Array) => string;464    /** Create a string from utf8 code units, fatal=true will throw an error if UTF-8 bytes are invalid, fatal=false will insert replacement characters */465    toUTF8: (buffer: Uint8Array, start: number, end: number, fatal: boolean) => string;466    /** Get the utf8 code unit count from a string if it were to be transformed to utf8 */467    utf8ByteLength: (input: string) => number;468    /** Encode UTF8 bytes generated from `source` string into `destination` at byteOffset. Returns the number of bytes encoded. */469    encodeUTF8Into: (destination: Uint8Array, source: string, byteOffset: number) => number;470    /** Generate a Uint8Array filled with random bytes with byteLength */471    randomBytes: (byteLength: number) => Uint8Array;472    /** Interprets `buffer` as an array of 32-bit values and swaps the byte order in-place. */473    swap32: (buffer: Uint8Array) => Uint8Array;474};475 476/* Excluded declaration from this release type: ByteUtils */477 478/**479 * Calculate the bson size for a passed in Javascript object.480 *481 * @param object - the Javascript object to calculate the BSON byte size for482 * @returns size of BSON object in bytes483 * @public484 */485export declare function calculateObjectSize(object: Document, options?: CalculateObjectSizeOptions): number;486 487/** @public */488export declare type CalculateObjectSizeOptions = Pick<SerializeOptions, 'serializeFunctions' | 'ignoreUndefined'>;489 490/**491 * A class representation of the BSON Code type.492 * @public493 * @category BSONType494 */495export declare class Code extends BSONValue {496    get _bsontype(): 'Code';497    code: string;498    scope: Document | null;499    /**500     * @param code - a string or function.501     * @param scope - an optional scope for the function.502     */503    constructor(code: string | Function, scope?: Document | null);504    toJSON(): {505        code: string;506        scope?: Document;507    };508    /* Excluded from this release type: toExtendedJSON */509    /* Excluded from this release type: fromExtendedJSON */510    inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;511}512 513/** @public */514export declare interface CodeExtended {515    $code: string;516    $scope?: Document;517}518 519/**520 * A class representation of the BSON DBRef type.521 * @public522 * @category BSONType523 */524export declare class DBRef extends BSONValue {525    get _bsontype(): 'DBRef';526    collection: string;527    oid: ObjectId;528    db?: string;529    fields: Document;530    /**531     * @param collection - the collection name.532     * @param oid - the reference ObjectId.533     * @param db - optional db name, if omitted the reference is local to the current db.534     */535    constructor(collection: string, oid: ObjectId, db?: string, fields?: Document);536    /* Excluded from this release type: namespace */537    /* Excluded from this release type: namespace */538    toJSON(): DBRefLike & Document;539    /* Excluded from this release type: toExtendedJSON */540    /* Excluded from this release type: fromExtendedJSON */541    inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;542}543 544/** @public */545export declare interface DBRefLike {546    $ref: string;547    $id: ObjectId;548    $db?: string;549}550 551/**552 * A class representation of the BSON Decimal128 type.553 * @public554 * @category BSONType555 */556export declare class Decimal128 extends BSONValue {557    get _bsontype(): 'Decimal128';558    readonly bytes: Uint8Array;559    /**560     * @param bytes - a buffer containing the raw Decimal128 bytes in little endian order,561     *                or a string representation as returned by .toString()562     */563    constructor(bytes: Uint8Array | string);564    /**565     * Create a Decimal128 instance from a string representation566     *567     * @param representation - a numeric string representation.568     */569    static fromString(representation: string): Decimal128;570    /**571     * Create a Decimal128 instance from a string representation, allowing for rounding to 34572     * significant digits573     *574     * @example Example of a number that will be rounded575     * ```ts576     * > let d = Decimal128.fromString('37.499999999999999196428571428571375')577     * Uncaught:578     * BSONError: "37.499999999999999196428571428571375" is not a valid Decimal128 string - inexact rounding579     * at invalidErr (/home/wajames/js-bson/lib/bson.cjs:1402:11)580     * at Decimal128.fromStringInternal (/home/wajames/js-bson/lib/bson.cjs:1633:25)581     * at Decimal128.fromString (/home/wajames/js-bson/lib/bson.cjs:1424:27)582     *583     * > d = Decimal128.fromStringWithRounding('37.499999999999999196428571428571375')584     * new Decimal128("37.49999999999999919642857142857138")585     * ```586     * @param representation - a numeric string representation.587     */588    static fromStringWithRounding(representation: string): Decimal128;589    private static _fromString;590    /** Create a string representation of the raw Decimal128 value */591    toString(): string;592    toJSON(): Decimal128Extended;593    /* Excluded from this release type: toExtendedJSON */594    /* Excluded from this release type: fromExtendedJSON */595    inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;596}597 598/** @public */599export declare interface Decimal128Extended {600    $numberDecimal: string;601}602 603/**604 * Deserialize data as BSON.605 *606 * @param buffer - the buffer containing the serialized set of BSON documents.607 * @returns returns the deserialized Javascript Object.608 * @public609 */610export declare function deserialize(buffer: Uint8Array, options?: DeserializeOptions): Document;611 612/** @public */613export declare interface DeserializeOptions {614    /**615     * when deserializing a Long return as a BigInt.616     * @defaultValue `false`617     */618    useBigInt64?: boolean;619    /**620     * when deserializing a Long will fit it into a Number if it's smaller than 53 bits.621     * @defaultValue `true`622     */623    promoteLongs?: boolean;624    /**625     * when deserializing a Binary will return it as a node.js Buffer instance.626     * @defaultValue `false`627     */628    promoteBuffers?: boolean;629    /**630     * when deserializing will promote BSON values to their Node.js closest equivalent types.631     * @defaultValue `true`632     */633    promoteValues?: boolean;634    /**635     * allow to specify if there what fields we wish to return as unserialized raw buffer.636     * @defaultValue `null`637     */638    fieldsAsRaw?: Document;639    /**640     * return BSON regular expressions as BSONRegExp instances.641     * @defaultValue `false`642     */643    bsonRegExp?: boolean;644    /**645     * allows the buffer to be larger than the parsed BSON object.646     * @defaultValue `false`647     */648    allowObjectSmallerThanBufferSize?: boolean;649    /**650     * Offset into buffer to begin reading document from651     * @defaultValue `0`652     */653    index?: number;654    raw?: boolean;655    /** Allows for opt-out utf-8 validation for all keys or656     * specified keys. Must be all true or all false.657     *658     * @example659     * ```js660     * // disables validation on all keys661     *  validation: { utf8: false }662     *663     * // enables validation only on specified keys a, b, and c664     *  validation: { utf8: { a: true, b: true, c: true } }665     *666     *  // disables validation only on specified keys a, b667     *  validation: { utf8: { a: false, b: false } }668     * ```669     */670    validation?: {671        utf8: boolean | Record<string, true> | Record<string, false>;672    };673}674 675/**676 * Deserialize stream data as BSON documents.677 *678 * @param data - the buffer containing the serialized set of BSON documents.679 * @param startIndex - the start index in the data Buffer where the deserialization is to start.680 * @param numberOfDocuments - number of documents to deserialize.681 * @param documents - an array where to store the deserialized documents.682 * @param docStartIndex - the index in the documents array from where to start inserting documents.683 * @param options - additional options used for the deserialization.684 * @returns next index in the buffer after deserialization **x** numbers of documents.685 * @public686 */687export declare function deserializeStream(data: Uint8Array | ArrayBuffer, startIndex: number, numberOfDocuments: number, documents: Document[], docStartIndex: number, options: DeserializeOptions): number;688 689/** @public */690export declare interface Document {691    [key: string]: any;692}693 694/**695 * A class representation of the BSON Double type.696 * @public697 * @category BSONType698 */699export declare class Double extends BSONValue {700    get _bsontype(): 'Double';701    value: number;702    /**703     * Create a Double type704     *705     * @param value - the number we want to represent as a double.706     */707    constructor(value: number);708    /**709     * Attempt to create an double type from string.710     *711     * This method will throw a BSONError on any string input that is not representable as a IEEE-754 64-bit double.712     * Notably, this method will also throw on the following string formats:713     * - Strings in non-decimal and non-exponential formats (binary, hex, or octal digits)714     * - Strings with characters other than numeric, floating point, or leading sign characters (Note: 'Infinity', '-Infinity', and 'NaN' input strings are still allowed)715     * - Strings with leading and/or trailing whitespace716     *717     * Strings with leading zeros, however, are also allowed718     *719     * @param value - the string we want to represent as a double.720     */721    static fromString(value: string): Double;722    /**723     * Access the number value.724     *725     * @returns returns the wrapped double number.726     */727    valueOf(): number;728    toJSON(): number;729    toString(radix?: number): string;730    /* Excluded from this release type: toExtendedJSON */731    /* Excluded from this release type: fromExtendedJSON */732    inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;733}734 735/** @public */736export declare interface DoubleExtended {737    $numberDouble: string;738}739 740/** @public */741export declare const EJSON: {742    parse: typeof parse;743    stringify: typeof stringify;744    serialize: typeof EJSONserialize;745    deserialize: typeof EJSONdeserialize;746};747 748/**749 * Deserializes an Extended JSON object into a plain JavaScript object with native/BSON types750 *751 * @param ejson - The Extended JSON object to deserialize752 * @param options - Optional settings passed to the parse method753 */754declare function EJSONdeserialize(ejson: Document, options?: EJSONOptions): any;755 756/** @public */757export declare type EJSONOptions = {758    /**759     * Output using the Extended JSON v1 spec760     * @defaultValue `false`761     */762    legacy?: boolean;763    /**764     * Enable Extended JSON's `relaxed` mode, which attempts to return native JS types where possible, rather than BSON types765     * @defaultValue `false` */766    relaxed?: boolean;767    /**768     * Enable native bigint support769     * @defaultValue `false`770     */771    useBigInt64?: boolean;772};773 774/**775 * Serializes an object to an Extended JSON string, and reparse it as a JavaScript object.776 *777 * @param value - The object to serialize778 * @param options - Optional settings passed to the `stringify` function779 */780declare function EJSONserialize(value: any, options?: EJSONOptions): Document;781 782declare type InspectFn = (x: unknown, options?: unknown) => string;783 784/**785 * A class representation of a BSON Int32 type.786 * @public787 * @category BSONType788 */789export declare class Int32 extends BSONValue {790    get _bsontype(): 'Int32';791    value: number;792    /**793     * Create an Int32 type794     *795     * @param value - the number we want to represent as an int32.796     */797    constructor(value: number | string);798    /**799     * Attempt to create an Int32 type from string.800     *801     * This method will throw a BSONError on any string input that is not representable as an Int32.802     * Notably, this method will also throw on the following string formats:803     * - Strings in non-decimal formats (exponent notation, binary, hex, or octal digits)804     * - Strings non-numeric and non-leading sign characters (ex: '2.0', '24,000')805     * - Strings with leading and/or trailing whitespace806     *807     * Strings with leading zeros, however, are allowed.808     *809     * @param value - the string we want to represent as an int32.810     */811    static fromString(value: string): Int32;812    /**813     * Access the number value.814     *815     * @returns returns the wrapped int32 number.816     */817    valueOf(): number;818    toString(radix?: number): string;819    toJSON(): number;820    /* Excluded from this release type: toExtendedJSON */821    /* Excluded from this release type: fromExtendedJSON */822    inspect(depth?: number, options?: unknown, inspect?: InspectFn): string;823}824 825/** @public */826export declare interface Int32Extended {827    $numberInt: string;828}829 830/**831 * A class representing a 64-bit integer832 * @public833 * @category BSONType834 * @remarks835 * The internal representation of a long is the two given signed, 32-bit values.836 * We use 32-bit pieces because these are the size of integers on which837 * Javascript performs bit-operations.  For operations like addition and838 * multiplication, we split each number into 16 bit pieces, which can easily be839 * multiplied within Javascript's floating-point representation without overflow840 * or change in sign.841 * In the algorithms below, we frequently reduce the negative case to the842 * positive case by negating the input(s) and then post-processing the result.843 * Note that we must ALWAYS check specially whether those values are MIN_VALUE844 * (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as845 * a positive number, it overflows back into a negative).  Not handling this846 * case would often result in infinite recursion.847 * Common constant values ZERO, ONE, NEG_ONE, etc. are found as static properties on this class.848 */849export declare class Long extends BSONValue {850    get _bsontype(): 'Long';851    /** An indicator used to reliably determine if an object is a Long or not. */852    get __isLong__(): boolean;853    /**854     * The high 32 bits as a signed value.855     */856    high: number;857    /**858     * The low 32 bits as a signed value.859     */860    low: number;861    /**862     * Whether unsigned or not.863     */864    unsigned: boolean;865    /**866     * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.867     *868     * @param low - The low (signed) 32 bits of the long869     * @param high - The high (signed) 32 bits of the long870     * @param unsigned - Whether unsigned or not, defaults to signed871     */872    constructor(low: number, high?: number, unsigned?: boolean);873    /**874     * Constructs a 64 bit two's-complement integer, given a bigint representation.875     *876     * @param value - BigInt representation of the long value877     * @param unsigned - Whether unsigned or not, defaults to signed878     */879    constructor(value: bigint, unsigned?: boolean);880    /**881     * Constructs a 64 bit two's-complement integer, given a string representation.882     *883     * @param value - String representation of the long value884     * @param unsigned - Whether unsigned or not, defaults to signed885     */886    constructor(value: string, unsigned?: boolean);887    static TWO_PWR_24: Long;888    /** Maximum unsigned value. */889    static MAX_UNSIGNED_VALUE: Long;890    /** Signed zero */891    static ZERO: Long;892    /** Unsigned zero. */893    static UZERO: Long;894    /** Signed one. */895    static ONE: Long;896    /** Unsigned one. */897    static UONE: Long;898    /** Signed negative one. */899    static NEG_ONE: Long;900    /** Maximum signed value. */901    static MAX_VALUE: Long;902    /** Minimum signed value. */903    static MIN_VALUE: Long;904    /**905     * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits.906     * Each is assumed to use 32 bits.907     * @param lowBits - The low 32 bits908     * @param highBits - The high 32 bits909     * @param unsigned - Whether unsigned or not, defaults to signed910     * @returns The corresponding Long value911     */912    static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long;913    /**914     * Returns a Long representing the given 32 bit integer value.915     * @param value - The 32 bit integer in question916     * @param unsigned - Whether unsigned or not, defaults to signed917     * @returns The corresponding Long value918     */919    static fromInt(value: number, unsigned?: boolean): Long;920    /**921     * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.922     * @param value - The number in question923     * @param unsigned - Whether unsigned or not, defaults to signed924     * @returns The corresponding Long value925     */926    static fromNumber(value: number, unsigned?: boolean): Long;927    /**928     * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.929     * @param value - The number in question930     * @param unsigned - Whether unsigned or not, defaults to signed931     * @returns The corresponding Long value932     */933    static fromBigInt(value: bigint, unsigned?: boolean): Long;934    /* Excluded from this release type: _fromString */935    /**936     * Returns a signed Long representation of the given string, written using radix 10.937     * Will throw an error if the given text is not exactly representable as a Long.938     * Throws an error if any of the following conditions are true:939     * - the string contains invalid characters for the radix 10940     * - the string contains whitespace941     * - the value the string represents is too large or too small to be a Long942     * Unlike Long.fromString, this method does not coerce '+/-Infinity' and 'NaN' to Long.Zero943     * @param str - The textual representation of the Long944     * @returns The corresponding Long value945     */946    static fromStringStrict(str: string): Long;947    /**948     * Returns a Long representation of the given string, written using the radix 10.949     * Will throw an error if the given parameters are not exactly representable as a Long.950     * Throws an error if any of the following conditions are true:951     * - the string contains invalid characters for the given radix952     * - the string contains whitespace953     * - the value the string represents is too large or too small to be a Long954     * Unlike Long.fromString, this method does not coerce '+/-Infinity' and 'NaN' to Long.Zero955     * @param str - The textual representation of the Long956     * @param unsigned - Whether unsigned or not, defaults to signed957     * @returns The corresponding Long value958     */959    static fromStringStrict(str: string, unsigned?: boolean): Long;960    /**961     * Returns a signed Long representation of the given string, written using the specified radix.962     * Will throw an error if the given parameters are not exactly representable as a Long.963     * Throws an error if any of the following conditions are true:964     * - the string contains invalid characters for the given radix965     * - the string contains whitespace966     * - the value the string represents is too large or too small to be a Long967     * Unlike Long.fromString, this method does not coerce '+/-Infinity' and 'NaN' to Long.Zero968     * @param str - The textual representation of the Long969     * @param radix - The radix in which the text is written (2-36), defaults to 10970     * @returns The corresponding Long value971     */972    static fromStringStrict(str: string, radix?: boolean): Long;973    /**974     * Returns a Long representation of the given string, written using the specified radix.975     * Will throw an error if the given parameters are not exactly representable as a Long.976     * Throws an error if any of the following conditions are true:977     * - the string contains invalid characters for the given radix978     * - the string contains whitespace979     * - the value the string represents is too large or too small to be a Long980     * Unlike Long.fromString, this method does not coerce '+/-Infinity' and 'NaN' to Long.Zero981     * @param str - The textual representation of the Long982     * @param unsigned - Whether unsigned or not, defaults to signed983     * @param radix - The radix in which the text is written (2-36), defaults to 10984     * @returns The corresponding Long value985     */986    static fromStringStrict(str: string, unsigned?: boolean, radix?: number): Long;987    /**988     * Returns a signed Long representation of the given string, written using radix 10.989     *990     * If the input string is empty, this function will throw a BSONError.991     *992     * If input string does not have valid signed 64-bit Long representation, this method will return a coerced value:993     * - inputs that overflow 64-bit signed long will be coerced to Long.MAX_VALUE and Long.MIN_VALUE respectively994     * - 'NaN' or '+/-Infinity' are coerced to Long.ZERO995     * - other invalid characters sequences have variable behavior996     *997     * @param str - The textual representation of the Long998     * @returns The corresponding Long value999     */1000    static fromString(str: string): Long;1001    /**1002     * Returns a signed Long representation of the given string, written using the provided radix.1003     *1004     * If the input string is empty or a provided radix is not within (2-36), this function will throw a BSONError.1005     *1006     * If input parameters do not have valid signed 64-bit Long representation, this method will return a coerced value:1007     * - inputs that overflow 64-bit signed long will be coerced to Long.MAX_VALUE and Long.MIN_VALUE respectively1008     * - if the radix is less than 24, 'NaN' is coerced to Long.ZERO1009     * - if the radix is less than 35, '+/-Infinity' inputs are coerced to Long.ZERO1010     * - other invalid characters sequences have variable behavior1011     * @param str - The textual representation of the Long1012     * @param radix - The radix in which the text is written (2-36), defaults to 101013     * @returns The corresponding Long value1014     */1015    static fromString(str: string, radix?: number): Long;1016    /**1017     * Returns a Long representation of the given string, written using radix 10.1018     *1019     * If the input string is empty, this function will throw a BSONError.1020     *1021     * If input parameters do not have a valid 64-bit Long representation, this method will return a coerced value:1022     * - inputs that overflow 64-bit long will be coerced to max or min (if signed) values1023     * - if the radix is less than 24, 'NaN' is coerced to Long.ZERO1024     * - if the radix is less than 35, '+/-Infinity' inputs are coerced to Long.ZERO1025     * - other invalid characters sequences have variable behavior1026     * @param str - The textual representation of the Long1027     * @param unsigned - Whether unsigned or not, defaults to signed1028     * @returns The corresponding Long value1029     */1030    static fromString(str: string, unsigned?: boolean): Long;1031    /**1032     * Returns a Long representation of the given string, written using the specified radix.1033     *1034     * If the input string is empty or a provided radix is not within (2-36), this function will throw a BSONError.1035     *1036     * If input parameters do not have a valid 64-bit Long representation, this method will return a coerced value:1037     * - inputs that overflow 64-bit long will be coerced to max or min (if signed) values1038     * - if the radix is less than 24, 'NaN' is coerced to Long.ZERO1039     * - if the radix is less than 35, '+/-Infinity' inputs are coerced to Long.ZERO1040     * - other invalid characters sequences have variable behavior1041     * @param str - The textual representation of the Long1042     * @param unsigned - Whether unsigned or not, defaults to signed1043     * @param radix - The radix in which the text is written (2-36), defaults to 101044     * @returns The corresponding Long value1045     */1046    static fromString(str: string, unsigned?: boolean, radix?: number): Long;1047    /**1048     * Creates a Long from its byte representation.1049     * @param bytes - Byte representation1050     * @param unsigned - Whether unsigned or not, defaults to signed1051     * @param le - Whether little or big endian, defaults to big endian1052     * @returns The corresponding Long value1053     */1054    static fromBytes(bytes: number[], unsigned?: boolean, le?: boolean): Long;1055    /**1056     * Creates a Long from its little endian byte representation.1057     * @param bytes - Little endian byte representation1058     * @param unsigned - Whether unsigned or not, defaults to signed1059     * @returns The corresponding Long value1060     */1061    static fromBytesLE(bytes: number[], unsigned?: boolean): Long;1062    /**1063     * Creates a Long from its big endian byte representation.1064     * @param bytes - Big endian byte representation1065     * @param unsigned - Whether unsigned or not, defaults to signed1066     * @returns The corresponding Long value1067     */1068    static fromBytesBE(bytes: number[], unsigned?: boolean): Long;1069    /**1070     * Tests if the specified object is a Long.1071     */1072    static isLong(value: unknown): value is Long;1073    /**1074     * Converts the specified value to a Long.1075     * @param unsigned - Whether unsigned or not, defaults to signed1076     */1077    static fromValue(val: number | string | {1078        low: number;1079        high: number;1080        unsigned?: boolean;1081    }, unsigned?: boolean): Long;1082    /** Returns the sum of this and the specified Long. */1083    add(addend: string | number | Long | Timestamp): Long;1084    /**1085     * Returns the sum of this and the specified Long.1086     * @returns Sum1087     */1088    and(other: string | number | Long | Timestamp): Long;1089    /**1090     * Compares this Long's value with the specified's.1091     * @returns 0 if they are the same, 1 if the this is greater and -1 if the given one is greater1092     */1093    compare(other: string | number | Long | Timestamp): 0 | 1 | -1;1094    /** This is an alias of {@link Long.compare} */1095    comp(other: string | number | Long | Timestamp): 0 | 1 | -1;1096    /**1097     * Returns this Long divided by the specified. The result is signed if this Long is signed or unsigned if this Long is unsigned.1098     * @returns Quotient1099     */1100    divide(divisor: string | number | Long | Timestamp): Long;1101    /**This is an alias of {@link Long.divide} */1102    div(divisor: string | number | Long | Timestamp): Long;1103    /**1104     * Tests if this Long's value equals the specified's.1105     * @param other - Other value1106     */1107    equals(other: string | number | Long | Timestamp): boolean;1108    /** This is an alias of {@link Long.equals} */1109    eq(other: string | number | Long | Timestamp): boolean;1110    /** Gets the high 32 bits as a signed integer. */1111    getHighBits(): number;1112    /** Gets the high 32 bits as an unsigned integer. */1113    getHighBitsUnsigned(): number;1114    /** Gets the low 32 bits as a signed integer. */1115    getLowBits(): number;1116    /** Gets the low 32 bits as an unsigned integer. */1117    getLowBitsUnsigned(): number;1118    /** Gets the number of bits needed to represent the absolute value of this Long. */1119    getNumBitsAbs(): number;1120    /** Tests if this Long's value is greater than the specified's. */1121    greaterThan(other: string | number | Long | Timestamp): boolean;1122    /** This is an alias of {@link Long.greaterThan} */1123    gt(other: string | number | Long | Timestamp): boolean;1124    /** Tests if this Long's value is greater than or equal the specified's. */1125    greaterThanOrEqual(other: string | number | Long | Timestamp): boolean;1126    /** This is an alias of {@link Long.greaterThanOrEqual} */1127    gte(other: string | number | Long | Timestamp): boolean;1128    /** This is an alias of {@link Long.greaterThanOrEqual} */1129    ge(other: string | number | Long | Timestamp): boolean;1130    /** Tests if this Long's value is even. */1131    isEven(): boolean;1132    /** Tests if this Long's value is negative. */1133    isNegative(): boolean;1134    /** Tests if this Long's value is odd. */1135    isOdd(): boolean;1136    /** Tests if this Long's value is positive. */1137    isPositive(): boolean;1138    /** Tests if this Long's value equals zero. */1139    isZero(): boolean;1140    /** Tests if this Long's value is less than the specified's. */1141    lessThan(other: string | number | Long | Timestamp): boolean;1142    /** This is an alias of {@link Long#lessThan}. */1143    lt(other: string | number | Long | Timestamp): boolean;1144    /** Tests if this Long's value is less than or equal the specified's. */1145    lessThanOrEqual(other: string | number | Long | Timestamp): boolean;1146    /** This is an alias of {@link Long.lessThanOrEqual} */1147    lte(other: string | number | Long | Timestamp): boolean;1148    /** Returns this Long modulo the specified. */1149    modulo(divisor: string | number | Long | Timestamp): Long;1150    /** This is an alias of {@link Long.modulo} */1151    mod(divisor: string | number | Long | Timestamp): Long;1152    /** This is an alias of {@link Long.modulo} */1153    rem(divisor: string | number | Long | Timestamp): Long;1154    /**1155     * Returns the product of this and the specified Long.1156     * @param multiplier - Multiplier1157     * @returns Product1158     */1159    multiply(multiplier: string | number | Long | Timestamp): Long;1160    /** This is an alias of {@link Long.multiply} */1161    mul(multiplier: string | number | Long | Timestamp): Long;1162    /** Returns the Negation of this Long's value. */1163    negate(): Long;1164    /** This is an alias of {@link Long.negate} */1165    neg(): Long;1166    /** Returns the bitwise NOT of this Long. */1167    not(): Long;1168    /** Tests if this Long's value differs from the specified's. */1169    notEquals(other: string | number | Long | Timestamp): boolean;1170    /** This is an alias of {@link Long.notEquals} */1171    neq(other: string | number | Long | Timestamp): boolean;1172    /** This is an alias of {@link Long.notEquals} */1173    ne(other: string | number | Long | Timestamp): boolean;1174    /**1175     * Returns the bitwise OR of this Long and the specified.1176     */1177    or(other: number | string | Long): Long;1178    /**1179     * Returns this Long with bits shifted to the left by the given amount.1180     * @param numBits - Number of bits1181     * @returns Shifted Long1182     */1183    shiftLeft(numBits: number | Long): Long;1184    /** This is an alias of {@link Long.shiftLeft} */1185    shl(numBits: number | Long): Long;1186    /**1187     * Returns this Long with bits arithmetically shifted to the right by the given amount.1188     * @param numBits - Number of bits1189     * @returns Shifted Long1190     */1191    shiftRight(numBits: number | Long): Long;1192    /** This is an alias of {@link Long.shiftRight} */1193    shr(numBits: number | Long): Long;1194    /**1195     * Returns this Long with bits logically shifted to the right by the given amount.1196     * @param numBits - Number of bits1197     * @returns Shifted Long1198     */1199    shiftRightUnsigned(numBits: Long | number): Long;1200    /** This is an alias of {@link Long.shiftRightUnsigned} */

Showing the first 1,200 of 1724 lines. Download the file for the rest.