mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
19 lines
414 B
TypeScript
19 lines
414 B
TypeScript
import * as bson from 'bson';
|
|
|
|
let BSON = new bson.BSON();
|
|
let Long = bson.Long;
|
|
|
|
let doc = {long: Long.fromNumber(100)}
|
|
|
|
// Serialize a document
|
|
let data = BSON.serialize(doc, false, true, false);
|
|
console.log("data:", data);
|
|
|
|
// Deserialize the resulting Buffer
|
|
let doc_2 = BSON.deserialize(data);
|
|
console.log("doc_2:", doc_2);
|
|
|
|
BSON = new bson.BSON();
|
|
data = BSON.serialize(doc);
|
|
doc_2 = BSON.deserialize(data);
|