@@ -32,7 +32,9 @@ assert.strictEqual(0, d.length);
32
32
33
33
var ui32 = new Uint32Array ( 4 ) . fill ( 42 ) ;
34
34
var e = Buffer . from ( ui32 ) ;
35
- assert . deepEqual ( ui32 , e ) ;
35
+ for ( const [ index , value ] of e . entries ( ) ) {
36
+ assert . strictEqual ( value , ui32 [ index ] ) ;
37
+ }
36
38
37
39
// First check Buffer#fill() works as expected.
38
40
@@ -463,32 +465,32 @@ for (let i = 0; i < Buffer.byteLength(utf8String); i++) {
463
465
assert . equal ( d [ 0 ] , 23 ) ;
464
466
assert . equal ( d [ 1 ] , 42 ) ;
465
467
assert . equal ( d [ 2 ] , 255 ) ;
466
- assert . deepEqual ( d , Buffer . from ( d ) ) ;
468
+ assert . deepStrictEqual ( d , Buffer . from ( d ) ) ;
467
469
}
468
470
469
471
{
470
472
const e = Buffer . from ( 'über' ) ;
471
473
console . error ( 'uber: \'%s\'' , e . toString ( ) ) ;
472
- assert . deepEqual ( e , Buffer . from ( [ 195 , 188 , 98 , 101 , 114 ] ) ) ;
474
+ assert . deepStrictEqual ( e , Buffer . from ( [ 195 , 188 , 98 , 101 , 114 ] ) ) ;
473
475
}
474
476
475
477
{
476
478
const f = Buffer . from ( 'über' , 'ascii' ) ;
477
479
console . error ( 'f.length: %d (should be 4)' , f . length ) ;
478
- assert . deepEqual ( f , Buffer . from ( [ 252 , 98 , 101 , 114 ] ) ) ;
480
+ assert . deepStrictEqual ( f , Buffer . from ( [ 252 , 98 , 101 , 114 ] ) ) ;
479
481
}
480
482
481
483
[ 'ucs2' , 'ucs-2' , 'utf16le' , 'utf-16le' ] . forEach ( function ( encoding ) {
482
484
{
483
485
const f = Buffer . from ( 'über' , encoding ) ;
484
486
console . error ( 'f.length: %d (should be 8)' , f . length ) ;
485
- assert . deepEqual ( f , Buffer . from ( [ 252 , 0 , 98 , 0 , 101 , 0 , 114 , 0 ] ) ) ;
487
+ assert . deepStrictEqual ( f , Buffer . from ( [ 252 , 0 , 98 , 0 , 101 , 0 , 114 , 0 ] ) ) ;
486
488
}
487
489
488
490
{
489
491
const f = Buffer . from ( 'привет' , encoding ) ;
490
492
console . error ( 'f.length: %d (should be 12)' , f . length ) ;
491
- assert . deepEqual ( f ,
493
+ assert . deepStrictEqual ( f ,
492
494
Buffer . from ( [ 63 , 4 , 64 , 4 , 56 , 4 , 50 , 4 , 53 , 4 , 66 , 4 ] ) ) ;
493
495
assert . equal ( f . toString ( encoding ) , 'привет' ) ;
494
496
}
@@ -499,23 +501,23 @@ for (let i = 0; i < Buffer.byteLength(utf8String); i++) {
499
501
const size = f . write ( 'あいうえお' , encoding ) ;
500
502
console . error ( 'bytes written to buffer: %d (should be 4)' , size ) ;
501
503
assert . equal ( size , 4 ) ;
502
- assert . deepEqual ( f , Buffer . from ( [ 0x42 , 0x30 , 0x44 , 0x30 , 0x00 ] ) ) ;
504
+ assert . deepStrictEqual ( f , Buffer . from ( [ 0x42 , 0x30 , 0x44 , 0x30 , 0x00 ] ) ) ;
503
505
}
504
506
} ) ;
505
507
506
508
{
507
509
const f = Buffer . from ( '\uD83D\uDC4D' , 'utf-16le' ) ; // THUMBS UP SIGN (U+1F44D)
508
510
assert . equal ( f . length , 4 ) ;
509
- assert . deepEqual ( f , Buffer . from ( '3DD84DDC' , 'hex' ) ) ;
511
+ assert . deepStrictEqual ( f , Buffer . from ( '3DD84DDC' , 'hex' ) ) ;
510
512
}
511
513
512
514
513
515
var arrayIsh = { 0 : 0 , 1 : 1 , 2 : 2 , 3 : 3 , length : 4 } ;
514
516
var g = Buffer . from ( arrayIsh ) ;
515
- assert . deepEqual ( g , Buffer . from ( [ 0 , 1 , 2 , 3 ] ) ) ;
517
+ assert . deepStrictEqual ( g , Buffer . from ( [ 0 , 1 , 2 , 3 ] ) ) ;
516
518
var strArrayIsh = { 0 : '0' , 1 : '1' , 2 : '2' , 3 : '3' , length : 4 } ;
517
519
g = Buffer . from ( strArrayIsh ) ;
518
- assert . deepEqual ( g , Buffer . from ( [ 0 , 1 , 2 , 3 ] ) ) ;
520
+ assert . deepStrictEqual ( g , Buffer . from ( [ 0 , 1 , 2 , 3 ] ) ) ;
519
521
520
522
521
523
//
@@ -526,10 +528,10 @@ assert.equal('TWFu', (Buffer.from('Man')).toString('base64'));
526
528
{
527
529
// test that regular and URL-safe base64 both work
528
530
const expected = [ 0xff , 0xff , 0xbe , 0xff , 0xef , 0xbf , 0xfb , 0xef , 0xff ] ;
529
- assert . deepEqual ( Buffer . from ( '//++/++/++//' , 'base64' ) ,
530
- Buffer . from ( expected ) ) ;
531
- assert . deepEqual ( Buffer . from ( '__--_--_--__' , 'base64' ) ,
532
- Buffer . from ( expected ) ) ;
531
+ assert . deepStrictEqual ( Buffer . from ( '//++/++/++//' , 'base64' ) ,
532
+ Buffer . from ( expected ) ) ;
533
+ assert . deepStrictEqual ( Buffer . from ( '__--_--_--__' , 'base64' ) ,
534
+ Buffer . from ( expected ) ) ;
533
535
}
534
536
535
537
{
@@ -1021,7 +1023,7 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);
1021
1023
1022
1024
assert . equal ( string , '{"type":"Buffer","data":[116,101,115,116]}' ) ;
1023
1025
1024
- assert . deepEqual ( buffer , JSON . parse ( string , function ( key , value ) {
1026
+ assert . deepStrictEqual ( buffer , JSON . parse ( string , function ( key , value ) {
1025
1027
return value && value . type === 'Buffer'
1026
1028
? Buffer . from ( value . data )
1027
1029
: value ;
@@ -1167,92 +1169,92 @@ assert.throws(function() {
1167
1169
( function ( ) {
1168
1170
var buf = Buffer . allocUnsafe ( 3 ) ;
1169
1171
buf . writeUIntLE ( 0x123456 , 0 , 3 ) ;
1170
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x56 , 0x34 , 0x12 ] ) ;
1172
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x56 , 0x34 , 0x12 ] ) ;
1171
1173
assert . equal ( buf . readUIntLE ( 0 , 3 ) , 0x123456 ) ;
1172
1174
1173
1175
buf = Buffer . allocUnsafe ( 3 ) ;
1174
1176
buf . writeUIntBE ( 0x123456 , 0 , 3 ) ;
1175
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x12 , 0x34 , 0x56 ] ) ;
1177
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x12 , 0x34 , 0x56 ] ) ;
1176
1178
assert . equal ( buf . readUIntBE ( 0 , 3 ) , 0x123456 ) ;
1177
1179
1178
1180
buf = Buffer . allocUnsafe ( 3 ) ;
1179
1181
buf . writeIntLE ( 0x123456 , 0 , 3 ) ;
1180
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x56 , 0x34 , 0x12 ] ) ;
1182
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x56 , 0x34 , 0x12 ] ) ;
1181
1183
assert . equal ( buf . readIntLE ( 0 , 3 ) , 0x123456 ) ;
1182
1184
1183
1185
buf = Buffer . allocUnsafe ( 3 ) ;
1184
1186
buf . writeIntBE ( 0x123456 , 0 , 3 ) ;
1185
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x12 , 0x34 , 0x56 ] ) ;
1187
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x12 , 0x34 , 0x56 ] ) ;
1186
1188
assert . equal ( buf . readIntBE ( 0 , 3 ) , 0x123456 ) ;
1187
1189
1188
1190
buf = Buffer . allocUnsafe ( 3 ) ;
1189
1191
buf . writeIntLE ( - 0x123456 , 0 , 3 ) ;
1190
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0xaa , 0xcb , 0xed ] ) ;
1192
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0xaa , 0xcb , 0xed ] ) ;
1191
1193
assert . equal ( buf . readIntLE ( 0 , 3 ) , - 0x123456 ) ;
1192
1194
1193
1195
buf = Buffer . allocUnsafe ( 3 ) ;
1194
1196
buf . writeIntBE ( - 0x123456 , 0 , 3 ) ;
1195
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0xed , 0xcb , 0xaa ] ) ;
1197
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0xed , 0xcb , 0xaa ] ) ;
1196
1198
assert . equal ( buf . readIntBE ( 0 , 3 ) , - 0x123456 ) ;
1197
1199
1198
1200
buf = Buffer . allocUnsafe ( 3 ) ;
1199
1201
buf . writeIntLE ( - 0x123400 , 0 , 3 ) ;
1200
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x00 , 0xcc , 0xed ] ) ;
1202
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x00 , 0xcc , 0xed ] ) ;
1201
1203
assert . equal ( buf . readIntLE ( 0 , 3 ) , - 0x123400 ) ;
1202
1204
1203
1205
buf = Buffer . allocUnsafe ( 3 ) ;
1204
1206
buf . writeIntBE ( - 0x123400 , 0 , 3 ) ;
1205
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0xed , 0xcc , 0x00 ] ) ;
1207
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0xed , 0xcc , 0x00 ] ) ;
1206
1208
assert . equal ( buf . readIntBE ( 0 , 3 ) , - 0x123400 ) ;
1207
1209
1208
1210
buf = Buffer . allocUnsafe ( 3 ) ;
1209
1211
buf . writeIntLE ( - 0x120000 , 0 , 3 ) ;
1210
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x00 , 0x00 , 0xee ] ) ;
1212
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x00 , 0x00 , 0xee ] ) ;
1211
1213
assert . equal ( buf . readIntLE ( 0 , 3 ) , - 0x120000 ) ;
1212
1214
1213
1215
buf = Buffer . allocUnsafe ( 3 ) ;
1214
1216
buf . writeIntBE ( - 0x120000 , 0 , 3 ) ;
1215
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0xee , 0x00 , 0x00 ] ) ;
1217
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0xee , 0x00 , 0x00 ] ) ;
1216
1218
assert . equal ( buf . readIntBE ( 0 , 3 ) , - 0x120000 ) ;
1217
1219
1218
1220
buf = Buffer . allocUnsafe ( 5 ) ;
1219
1221
buf . writeUIntLE ( 0x1234567890 , 0 , 5 ) ;
1220
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x90 , 0x78 , 0x56 , 0x34 , 0x12 ] ) ;
1222
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x90 , 0x78 , 0x56 , 0x34 , 0x12 ] ) ;
1221
1223
assert . equal ( buf . readUIntLE ( 0 , 5 ) , 0x1234567890 ) ;
1222
1224
1223
1225
buf = Buffer . allocUnsafe ( 5 ) ;
1224
1226
buf . writeUIntBE ( 0x1234567890 , 0 , 5 ) ;
1225
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x12 , 0x34 , 0x56 , 0x78 , 0x90 ] ) ;
1227
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x12 , 0x34 , 0x56 , 0x78 , 0x90 ] ) ;
1226
1228
assert . equal ( buf . readUIntBE ( 0 , 5 ) , 0x1234567890 ) ;
1227
1229
1228
1230
buf = Buffer . allocUnsafe ( 5 ) ;
1229
1231
buf . writeIntLE ( 0x1234567890 , 0 , 5 ) ;
1230
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x90 , 0x78 , 0x56 , 0x34 , 0x12 ] ) ;
1232
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x90 , 0x78 , 0x56 , 0x34 , 0x12 ] ) ;
1231
1233
assert . equal ( buf . readIntLE ( 0 , 5 ) , 0x1234567890 ) ;
1232
1234
1233
1235
buf = Buffer . allocUnsafe ( 5 ) ;
1234
1236
buf . writeIntBE ( 0x1234567890 , 0 , 5 ) ;
1235
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x12 , 0x34 , 0x56 , 0x78 , 0x90 ] ) ;
1237
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x12 , 0x34 , 0x56 , 0x78 , 0x90 ] ) ;
1236
1238
assert . equal ( buf . readIntBE ( 0 , 5 ) , 0x1234567890 ) ;
1237
1239
1238
1240
buf = Buffer . allocUnsafe ( 5 ) ;
1239
1241
buf . writeIntLE ( - 0x1234567890 , 0 , 5 ) ;
1240
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x70 , 0x87 , 0xa9 , 0xcb , 0xed ] ) ;
1242
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x70 , 0x87 , 0xa9 , 0xcb , 0xed ] ) ;
1241
1243
assert . equal ( buf . readIntLE ( 0 , 5 ) , - 0x1234567890 ) ;
1242
1244
1243
1245
buf = Buffer . allocUnsafe ( 5 ) ;
1244
1246
buf . writeIntBE ( - 0x1234567890 , 0 , 5 ) ;
1245
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0xed , 0xcb , 0xa9 , 0x87 , 0x70 ] ) ;
1247
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0xed , 0xcb , 0xa9 , 0x87 , 0x70 ] ) ;
1246
1248
assert . equal ( buf . readIntBE ( 0 , 5 ) , - 0x1234567890 ) ;
1247
1249
1248
1250
buf = Buffer . allocUnsafe ( 5 ) ;
1249
1251
buf . writeIntLE ( - 0x0012000000 , 0 , 5 ) ;
1250
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0x00 , 0x00 , 0x00 , 0xee , 0xff ] ) ;
1252
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0x00 , 0x00 , 0x00 , 0xee , 0xff ] ) ;
1251
1253
assert . equal ( buf . readIntLE ( 0 , 5 ) , - 0x0012000000 ) ;
1252
1254
1253
1255
buf = Buffer . allocUnsafe ( 5 ) ;
1254
1256
buf . writeIntBE ( - 0x0012000000 , 0 , 5 ) ;
1255
- assert . deepEqual ( buf . toJSON ( ) . data , [ 0xff , 0xee , 0x00 , 0x00 , 0x00 ] ) ;
1257
+ assert . deepStrictEqual ( buf . toJSON ( ) . data , [ 0xff , 0xee , 0x00 , 0x00 , 0x00 ] ) ;
1256
1258
assert . equal ( buf . readIntBE ( 0 , 5 ) , - 0x0012000000 ) ;
1257
1259
} ) ( ) ;
1258
1260
@@ -1292,7 +1294,7 @@ assert.throws(function() {
1292
1294
}
1293
1295
1294
1296
var utf16Buf = Buffer . from ( '0123456789' , 'utf16le' ) ;
1295
- assert . deepEqual ( utf16Buf . slice ( 0 , 6 ) , Buffer . from ( '012' , 'utf16le' ) ) ;
1297
+ assert . deepStrictEqual ( utf16Buf . slice ( 0 , 6 ) , Buffer . from ( '012' , 'utf16le' ) ) ;
1296
1298
1297
1299
assert . equal ( buf . slice ( '0' , '1' ) , '0' ) ;
1298
1300
assert . equal ( buf . slice ( '-5' , '10' ) , '56789' ) ;
0 commit comments