@@ -3,7 +3,7 @@ var test = require('tape')
3
3
var HashBase = require ( '../' )
4
4
5
5
var utf8text = 'УТФ-8 text'
6
- var utf8buf = new Buffer ( utf8text , 'utf8' )
6
+ var utf8buf = Buffer . from ( utf8text , 'utf8' )
7
7
function noop ( ) { }
8
8
9
9
function createHashBase ( t ) { t . base = new HashBase ( 64 ) }
@@ -38,7 +38,7 @@ test('HashBase#_transform', function (t) {
38
38
t . plan ( 1 )
39
39
var err = new Error ( 'hey' )
40
40
t . base . update = function ( ) { throw err }
41
- t . base . _transform ( new Buffer ( 0 ) , 'buffer' , function ( _err ) {
41
+ t . base . _transform ( Buffer . allocUnsafe ( 0 ) , 'buffer' , function ( _err ) {
42
42
t . true ( _err === err )
43
43
} )
44
44
t . end ( )
@@ -52,7 +52,7 @@ test('HashBase#_flush', function (t) {
52
52
53
53
t . test ( 'should use HashBase#digest' , function ( t ) {
54
54
t . plan ( 2 )
55
- var buffer = new Buffer ( 0 )
55
+ var buffer = Buffer . allocUnsafe ( 0 )
56
56
t . base . push = function ( data ) { t . true ( data === buffer ) }
57
57
t . base . digest = function ( ) { return buffer }
58
58
t . base . _flush ( function ( err ) { t . same ( err , null ) } )
@@ -92,13 +92,13 @@ test('HashBase#update', function (t) {
92
92
t . test ( 'should use HashBase#_update' , function ( t ) {
93
93
t . plan ( 1 )
94
94
t . base . _update = t . pass
95
- t . base . update ( new Buffer ( 64 ) )
95
+ t . base . update ( Buffer . allocUnsafe ( 64 ) )
96
96
t . end ( )
97
97
} )
98
98
99
99
t . test ( 'default encoding is utf8' , function ( t ) {
100
100
t . plan ( 1 )
101
- var buffer = new Buffer ( 64 )
101
+ var buffer = Buffer . allocUnsafe ( 64 )
102
102
buffer . fill ( 0 )
103
103
utf8buf . copy ( buffer )
104
104
t . base . _update = function ( ) { t . same ( this . _block , buffer ) }
@@ -108,22 +108,21 @@ test('HashBase#update', function (t) {
108
108
109
109
t . test ( 'decode string with custom encoding' , function ( t ) {
110
110
t . plan ( 1 )
111
- var buffer = new Buffer ( 64 )
112
- buffer . fill ( 0x42 )
111
+ var buffer = Buffer . allocUnsafe ( 64 ) . fill ( 0x42 )
113
112
t . base . _update = function ( ) { t . same ( this . _block , buffer ) }
114
113
t . base . update ( buffer . toString ( 'hex' ) , 'hex' )
115
114
t . end ( )
116
115
} )
117
116
118
117
t . test ( 'data length is more than 2^32 bits' , function ( t ) {
119
118
t . base . _length = [ Math . pow ( 2 , 32 ) - 1 , 0 , 0 , 0 ]
120
- t . base . update ( new Buffer ( 1 ) )
119
+ t . base . update ( Buffer . allocUnsafe ( 1 ) )
121
120
t . same ( t . base . _length , [ 7 , 1 , 0 , 0 ] )
122
121
t . end ( )
123
122
} )
124
123
125
124
t . test ( 'should return `this`' , function ( t ) {
126
- t . same ( t . base . update ( new Buffer ( 0 ) ) , t . base )
125
+ t . same ( t . base . update ( Buffer . allocUnsafe ( 0 ) ) , t . base )
127
126
t . end ( )
128
127
} )
129
128
0 commit comments