Skip to content

Commit e403bd9

Browse files
author
Jessica Lord
authored
docs(readme): mention addon parser, cleanup copy (#230)
NODE-995
1 parent 1c8bdde commit e403bd9

File tree

1 file changed

+30
-27
lines changed

1 file changed

+30
-27
lines changed

README.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# BSON parser
22

3-
If you don't yet know what BSON actually is, read [the spec](http://bsonspec.org).
3+
BSON 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).
44

5-
The browser version of the BSON parser is compiled using webpack and the current
6-
version is pre-compiled in the browser_build directory. To build a new version perform the following operation.
5+
This browser version of the BSON parser is compiled using [webpack](https://webpack.js.org/) and the current version is pre-compiled in the `browser_build` directory.
6+
7+
This is the default BSON parser, however, there is a C++ Node.js addon version as well that does not support the browser. It can be found at [mongod-js/bson-ext](https://github.com/mongodb-js/bson-ext).
8+
9+
## Usage
10+
11+
To build a new version perform the following operations:
712

813
```
914
npm install
@@ -33,7 +38,7 @@ A simple example of how to use BSON in the browser:
3338
</script>
3439
```
3540

36-
A simple example of how to use BSON in `node.js`:
41+
A simple example of how to use BSON in `Node.js`:
3742

3843
```js
3944
// Get BSON parser class
@@ -63,68 +68,66 @@ console.log('doc_2:', doc_2)
6368

6469
### BSON types
6570

66-
For all BSON types documentation, please refer to the documentation for the mongodb driver.
67-
68-
https://github.com/mongodb/node-mongodb-native
71+
For all BSON types documentation, please refer to the documentation for the [MongoDB Node.js driver](https://github.com/mongodb/node-mongodb-native).
6972

7073
### BSON serialization and deserialiation
7174

72-
**`new BSON()`** - Creates a new BSON seralizer/deserializer you can use to serialize and deserialize BSON.
75+
**`new BSON()`** - Creates a new BSON serializer/deserializer you can use to serialize and deserialize BSON.
7376

7477
#### BSON.serialize
7578

76-
The BSON serialize method takes a javascript object and an optional options object and returns a Node.js Buffer.
79+
The BSON `serialize` method takes a JavaScript object and an optional options object and returns a Node.js Buffer.
7780

78-
* BSON.serialize(object, options)
79-
* @param {Object} object the Javascript object to serialize.
81+
* `BSON.serialize(object, options)`
82+
* @param {Object} object the JavaScript object to serialize.
8083
* @param {Boolean} [options.checkKeys=false] the serializer will check if keys are valid.
81-
* @param {Boolean} [options.serializeFunctions=false] serialize the javascript. functions.
84+
* @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript functions.
8285
* @param {Boolean} [options.ignoreUndefined=true]
8386
* @return {Buffer} returns a Buffer instance.
8487

8588
#### BSON.serializeWithBufferAndIndex
8689

87-
The 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.
90+
The 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.
8891

89-
* BSON.serializeWithBufferAndIndex(object, buffer, options)
90-
* @param {Object} object the Javascript object to serialize.
92+
* `BSON.serializeWithBufferAndIndex(object, buffer, options)`
93+
* @param {Object} object the JavaScript object to serialize.
9194
* @param {Buffer} buffer the Buffer you pre-allocated to store the serialized BSON object.
9295
* @param {Boolean} [options.checkKeys=false] the serializer will check if keys are valid.
93-
* @param {Boolean} [options.serializeFunctions=false] serialize the javascript functions.
96+
* @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript functions.
9497
* @param {Boolean} [options.ignoreUndefined=true] ignore undefined fields.
9598
* @param {Number} [options.index=0] the index in the buffer where we wish to start serializing into.
9699
* @return {Number} returns the index pointing to the last written byte in the buffer.
97100

98101
#### BSON.calculateObjectSize
99102

100-
The BSON calculateObjectSize method takes a javascript object and an optional options object and returns the size of the BSON object.
103+
The BSON `calculateObjectSize` method takes a JavaScript object and an optional options object and returns the size of the BSON object.
101104

102-
* BSON.calculateObjectSize(object, options)
103-
* @param {Object} object the Javascript object to serialize.
104-
* @param {Boolean} [options.serializeFunctions=false] serialize the javascript. functions.
105+
* `BSON.calculateObjectSize(object, options)`
106+
* @param {Object} object the JavaScript object to serialize.
107+
* @param {Boolean} [options.serializeFunctions=false] serialize the JavaScript functions.
105108
* @param {Boolean} [options.ignoreUndefined=true]
106109
* @return {Buffer} returns a Buffer instance.
107110

108111
#### BSON.deserialize
109112

110-
The BSON deserialize method takes a node.js Buffer and an optional options object and returns a deserialized Javascript object.
113+
The BSON `deserialize` method takes a Node.js Buffer and an optional options object and returns a deserialized JavaScript object.
111114

112-
* BSON.deserialize(buffer, options)
115+
* `BSON.deserialize(buffer, options)`
113116
* @param {Object} [options.evalFunctions=false] evaluate functions in the BSON document scoped to the object deserialized.
114117
* @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse.
115118
* @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function.
116119
* @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits
117-
* @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a node.js Buffer instance.
120+
* @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a Node.js Buffer instance.
118121
* @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
119122
* @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
120123
* @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
121124
* @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents.
122125

123126
#### BSON.deserializeStream
124127

125-
The BSON deserializeStream method takes a node.js Buffer, startIndex and allow more control over deserialization of a Buffer containing concatenated BSON documents.
128+
The BSON `deserializeStream` method takes a Node.js Buffer, `startIndex` and allow more control over deserialization of a Buffer containing concatenated BSON documents.
126129

127-
* BSON.deserializeStream(buffer, startIndex, numberOfDocuments, documents, docStartIndex, options)
130+
* `BSON.deserializeStream(buffer, startIndex, numberOfDocuments, documents, docStartIndex, options)`
128131
* @param {Buffer} buffer the buffer containing the serialized set of BSON documents.
129132
* @param {Number} startIndex the start index in the data Buffer where the deserialization is to start.
130133
* @param {Number} numberOfDocuments number of documents to deserialize.
@@ -134,11 +137,11 @@ The BSON deserializeStream method takes a node.js Buffer, startIndex and allow m
134137
* @param {Object} [options.cacheFunctions=false] cache evaluated functions for reuse.
135138
* @param {Object} [options.cacheFunctionsCrc32=false] use a crc32 code for caching, otherwise use the string of the function.
136139
* @param {Object} [options.promoteLongs=true] when deserializing a Long will fit it into a Number if it's smaller than 53 bits
137-
* @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a node.js Buffer instance.
140+
* @param {Object} [options.promoteBuffers=false] when deserializing a Binary will return it as a Node.js Buffer instance.
138141
* @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
139142
* @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
140143
* @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
141-
* @return {Object} returns the deserialized Javascript Object.
144+
* @return {Object} returns the deserialized JavaScript Object.
142145

143146
## FAQ
144147

0 commit comments

Comments
 (0)