@@ -10,23 +10,23 @@ const HiredisParser = require('../test/hiredis')
10
10
function returnError ( error ) { }
11
11
function checkReply ( error , res ) { }
12
12
13
- const startBuffer = new Buffer ( '$100\r\nabcdefghij' )
14
- const chunkBuffer = new Buffer ( 'abcdefghijabcdefghijabcdefghij' )
15
- const stringBuffer = new Buffer ( '+testing a simple string\r\n' )
16
- const integerBuffer = new Buffer ( ':1237884\r\n' )
17
- const bigIntegerBuffer = new Buffer ( ':184467440737095516171234567890\r\n' ) // 2^64 + 1
18
- const errorBuffer = new Buffer ( '-Error ohnoesitbroke\r\n' )
19
- const endBuffer = new Buffer ( '\r\n' )
13
+ const startBuffer = Buffer . from ( '$100\r\nabcdefghij' )
14
+ const chunkBuffer = Buffer . from ( 'abcdefghijabcdefghijabcdefghij' )
15
+ const stringBuffer = Buffer . from ( '+testing a simple string\r\n' )
16
+ const integerBuffer = Buffer . from ( ':1237884\r\n' )
17
+ const bigIntegerBuffer = Buffer . from ( ':184467440737095516171234567890\r\n' ) // 2^64 + 1
18
+ const errorBuffer = Buffer . from ( '-Error ohnoesitbroke\r\n' )
19
+ const endBuffer = Buffer . from ( '\r\n' )
20
20
const lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, ' +
21
21
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ' +
22
22
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ' +
23
23
'ut aliquip ex ea commodo consequat. Duis aute irure dolor in' // 256 chars
24
24
const bigStringArray = ( new Array ( Math . pow ( 2 , 16 ) / lorem . length ) . join ( lorem + ' ' ) ) . split ( ' ' ) // Math.pow(2, 16) chars long
25
- const startBigBuffer = new Buffer ( '$' + ( 4 * 1024 * 1024 ) + '\r\n' )
25
+ const startBigBuffer = Buffer . from ( '$' + ( 4 * 1024 * 1024 ) + '\r\n' )
26
26
27
27
const chunks = new Array ( 64 )
28
28
for ( var i = 0 ; i < 64 ; i ++ ) {
29
- chunks [ i ] = new Buffer ( bigStringArray . join ( ' ' ) + '.' ) // Math.pow(2, 16) chars long
29
+ chunks [ i ] = Buffer . from ( bigStringArray . join ( ' ' ) + '.' ) // Math.pow(2, 16) chars long
30
30
}
31
31
32
32
const arraySize = 100
@@ -38,24 +38,24 @@ for (i = 0; i < arraySize; i++) {
38
38
array += size + '\r\n' + lorem . slice ( 0 , size ) + '\r\n'
39
39
}
40
40
41
- const arrayBuffer = new Buffer ( array )
41
+ const arrayBuffer = Buffer . from ( array )
42
42
43
43
const bigArraySize = 160
44
- const bigArrayChunks = [ new Buffer ( '*1\r\n*1\r\n*' + bigArraySize ) ]
44
+ const bigArrayChunks = [ Buffer . from ( '*1\r\n*1\r\n*' + bigArraySize ) ]
45
45
for ( i = 0 ; i < bigArraySize ; i ++ ) {
46
46
// A chunk has a maximum size of 2^16 bytes.
47
47
size = 65000 + i
48
48
if ( i % 2 ) {
49
49
// The "x" in the beginning is important to prevent benchmark manipulation due to a minor jsparser optimization
50
- bigArrayChunks . push ( new Buffer ( 'x\r\n$' + size + '\r\n' + Array ( size + 1 ) . join ( 'a' ) + '\r\n:' + ( Math . random ( ) * 1000000 | 0 ) ) )
50
+ bigArrayChunks . push ( Buffer . from ( 'x\r\n$' + size + '\r\n' + Array ( size + 1 ) . join ( 'a' ) + '\r\n:' + ( Math . random ( ) * 1000000 | 0 ) ) )
51
51
} else {
52
- bigArrayChunks . push ( new Buffer ( '\r\n+this is some short text about nothing\r\n:' + size + '\r\n$' + size + '\r\n' + Array ( size ) . join ( 'b' ) ) )
52
+ bigArrayChunks . push ( Buffer . from ( '\r\n+this is some short text about nothing\r\n:' + size + '\r\n$' + size + '\r\n' + Array ( size ) . join ( 'b' ) ) )
53
53
}
54
54
}
55
- bigArrayChunks . push ( new Buffer ( '\r\n' ) )
55
+ bigArrayChunks . push ( Buffer . from ( '\r\n' ) )
56
56
57
- const chunkedStringPart1 = new Buffer ( '+foobar' )
58
- const chunkedStringPart2 = new Buffer ( 'bazEND\r\n' )
57
+ const chunkedStringPart1 = Buffer . from ( '+foobar' )
58
+ const chunkedStringPart2 = Buffer . from ( 'bazEND\r\n' )
59
59
60
60
const options = {
61
61
returnReply : checkReply ,
0 commit comments