File tree Expand file tree Collapse file tree 2 files changed +16
-18
lines changed
Expand file tree Collapse file tree 2 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -2138,18 +2138,8 @@ void Kill(const FunctionCallbackInfo<Value>& args) {
21382138// and nanoseconds, to avoid any integer overflow possibility.
21392139// Pass in an Array from a previous hrtime() call to instead get a time diff.
21402140void Hrtime (const FunctionCallbackInfo<Value>& args) {
2141- Environment* env = Environment::GetCurrent (args);
2142-
21432141 uint64_t t = uv_hrtime ();
21442142
2145- if (!args[1 ]->IsUndefined ()) {
2146- if (!args[1 ]->IsArray ()) {
2147- return env->ThrowTypeError (
2148- " process.hrtime() only accepts an Array tuple" );
2149- }
2150- args.GetReturnValue ().Set (true );
2151- }
2152-
21532143 Local<ArrayBuffer> ab = args[0 ].As <Uint32Array>()->Buffer ();
21542144 uint32_t * fields = static_cast <uint32_t *>(ab->GetContents ().Data ());
21552145
Original file line number Diff line number Diff line change 192192 }
193193
194194 process . hrtime = function hrtime ( ar ) {
195- const ret = [ 0 , 0 ] ;
196- if ( _hrtime ( hrValues , ar ) ) {
197- ret [ 0 ] = ( hrValues [ 0 ] * 0x100000000 + hrValues [ 1 ] ) - ar [ 0 ] ;
198- ret [ 1 ] = hrValues [ 2 ] - ar [ 1 ] ;
199- } else {
200- ret [ 0 ] = hrValues [ 0 ] * 0x100000000 + hrValues [ 1 ] ;
201- ret [ 1 ] = hrValues [ 2 ] ;
195+ _hrtime ( hrValues ) ;
196+
197+ if ( typeof ar !== 'undefined' ) {
198+ if ( Array . isArray ( ar ) ) {
199+ return [
200+ ( hrValues [ 0 ] * 0x100000000 + hrValues [ 1 ] ) - ar [ 0 ] ,
201+ hrValues [ 2 ] - ar [ 1 ]
202+ ] ;
203+ }
204+
205+ throw new TypeError ( 'process.hrtime() only accepts an Array tuple' ) ;
202206 }
203- return ret ;
207+
208+ return [
209+ hrValues [ 0 ] * 0x100000000 + hrValues [ 1 ] ,
210+ hrValues [ 2 ]
211+ ] ;
204212 } ;
205213 } ;
206214
You can’t perform that action at this time.
0 commit comments