Replace deprecated Node Buffer constructor (#3126)

This commit is contained in:
Vladan Kudláč
2025-03-05 02:01:02 +01:00
committed by GitHub
parent 422ee45123
commit e6ce277589
2 changed files with 5 additions and 5 deletions

View File

@@ -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

View File

@@ -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);