index.js 902 B

123456789101112131415161718192021222324252627282930
  1. var bson = null;
  2. try {
  3. // Load the precompiled win32 binary
  4. if(process.platform == "win32" && process.arch == "x64") {
  5. bson = require('./win32/x64/bson');
  6. } else if(process.platform == "win32" && process.arch == "ia32") {
  7. bson = require('./win32/ia32/bson');
  8. } else {
  9. bson = require('bindings')('bson.node');
  10. }
  11. } catch(err) {
  12. // Attempt to load the release bson version
  13. try {
  14. bson = require('bindings')('bson.node');
  15. } catch (err) {
  16. throw new Error("js-bson: Failed to load c++ bson extension, using pure JS version");
  17. }
  18. }
  19. exports.BSON = bson.BSON;
  20. // Just add constants tot he Native BSON parser
  21. exports.BSON.BSON_BINARY_SUBTYPE_DEFAULT = 0;
  22. exports.BSON.BSON_BINARY_SUBTYPE_FUNCTION = 1;
  23. exports.BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
  24. exports.BSON.BSON_BINARY_SUBTYPE_UUID = 3;
  25. exports.BSON.BSON_BINARY_SUBTYPE_MD5 = 4;
  26. exports.BSON.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;