Code coverage report for core/src/time/time-factory.ts

Statements: 100% (7 / 7)      Branches: 75% (3 / 4)      Functions: 100% (3 / 3)      Lines: 100% (7 / 7)      Ignored: none     

All files » core/src/time/ » time-factory.ts
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 261                       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();
}