bson 1.0.6 → 1.1.0
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 +33 -0
- package/README.md +20 -2
- package/browser_build/bson.js +1021 -294
- package/lib/bson/binary.js +10 -0
- package/lib/bson/objectid.js +8 -2
- package/lib/bson/parser/calculate_size.js +4 -2
- package/lib/bson/parser/serializer.js +7 -3
- package/lib/bson/parser/utils.js +14 -0
- package/lib/bson/symbol.js +4 -1
- package/package.json +13 -5
package/HISTORY.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
<a name="1.1.0"></a>
|
|
2
|
+
# [1.1.0](https://github.com/mongodb/js-bson/compare/v1.0.9...v1.1.0) (2018-08-13)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **serializer:** do not use checkKeys for $clusterTime ([573e141](https://github.com/mongodb/js-bson/commit/573e141))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<a name="1.0.9"></a>
|
|
12
|
+
## [1.0.9](https://github.com/mongodb/js-bson/compare/v1.0.8...v1.0.9) (2018-06-07)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **serializer:** remove use of `const` ([5feb12f](https://github.com/mongodb/js-bson/commit/5feb12f))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<a name="1.0.7"></a>
|
|
22
|
+
## [1.0.7](https://github.com/mongodb/js-bson/compare/v1.0.6...v1.0.7) (2018-06-06)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **binary:** add type checking for buffer ([26b05b5](https://github.com/mongodb/js-bson/commit/26b05b5))
|
|
28
|
+
* **bson:** fix custom inspect property ([080323b](https://github.com/mongodb/js-bson/commit/080323b))
|
|
29
|
+
* **readme:** clarify documentation about deserialize methods ([20f764c](https://github.com/mongodb/js-bson/commit/20f764c))
|
|
30
|
+
* **serialization:** normalize function stringification ([1320c10](https://github.com/mongodb/js-bson/commit/1320c10))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
1
34
|
<a name="1.0.6"></a>
|
|
2
35
|
## [1.0.6](https://github.com/mongodb/js-bson/compare/v1.0.5...v1.0.6) (2018-03-12)
|
|
3
36
|
|
package/README.md
CHANGED
|
@@ -123,7 +123,7 @@ The BSON `deserialize` method takes a Node.js Buffer and an optional options obj
|
|
|
123
123
|
* @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
|
|
124
124
|
* @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
|
|
125
125
|
* @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
|
|
126
|
-
* @return {
|
|
126
|
+
* @return {Object} returns the deserialized Javascript Object.
|
|
127
127
|
|
|
128
128
|
#### BSON.deserializeStream
|
|
129
129
|
|
|
@@ -143,10 +143,28 @@ The BSON `deserializeStream` method takes a Node.js Buffer, `startIndex` and all
|
|
|
143
143
|
* @param {Object} [options.promoteValues=false] when deserializing will promote BSON values to their Node.js closest equivalent types.
|
|
144
144
|
* @param {Object} [options.fieldsAsRaw=null] allow to specify if there what fields we wish to return as unserialized raw buffer.
|
|
145
145
|
* @param {Object} [options.bsonRegExp=false] return BSON regular expressions as BSONRegExp instances.
|
|
146
|
-
* @return {
|
|
146
|
+
* @return {Number} returns the next index in the buffer after deserialization **x** numbers of documents.
|
|
147
147
|
|
|
148
148
|
## FAQ
|
|
149
149
|
|
|
150
150
|
#### Why does `undefined` get converted to `null`?
|
|
151
151
|
|
|
152
152
|
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.
|
|
153
|
+
|
|
154
|
+
#### How do I add custom serialization logic?
|
|
155
|
+
|
|
156
|
+
This library looks for `toBSON()` functions on every path, and calls the `toBSON()` function to get the value to serialize.
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
var bson = new BSON();
|
|
160
|
+
|
|
161
|
+
class CustomSerialize {
|
|
162
|
+
toBSON() {
|
|
163
|
+
return 42;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const obj = { answer: new CustomSerialize() };
|
|
168
|
+
// "{ answer: 42 }"
|
|
169
|
+
console.log(bson.deserialize(bson.serialize(obj)));
|
|
170
|
+
```
|