Takes a value and transform into a positive number returns a negative number if the number is negative or invalid
| 23 | // Takes a value and transform into a positive number |
| 24 | // returns a negative number if the number is negative or invalid |
| 25 | inline static double |
| 26 | ToMaybePositiveValue(const v8::Local<v8::Value> &v, const v8::Local<v8::Context> &ctx) { |
| 27 | double value = -1; |
| 28 | if (v->IsNullOrUndefined()) { |
| 29 | return -1; |
| 30 | } |
| 31 | Local<Number> numberValue; |
| 32 | auto success = v->ToNumber(ctx).ToLocal(&numberValue); |
| 33 | if (success) { |
| 34 | value = numberValue->Value(); |
| 35 | if (isnan(value)) { |
| 36 | value = -1; |
| 37 | } |
| 38 | } |
| 39 | return value; |
| 40 | } |
| 41 | |
| 42 | static double now_ms() { |
| 43 | struct timespec res; |
no test coverage detected