Stop using deprecated Buffer constructor
This commit is contained in:
parent
2423b5a4c4
commit
d89e785440
@ -11,7 +11,7 @@ module.exports = function lzma () {
|
||||
}
|
||||
|
||||
// Decode (from base64)
|
||||
var lzma = new Buffer(req.query.lzma, 'base64')
|
||||
var lzma = Buffer.from(req.query.lzma, 'base64')
|
||||
.toString('binary')
|
||||
.split('')
|
||||
.map(function (c) {
|
||||
|
@ -6,7 +6,7 @@ if (process.argv.length !== 3) {
|
||||
var LZMA = require('lzma').LZMA;
|
||||
var lzmaWorker = new LZMA();
|
||||
var lzmaInput = decodeURIComponent(process.argv[2]);
|
||||
var lzmaBuffer = new Buffer(lzmaInput, 'base64')
|
||||
var lzmaBuffer = Buffer.from(lzmaInput, 'base64')
|
||||
.toString('binary')
|
||||
.split('')
|
||||
.map(function(c) {
|
||||
|
@ -1124,7 +1124,7 @@ describe('histogram-dataview for date column type', function() {
|
||||
self.testClient.getDataview('minute_histogram', params, function (err, dataviewWithOffset) {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.notEqual(dataview.offset, dataviewWithOffset.offset);
|
||||
assert.notStrictEqual(dataview.offset, dataviewWithOffset.offset);
|
||||
dataview.offset = dataviewWithOffset.offset;
|
||||
assert.deepStrictEqual(dataview, dataviewWithOffset);
|
||||
done();
|
||||
@ -1158,7 +1158,7 @@ describe('histogram-dataview for date column type', function() {
|
||||
function (err, filteredWithOffsetDataview) {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.notEqual(filteredWithOffsetDataview.offset, filteredDataview.offset);
|
||||
assert.notStrictEqual(filteredWithOffsetDataview.offset, filteredDataview.offset);
|
||||
filteredWithOffsetDataview.offset = filteredDataview.offset;
|
||||
assert.deepStrictEqual(filteredWithOffsetDataview, filteredDataview);
|
||||
done();
|
||||
|
@ -310,7 +310,7 @@ var QueryTables = require('cartodb-query-tables').queryTables;
|
||||
method: 'GET',
|
||||
headers: { host: 'localhost' }
|
||||
}, {}, function (res) {
|
||||
assert.notEqual(res.statusCode, 200);
|
||||
assert.notStrictEqual(res.statusCode, 200);
|
||||
helper.checkNoCache(res);
|
||||
done();
|
||||
});
|
||||
@ -335,7 +335,7 @@ var QueryTables = require('cartodb-query-tables').queryTables;
|
||||
method: 'GET',
|
||||
headers: { host: 'localhost' }
|
||||
}, {}, function (res) {
|
||||
assert.notEqual(res.statusCode, 200);
|
||||
assert.notStrictEqual(res.statusCode, 200);
|
||||
helper.checkNoCache(res);
|
||||
done();
|
||||
});
|
||||
|
@ -195,7 +195,7 @@ describe('layers visibility for previews', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
var next = this;
|
||||
var img = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||
var img = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
|
||||
var previewFixturePath = previewFixture(scenario.name);
|
||||
|
||||
assert.imageIsSimilarToFile(img, previewFixturePath, IMAGE_TOLERANCE, next);
|
||||
|
@ -161,7 +161,7 @@ describe('named maps authentication', function () {
|
||||
function (res, err) {
|
||||
var img;
|
||||
if (!err && res.headers['content-type'] === 'image/png') {
|
||||
img = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||
img = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
|
||||
}
|
||||
return callback(err, res, img);
|
||||
}
|
||||
@ -230,7 +230,7 @@ describe('named maps authentication', function () {
|
||||
function (res, err) {
|
||||
var img;
|
||||
if (!err && res.headers['content-type'] === 'image/png') {
|
||||
img = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||
img = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
|
||||
}
|
||||
return callback(err, res, img);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ describe('named maps static view', function () {
|
||||
|
||||
assert.response(server, requestOptions, expectedResponse, function (res, err) {
|
||||
testHelper.deleteRedisKeys({ 'user:localhost:mapviews:global': 5 }, function () {
|
||||
return callback(err, mapnik.Image.fromBytes(new Buffer(res.body, 'binary')));
|
||||
return callback(err, mapnik.Image.fromBytes(Buffer.from(res.body, 'binary')));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ describe('named maps preview stats', function () {
|
||||
function (res, err) {
|
||||
var img;
|
||||
if (!err && res.headers['content-type'] === 'image/png') {
|
||||
img = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||
img = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
|
||||
}
|
||||
return callback(err, res, img);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ describe('retina support', function () {
|
||||
function (res, err) {
|
||||
assert.ok(!err, 'Failed to request 0/0/0' + scaleFactor + '.png tile');
|
||||
|
||||
var image = new mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||
var image = new mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
|
||||
|
||||
assert.strictEqual(image.width(), imageSize);
|
||||
assert.strictEqual(image.height(), imageSize);
|
||||
|
@ -404,7 +404,7 @@ function getGeneric (layergroupConfig, url, expectedResponse, callback) {
|
||||
|
||||
var img;
|
||||
if (contentType === pngContentType) {
|
||||
img = new mapnik.Image.fromBytesSync(new Buffer(res.body, 'binary'));
|
||||
img = new mapnik.Image.fromBytesSync(Buffer.from(res.body, 'binary'));
|
||||
}
|
||||
|
||||
var keysToDelete = {
|
||||
|
@ -128,7 +128,7 @@ describe('regressions', function () {
|
||||
const timestampA = parseInt(cacheBusterA, 10);
|
||||
const timestampB = parseInt(cacheBusterB, 10);
|
||||
|
||||
assert.notEqual(timestampA, timestampB);
|
||||
assert.notStrictEqual(timestampA, timestampB);
|
||||
assert.ok(timestampA < timestampB, `timestampA: ${timestampA} > timestampB:${timestampB}`);
|
||||
|
||||
testClient.drain(done);
|
||||
|
@ -166,7 +166,7 @@ describe('turbo-carto for named maps', function () {
|
||||
assert.strictEqual(res.headers['content-type'], 'image/png');
|
||||
|
||||
var fixturePath = './test/fixtures/turbo-carto-named-maps-reds.png';
|
||||
var image = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||
var image = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
|
||||
|
||||
assert.imageIsSimilarToFile(image, fixturePath, IMAGE_TOLERANCE_PER_MIL, next);
|
||||
},
|
||||
@ -225,7 +225,7 @@ describe('turbo-carto for named maps', function () {
|
||||
assert.strictEqual(res.headers['content-type'], 'image/png');
|
||||
|
||||
var fixturePath = './test/fixtures/turbo-carto-named-maps-blues.png';
|
||||
var image = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||
var image = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
|
||||
|
||||
assert.imageIsSimilarToFile(image, fixturePath, IMAGE_TOLERANCE_PER_MIL, next);
|
||||
},
|
||||
|
@ -167,7 +167,7 @@ describe('named_layers datasources', function () {
|
||||
assert.strictEqual(layers[1].type, 'cartodb');
|
||||
assert.strictEqual(layers[1].options.sql, wadusTemplateSql);
|
||||
var layerDatasource = datasource.getLayerDatasource(1);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
done();
|
||||
@ -188,13 +188,13 @@ describe('named_layers datasources', function () {
|
||||
assert.strictEqual(layers[1].type, 'mapnik');
|
||||
assert.strictEqual(layers[1].options.sql, wadusMapnikSql);
|
||||
var layerDatasource = datasource.getLayerDatasource(1);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
assert.strictEqual(layers[2].type, 'cartodb');
|
||||
assert.strictEqual(layers[2].options.sql, wadusTemplateSql);
|
||||
layerDatasource = datasource.getLayerDatasource(2);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
done();
|
||||
@ -211,19 +211,19 @@ describe('named_layers datasources', function () {
|
||||
assert.strictEqual(layers[0].type, 'mapnik');
|
||||
assert.strictEqual(layers[0].options.sql, wadusMapnikSql);
|
||||
var layerDatasource = datasource.getLayerDatasource(0);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
assert.strictEqual(layers[1].type, 'cartodb');
|
||||
assert.strictEqual(layers[1].options.sql, wadusTemplateSql);
|
||||
layerDatasource = datasource.getLayerDatasource(1);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
assert.strictEqual(layers[2].type, 'cartodb');
|
||||
assert.strictEqual(layers[2].options.sql, wadusTemplateSql);
|
||||
layerDatasource = datasource.getLayerDatasource(2);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
done();
|
||||
@ -247,19 +247,19 @@ describe('named_layers datasources', function () {
|
||||
assert.strictEqual(layers[0].type, 'cartodb');
|
||||
assert.strictEqual(layers[0].options.sql, wadusTemplateSql);
|
||||
var layerDatasource = datasource.getLayerDatasource(0);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
assert.strictEqual(layers[1].type, 'mapnik');
|
||||
assert.strictEqual(layers[1].options.sql, wadusMapnikSql);
|
||||
layerDatasource = datasource.getLayerDatasource(1);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
assert.strictEqual(layers[2].type, 'cartodb');
|
||||
assert.strictEqual(layers[2].options.sql, wadusTemplateSql);
|
||||
layerDatasource = datasource.getLayerDatasource(2);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
assert.strictEqual(layers[3].type, 'cartodb');
|
||||
@ -269,7 +269,7 @@ describe('named_layers datasources', function () {
|
||||
assert.strictEqual(layers[4].type, 'cartodb');
|
||||
assert.strictEqual(layers[4].options.sql, wadusTemplateSql);
|
||||
layerDatasource = datasource.getLayerDatasource(4);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
assert.strictEqual(layers[5].type, 'cartodb');
|
||||
@ -279,13 +279,13 @@ describe('named_layers datasources', function () {
|
||||
assert.strictEqual(layers[6].type, 'mapnik');
|
||||
assert.strictEqual(layers[6].options.sql, wadusMapnikSql);
|
||||
layerDatasource = datasource.getLayerDatasource(6);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
assert.strictEqual(layers[7].type, 'cartodb');
|
||||
assert.strictEqual(layers[7].options.sql, wadusTemplateSql);
|
||||
layerDatasource = datasource.getLayerDatasource(7);
|
||||
assert.notEqual(layerDatasource, undefined);
|
||||
assert.notStrictEqual(layerDatasource, undefined);
|
||||
assert.ok(layerDatasource.user);
|
||||
|
||||
done();
|
||||
|
@ -235,7 +235,7 @@ describe('mapconfig-named-layers-adapter', function () {
|
||||
var layers = mapConfig.layers;
|
||||
assert.ok(layers.length, 1);
|
||||
assert.ok(layers[0].type, 'cartodb');
|
||||
assert.notEqual(context.datasource.getLayerDatasource(0), undefined);
|
||||
assert.notStrictEqual(context.datasource.getLayerDatasource(0), undefined);
|
||||
|
||||
done();
|
||||
}
|
||||
@ -257,7 +257,7 @@ describe('mapconfig-named-layers-adapter', function () {
|
||||
assert.ok(!err);
|
||||
var layers = mapConfig.layers;
|
||||
assert.strictEqual(layers.length, 1);
|
||||
assert.notEqual(context.datasource.getLayerDatasource(0), undefined);
|
||||
assert.notStrictEqual(context.datasource.getLayerDatasource(0), undefined);
|
||||
|
||||
templateMaps.delTemplate(username, tokenAuthTemplateName, done);
|
||||
}
|
||||
@ -283,11 +283,11 @@ describe('mapconfig-named-layers-adapter', function () {
|
||||
|
||||
assert.strictEqual(layers[0].type, 'mapnik');
|
||||
assert.strictEqual(layers[0].options.cartocss, '#layer { polygon-fill: green; }');
|
||||
assert.notEqual(context.datasource.getLayerDatasource(0), undefined);
|
||||
assert.notStrictEqual(context.datasource.getLayerDatasource(0), undefined);
|
||||
|
||||
assert.strictEqual(layers[1].type, 'cartodb');
|
||||
assert.strictEqual(layers[1].options.cartocss, '#layer { marker-fill: red; }');
|
||||
assert.notEqual(context.datasource.getLayerDatasource(1), undefined);
|
||||
assert.notStrictEqual(context.datasource.getLayerDatasource(1), undefined);
|
||||
|
||||
templateMaps.delTemplate(username, multipleLayersTemplateName, done);
|
||||
}
|
||||
@ -320,11 +320,11 @@ describe('mapconfig-named-layers-adapter', function () {
|
||||
|
||||
assert.strictEqual(layers[0].type, 'mapnik');
|
||||
assert.strictEqual(layers[0].options.cartocss, '#layer { polygon-fill: ' + polygonColor + '; }');
|
||||
assert.notEqual(context.datasource.getLayerDatasource(0), undefined);
|
||||
assert.notStrictEqual(context.datasource.getLayerDatasource(0), undefined);
|
||||
|
||||
assert.strictEqual(layers[1].type, 'cartodb');
|
||||
assert.strictEqual(layers[1].options.cartocss, '#layer { marker-fill: ' + color + '; }');
|
||||
assert.notEqual(context.datasource.getLayerDatasource(1), undefined);
|
||||
assert.notStrictEqual(context.datasource.getLayerDatasource(1), undefined);
|
||||
|
||||
templateMaps.delTemplate(username, multipleLayersTemplateName, done);
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ assert.imageBufferIsSimilarToFile = function (buffer, referenceImageRelativeFile
|
||||
};
|
||||
|
||||
assert.imageBuffersAreSimilar = function (bufferA, bufferB, tolerance, callback) {
|
||||
var testImage = mapnik.Image.fromBytes(Buffer.isBuffer(bufferA) ? bufferA : new Buffer(bufferA, 'binary'));
|
||||
var referenceImage = mapnik.Image.fromBytes(Buffer.isBuffer(bufferB) ? bufferB : new Buffer(bufferB, 'binary'));
|
||||
var testImage = mapnik.Image.fromBytes(Buffer.isBuffer(bufferA) ? bufferA : Buffer.from(bufferA, 'binary'));
|
||||
var referenceImage = mapnik.Image.fromBytes(Buffer.isBuffer(bufferB) ? bufferB : Buffer.from(bufferB, 'binary'));
|
||||
|
||||
imagesAreSimilar(testImage, referenceImage, tolerance, callback);
|
||||
};
|
||||
|
@ -924,11 +924,11 @@ TestClient.prototype.getTile = function (z, x, y, params, callback) {
|
||||
var body;
|
||||
switch (res.headers['content-type']) {
|
||||
case 'image/png':
|
||||
body = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||
body = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
|
||||
break;
|
||||
case 'application/x-protobuf':
|
||||
body = new mapnik.VectorTile(z, x, y);
|
||||
body.setDataSync(new Buffer(res.body, 'binary'));
|
||||
body.setDataSync(Buffer.from(res.body, 'binary'));
|
||||
break;
|
||||
case 'application/json; charset=utf-8':
|
||||
body = JSON.parse(res.body);
|
||||
@ -1098,7 +1098,7 @@ TestClient.prototype.getStaticCenter = function (params, callback) {
|
||||
var body;
|
||||
switch (res.headers['content-type']) {
|
||||
case 'image/png':
|
||||
body = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||
body = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
|
||||
break;
|
||||
case 'application/json; charset=utf-8':
|
||||
body = JSON.parse(res.body);
|
||||
@ -1335,7 +1335,7 @@ module.exports.getStaticMap = function getStaticMap (templateName, params, callb
|
||||
|
||||
assert.response(server, requestOptions, expectedResponse, function (res, err) {
|
||||
helper.deleteRedisKeys({ 'user:localhost:mapviews:global': 5 }, function () {
|
||||
return callback(err, mapnik.Image.fromBytes(new Buffer(res.body, 'binary')));
|
||||
return callback(err, mapnik.Image.fromBytes(Buffer.from(res.body, 'binary')));
|
||||
});
|
||||
});
|
||||
};
|
||||
@ -1537,11 +1537,11 @@ TestClient.prototype.getNamedTile = function (name, z, x, y, format, options, ca
|
||||
let body;
|
||||
switch (res.headers['content-type']) {
|
||||
case 'image/png':
|
||||
body = mapnik.Image.fromBytes(new Buffer(res.body, 'binary'));
|
||||
body = mapnik.Image.fromBytes(Buffer.from(res.body, 'binary'));
|
||||
break;
|
||||
case 'application/x-protobuf':
|
||||
body = new mapnik.VectorTile(z, x, y);
|
||||
body.setDataSync(new Buffer(res.body, 'binary'));
|
||||
body.setDataSync(Buffer.from(res.body, 'binary'));
|
||||
break;
|
||||
case 'application/json; charset=utf-8':
|
||||
body = JSON.parse(res.body);
|
||||
|
@ -33,7 +33,7 @@ function lzma_compress_to_base64 (payload, mode, callback) {
|
||||
lzmaWorker.compress(payload, mode,
|
||||
function (ints) {
|
||||
ints = ints.map(function (c) { return String.fromCharCode(c + 128); }).join('');
|
||||
var base64 = new Buffer(ints, 'binary').toString('base64');
|
||||
var base64 = Buffer.from(ints, 'binary').toString('base64');
|
||||
callback(null, base64);
|
||||
},
|
||||
function (/* percent */) {
|
||||
|
@ -13,6 +13,6 @@ describe('profiler', function () {
|
||||
|
||||
it('Profiler is NOT null in ProfilerProxy when profiling is enabled', function () {
|
||||
var profilerProxy = new ProfilerProxy({ profile: true });
|
||||
assert.notEqual(profilerProxy.profiler, null);
|
||||
assert.notStrictEqual(profilerProxy.profiler, null);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user