From 960c7ef8a00f7b1895b20813d9ef735756633fa1 Mon Sep 17 00:00:00 2001 From: Andrey Tselishchev Date: Sat, 21 Jul 2018 03:33:17 +0300 Subject: [PATCH] [@types/bson] Updated BSON types (#27259) * `Binary`: Added `sub_type` property. * `Code`: Added `code` and `scope` properties * Added missing `Int32` type * `Decimal128`: Added `bytes` property * `BSONRegExp`: Added `pattern` and `options` properties * `Symbol`: Added `valueOf()` method --- types/bson/index.d.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/types/bson/index.d.ts b/types/bson/index.d.ts index 6bad691dcf..e6afab65a5 100644 --- a/types/bson/index.d.ts +++ b/types/bson/index.d.ts @@ -131,6 +131,8 @@ export class Binary { /** The underlying Buffer which stores the binary data. */ readonly buffer: Buffer; + /** Binary data subtype */ + readonly sub_type?: number; /** The length of the binary. */ length(): number; @@ -146,11 +148,16 @@ export class Binary { /** 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); + + readonly code: string | Function; + readonly scope?: any; + } /** @@ -180,6 +187,16 @@ export class Double { valueOf(): number; } +/** A class representation of the BSON Int32 type. */ +export class Int32 { + /** + * @param value The number we want to represent as an int32. + */ + constructor(value: number); + + valueOf(): number; +} + /** * Base class for Long and Timestamp. * In original js-node@1.0.x code 'Timestamp' is a 100% copy-paste of 'Long' @@ -315,6 +332,9 @@ export class Decimal128 { */ constructor(bytes: Buffer); + /** A buffer containing the raw Decimal128 bytes. */ + readonly bytes: Buffer; + toJSON(): string; toString(): string; } @@ -386,7 +406,12 @@ export { ObjectID as ObjectId }; /** A class representation of the BSON RegExp type. */ export class BSONRegExp { + constructor(pattern: string, options: string); + + readonly pattern: string; + readonly options: string; + } /** @@ -394,7 +419,12 @@ export class BSONRegExp { * @deprecated */ export class Symbol { + constructor(value: string); + + /** Access the wrapped string value. */ + valueOf(): string; + } /** A class representation of the BSON Timestamp type. */