@@ -305,25 +305,30 @@ class Buffer extends Uint8Array {
305
305
else
306
306
super ( allocPool , offset , bufferOrLength ) ;
307
307
}
308
- else if ( typeof bufferOrLength === 'string' ) {
309
- var codec = byte_offset ;
310
- if ( codec === undefined || codec === 'utf8' || codec === 'utf-8' || codec == 'ascii' || codec === 'binary' ) {
311
- var byte_length = Buffer . byteLength ( bufferOrLength , codec ) ;
312
-
313
- let offset = getPool ( byte_length ) ;
314
- if ( offset === - 1 )
315
- super ( byte_length ) ;
316
- else
317
- super ( allocPool , offset , byte_length ) ;
318
-
319
- this . write ( bufferOrLength , codec ) ;
320
- } else
321
- super ( encoding . decode ( bufferOrLength , codec ) . buffer ) ;
322
- }
323
308
else if ( bufferOrLength instanceof Uint8Array || Array . isArray ( bufferOrLength ) )
324
309
super ( bufferOrLength ) ;
325
- else
326
- super ( bufferOrLength , byte_offset , byte_length ) ;
310
+ else {
311
+ if ( bufferOrLength instanceof Date )
312
+ bufferOrLength = bufferOrLength . toString ( ) ;
313
+
314
+ if ( typeof bufferOrLength === 'string' ) {
315
+ var codec = byte_offset ;
316
+ if ( codec === undefined || codec === 'utf8' || codec === 'utf-8' || codec == 'ascii' || codec === 'binary' ) {
317
+ var byte_length = Buffer . byteLength ( bufferOrLength , codec ) ;
318
+
319
+ let offset = getPool ( byte_length ) ;
320
+ if ( offset === - 1 )
321
+ super ( byte_length ) ;
322
+ else
323
+ super ( allocPool , offset , byte_length ) ;
324
+
325
+ this . write ( bufferOrLength , codec ) ;
326
+ } else
327
+ super ( encoding . decode ( bufferOrLength , codec ) . buffer ) ;
328
+ }
329
+ else
330
+ super ( bufferOrLength , byte_offset , byte_length ) ;
331
+ }
327
332
}
328
333
329
334
write ( buf , offset , length , codec ) {
0 commit comments