UNPKG

@fraserdarwent/xapi-node

Version:

This project is made possible to get data from Forex market, execute market or limit order with NodeJS/JS through WebSocket connection

33 lines 922 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Time = void 0; function calculateElapsedTime(time) { if (typeof window === 'undefined') { const hrtime = process.hrtime(time); return Math.floor(hrtime[0] * 1000 + hrtime[1] / 1000000); } else { return performance.now() - time[0]; } } class Time { constructor() { this.unit = (typeof window === 'undefined') ? process.hrtime() : [performance.now(), 0]; this.UTCTimestamp = Date.now(); return this; } getDifference(time) { return time.elapsedMs() - this.elapsedMs(); } get() { return new Date(Date.now() - calculateElapsedTime(this.unit)); } elapsedMs() { return calculateElapsedTime(this.unit); } getUTC() { return new Date(this.UTCTimestamp); } } exports.Time = Time; //# sourceMappingURL=Time.js.map