bson 2.0.4 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +41 -0
- package/README.md +20 -2
- package/browser_build/bson.js +14259 -14337
- package/lib/bson/binary.js +13 -3
- package/lib/bson/bson.js +3 -2
- package/lib/bson/decimal128.js +4 -4
- package/lib/bson/objectid.js +4 -4
- package/lib/bson/parser/calculate_size.js +4 -2
- package/lib/bson/parser/deserializer.js +16 -3
- package/lib/bson/parser/serializer.js +9 -6
- package/lib/bson/parser/utils.js +13 -0
- package/lib/bson/regexp.js +1 -1
- package/package.json +2 -2
package/HISTORY.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
+
<a name="2.0.8"></a>
|
|
2
|
+
## [2.0.8](https://github.com/mongodb/js-bson/compare/v2.0.7...v2.0.8) (2018-06-06)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **readme:** clarify documentation about deserialize methods ([e311056](https://github.com/mongodb/js-bson/commit/e311056))
|
|
8
|
+
* **serialization:** normalize function stringification ([21eb0b0](https://github.com/mongodb/js-bson/commit/21eb0b0))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
<a name="2.0.7"></a>
|
|
13
|
+
## [2.0.7](https://github.com/mongodb/js-bson/compare/v2.0.6...v2.0.7) (2018-05-31)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **binary:** add type checking for buffer ([cbfb25d](https://github.com/mongodb/js-bson/commit/cbfb25d))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<a name="2.0.6"></a>
|
|
23
|
+
## [2.0.6](https://github.com/mongodb/js-bson/compare/v2.0.5...v2.0.6) (2018-04-27)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* **deserializeStream:** allow multiple documents to be deserialized ([6fc5984](https://github.com/mongodb/js-bson/commit/6fc5984)), closes [#244](https://github.com/mongodb/js-bson/issues/244)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
<a name="2.0.5"></a>
|
|
33
|
+
## [2.0.5](https://github.com/mongodb/js-bson/compare/v2.0.4...v2.0.5) (2018-04-06)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* **regexp:** properly construct new BSONRegExp when constructor called without new ([#242](https://github.com/mongodb/js-bson/issues/242)) ([93ae799](https://github.com/mongodb/js-bson/commit/93ae799))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
1
42
|
<a name="2.0.4"></a>
|
|
2
43
|
## [2.0.4](https://github.com/mongodb/js-bson/compare/v2.0.3...v2.0.4) (2018-03-12)
|
|
3
44
|
|
package/README.md
CHANGED
|
@@ -121,7 +121,7 @@ The BSON `deserialize` method takes a Node.js Buffer and an optional options obj
|
|
|
121
121
|
* @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
|
|
122
122
|
* @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
|
|
123
123
|
* @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
|
|
124
|
-
* @return {
|
|
124
|
+
* @return {Object} returns the deserialized Javascript Object.
|
|
125
125
|
|
|
126
126
|
#### BSON.deserializeStream
|
|
127
127
|
|
|
@@ -141,10 +141,28 @@ The BSON `deserializeStream` method takes a Node.js Buffer, `startIndex` and all
|
|
|
141
141
|
* @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
|
|
142
142
|
* @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
|
|
143
143
|
* @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
|
|
144
|
-
* @return {
|
|
144
|
+
* @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents.
|
|
145
145
|
|
|
146
146
|
## FAQ
|
|
147
147
|
|
|
148
148
|
#### Why does `undefined` get converted to `null`?
|
|
149
149
|
|
|
150
150
|
The `undefined` BSON type has been [deprecated for many years](http://bsonspec.org/spec.html), so this library has dropped support for it. Use the `ignoreUndefined` option (for example, from the [driver](http://mongodb.github.io/node-mongodb-native/2.2/api/MongoClient.html#connect) ) to instead remove `undefined` keys.
|
|
151
|
+
|
|
152
|
+
#### How do I add custom serialization logic?
|
|
153
|
+
|
|
154
|
+
This library looks for `toBSON()` functions on every path, and calls the `toBSON()` function to get the value to serialize.
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
var bson = new BSON();
|
|
158
|
+
|
|
159
|
+
class CustomSerialize {
|
|
160
|
+
toBSON() {
|
|
161
|
+
return 42;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const obj = { answer: new CustomSerialize() };
|
|
166
|
+
// "{ answer: 42 }"
|
|
167
|
+
console.log(bson.deserialize(bson.serialize(obj)));
|
|
168
|
+
```
|