All files / src/data StopwatchData.ts

100% Statements 16/16
100% Branches 0/0
100% Functions 3/3
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 772x                                                                                   9x 9x 9x 9x 9x 9x 9x                 9x 9x   18x 18x   27x           9x 9x           2x
import Type from "../Stopwatch.Event";
 
/*** docs exclude
 * Stopwatch data
 * @property {boolean} started started
 * @property {number} startTime requestAnimationFrame start time
 * @property {number} elapsedTime elapsed time = now time - start time
 * @property {number} frameTime requestAnimationFrame now time
 * @property {boolean} paused paused
 * @property {number} rafId return id from requestAnimationFrame
 * @property {object} event event items
 * @property {number[]} alarms set alarm times
 * @property {number[]} completeAlarms complete alarm times
 * @property {function} a zzz
 * @example
 * ```js
 * const stopwatch = new Stopwatch();
 * ```
 ***/
 class StopwatchData {
 
	// 필드
	started: boolean;
	startTime: number;
	elapsedTime: number;
	frameTime: number;
	paused: boolean;
	rafId: number;
 
	event: {
		[key: string]: Function[],
		update: Function[],
		tick: Function[],
		alarm: Function[]
	};
 
	alarms: number[];
	completeAlarms: number[];
 
 
	constructor(){
 
		this.started = false;
		this.startTime = null;
		this.elapsedTime = null;
		this.frameTime = null;
		this.paused = false;
		this.rafId = null;
		this.event = {
			
			update: null,
			tick: null,
			alarm: null
			
		};
 
		// synonym
		const synonymGroup: string[][] = Type.getSynonyms();
		synonymGroup.forEach(( synonyms ) => {
 
			const array: Function[] = [];
			synonyms.forEach(( synonym ) => {
 
				this.event[ synonym ] = array;
 
			});
 
		});
 
		this.alarms = [];
		this.completeAlarms = [];
 
	}
 
}
 
export default StopwatchData;