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) {
2138
2138
// and nanoseconds, to avoid any integer overflow possibility.
2139
2139
// Pass in an Array from a previous hrtime() call to instead get a time diff.
2140
2140
void Hrtime (const FunctionCallbackInfo<Value>& args) {
2141
- Environment* env = Environment::GetCurrent (args);
2142
-
2143
2141
uint64_t t = uv_hrtime ();
2144
2142
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
-
2153
2143
Local<ArrayBuffer> ab = args[0 ].As <Uint32Array>()->Buffer ();
2154
2144
uint32_t * fields = static_cast <uint32_t *>(ab->GetContents ().Data ());
2155
2145
Original file line number Diff line number Diff line change 192
192
}
193
193
194
194
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' ) ;
202
206
}
203
- return ret ;
207
+
208
+ return [
209
+ hrValues [ 0 ] * 0x100000000 + hrValues [ 1 ] ,
210
+ hrValues [ 2 ]
211
+ ] ;
204
212
} ;
205
213
} ;
206
214
You can’t perform that action at this time.
0 commit comments