From 47ecb1abeeb940ed4a58c5c5091a5b358b833383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladan=20Kudl=C3=A1=C4=8D?= Date: Wed, 8 Jan 2025 18:46:29 +0100 Subject: [PATCH] Replace deprecated Node Buffer constructor --- platform/node/test/js/map.test.js | 8 ++++---- test/fixtures/sprites/convert_sprite.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/platform/node/test/js/map.test.js b/platform/node/test/js/map.test.js index 60948721d9d..3d1f291246a 100644 --- a/platform/node/test/js/map.test.js +++ b/platform/node/test/js/map.test.js @@ -199,7 +199,7 @@ test('Map', function(t) { var map = new mbgl.Map(options); t.throws(function() { - map.addImage('foo', new Buffer(''), { + map.addImage('foo', Buffer.from(''), { width: 401, height: 400, pixelRatio: 1 @@ -214,7 +214,7 @@ test('Map', function(t) { var map = new mbgl.Map(options); t.throws(function() { - map.addImage('foo', new Buffer(''), { + map.addImage('foo', Buffer.from(''), { width: 1025, height: 1025, pixelRatio: 1 @@ -230,7 +230,7 @@ test('Map', function(t) { var map = new mbgl.Map(options); t.throws(function() { - map.addImage('foo', new Buffer(' '), { + map.addImage('foo', Buffer.from(' '), { width: 401, height: 400, pixelRatio: 1 @@ -245,7 +245,7 @@ test('Map', function(t) { var map = new mbgl.Map(options); t.doesNotThrow(function() { - map.addImage('foo', new Buffer(' '), { + map.addImage('foo', Buffer.from(' '), { width: 1, height: 1, pixelRatio: 1 diff --git a/test/fixtures/sprites/convert_sprite.js b/test/fixtures/sprites/convert_sprite.js index ba4ff5c29f0..bf279f95de2 100644 --- a/test/fixtures/sprites/convert_sprite.js +++ b/test/fixtures/sprites/convert_sprite.js @@ -7,7 +7,7 @@ var zlib = require('zlib'); var PNG = require('png-js'); var png = PNG.load('styles/sprites/bright.png'); png.decodePixels(function(data) { - var result = new Buffer(8 + data.length); + var result = Buffer.alloc(8 + data.length); result.writeUInt32BE(png.width, 0); result.writeUInt32BE(png.height, 4); data.copy(result, 8);