mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
c1aab06798
This sets up the typescript compiler. Allowing gradual migration to typescript. Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai> Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com> Co-authored-by: Fredrik Oseberg <fredrik.oseberg@getunleash.ai> Co-authored-by: Clint Checkett <clintchecketts@churchofjesuschrist.org> fixes: #676
29 lines
727 B
JavaScript
29 lines
727 B
JavaScript
'use strict';
|
|
|
|
const NS_TO_S = 1e9;
|
|
|
|
// seconds takes a tuple of [seconds, nanoseconds]
|
|
// and returns the time in seconds
|
|
const seconds = diff => diff[0] + diff[1] / NS_TO_S;
|
|
|
|
module.exports = {
|
|
// new returns a timer function. Call it to measure the time since the call to new().
|
|
// the timer function returns the duration in seconds
|
|
//
|
|
// usage:
|
|
//
|
|
// t = timer.new()
|
|
// setTimeout(() => {
|
|
// diff = t()
|
|
// console.log(diff) // 0.500003192s
|
|
// }, 500)
|
|
//
|
|
new: () => {
|
|
const now = process.hrtime();
|
|
// the timer function returns the time in seconds
|
|
// since new() was called
|
|
return () => seconds(process.hrtime(now));
|
|
},
|
|
seconds,
|
|
};
|