mongodb-extjson
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
var btoa = require('./shared').btoa; | ||
@@ -2,0 +4,0 @@ |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * A class representation of the BSON Code type. |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * A class representation of the BSON DBRef type. |
"use strict" | ||
const Long = require('./long'); | ||
var Long = require('./long'); | ||
@@ -5,0 +5,0 @@ var PARSE_STRING_REGEXP = /^(\+|\-)?(\d+|(\d*\.\d*))?(E|e)?([\-\+])?(\d+)?$/; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * A class representation of the BSON Double type. |
@@ -1,18 +0,21 @@ | ||
const Binary = require('./binary'); | ||
const Code = require('./code'); | ||
const DBRef = require('./db_ref'); | ||
const Decimal128 = require('./decimal128'); | ||
const Double = require('./double'); | ||
const Int32 = require('./int_32'); | ||
const Long = require('./long'); | ||
const MaxKey = require('./max_key'); | ||
const MinKey = require('./min_key'); | ||
const ObjectID = require('./objectid'); | ||
const BSONRegExp = require('./regexp'); | ||
const Symbol = require('./symbol'); | ||
const Timestamp = require('./timestamp'); | ||
"use strict"; | ||
var Binary = require('./binary'); | ||
var Code = require('./code'); | ||
var DBRef = require('./db_ref'); | ||
var Decimal128 = require('./decimal128'); | ||
var Double = require('./double'); | ||
var Int32 = require('./int_32'); | ||
var Long = require('./long'); | ||
var MaxKey = require('./max_key'); | ||
var MinKey = require('./min_key'); | ||
var ObjectID = require('./objectid'); | ||
var BSONRegExp = require('./regexp'); | ||
var Symbol = require('./symbol'); | ||
var Timestamp = require('./timestamp'); | ||
module.exports = { | ||
Binary, Code, DBRef, Decimal128, Double, | ||
Int32, Long, MaxKey, MinKey, ObjectID, BSONRegExp, Symbol, Timestamp | ||
Binary: Binary, Code: Code, DBRef: DBRef, Decimal128: Decimal128, Double: Double, | ||
Int32: Int32, Long: Long, MaxKey: MaxKey, MinKey: MinKey, ObjectID: ObjectID, | ||
BSONRegExp: BSONRegExp, Symbol: Symbol, Timestamp: Timestamp | ||
}; |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * A class representation of the BSON Int32 type. |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
@@ -2,0 +4,0 @@ // you may not use this file except in compliance with the License. |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * A class representation of the BSON MaxKey type. |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * A class representation of the BSON MinKey type. |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -28,3 +30,3 @@ * Machine id. | ||
var convertToHex = function(bytes) { | ||
let hexString = ''; | ||
var hexString = ''; | ||
@@ -31,0 +33,0 @@ for (var i = 0; i < bytes.length; i++) { |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * A class representation of the BSON RegExp type. |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; | ||
@@ -2,0 +4,0 @@ |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
/** | ||
@@ -2,0 +4,0 @@ * A class representation of the BSON Symbol type. |
@@ -0,1 +1,3 @@ | ||
"use strict"; | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
@@ -2,0 +4,0 @@ // you may not use this file except in compliance with the License. |
@@ -0,4 +1,15 @@ | ||
"use strict"; | ||
var bsonModule = require('./bson') | ||
var atob = require('./bson/shared').atob; | ||
var bufferConstructor = null; | ||
if (typeof Buffer !== 'undefined') { | ||
bufferConstructor = new Buffer(1) instanceof Uint8Array | ||
? Buffer | ||
: Uint8Array; | ||
} else { | ||
bufferConstructor = Uint8Array; | ||
} | ||
var ExtJSON = function(module) { | ||
@@ -42,11 +53,15 @@ if (module) { | ||
if (typeof Buffer !== 'undefined') { | ||
var data = new Buffer(value['$binary'], 'base64'); | ||
} else { | ||
var data = new Uint8Array(atob(value['$binary']) | ||
.split("") | ||
.map(function(c) { | ||
return c.charCodeAt(0); | ||
})); | ||
if (bufferConstructor === Buffer) { | ||
var data = new Buffer(value['$binary'], 'base64'); | ||
var type = value['$type'] ? parseInt(value['$type'], 16) : 0; | ||
return new self.bson.Binary(data, type); | ||
} | ||
} | ||
var data = new Uint8Array(atob(value['$binary']) | ||
.split("") | ||
.map(function(c) { | ||
return c.charCodeAt(0); | ||
})); | ||
var type = value['$type'] ? parseInt(value['$type'], 16) : 0; | ||
@@ -53,0 +68,0 @@ return new self.bson.Binary(data, type); |
{ | ||
"name": "mongodb-extjson", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "MongoDB Extended JSON library", | ||
@@ -30,4 +30,5 @@ "main": "index.js", | ||
"mocha": "^3.2.0", | ||
"mongodb": "^2.2.24" | ||
"mongodb": "mongodb/node-mongodb-native#2.2", | ||
"typedarray": "0.0.6" | ||
} | ||
} |
@@ -7,3 +7,3 @@ var ExtJSON = require('../'), | ||
describe('Extended JSON', () => { | ||
describe('Extended JSON', function() { | ||
beforeEach(function() { | ||
@@ -71,2 +71,5 @@ var mongodb = ExtJSON.extend(require('mongodb')); | ||
buffer = new Uint8Array(64); | ||
for(var i = 0; i < buffer.length; i++) buffer[i] = i; | ||
browserDoc = { | ||
@@ -96,3 +99,3 @@ _id: new Int32(100), | ||
it('should correctly extend the existing mongodb module', (done) => { | ||
it('should correctly extend the existing mongodb module', function(done) { | ||
// Serialize the document | ||
@@ -104,3 +107,3 @@ var json = '{"_id":{"$numberInt":"100"},"gh":{"$numberInt":"1"},"binary":{"$binary":"AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4OTo7PD0+Pw==","$type":"00"},"date":"2017-03-01T12:40:56.737Z","code":{"$code":"function() {}","$scope":{"a":{"$numberInt":"1"}}},"dbRef":{"$ref":"tests","$id":{"$numberInt":"1"},"$db":"test"},"decimal":{"$numberDecimal":"100"},"double":{"$numberDouble":"10.1"},"int32":{"$numberInt":"10"},"long":{"$numberLong":"200"},"maxKey":{"$maxKey":1},"minKey":{"$minKey":1},"objectId":{"$oid":"111111111111111111111111"},"regexp":{"$regex":"hello world","$options":"i"},"symbol":{"$symbol":"symbol"},"timestamp":{"$timestamp":"1000"},"int32Number":300,"doubleNumber":200.2,"longNumberIntFit":7036874417766400,"doubleNumberIntFit":19007199250000000}'; | ||
it('should correctly deserialize using strict and non-strict mode using nodeDoc', (done) => { | ||
it('should correctly deserialize using strict and non-strict mode using nodeDoc', function(done) { | ||
// Create ExtJSON instance | ||
@@ -130,3 +133,3 @@ var extJSON = new ExtJSON(); | ||
it('should correctly deserialize using strict and non-strict mode using browserDoc', (done) => { | ||
it('should correctly deserialize using strict and non-strict mode using browserDoc', function(done) { | ||
// Create ExtJSON instance | ||
@@ -156,3 +159,3 @@ var extJSON = new ExtJSON(); | ||
it('should correctly serialize and deserialize using built in BSON', (done) => { | ||
it('should correctly serialize and deserialize using built in BSON', function(done) { | ||
// Create ExtJSON instance | ||
@@ -159,0 +162,0 @@ var extJSON = new ExtJSON(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122197
3321
3