@types/bson
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -1,2 +0,2 @@ | ||
// Type definitions for bson 1.0.4 | ||
// Type definitions for bson 1.0.6 | ||
// Project: https://github.com/mongodb/js-bson | ||
@@ -9,17 +9,44 @@ // Definitions by: Hiroki Horiuchi <https://github.com/horiuchi> | ||
interface CommonSerializeOptions { | ||
/** {default:false}, the serializer will check if keys are valid. */ | ||
checkKeys?: boolean; | ||
/** {default:false}, serialize the javascript functions. */ | ||
serializeFunctions?: boolean; | ||
/** {default:true}, ignore undefined fields. */ | ||
ignoreUndefined?: boolean; | ||
} | ||
export interface SerializeOptions extends CommonSerializeOptions { | ||
/** {default:1024*1024*17}, minimum size of the internal temporary serialization buffer. */ | ||
minInternalBufferSize?: number; | ||
} | ||
export interface SerializeWithBufferAndIndexOptions extends CommonSerializeOptions { | ||
/** {default:0}, the index in the buffer where we wish to start serializing into. */ | ||
index?: number; | ||
} | ||
export interface DeserializeOptions { | ||
/** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized. */ | ||
/** {default:false}, evaluate functions in the BSON document scoped to the object deserialized. */ | ||
evalFunctions?: boolean; | ||
/** {Boolean, default:false}, cache evaluated functions for reuse. */ | ||
/** {default:false}, cache evaluated functions for reuse. */ | ||
cacheFunctions?: boolean; | ||
/** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function. */ | ||
/** {default:false}, use a crc32 code for caching, otherwise use the string of the function. */ | ||
cacheFunctionsCrc32?: boolean; | ||
/** {Boolean, default:false}, deserialize Binary data directly into node.js Buffer object. */ | ||
/** {default:true}, when deserializing a Long will fit it into a Number if it's smaller than 53 bits. */ | ||
promoteLongs?: boolean; | ||
/** {default:false}, deserialize Binary data directly into node.js Buffer object. */ | ||
promoteBuffers?: boolean; | ||
/** {default:false}, when deserializing will promote BSON values to their Node.js closest equivalent types. */ | ||
promoteValues?: boolean; | ||
/** {default:null}, allow to specify if there what fields we wish to return as unserialized raw buffer. */ | ||
fieldsAsRaw?: { readonly [fieldName: string]: boolean }; | ||
/** {default:false}, return BSON regular expressions as BSONRegExp instances. */ | ||
bsonRegExp?: boolean; | ||
} | ||
export interface CalculateObjectSizeOptions { | ||
/** {Boolean, default:false}, serialize the javascript functions */ | ||
/** {default:false}, serialize the javascript functions */ | ||
serializeFunctions?: boolean; | ||
/** {Boolean, default:true}, ignore undefined fields. */ | ||
/** {default:true}, ignore undefined fields. */ | ||
ignoreUndefined?: boolean; | ||
@@ -29,12 +56,32 @@ } | ||
export class BSON { | ||
/** | ||
* @param {Object} object the Javascript object to serialize. | ||
* @param {Boolean} checkKeys the serializer will check if keys are valid. | ||
* @param {Boolean} asBuffer return the serialized object as a Buffer object (ignore). | ||
* @param {Boolean} serializeFunctions serialize the javascript functions (default:false) | ||
* @return {Buffer} returns a TypedArray or Array depending on what your browser supports | ||
* Serialize a Javascript object. | ||
* | ||
* @param object The Javascript object to serialize. | ||
* @param options Serialize options. | ||
* @return The Buffer object containing the serialized object. | ||
*/ | ||
serialize(object: any, checkKeys?: boolean, asBuffer?: boolean, serializeFunctions?: boolean): Buffer; | ||
deserialize(buffer: Buffer, options?: DeserializeOptions, isArray?: boolean): any; | ||
serialize(object: any, options?: SerializeOptions): Buffer; | ||
/** | ||
* Serialize a Javascript object using a predefined Buffer and index into the buffer, useful when pre-allocating the space for serialization. | ||
* | ||
* @param object The Javascript object to serialize. | ||
* @param buffer The Buffer you pre-allocated to store the serialized BSON object. | ||
* @param options Serialize options. | ||
* @returns The index pointing to the last written byte in the buffer | ||
*/ | ||
serializeWithBufferAndIndex(object: any, buffer: Buffer, options?: SerializeWithBufferAndIndexOptions): number; | ||
/** | ||
* Deserialize data as BSON. | ||
* | ||
* @param buffer The buffer containing the serialized set of BSON documents. | ||
* @param options Deserialize options. | ||
* @returns The deserialized Javascript Object. | ||
*/ | ||
deserialize(buffer: Buffer, options?: DeserializeOptions): any; | ||
/** | ||
* Calculate the bson size for a passed in Javascript object. | ||
@@ -47,13 +94,40 @@ * | ||
calculateObjectSize(object: any, options?: CalculateObjectSizeOptions): number; | ||
/** | ||
* Deserialize stream data as BSON documents. | ||
* | ||
* @param data The buffer containing the serialized set of BSON documents. | ||
* @param startIndex The start index in the data Buffer where the deserialization is to start. | ||
* @param numberOfDocuments Number of documents to deserialize | ||
* @param documents An array where to store the deserialized documents | ||
* @param docStartIndex The index in the documents array from where to start inserting documents | ||
* @param options Additional options used for the deserialization | ||
* @returns The next index in the buffer after deserialization of the `numberOfDocuments` | ||
*/ | ||
deserializeStream( | ||
data: Buffer, | ||
startIndex: number, | ||
numberOfDocuments: number, | ||
documents: Array<any>, | ||
docStartIndex: number, | ||
options?: DeserializeOptions | ||
): number; | ||
} | ||
/** A class representation of the BSON Binary type. */ | ||
export class Binary { | ||
static SUBTYPE_DEFAULT: number; | ||
static SUBTYPE_FUNCTION: number; | ||
static SUBTYPE_BYTE_ARRAY: number; | ||
static SUBTYPE_UUID_OLD: number; | ||
static SUBTYPE_UUID: number; | ||
static SUBTYPE_MD5: number; | ||
static SUBTYPE_USER_DEFINED: number; | ||
static readonly SUBTYPE_DEFAULT: number; | ||
static readonly SUBTYPE_FUNCTION: number; | ||
static readonly SUBTYPE_BYTE_ARRAY: number; | ||
static readonly SUBTYPE_UUID_OLD: number; | ||
static readonly SUBTYPE_UUID: number; | ||
static readonly SUBTYPE_MD5: number; | ||
static readonly SUBTYPE_USER_DEFINED: number; | ||
/** | ||
* @param buffer A buffer object containing the binary data | ||
* @param subType Binary data subtype | ||
*/ | ||
constructor(buffer: Buffer, subType?: number); | ||
@@ -75,7 +149,24 @@ | ||
} | ||
/** A class representation of the BSON Code type. */ | ||
export class Code { | ||
/** | ||
* @param code A string or function. | ||
* @param scope An optional scope for the function. | ||
*/ | ||
constructor(code: string | Function, scope?: any); | ||
} | ||
/** | ||
* A class representation of the BSON DBRef type. | ||
* @deprecated | ||
*/ | ||
export class DBRef { | ||
/** | ||
* @param namespace The collection name. | ||
* @param oid The reference ObjectID. | ||
* @param db Optional db name, if omitted the reference is local to the current db | ||
*/ | ||
constructor(namespace: string, oid: ObjectID, db?: string); | ||
namespace: string; | ||
@@ -85,3 +176,8 @@ oid: ObjectID; | ||
} | ||
/** A class representation of the BSON Double type. */ | ||
export class Double { | ||
/** | ||
* @param value The number we want to represent as a double. | ||
*/ | ||
constructor(value: number); | ||
@@ -91,51 +187,136 @@ | ||
} | ||
export class Long { | ||
static MAX_VALUE: Long; | ||
static MIN_VALUE: Long; | ||
static NEG_ONE: Long; | ||
static ONE: Long; | ||
static ZERO: Long; | ||
static fromInt(i: number): Long; | ||
static fromNumber(n: number): Long; | ||
static fromBits(lowBits: number, highBits: number): Long; | ||
static fromString(s: string, opt_radix?: number): Long; | ||
/** | ||
* Base class for Long and Timestamp. | ||
* In original js-node@1.0.x code 'Timestamp' is a 100% copy-paste of 'Long' | ||
* with 'Long' replaced by 'Timestamp' (changed to inheritance in js-node@2.0.0) | ||
*/ | ||
declare class LongLike<T> { | ||
/** | ||
* @param low The low (signed) 32 bits. | ||
* @param high The high (signed) 32 bits. | ||
*/ | ||
constructor(low: number, high: number); | ||
add(other: Long): Long; | ||
and(other: Long): Long; | ||
compare(other: Long): number; | ||
div(other: Long): Long; | ||
equals(other: Long): boolean; | ||
/** Returns the sum of `this` and the `other`. */ | ||
add(other: T): T; | ||
/** Returns the bitwise-AND of `this` and the `other`. */ | ||
and(other: T): T; | ||
/** | ||
* Compares `this` with the given `other`. | ||
* @returns 0 if they are the same, 1 if the this is greater, and -1 if the given one is greater. | ||
*/ | ||
compare(other: T): number; | ||
/** Returns `this` divided by the given `other`. */ | ||
div(other: T): T; | ||
/** Return whether `this` equals the `other` */ | ||
equals(other: T): boolean; | ||
/** Return the high 32-bits value. */ | ||
getHighBits(): number; | ||
/** Return the low 32-bits value. */ | ||
getLowBits(): number; | ||
/** Return the low unsigned 32-bits value. */ | ||
getLowBitsUnsigned(): number; | ||
/** Returns the number of bits needed to represent the absolute value of `this`. */ | ||
getNumBitsAbs(): number; | ||
greaterThan(other: Long): number; | ||
greaterThanOrEqual(other: Long): number; | ||
/** Return whether `this` is greater than the `other`. */ | ||
greaterThan(other: T): boolean; | ||
/** Return whether `this` is greater than or equal to the `other`. */ | ||
greaterThanOrEqual(other: T): boolean; | ||
/** Return whether `this` value is negative. */ | ||
isNegative(): boolean; | ||
/** Return whether `this` value is odd. */ | ||
isOdd(): boolean; | ||
/** Return whether `this` value is zero. */ | ||
isZero(): boolean; | ||
lessThan(other: Long): boolean; | ||
lessThanOrEqual(other: Long): boolean; | ||
modulo(other: Long): Long; | ||
multiply(other: Long): Long; | ||
negate(): Long; | ||
not(): Long; | ||
notEquals(other: Long): boolean; | ||
or(other: Long): Long; | ||
shiftLeft(other: number): Long; | ||
shiftRight(other: number): Long; | ||
shiftRightUnsigned(other: number): Long; | ||
subtract(other: Long): Long; | ||
/** Return whether `this` is less than the `other`. */ | ||
lessThan(other: T): boolean; | ||
/** Return whether `this` is less than or equal to the `other`. */ | ||
lessThanOrEqual(other: T): boolean; | ||
/** Returns `this` modulo the given `other`. */ | ||
modulo(other: T): T; | ||
/** Returns the product of `this` and the given `other`. */ | ||
multiply(other: T): T; | ||
/** The negation of this value. */ | ||
negate(): T; | ||
/** The bitwise-NOT of this value. */ | ||
not(): T; | ||
/** Return whether `this` does not equal to the `other`. */ | ||
notEquals(other: T): boolean; | ||
/** Returns the bitwise-OR of `this` and the given `other`. */ | ||
or(other: T): T; | ||
/** | ||
* Returns `this` with bits shifted to the left by the given amount. | ||
* @param numBits The number of bits by which to shift. | ||
*/ | ||
shiftLeft(numBits: number): T; | ||
/** | ||
* Returns `this` with bits shifted to the right by the given amount. | ||
* @param numBits The number of bits by which to shift. | ||
*/ | ||
shiftRight(numBits: number): T; | ||
/** | ||
* Returns `this` with bits shifted to the right by the given amount, with the new top bits matching the current sign bit. | ||
* @param numBits The number of bits by which to shift. | ||
*/ | ||
shiftRightUnsigned(numBits: number): T; | ||
/** Returns the difference of `this` and the given `other`. */ | ||
subtract(other: T): T; | ||
/** Return the int value (low 32 bits). */ | ||
toInt(): number; | ||
/** Return the JSON value. */ | ||
toJSON(): string; | ||
/** Returns closest floating-point representation to `this` value */ | ||
toNumber(): number; | ||
/** | ||
* Return as a string | ||
* @param radix the radix in which the text should be written. {default:10} | ||
*/ | ||
toString(radix?: number): string; | ||
xor(other: Long): Long; | ||
/** Returns the bitwise-XOR of `this` and the given `other`. */ | ||
xor(other: T): T; | ||
} | ||
/** | ||
* A class representation of the BSON Long type, a 64-bit two's-complement | ||
* integer value, which faithfully simulates the behavior of a Java "Long". This | ||
* implementation is derived from LongLib in GWT. | ||
*/ | ||
export class Long extends LongLike<Long> { | ||
static readonly MAX_VALUE: Long; | ||
static readonly MIN_VALUE: Long; | ||
static readonly NEG_ONE: Long; | ||
static readonly ONE: Long; | ||
static readonly ZERO: Long; | ||
/** Returns a Long representing the given (32-bit) integer value. */ | ||
static fromInt(i: number): Long; | ||
/** Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. */ | ||
static fromNumber(n: number): Long; | ||
/** | ||
* Returns a Long representing the 64-bit integer that comes by concatenating the given high and low bits. Each is assumed to use 32 bits. | ||
* @param lowBits The low 32-bits. | ||
* @param highBits The high 32-bits. | ||
*/ | ||
static fromBits(lowBits: number, highBits: number): Long; | ||
/** | ||
* Returns a Long representation of the given string | ||
* @param opt_radix The radix in which the text is written. {default:10} | ||
*/ | ||
static fromString(s: string, opt_radix?: number): Long; | ||
} | ||
/** A class representation of the BSON Decimal128 type. */ | ||
export class Decimal128 { | ||
/** Create a Decimal128 instance from a string representation. */ | ||
static fromString(s: string): Decimal128; | ||
/** | ||
* @param bytes A buffer containing the raw Decimal128 bytes. | ||
*/ | ||
constructor(bytes: Buffer); | ||
@@ -146,8 +327,14 @@ | ||
} | ||
/** A class representation of the BSON MaxKey type. */ | ||
export class MaxKey { | ||
constructor(); | ||
} | ||
/** A class representation of the BSON MinKey type. */ | ||
export class MinKey { | ||
constructor(); | ||
} | ||
/** A class representation of the BSON ObjectID type. */ | ||
export class ObjectID { | ||
@@ -183,6 +370,6 @@ /** | ||
* Compares the equality of this ObjectID with `otherID`. | ||
* @param {object} otherID ObjectID instance to compare against. | ||
* @param {ObjectID|string} otherID ObjectID instance to compare against. | ||
* @return {boolean} the result of comparing two ObjectID's | ||
*/ | ||
equals(otherID: ObjectID): boolean; | ||
equals(otherID: ObjectID | string): boolean; | ||
/** | ||
@@ -196,3 +383,3 @@ * Generate a 12 byte id string used in ObjectID's | ||
* Returns the generation date (accurate up to the second) that this ID was generated. | ||
* @return {date} the generation date | ||
* @return {Date} the generation date | ||
*/ | ||
@@ -206,54 +393,43 @@ getTimestamp(): Date; | ||
} | ||
export { ObjectID as ObjectId }; | ||
/** A class representation of the BSON RegExp type. */ | ||
export class BSONRegExp { | ||
constructor(pattern: string, options: string); | ||
} | ||
/** | ||
* A class representation of the BSON Symbol type. | ||
* @deprecated | ||
*/ | ||
export class Symbol { | ||
constructor(value: string); | ||
} | ||
export class Timestamp { | ||
constructor(low: number, high: number); | ||
static MAX_VALUE: Timestamp; | ||
static MIN_VALUE: Timestamp; | ||
static NEG_ONE: Timestamp; | ||
static ONE: Timestamp; | ||
static ZERO: Timestamp; | ||
/** A class representation of the BSON Timestamp type. */ | ||
export class Timestamp extends LongLike<Timestamp> { | ||
static fromBits(lowBits: number, highBits: number): Timestamp; | ||
static readonly MAX_VALUE: Timestamp; | ||
static readonly MIN_VALUE: Timestamp; | ||
static readonly NEG_ONE: Timestamp; | ||
static readonly ONE: Timestamp; | ||
static readonly ZERO: Timestamp; | ||
/** Returns a Timestamp represented by the given (32-bit) integer value */ | ||
static fromInt(value: number): Timestamp; | ||
/** Returns a Timestamp representing the given number value, provided that it is a finite number. */ | ||
static fromNumber(value: number): Timestamp; | ||
static fromString(str: string, radix?: number): Timestamp; | ||
/** | ||
* Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits. | ||
* @param lowBits The low 32-bits. | ||
* @param highBits The high 32-bits. | ||
*/ | ||
static fromBits(lowBits: number, highBits: number): Timestamp; | ||
/** | ||
* Returns a Timestamp from the given string. | ||
* @param opt_radix The radix in which the text is written. {default:10} | ||
*/ | ||
static fromString(str: string, opt_radix?: number): Timestamp; | ||
add(other: Timestamp): Timestamp; | ||
and(other: Timestamp): Timestamp; | ||
compare(other: Timestamp): number; | ||
div(other: Timestamp): Timestamp; | ||
equals(other: Timestamp): boolean; | ||
getHighBits(): number; | ||
getLowBits(): number; | ||
getLowBitsUnsigned(): number; | ||
getNumBitsAbs(): number; | ||
greaterThan(other: Timestamp): number; | ||
greaterThanOrEqual(other: Timestamp): number; | ||
isNegative(): boolean; | ||
isOdd(): boolean; | ||
isZero(): boolean; | ||
lessThan(other: Timestamp): boolean; | ||
lessThanOrEqual(other: Timestamp): boolean; | ||
modulo(other: Timestamp): Timestamp; | ||
multiply(other: Timestamp): Timestamp; | ||
negate(): Timestamp; | ||
not(): Timestamp; | ||
notEquals(other: Timestamp): boolean; | ||
or(other: Timestamp): Timestamp; | ||
shiftLeft(other: number): Timestamp; | ||
shiftRight(other: number): Timestamp; | ||
shiftRightUnsigned(other: number): Timestamp; | ||
subtract(other: Timestamp): Timestamp; | ||
toInt(): number; | ||
toJSON(): string; | ||
toNumber(): number; | ||
toString(radix?: number): string; | ||
xor(other: Timestamp): Timestamp; | ||
} |
{ | ||
"name": "@types/bson", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "TypeScript definitions for bson", | ||
@@ -27,4 +27,4 @@ "license": "MIT", | ||
}, | ||
"typesPublisherContentHash": "0b81495941c23345b33a117309c02f1a1675f1e1fa9d2298615b512f03982f75", | ||
"typesPublisherContentHash": "05f0493b3f68d64a42e2536b3489084092f91d1909321aa0cefd3d49f96ac4ff", | ||
"typeScriptVersion": "2.0" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
Additional Details | ||
* Last updated: Mon, 18 Jun 2018 22:47:04 GMT | ||
* Last updated: Fri, 06 Jul 2018 21:56:16 GMT | ||
* Dependencies: node | ||
@@ -14,0 +14,0 @@ * Global values: none |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18167
380
1