forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bson.d.ts
133 lines (109 loc) · 4.8 KB
/
bson.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Type definitions for bson 0.4.21
// Project: https://github.com/mongodb/js-bson
// Definitions by: Hiroki Horiuchi <https://github.com/horiuchi/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts"/>
declare module 'bson' {
namespace bson {
export module BSONPure {
export interface DeserializeOptions {
/** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized. */
evalFunctions?: boolean;
/** {Boolean, 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. */
cacheFunctionsCrc32?: boolean;
/** {Boolean, default:false}, deserialize Binary data directly into node.js Buffer object. */
promoteBuffers?: boolean;
}
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(object: any, checkKeys?: boolean, asBuffer?: boolean, serializeFunctions?: boolean): Buffer;
deserialize(buffer: Buffer, options?: DeserializeOptions, isArray?: boolean): any;
}
export interface Binary {}
export interface BinaryStatic {
SUBTYPE_DEFAULT: number;
SUBTYPE_FUNCTION: number;
SUBTYPE_BYTE_ARRAY: number;
SUBTYPE_UUID_OLD: number;
SUBTYPE_UUID: number;
SUBTYPE_MD5: number;
SUBTYPE_USER_DEFINED: number;
new (buffer: Buffer, subType?: number): Binary;
}
export let Binary: BinaryStatic;
export interface Code {}
export interface CodeStatic {
new (code: string | Function, scope?: any): Code;
}
export let Code: CodeStatic;
export interface DBRef {}
export interface DBRefStatic {
new (namespace: string, oid: ObjectID, db?: string): DBRef;
}
export let DBRef: DBRefStatic;
export interface Double {}
export interface DoubleStatic {
new (value: number): Double;
}
export let Double: DoubleStatic;
export interface Long {}
export interface LongStatic {
new (low: number, high: number): Long;
fromInt(i: number): Long;
fromNumber(n: number): Long;
fromBits(lowBits: number, highBits: number): Long;
fromString(s: string, opt_radix?: number): Long;
}
export let Long: LongStatic;
export interface MaxKey {}
export interface MaxKeyStatic {
new (): MaxKey;
}
export let MaxKey: MaxKeyStatic;
export interface MinKey {}
export interface MinKeyStatic {
new (): MinKey;
}
export let MinKey: MinKeyStatic;
export interface ObjectID {}
export interface ObjectIDStatic {
new (id?: number | string | ObjectID): ObjectID;
createPk(): ObjectID;
createFromTime(time: number): ObjectID;
createFromHexString(hexString: string): ObjectID;
isValid(id: number | string | ObjectID): boolean;
}
export let ObjectID: ObjectIDStatic;
export let ObjectId: ObjectIDStatic;
export interface BSONRegExp {}
export interface BSONRegExpStatic {
new (pattern: string, options: string): BSONRegExp;
}
export let BSONRegExp: BSONRegExpStatic;
export interface Symbol {}
export interface SymbolStatic {
new (value: string): Symbol;
}
export let Symbol: SymbolStatic;
export interface Timestamp {}
export interface TimestampStatic {
new (low: number, high: number): Timestamp;
fromInt(i: number): Timestamp;
fromNumber(n: number): Timestamp;
fromBits(lowBits: number, highBits: number): Timestamp;
fromString(s: string, opt_radix?: number): Timestamp;
}
export let Timestamp: TimestampStatic;
}
export let BSONNative: typeof BSONPure;
}
export = bson;
}