early/dist/index.js

33 lines
2.6 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const beautycolor = require("beautycolor");
const smartq = require("smartq");
const early_hrtMeasurement_1 = require("./early.hrtMeasurement");
exports.HrtMeasurement = early_hrtMeasurement_1.HrtMeasurement;
let doText = false;
let moduleName = 'undefined module name';
let startHrt;
if (process.argv.indexOf('-v') === -1) {
doText = true;
}
/**
* start the loading
*/
exports.start = function (moduleNameArg = '', loaderLengthArg = '10') {
moduleName = moduleNameArg;
startHrt = new early_hrtMeasurement_1.HrtMeasurement();
startHrt.start();
if (doText) {
console.log(`**** starting ${beautycolor.coloredString(moduleNameArg, 'green')} ****`);
}
};
exports.stop = () => {
let done = smartq.defer();
let earlyExecutionTime = startHrt.stop().milliSeconds;
let earlyExecutionTimeString = (earlyExecutionTime / 1000).toString();
console.log(`OK! -> finished loading within ${beautycolor.coloredString(earlyExecutionTimeString, 'blue')}`);
done.resolve(earlyExecutionTime);
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QiwyQ0FBMEM7QUFDMUMsaUNBQWdDO0FBQ2hDLGlFQUF1RDtBQUdyRCx5QkFITyxxQ0FBYyxDQUdQO0FBR2hCLElBQUksTUFBTSxHQUFZLEtBQUssQ0FBQTtBQUMzQixJQUFJLFVBQVUsR0FBVyx1QkFBdUIsQ0FBQTtBQUNoRCxJQUFJLFFBQXdCLENBQUE7QUFFNUIsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO0lBQ3RDLE1BQU0sR0FBRyxJQUFJLENBQU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