bson 0.1.8 → 0.2.2
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/README.md +45 -1
- package/browser_build/bson.js +205 -176
- package/build/Release/bson.exp +0 -0
- package/build/Release/bson.lib +0 -0
- package/build/Release/bson.node +0 -0
- package/build/Release/bson.pdb +0 -0
- package/build/Release/obj/bson/bson.lastbuildstate +2 -0
- package/build/Release/obj/bson/bson.node.intermediate.manifest +10 -0
- package/build/Release/obj/bson/bson.obj +0 -0
- package/build/Release/obj/bson/bson.vcxprojResolveAssemblyReference.cache +0 -0
- package/build/Release/obj/bson/bson.write.1.tlog +3 -0
- package/build/Release/obj/bson/cl.command.1.tlog +0 -0
- package/build/Release/obj/bson/cl.read.1.tlog +0 -0
- package/build/Release/obj/bson/cl.write.1.tlog +0 -0
- package/build/Release/obj/bson/link.command.1.tlog +0 -0
- package/build/Release/obj/bson/link.read.1.tlog +0 -0
- package/build/Release/obj/bson/link.write.1.tlog +0 -0
- package/build/Release/obj/bson/mt.command.1.tlog +0 -0
- package/build/Release/obj/bson/mt.read.1.tlog +0 -0
- package/build/Release/obj/bson/mt.write.1.tlog +0 -0
- package/build/Release/obj/bson/vcwindows7.1sdk.pdb +0 -0
- package/build/binding.sln +21 -0
- package/build/bson.vcxproj +127 -0
- package/build/bson.vcxproj.filters +19 -0
- package/build/config.gypi +17 -8
- package/ext/bson.cc +68 -29
- package/ext/bson.h +9 -5
- package/ext/win32/ia32/bson.node +0 -0
- package/ext/win32/x64/bson.node +0 -0
- package/lib/bson/bson.js +192 -172
- package/lib/bson/objectid.js +4 -4
- package/package.json +2 -2
- package/benchmarks/benchmarks.js +0 -130
- package/build/Makefile +0 -355
- package/build/Release/.deps/Release/bson.node.d +0 -1
- package/build/Release/.deps/Release/obj.target/bson/ext/bson.o.d +0 -34
- package/build/Release/linker.lock +0 -0
- package/build/Release/obj.target/bson/ext/bson.o +0 -0
- package/build/binding.Makefile +0 -6
- package/build/bson.target.mk +0 -154
- package/build/gyp-mac-tool +0 -211
- package/test/browser/browser_example.htm +0 -19
- package/test/browser/bson_test.js +0 -260
- package/test/browser/nodeunit.js +0 -2034
- package/test/browser/suite2.js +0 -13
- package/test/browser/suite3.js +0 -7
- package/test/browser/test.html +0 -30
- package/test/node/bson_array_test.js +0 -240
- package/test/node/bson_parser_comparision_test.js +0 -493
- package/test/node/bson_test.js +0 -1694
- package/test/node/bson_typed_array_test.js +0 -392
- package/test/node/data/test_gs_weird_bug.png +0 -0
- package/test/node/test_full_bson.js +0 -315
- package/test/node/to_bson_test.js +0 -109
- package/test/node/tools/utils.js +0 -80
package/README.md
CHANGED
|
@@ -1 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
Javascript + C++ BSON parser
|
|
2
|
+
============================
|
|
3
|
+
|
|
4
|
+
This BSON parser is primarily meant for usage with the `mongodb` node.js driver. However thanks to such wonderful tools at `onejs` we are able to package up a BSON parser that will work in the browser aswell. The current build is located in the `browser_build/bson.js` file.
|
|
5
|
+
|
|
6
|
+
A simple example on how to use it
|
|
7
|
+
|
|
8
|
+
<head>
|
|
9
|
+
<script src="https://raw.github.com/mongodb/js-bson/master/browser_build/bson.js">
|
|
10
|
+
</script>
|
|
11
|
+
</head>
|
|
12
|
+
<body onload="start();">
|
|
13
|
+
<script>
|
|
14
|
+
function start() {
|
|
15
|
+
var BSON = bson().BSON;
|
|
16
|
+
var Long = bson().Long;
|
|
17
|
+
|
|
18
|
+
var doc = {long: Long.fromNumber(100)}
|
|
19
|
+
|
|
20
|
+
// Serialize a document
|
|
21
|
+
var data = BSON.serialize(doc, false, true, false);
|
|
22
|
+
// De serialize it again
|
|
23
|
+
var doc_2 = BSON.deserialize(data);
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
</body>
|
|
27
|
+
|
|
28
|
+
It's got two simple methods to use in your application.
|
|
29
|
+
|
|
30
|
+
* BSON.serialize(object, checkKeys, asBuffer, serializeFunctions)
|
|
31
|
+
* @param {Object} object the Javascript object to serialize.
|
|
32
|
+
* @param {Boolean} checkKeys the serializer will check if keys are valid.
|
|
33
|
+
* @param {Boolean} asBuffer return the serialized object as a Buffer object **(ignore)**.
|
|
34
|
+
* @param {Boolean} serializeFunctions serialize the javascript functions **(default:false)**
|
|
35
|
+
* @return {TypedArray/Array} returns a TypedArray or Array depending on what your browser supports
|
|
36
|
+
|
|
37
|
+
* BSON.deserialize(buffer, options, isArray)
|
|
38
|
+
* Options
|
|
39
|
+
* **evalFunctions** {Boolean, default:false}, evaluate functions in the BSON document scoped to the object deserialized.
|
|
40
|
+
* **cacheFunctions** {Boolean, default:false}, cache evaluated functions for reuse.
|
|
41
|
+
* **cacheFunctionsCrc32** {Boolean, default:false}, use a crc32 code for caching, otherwise use the string of the function.
|
|
42
|
+
* @param {TypedArray/Array} a TypedArray/Array containing the BSON data
|
|
43
|
+
* @param {Object} [options] additional options used for the deserialization.
|
|
44
|
+
* @param {Boolean} [isArray] ignore used for recursive parsing.
|
|
45
|
+
* @return {Object} returns the deserialized Javascript Object.
|