From 759dd8529f1d7cef5e394997e20547010597b193 Mon Sep 17 00:00:00 2001 From: Sophie Saskin Date: Wed, 8 Aug 2018 09:21:26 -0400 Subject: [PATCH] fix(buffer): replace deprecated Buffer constructor Replace Buffer constructor with buffer.alloc and buffer.from Fixes Node-1461 --- lib/gridfs-stream/upload.js | 6 ++-- lib/gridfs/chunk.js | 6 ++-- lib/gridfs/grid_store.js | 6 ++-- test/functional/cursor_tests.js | 2 +- test/functional/cursorstream_tests.js | 6 ++-- test/functional/find_tests.js | 4 +-- test/functional/gridfs_stream_tests.js | 6 ++-- test/functional/gridfs_tests.js | 32 +++++++++---------- test/functional/insert_tests.js | 18 +++++------ test/functional/operation_example_tests.js | 10 +++--- .../operation_generators_example_tests.js | 10 +++--- .../operation_promises_example_tests.js | 10 +++--- test/functional/promote_buffers_tests.js | 10 +++--- 13 files changed, 63 insertions(+), 63 deletions(-) diff --git a/lib/gridfs-stream/upload.js b/lib/gridfs-stream/upload.js index c213302795..45f0e474d6 100644 --- a/lib/gridfs-stream/upload.js +++ b/lib/gridfs-stream/upload.js @@ -41,7 +41,7 @@ function GridFSBucketWriteStream(bucket, filename, options) { this.id = options.id ? options.id : core.BSON.ObjectId(); this.chunkSizeBytes = this.options.chunkSizeBytes; - this.bufToStore = new Buffer(this.chunkSizeBytes); + this.bufToStore = Buffer.alloc(this.chunkSizeBytes); this.length = 0; this.md5 = !options.disableMD5 && crypto.createHash('md5'); this.n = 0; @@ -389,7 +389,7 @@ function doWrite(_this, chunk, encoding, callback) { return false; } - var inputBuf = Buffer.isBuffer(chunk) ? chunk : new Buffer(chunk, encoding); + var inputBuf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding); _this.length += inputBuf.length; @@ -501,7 +501,7 @@ function writeRemnant(_this, callback) { // Create a new buffer to make sure the buffer isn't bigger than it needs // to be. - var remnant = new Buffer(_this.pos); + var remnant = Buffer.alloc(_this.pos); _this.bufToStore.copy(remnant, 0, 0, _this.pos); if (_this.md5) { _this.md5.update(remnant); diff --git a/lib/gridfs/chunk.js b/lib/gridfs/chunk.js index b033d86826..fef81c14fc 100644 --- a/lib/gridfs/chunk.js +++ b/lib/gridfs/chunk.js @@ -29,11 +29,11 @@ var Chunk = function(file, mongoObject, writeConcern) { this.data = new Binary(); if (typeof mongoObjectFinal.data === 'string') { - var buffer = new Buffer(mongoObjectFinal.data.length); + var buffer = Buffer.alloc(mongoObjectFinal.data.length); buffer.write(mongoObjectFinal.data, 0, mongoObjectFinal.data.length, 'binary'); this.data = new Binary(buffer); } else if (Array.isArray(mongoObjectFinal.data)) { - buffer = new Buffer(mongoObjectFinal.data.length); + buffer = Buffer.alloc(mongoObjectFinal.data.length); var data = mongoObjectFinal.data.join(''); buffer.write(data, 0, data.length, 'binary'); this.data = new Binary(buffer); @@ -91,7 +91,7 @@ Chunk.prototype.readSlice = function(length) { data = this.data.buffer.slice(this.internalPosition, this.internalPosition + length); } else { //Native BSON - data = new Buffer(length); + data = Buffer.alloc(length); length = this.data.readInto(data, this.internalPosition); } this.internalPosition = this.internalPosition + length; diff --git a/lib/gridfs/grid_store.js b/lib/gridfs/grid_store.js index 0414dd2865..bf72537b58 100644 --- a/lib/gridfs/grid_store.js +++ b/lib/gridfs/grid_store.js @@ -414,7 +414,7 @@ var writeFile = function(self, file, options, callback) { // Write a chunk var writeChunk = function() { // Allocate the buffer - var _buffer = new Buffer(self.chunkSize); + var _buffer = Buffer.alloc(self.chunkSize); // Read the file fs.read(file, _buffer, 0, _buffer.length, offset, function(err, bytesRead, data) { if (err) return callback(err, self); @@ -743,7 +743,7 @@ GridStore.prototype.read = function(length, buffer, options, callback) { var read = function(self, length, buffer, options, callback) { // The data is a c-terminated string and thus the length - 1 var finalLength = length == null ? self.length - self.position : length; - var finalBuffer = buffer == null ? new Buffer(finalLength) : buffer; + var finalBuffer = buffer == null ? Buffer.alloc(finalLength) : buffer; // Add a index to buffer to keep track of writing position or apply current index finalBuffer._index = buffer != null && buffer._index != null ? buffer._index : 0; @@ -1550,7 +1550,7 @@ var _writeNormal = function(self, data, close, options, callback) { if (Buffer.isBuffer(data)) { return writeBuffer(self, data, close, callback); } else { - return writeBuffer(self, new Buffer(data, 'binary'), close, callback); + return writeBuffer(self, Buffer.from(data, 'binary'), close, callback); } }; diff --git a/test/functional/cursor_tests.js b/test/functional/cursor_tests.js index 47ff4d2d71..21146f6777 100644 --- a/test/functional/cursor_tests.js +++ b/test/functional/cursor_tests.js @@ -2196,7 +2196,7 @@ describe('Cursor', function() { if (++i === 5) { client.topology .connections()[0] - .write(new Buffer('312312321321askdjljsaNCKnablibh')); + .write(Buffer.from('312312321321askdjljsaNCKnablibh')); } }); diff --git a/test/functional/cursorstream_tests.js b/test/functional/cursorstream_tests.js index 3b30e80e9a..79621dd261 100644 --- a/test/functional/cursorstream_tests.js +++ b/test/functional/cursorstream_tests.js @@ -101,7 +101,7 @@ describe('Cursor Streams', function() { var docs = []; for (var i = 0; i < 10000; i++) { - docs.push({ a: i, bin: new Binary(new Buffer(256)) }); + docs.push({ a: i, bin: new Binary(Buffer.alloc(256)) }); } var j = 0; @@ -179,7 +179,7 @@ describe('Cursor Streams', function() { var counter2 = 0; for (var i = 0; i < 1000; i++) { - docs.push({ a: i, bin: new Binary(new Buffer(256)) }); + docs.push({ a: i, bin: new Binary(Buffer.alloc(256)) }); } var client = self.configuration.newClient(self.configuration.writeConcernMax(), { @@ -238,7 +238,7 @@ describe('Cursor Streams', function() { var docs = []; for (var i = 0; i < 2000; i++) { - docs.push({ a: i, b: new Binary(new Buffer(1024)) }); + docs.push({ a: i, b: new Binary(Buffer.alloc(1024)) }); } var allDocs = []; diff --git a/test/functional/find_tests.js b/test/functional/find_tests.js index 482fd50855..9e9848c55d 100644 --- a/test/functional/find_tests.js +++ b/test/functional/find_tests.js @@ -2219,7 +2219,7 @@ describe('Find', function() { a: 1, b: 'helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld', - c: new Binary(new Buffer(1024)) + c: new Binary(Buffer.alloc(1024)) }); } @@ -2233,7 +2233,7 @@ describe('Find', function() { a: 1, b: 'helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld helloworld', - c: new Binary(new Buffer(1024)) + c: new Binary(Buffer.alloc(1024)) }); } diff --git a/test/functional/gridfs_stream_tests.js b/test/functional/gridfs_stream_tests.js index d70e80ba53..6bb98d5fa7 100644 --- a/test/functional/gridfs_stream_tests.js +++ b/test/functional/gridfs_stream_tests.js @@ -1055,7 +1055,7 @@ describe('GridFS Stream', function() { testSpec.act.arguments.filename, testSpec.act.arguments.options ); - var buf = new Buffer(testSpec.act.arguments.source.$hex, 'hex'); + var buf = Buffer.from(testSpec.act.arguments.source.$hex, 'hex'); res.on('error', function(err) { test.equal(null, err); @@ -1112,7 +1112,7 @@ describe('GridFS Stream', function() { var _runTest = function() { var bucket = new GridFSBucket(db, { bucketName: BUCKET_NAME }); - var res = new Buffer(0); + var res = Buffer.alloc(0); var download = bucket.openDownloadStream( EJSON.parse(JSON.stringify(testSpec.act.arguments.id), { relaxed: true }) @@ -1235,7 +1235,7 @@ describe('GridFS Stream', function() { keys.forEach(function(key) { if (doc[key] && typeof doc[key] === 'object') { if (doc[key].$hex != null) { - doc[key] = new Buffer(doc[key].$hex, 'hex'); + doc[key] = Buffer.from(doc[key].$hex, 'hex'); } else { convert$hexToBuffer(doc[key]); } diff --git a/test/functional/gridfs_tests.js b/test/functional/gridfs_tests.js index 78f5ded394..6a801d09f8 100644 --- a/test/functional/gridfs_tests.js +++ b/test/functional/gridfs_tests.js @@ -1665,7 +1665,7 @@ describe('GridFS', function() { gridStore.open(function(err, gridStore) { expect(err).to.not.exist; - gridStore.write(new Buffer('012345678901234567890', 'utf8'), function(err, gridStore) { + gridStore.write(Buffer.from('012345678901234567890', 'utf8'), function(err, gridStore) { expect(err).to.not.exist; gridStore.close(function() { @@ -1727,7 +1727,7 @@ describe('GridFS', function() { gridStore.open(function(err, gridStore) { expect(err).to.not.exist; - gridStore.write(new Buffer('012345678901234567890', 'utf8'), function(err, gridStore) { + gridStore.write(Buffer.from('012345678901234567890', 'utf8'), function(err, gridStore) { expect(err).to.not.exist; gridStore.close(function() { @@ -1851,7 +1851,7 @@ describe('GridFS', function() { expect(err).to.not.exist; // Create a chunkSize Buffer - var buffer = new Buffer(chunkSize); + var buffer = Buffer.alloc(chunkSize); // Write the buffer gridStore.write(buffer, function(err, gridStore) { @@ -2109,7 +2109,7 @@ describe('GridFS', function() { gridStore.open(function(err, gridStore) { expect(err).to.not.exist; - var d = new Buffer(5000); + var d = Buffer.alloc(5000); for (var j = 0; j < 5000; j++) { d[j] = 43; } @@ -2174,7 +2174,7 @@ describe('GridFS', function() { var gridStoreR = new GridStore(db, 'test_gs_read_stream', 'r'); var gridStoreW = new GridStore(db, 'test_gs_read_stream', 'w', { chunkSize: 56 }); // var data = fs.readFileSync("./test/gridstore/test_gs_weird_bug.png"); - var data = new Buffer(100); + var data = Buffer.alloc(100); for (var i = 0; i < 100; i++) { data[i] = i; } @@ -2210,7 +2210,7 @@ describe('GridFS', function() { expect(err).to.not.exist; // Put together all the chunks - var streamData = new Buffer(data.length); + var streamData = Buffer.alloc(data.length); var index = 0; var i; for (i = 0; i < chunks.length; i++) { @@ -2374,7 +2374,7 @@ describe('GridFS', function() { gridStore.open(function(err, gridStore) { expect(err).to.not.exist; - var data = new Buffer('hello world', 'utf8'); + var data = Buffer.from('hello world', 'utf8'); gridStore.write(data, function(err, gridStore) { expect(err).to.not.exist; @@ -2689,7 +2689,7 @@ describe('GridFS', function() { // Open the file gridStore.open(function(err, gridStore) { expect(err).to.not.exist; - var data = new Buffer(gridStore.chunkSize * 3); + var data = Buffer.alloc(gridStore.chunkSize * 3); // Write the binary file data to GridFS gridStore.write(data, function(err, gridStore) { expect(err).to.not.exist; @@ -2878,7 +2878,7 @@ describe('GridFS', function() { expect(err).to.not.exist; var db = client.db(configuration.db); var gridStore = new GridStore(db, 'test_gs_check_high_bits', 'w'); - var data = new Buffer(255); + var data = Buffer.alloc(255); for (var i = 0; i < 255; i++) { data[i] = i; } @@ -2896,7 +2896,7 @@ describe('GridFS', function() { // change testvalue into a string like "0,1,2,...,255" test.equal(data.toString('hex'), fileData.toString('hex')); // test.equal(Array.prototype.join.call(data), - // Array.prototype.join.call(new Buffer(fileData, "binary"))); + // Array.prototype.join.call(Buffer.from(fileData, "binary"))); client.close(); done(); }); @@ -3364,7 +3364,7 @@ describe('GridFS', function() { var write = function(left, callback) { if (left === 0) return callback(); - gridStore.write(new Buffer(5000), function() { + gridStore.write(Buffer.alloc(5000), function() { left = left - 1; write(left, callback); }); @@ -3467,7 +3467,7 @@ describe('GridFS', function() { expect(err).to.not.exist; var db = client.db(configuration.db); // Massive data Buffer - var data = new Buffer(1024 * 512); + var data = Buffer.alloc(1024 * 512); // Set some data in the buffer at a point we want to read in the next chunk data.write('Hello world!', 1024 * 256); @@ -3729,7 +3729,7 @@ describe('GridFS', function() { gridStore.chunkSize = 512; // Write multiple of chunk size - gridStore.write(new Buffer(gridStore.chunkSize * 4), function(err) { + gridStore.write(Buffer.alloc(gridStore.chunkSize * 4), function(err) { expect(err).to.not.exist; gridStore.close(function(err) { @@ -3800,7 +3800,7 @@ describe('GridFS', function() { gridStore.chunkSize = 512; // Get the data - var data = new Buffer(gridStore.chunkSize * 2); + var data = Buffer.alloc(gridStore.chunkSize * 2); for (var i = 0; i < gridStore.chunkSize * 2; i++) { data[i] = 0; } @@ -3873,7 +3873,7 @@ describe('GridFS', function() { ObjectID = configuration.require.ObjectID; // Create a test buffer - var buffer = new Buffer(200033); + var buffer = Buffer.alloc(200033); // Use connect method to connect to the Server MongoClient.connect(configuration.url(), { sslValidate: false }, function(err, client) { @@ -3917,7 +3917,7 @@ describe('GridFS', function() { var succeeded = []; // Create a test buffer - var buffer = new Buffer(2000); + var buffer = Buffer.alloc(2000); var client = configuration.newClient(configuration.writeConcernMax(), { poolSize: 1 }); client.connect(function(err, client) { diff --git a/test/functional/insert_tests.js b/test/functional/insert_tests.js index 7b61774dc0..a2f008364e 100644 --- a/test/functional/insert_tests.js +++ b/test/functional/insert_tests.js @@ -1567,11 +1567,11 @@ describe('Insert', function() { client.connect(function(err, client) { var db = client.db(configuration.db); db.createCollection('shouldAttempToForceBsonSize', function(err, collection) { - // var doc = {a:1, b:new Binary(new Buffer(16777216)/5)} + // var doc = {a:1, b:new Binary(Buffer.alloc(16777216)/5)} var doc = [ - { a: 1, b: new Binary(new Buffer(16777216 / 3)) }, - { a: 1, b: new Binary(new Buffer(16777216 / 3)) }, - { a: 1, b: new Binary(new Buffer(16777216 / 3)) } + { a: 1, b: new Binary(Buffer.alloc(16777216 / 3)) }, + { a: 1, b: new Binary(Buffer.alloc(16777216 / 3)) }, + { a: 1, b: new Binary(Buffer.alloc(16777216 / 3)) } ]; collection.insert(doc, configuration.writeConcernMax(), function(err, result) { @@ -1782,7 +1782,7 @@ describe('Insert', function() { symbol: new Symbol('abcdefghijkl'), objid: new ObjectID('abcdefghijkl'), double: new Double(1), - binary: new Binary(new Buffer('hello world')), + binary: new Binary(Buffer.from('hello world')), minkey: new MinKey(), maxkey: new MaxKey(), code: new Code('function () {}', { a: 55 }) @@ -1804,7 +1804,7 @@ describe('Insert', function() { test.equal(null, err); test.equal(1, doc.double); - collection.findOne({ binary: new Binary(new Buffer('hello world')) }, function( + collection.findOne({ binary: new Binary(Buffer.from('hello world')) }, function( err, doc ) { @@ -1872,7 +1872,7 @@ describe('Insert', function() { symbol: new Symbol('abcdefghijkl'), objid: new ObjectID('abcdefghijkl'), double: new Double(1), - binary: new Binary(new Buffer('hello world')), + binary: new Binary(Buffer.from('hello world')), minkey: new MinKey(), maxkey: new MaxKey(), code: new Code('function () {}', { a: 55 }) @@ -1894,7 +1894,7 @@ describe('Insert', function() { test.equal(null, err); test.equal(1, doc.double); - collection.findOne({ binary: new Binary(new Buffer('hello world')) }, function( + collection.findOne({ binary: new Binary(Buffer.from('hello world')) }, function( err, doc ) { @@ -2095,7 +2095,7 @@ describe('Insert', function() { var client = configuration.newClient(configuration.writeConcernMax(), { poolSize: 1 }); client.connect(function(err, client) { var db = client.db(configuration.db); - var k = new Buffer(15); + var k = Buffer.alloc(15); for (var i = 0; i < 15; i++) k[i] = 0; k.write('hello'); diff --git a/test/functional/operation_example_tests.js b/test/functional/operation_example_tests.js index 192e05b649..b828036052 100644 --- a/test/functional/operation_example_tests.js +++ b/test/functional/operation_example_tests.js @@ -7670,7 +7670,7 @@ describe('Operation Examples', function() { // Write a text string gridStore.write('Hello world', function(err, gridStore) { // Write a buffer - gridStore.write(new Buffer('Buffer Hello world'), function(err, gridStore) { + gridStore.write(Buffer.from('Buffer Hello world'), function(err, gridStore) { // Close the gridStore.close(function(err, result) { test.ok(result); @@ -8341,7 +8341,7 @@ describe('Operation Examples', function() { var gridStore = new GridStore(db, 'test_gs_seek_with_buffer', 'w'); gridStore.open(function(err, gridStore) { // Write some content to the file - gridStore.write(new Buffer('hello, world!', 'utf8'), function(err, gridStore) { + gridStore.write(Buffer.from('hello, world!', 'utf8'), function(err, gridStore) { // Flush the file to GridFS gridStore.close(function() { // Open the file in read mode @@ -8659,7 +8659,7 @@ describe('Operation Examples', function() { var gridStore = new GridStore(db, 'test_gs_getc_file', 'w'); gridStore.open(function(err, gridStore) { // Write some content to the file - gridStore.write(new Buffer('hello, world!', 'utf8'), function(err, gridStore) { + gridStore.write(Buffer.from('hello, world!', 'utf8'), function(err, gridStore) { // Flush the file to GridFS gridStore.close(function() { // Open the file in read mode @@ -8715,7 +8715,7 @@ describe('Operation Examples', function() { var gridStore = new GridStore(db, new ObjectID(), 'test_gs_getc_file', 'w'); gridStore.open(function(err, gridStore) { // Write some content to the file - gridStore.write(new Buffer('hello, world!', 'utf8'), function(err, gridStore) { + gridStore.write(Buffer.from('hello, world!', 'utf8'), function(err, gridStore) { // Flush the file to GridFS gridStore.close(function(err, fileData) { test.ok(fileData); @@ -8725,7 +8725,7 @@ describe('Operation Examples', function() { gridStore = new GridStore(db, new ObjectID(), 'test_gs_getc_file', 'w'); gridStore.open(function(err, gridStore) { // Write some content to the file - gridStore.write(new Buffer('hello, world!', 'utf8'), function(err, gridStore) { + gridStore.write(Buffer.from('hello, world!', 'utf8'), function(err, gridStore) { // Flush the file to GridFS gridStore.close(function(err, fileData) { test.equal(null, err); diff --git a/test/functional/operation_generators_example_tests.js b/test/functional/operation_generators_example_tests.js index 1a7ff5c232..3edf376b0e 100644 --- a/test/functional/operation_generators_example_tests.js +++ b/test/functional/operation_generators_example_tests.js @@ -5200,7 +5200,7 @@ describe('Operation (Generators)', function() { yield gridStore.write('Hello world'); // Write a buffer - yield gridStore.write(new Buffer('Buffer Hello world')); + yield gridStore.write(Buffer.from('Buffer Hello world')); // Close the yield gridStore.close(); @@ -5548,7 +5548,7 @@ describe('Operation (Generators)', function() { var gridStore = new GridStore(db, 'test_gs_seek_with_buffer', 'w'); yield gridStore.open(); // Write some content to the file - yield gridStore.write(new Buffer('hello, world!', 'utf8')); + yield gridStore.write(Buffer.from('hello, world!', 'utf8')); // Flush the file to GridFS yield gridStore.close(); @@ -5777,7 +5777,7 @@ describe('Operation (Generators)', function() { var gridStore = new GridStore(db, 'test_gs_getc_file', 'w'); yield gridStore.open(); // Write some content to the file - yield gridStore.write(new Buffer('hello, world!', 'utf8')); + yield gridStore.write(Buffer.from('hello, world!', 'utf8')); // Flush the file to GridFS yield gridStore.close(); // Open the file in read mode @@ -5830,7 +5830,7 @@ describe('Operation (Generators)', function() { var gridStore = new GridStore(db, new ObjectID(), 'test_gs_getc_file', 'w'); yield gridStore.open(); // Write some content to the file - yield gridStore.write(new Buffer('hello, world!', 'utf8')); + yield gridStore.write(Buffer.from('hello, world!', 'utf8')); // Flush the file to GridFS yield gridStore.close(); @@ -5838,7 +5838,7 @@ describe('Operation (Generators)', function() { gridStore = new GridStore(db, new ObjectID(), 'test_gs_getc_file', 'w'); yield gridStore.open(); // Write some content to the file - yield gridStore.write(new Buffer('hello, world!', 'utf8')); + yield gridStore.write(Buffer.from('hello, world!', 'utf8')); // Flush the file to GridFS var fileData = yield gridStore.close(); diff --git a/test/functional/operation_promises_example_tests.js b/test/functional/operation_promises_example_tests.js index cb4a32741f..725fc2866c 100644 --- a/test/functional/operation_promises_example_tests.js +++ b/test/functional/operation_promises_example_tests.js @@ -5740,7 +5740,7 @@ describe('Operation (Promises)', function() { }) .then(function(gridStore) { // Write a buffer - return gridStore.write(new Buffer('Buffer Hello world')); + return gridStore.write(Buffer.from('Buffer Hello world')); }) .then(function(gridStore) { // Close the @@ -6109,7 +6109,7 @@ describe('Operation (Promises)', function() { .open() .then(function(gridStore) { // Write some content to the file - return gridStore.write(new Buffer('hello, world!', 'utf8')); + return gridStore.write(Buffer.from('hello, world!', 'utf8')); }) .then(function(gridStore) { // Flush the file to GridFS @@ -6383,7 +6383,7 @@ describe('Operation (Promises)', function() { .open() .then(function(gridStore) { // Write some content to the file - return gridStore.write(new Buffer('hello, world!', 'utf8')); + return gridStore.write(Buffer.from('hello, world!', 'utf8')); }) .then(function(gridStore) { // Flush the file to GridFS @@ -6444,7 +6444,7 @@ describe('Operation (Promises)', function() { .open() .then(function(gridStore) { // Write some content to the file - return gridStore.write(new Buffer('hello, world!', 'utf8')); + return gridStore.write(Buffer.from('hello, world!', 'utf8')); }) .then(function(gridStore) { // Flush the file to GridFS @@ -6458,7 +6458,7 @@ describe('Operation (Promises)', function() { .then(function(gridStore) { test.ok(gridStore); // Write some content to the file - return gridStoreDupe.write(new Buffer('hello, world!', 'utf8')); + return gridStoreDupe.write(Buffer.from('hello, world!', 'utf8')); }) .then(function(gridStore) { test.ok(gridStore); diff --git a/test/functional/promote_buffers_tests.js b/test/functional/promote_buffers_tests.js index 4090ec8cf5..68b8efedd1 100644 --- a/test/functional/promote_buffers_tests.js +++ b/test/functional/promote_buffers_tests.js @@ -27,7 +27,7 @@ describe('Promote Buffers', function() { var db = client.db(configuration.db); db.collection('shouldCorrectlyHonorPromoteBuffer1').insert( { - doc: new Buffer(256) + doc: Buffer.alloc(256) }, function(err) { test.equal(null, err); @@ -67,7 +67,7 @@ describe('Promote Buffers', function() { db.collection('shouldCorrectlyHonorPromoteBuffer2').insert( { - doc: new Buffer(256) + doc: Buffer.alloc(256) }, function(err) { test.equal(null, err); @@ -108,7 +108,7 @@ describe('Promote Buffers', function() { db.collection('shouldCorrectlyHonorPromoteBuffer3').insert( { - doc: new Buffer(256) + doc: Buffer.alloc(256) }, function(err) { test.equal(null, err); @@ -146,7 +146,7 @@ describe('Promote Buffers', function() { var db = client.db(configuration.db); db.collection('shouldCorrectlyHonorPromoteBuffer4').insert( { - doc: new Buffer(256) + doc: Buffer.alloc(256) }, function(err) { test.equal(null, err); @@ -186,7 +186,7 @@ describe('Promote Buffers', function() { var db = client.db(configuration.db); db.collection('shouldCorrectlyHonorPromoteBuffer5').insert( { - doc: new Buffer(256) + doc: Buffer.alloc(256) }, function(err) { test.equal(null, err);