How to use the deserialize function from bson
Find comprehensive JavaScript bson.deserialize code examples handpicked from public code repositorys.
GitHub: dtube/avalon
155 156 157 158 159 160 161 162 163 164
let docSizeBuf = Buffer.alloc(4) fs.readSync(blocks.fd,docSizeBuf,{offset: 0, position: docPosition, length: 4}) let docSize = docSizeBuf.readInt32LE(0) let docBuf = Buffer.alloc(docSize) fs.readSync(blocks.fd,docBuf,{offset: 0, position: docPosition, length: docSize}) return BSON.deserialize(docBuf) }, readRange: (start,end) => { if (!blocks.isOpen) throw new Error(blocks.notOpenError)
64
93
0
1 2 3 4 5 6 7 8 9 10
const BSON = require('bson') const buffer = fs.readFileSync(process.argv[2]) const deserialize = (buffer) => { const object = BSON.deserialize(buffer) const keys = Object.keys(object) if (keys.every((key) => { return !isNaN(parseInt(key, 10))
1
18
4
+ 3 other calls in file
GitHub: 050602/KarlCat
32 33 34 35 36 37 38 39 40 41
this.socket = new TcpClient(port, host, define.some_config.SocketBufferMaxLen, true, this.connectCb.bind(this)); this.socket.on("data", (buf: Buffer) => { // console.log("what the fuck222222222222222222"); let data = BSON.deserialize(buf); let reqId = data.reqId; let req = this.reqs[reqId]; if (!req) { return;
3
8
1
+ 3 other calls in file
GitHub: InFlames513/inflames.db
4 5 6 7 8 9 10 11 12 13
class Database { constructor() { this.write = txt => fs.writeFileSync(this.file, txt, 'utf8', () => {}); this.file = "inflames.bson"; try { this.database = BSON.deserialize(fs.readFileSync(this.file)); } catch (e) { this.write("") this.database = {}; }
1
7
1
+ 13 other calls in file
63 64 65 66 67 68 69 70 71 72
// Serialize a document const data = BSON.serialize(doc); console.log('data:', data); // Deserialize the resulting Buffer const doc_2 = BSON.deserialize(data); console.log('doc_2:', doc_2); ``` ## Installation
1
1
3
+ 7 other calls in file
193 194 195 196 197 198 199 200 201 202
}); }, 5000); }); socket.on('message', function(message, remote) { var obj = bson.deserialize(message); //console.log('new message ------------'); //console.log(obj); if(heartbeatReceived) { heartbeatReceived(obj);
0
5
2
1 2 3 4 5 6 7 8 9 10 11 12
const bson = require('bson'); const fs = require('fs'); var packetQueue = []; function BSONDecode(buffer) { return bson.deserialize(buffer.slice(4)); } function BSONEncode(json) { const data = bson.serialize(json);
0
4
0
158 159 160 161 162 163 164 165 166 167
e: /[A-Za-z0-9]*/, f: new BSON.BSONRegExp('[A-Za-z0-9]*'), g: undefined }; const expected = BSON.deserialize(BSON.serialize(data, bsonOptions), bsonOptions); const coll = this.encryptedClient.db(dataDbName).collection(dataCollName); return Promise.resolve() .then(() => coll.insertOne(data, bsonOptions))
0
0
0
+ 3 other calls in file
152 153 154 155 156 157 158 159 160 161
let rawdoc = Buffer.concat(this._buffers, this._doclen); let obj; try { obj = BSON.deserialize(rawdoc); } catch (err) { // discard buffer this._reset(); cb(err);
0
0
0
151 152 153 154 155 156 157 158 159 160 161
// * Deserealize data from BSON // * @param {*} buffer buffer to deserialize // * @returns {Object} deserialized object // */ // const BJSONDeserialize = (buffer) => { // return deserialize(buffer); // } /** * load json file return object
0
0
0
GitHub: markioribot/nya
316 317 318 319 320 321 322 323 324 325
const data = await database.then(db => db.findOne({ guildId: context.guildId, storageId })) .catch(() => { throw context.error("Couldn't get data from database"); }); if (!data) return new c.NullLiteral; const json = BSON.deserialize(data.data.buffer); const value = c.convert(json[key]); return value; }),
0
0
0
+ 5 other calls in file
bson.ObjectId is the most popular function in bson (1017 examples)