@@ -8,7 +8,7 @@ ip.toBuffer = function (ip, buff, offset) {
8
8
let result ;
9
9
10
10
if ( this . isV4Format ( ip ) ) {
11
- result = buff || new Buffer ( offset + 4 ) ;
11
+ result = buff || Buffer . alloc ( offset + 4 ) ;
12
12
ip . split ( / \. / g) . map ( ( byte ) => {
13
13
result [ offset ++ ] = parseInt ( byte , 10 ) & 0xff ;
14
14
} ) ;
@@ -43,7 +43,7 @@ ip.toBuffer = function (ip, buff, offset) {
43
43
sections . splice ( ...argv ) ;
44
44
}
45
45
46
- result = buff || new Buffer ( offset + 16 ) ;
46
+ result = buff || Buffer . alloc ( offset + 16 ) ;
47
47
for ( i = 0 ; i < sections . length ; i ++ ) {
48
48
const word = parseInt ( sections [ i ] , 16 ) ;
49
49
result [ offset ++ ] = ( word >> 8 ) & 0xff ;
@@ -114,7 +114,7 @@ ip.fromPrefixLen = function (prefixlen, family) {
114
114
if ( family === 'ipv6' ) {
115
115
len = 16 ;
116
116
}
117
- const buff = new Buffer ( len ) ;
117
+ const buff = Buffer . alloc ( len ) ;
118
118
119
119
for ( let i = 0 , n = buff . length ; i < n ; ++ i ) {
120
120
let bits = 8 ;
@@ -133,7 +133,7 @@ ip.mask = function (addr, mask) {
133
133
addr = ip . toBuffer ( addr ) ;
134
134
mask = ip . toBuffer ( mask ) ;
135
135
136
- const result = new Buffer ( Math . max ( addr . length , mask . length ) ) ;
136
+ const result = Buffer . alloc ( Math . max ( addr . length , mask . length ) ) ;
137
137
138
138
// Same protocol - do bitwise and
139
139
let i ;
0 commit comments