{"bugs":{"url":"https://github.com/mongodb-js/bson-ext/issues"},"dist":{"shasum":"85a8a04abdb090663fa075ca4b57c13fa5d902ab","tarball":"https://registry.npmjs.org/bson-ext/-/bson-ext-2.0.6.tgz","fileCount":20,"integrity":"sha512-UFQFJDC0Hf2NLncLoO+ht/8tm63C5xlvFm55ur4zCpIJqZqZTdbY50uGy2pSraTEbLbCrqLGV/m4gSNlc8tQFw==","signatures":[{"sig":"MEUCIQDN5wRgxj3Vnabaw101BuEEJf79jrVTMSv+PkGcm3U08wIgRSVLIvj+fLnF2TO4MV/MTwl1yZZPqb/UQBufULTmRj0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":134667},"main":"./lib/index","name":"bson-ext","author":{"name":"Christian Amor Kvalheim","email":"christkv@gmail.com"},"readme":"# BSON parser\n\nBSON is short for Bin­ary JSON and is the bin­ary-en­coded seri­al­iz­a­tion of JSON-like doc­u­ments. You can learn more about it in [the specification](http://bsonspec.org).\n\nThis module is a C++ addon for Node.js that implements the BSON parsing and serialization outside of the JavaScript environment in order to increase speed and memory efficiency for certain workloads. It uses the same types as the pure JavaScript implementation, which can be found at [mongodb/js-bson](https://github.com/mongodb/js-bson).\n\n## Usage\n\nTo build a new version perform the following operation.\n\n```\nnpm install\nnpm run build\n```\n\nA simple example of how to use BSON in `Node.js`:\n\n```js\n// Get BSON parser class\nvar BSON = require('bson-ext')\n// Get the Long type\nvar Long = BSON.Long;\n// Create a bson parser instance, passing in all the types\n// This is needed so the C++ parser has references to the classes and can\n// use them to serialize and deserialize the types.\nvar bson = new BSON([BSON.Binary, BSON.Code, BSON.DBRef, BSON.Decimal128, BSON.Double, BSON.Int32, BSON.Long, BSON.Map, BSON.MaxKey, BSON.MinKey, BSON.ObjectId, BSON.BSONRegExp, BSON.Symbol, BSON.Timestamp]);\n\n// Serialize document\nvar doc = { long: Long.fromNumber(100) }\n\n// Serialize a document\nvar data = bson.serialize(doc)\nconsole.log('data:', data)\n\n// Deserialize the resulting Buffer\nvar doc_2 = bson.deserialize(data)\nconsole.log('doc_2:', doc_2)\n```\n\n## Installation\n\n`npm install bson-ext`\n\n## API\n\n### BSON types\n\nFor all BSON types documentation, please refer to the documentation for the [MongoDB Node.js driver](https://github.com/mongodb/node-mongodb-native).\n\n### BSON serialization and deserialiation\n\n**`new BSON()`** - Creates a new BSON serializer/deserializer you can use to serialize and deserialize BSON.\n\n#### BSON.serialize\n\nThe BSON `serialize` method takes a JavaScript object and an optional options object and returns a Node.js Buffer.\n\n  * `BSON.serialize(object, options)`\n    * @param {Object} object the JavaScript object to serialize.\n    * @param {Boolean} [options.checkKeys=false] the serializer will check if keys are valid.\n    * @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript. functions.\n    * @param {Boolean} [options.ignoreUndefined=true]\n    * @return {Buffer} returns a Buffer instance.\n\n#### BSON.serializeWithBufferAndIndex\n\nThe BSON `serializeWithBufferAndIndex` method takes an object, a target buffer instance and an optional options object and returns the end serialization index in the final buffer.\n\n  * `BSON.serializeWithBufferAndIndex(object, buffer, options)`\n    * @param {Object} object the JavaScript object to serialize.\n    * @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object.\n    * @param {Boolean} [options.checkKeys=false] the serializer will check if keys are valid.\n    * @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript functions.\n    * @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields.\n    * @param {Number} [options.index=0] the index in the buffer where we wish to start serializing into.\n    * @return {Number} returns the index pointing to the last written byte in the buffer.\n\n#### BSON.calculateObjectSize\n\nThe BSON `calculateObjectSize` method takes a JavaScript object and an optional options object and returns the size of the BSON object.\n\n  * `BSON.calculateObjectSize(object, options)`\n    * @param {Object} object the JavaScript object to serialize.\n    * @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript. functions.\n    * @param {Boolean} [options.ignoreUndefined=true]\n    * @return {Buffer} returns a Buffer instance.\n\n#### BSON.deserialize\n\nThe BSON `deserialize` method takes a Node.js Buffer and an optional options object and returns a deserialized JavaScript object.\n\n  * `BSON.deserialize(buffer, options)`\n    * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized.\n    * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse.\n    * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function.\n    * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits\n    * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a Node.js Buffer instance.\n    * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.\n    * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.\n    * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.\n    * @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents.\n\n#### BSON.deserializeStream\n\nThe BSON `deserializeStream` method takes a Node.js Buffer, `startIndex` and allow more control over deserialization of a Buffer containing concatenated BSON documents.\n\n  * `BSON.deserializeStream(buffer, startIndex, numberOfDocuments, documents, docStartIndex, options)`\n    * @param {Buffer} buffer the buffer containing the serialized set of BSON documents.\n    * @param {Number} startIndex the start index in the data Buffer where the deserialization is to start.\n    * @param {Number} numberOfDocuments number of documents to deserialize.\n    * @param {Array} documents an array where to store the deserialized documents.\n    * @param {Number} docStartIndex the index in the documents array from where to start inserting documents.\n    * @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized.\n    * @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse.\n    * @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function.\n    * @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits\n    * @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a Node.js Buffer instance.\n    * @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.\n    * @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.\n    * @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.\n    * @return {Object} returns the deserialized JavaScript Object.\n","engines":{"node":">=4"},"gitHead":"f24116e8ded149e978191d44ab2d678f108b85ee","scripts":{"test":"mocha ./test/node","format":"clang-format -i --style=file --glob=\"src/*.{h,cc}\"","install":"prebuild-install || node-gyp rebuild","rebuild":"prebuild --compile","release":"standard-version -i HISTORY.md","prebuild":"prebuild  --strip --verbose --all","changelog":"conventional-changelog -p angular -i HISTORY.md -s","prebuild-legacy":"prebuild  --strip --verbose --runtime node --target 4.0.0"},"_npmUser":{"name":"nbbeeken","email":"neal.beeken@mongodb.com"},"homepage":"https://github.com/mongodb-js/bson-ext#readme","keywords":["mongodb","bson","parser"],"licenses":[{"url":"http://www.apache.org/licenses/LICENSE-2.0","type":"Apache License, Version 2.0"}],"repository":{"url":"git://github.com/mongodb-js/bson-ext.git","type":"git"},"_npmVersion":"7.22.0","description":"The C++ bson parser for the node.js mongodb driver.","directories":{},"maintainers":[{"name":"mbroadst","email":"mbroadst@gmail.com"},{"name":"durran","email":"durran@gmail.com"},{"name":"nbbeeken","email":"neal.beeken@mongodb.com"},{"name":"kmahar","email":"kaitlin.mahar@mongodb.com"},{"name":"dariakp","email":"daria.pardue@mongodb.com"}],"_nodeVersion":"14.17.0","contributors":[],"dependencies":{"nan":"^2.14.0","bson":"^2.0.2","bindings":"^1.3.0","prebuild-install":"6.1.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.1.2","mocha":"^3.5.3","prebuild":"^9.0.1","clang-format":"^1.2.2","mongodb-extjson":"^2.1.0","standard-version":"^4.4.0","conventional-changelog-cli":"^1.3.15"},"_npmOperationalInternal":{"tmp":"tmp/bson-ext_2.0.6_1633454303460_0.20821336885213593","host":"s3://npm-registry-packages"},"_id":"bson-ext@2.0.6","version":"2.0.6"}