File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -317,14 +317,14 @@ class BufferHandler extends ReadOnlyHandler {
317317 if ( args . length > 0 && typeof args [ 0 ] === 'number' ) {
318318 return LocalBuffer . alloc ( args [ 0 ] ) ;
319319 }
320- return localReflectApply ( LocalBuffer . from , LocalBuffer , args ) ;
320+ return apply ( LocalBuffer . from , LocalBuffer , args ) ;
321321 }
322322
323323 construct ( target , args , newTarget ) {
324324 if ( args . length > 0 && typeof args [ 0 ] === 'number' ) {
325325 return LocalBuffer . alloc ( args [ 0 ] ) ;
326326 }
327- return localReflectApply ( LocalBuffer . from , LocalBuffer , args ) ;
327+ return apply ( LocalBuffer . from , LocalBuffer , args ) ;
328328 }
329329}
330330/* eslint-enable no-use-before-define */
Original file line number Diff line number Diff line change @@ -322,6 +322,20 @@ describe('contextify', () => {
322322 assert . ok ( d . constructor . constructor === Function ) ;
323323 } ) ;
324324
325+ it ( 'buffer (deprecated constructor)' , ( ) => {
326+ const result = vm . run ( 'new Buffer("Hello")' ) ;
327+ assert . ok ( result instanceof Buffer , '#1' ) ;
328+ assert . strictEqual ( result . toString ( ) , 'Hello' , '#2' ) ;
329+
330+ const result2 = vm . run ( 'new Buffer(5)' ) ;
331+ assert . ok ( result2 instanceof Buffer , '#3' ) ;
332+ assert . strictEqual ( result2 . length , 5 , '#4' ) ;
333+
334+ const result3 = vm . run ( 'Buffer("Hello")' ) ;
335+ assert . ok ( result3 instanceof Buffer , '#5' ) ;
336+ assert . strictEqual ( result3 . toString ( ) , 'Hello' , '#6' ) ;
337+ } ) ;
338+
325339 it ( 'function' , ( ) => {
326340 assert . strictEqual ( vm . run ( 'test.function instanceof Function' ) , true , '#1' ) ;
327341 assert . strictEqual ( vm . run ( 'test.function() instanceof Function' ) , true , '#2' ) ;
You can’t perform that action at this time.
0 commit comments