1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 1 1 1 18 1 1 11 | import {NanoTimeMeasurement, TimeMeasurement} from './primitives';
export interface TimeFactory {
now(): TimeMeasurement;
}
let timeFactory: TimeFactory;
export function setTimeFactory(factory?: TimeFactory): TimeFactory {
timeFactory = factory ? factory : {
now(): TimeMeasurement {
return NanoTimeMeasurement.fromMillis(Date.now());
},
};
return timeFactory;
}
export function getTimeFactory(): TimeFactory {
return timeFactory || setTimeFactory();
}
|