File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed
Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ const common = require ( '../common.js' ) ;
3+
4+ const bench = common . createBenchmark ( main , {
5+ bytes : [ 0 , 8 , 128 ] ,
6+ n : [ 1e6 ] ,
7+ operation : [ 'text' , 'arrayBuffer' , 'stream' ]
8+ } ) ;
9+
10+ function main ( { n, bytes, operation } ) {
11+ const buff = Buffer . allocUnsafe ( bytes ) ;
12+ const source = new Blob ( buff ) ;
13+ bench . start ( ) ;
14+ for ( let i = 0 ; i < n ; i ++ ) {
15+ switch ( operation ) {
16+ case 'text' :
17+ source . text ( ) ;
18+ break ;
19+ case 'arrayBuffer' :
20+ source . arrayBuffer ( ) ;
21+ break ;
22+ case 'stream' :
23+ source . stream ( ) ;
24+ break ;
25+ }
26+ }
27+ bench . end ( n ) ;
28+ }
Original file line number Diff line number Diff line change 88 PromiseResolve,
99 PromiseReject,
1010 SafePromisePrototypeFinally,
11+ PromisePrototypeThen,
1112 ReflectConstruct,
1213 RegExpPrototypeExec,
1314 RegExpPrototypeSymbolReplace,
@@ -308,13 +309,13 @@ class Blob {
308309 /**
309310 * @returns {Promise<string> }
310311 */
311- async text ( ) {
312+ text ( ) {
312313 if ( ! isBlob ( this ) )
313- throw new ERR_INVALID_THIS ( 'Blob' ) ;
314+ return PromiseReject ( new ERR_INVALID_THIS ( 'Blob' ) ) ;
314315
315316 dec ??= new TextDecoder ( ) ;
316317
317- return dec . decode ( await this . arrayBuffer ( ) ) ;
318+ return PromisePrototypeThen ( this . arrayBuffer ( ) , ( value ) => dec . decode ( value ) ) ;
318319 }
319320
320321 /**
You can’t perform that action at this time.
0 commit comments