diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +build/ diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..f95bb33 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts/" +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd4f2b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +.DS_Store diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..36348e7 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..668a38c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/shardus-perf-utils.iml b/.idea/shardus-perf-utils.iml new file mode 100644 index 0000000..639b18b --- /dev/null +++ b/.idea/shardus-perf-utils.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..ff15483 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,3 @@ +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/build/src/index.d.ts b/build/src/index.d.ts new file mode 100644 index 0000000..5298df7 --- /dev/null +++ b/build/src/index.d.ts @@ -0,0 +1,2 @@ +declare const _default: any; +export default _default; diff --git a/build/src/index.js b/build/src/index.js new file mode 100644 index 0000000..3df6009 --- /dev/null +++ b/build/src/index.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let profiler = require('./profiler/profiler'); +let nestedCounters = require('./profiler/nestedCounters'); +let memoryReporting = require('./profiler/memoryReporting'); +let statistics = require('./statistics/index'); +exports.default = Object.assign(Object.assign(Object.assign(Object.assign({}, profiler), nestedCounters), memoryReporting), statistics); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/build/src/index.js.map b/build/src/index.js.map new file mode 100644 index 0000000..86a54d5 --- /dev/null +++ b/build/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,IAAI,QAAQ,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;AAC7C,IAAI,cAAc,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAA;AACzD,IAAI,eAAe,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAA;AAC3D,IAAI,UAAU,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAE9C,8EAAmB,QAAQ,GAAK,cAAc,GAAK,eAAe,GAAK,UAAU,EAAC"} \ No newline at end of file diff --git a/build/src/profiler/StringifyReduce.d.ts b/build/src/profiler/StringifyReduce.d.ts new file mode 100644 index 0000000..aac47cb --- /dev/null +++ b/build/src/profiler/StringifyReduce.d.ts @@ -0,0 +1,5 @@ +export declare const makeShortHash: (x: any, n?: number) => any; +export declare const stringifyReduce: (val: any, isArrayProp?: boolean) => any; +export declare const replacer: (key: any, value: any) => any; +export declare const reviver: (key: any, value: any) => any; +export declare const reviverExpander: (key: any, value: any) => any; diff --git a/build/src/profiler/StringifyReduce.js b/build/src/profiler/StringifyReduce.js new file mode 100644 index 0000000..faae85b --- /dev/null +++ b/build/src/profiler/StringifyReduce.js @@ -0,0 +1,133 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.reviverExpander = exports.reviver = exports.replacer = exports.stringifyReduce = exports.makeShortHash = void 0; +exports.makeShortHash = (x, n = 4) => { + if (!x) { + return x; + } + if (x.length > 63) { + if (x.length === 64) { + return x.slice(0, n) + 'x' + x.slice(63 - n); + } + else if (x.length === 128) { + return x.slice(0, n) + 'xx' + x.slice(127 - n); + } + else if (x.length === 192) { + return x.slice(0, n) + 'xx' + x.slice(191 - n); + } + } + return x; +}; +const objToString = Object.prototype.toString; +const objKeys = ((obj) => { + const keys = []; + // tslint:disable-next-line: forin + for (const name in obj) { + keys.push(name); + } + return keys; +}) || Object.keys; +exports.stringifyReduce = (val, isArrayProp) => { + let i, max, str, keys, key, propVal, toStr; + if (val === true) { + return 'true'; + } + if (val === false) { + return 'false'; + } + switch (typeof val) { + case 'object': + if (val === null) { + return null; + } + else if (val.toJSON && typeof val.toJSON === 'function') { + return exports.stringifyReduce(val.toJSON(), isArrayProp); + } + else if (val instanceof Map) { + // let mapContainer = {stringifyReduce_map_2_array:[...val.entries()]} + // return stringifyReduce(mapContainer) + let mapContainer = { + dataType: 'stringifyReduce_map_2_array', + value: Array.from(val.entries()), + }; + return exports.stringifyReduce(mapContainer); + } + else { + toStr = objToString.call(val); + if (toStr === '[object Array]') { + str = '['; + max = val.length - 1; + for (i = 0; i < max; i++) { + str += exports.stringifyReduce(val[i], true) + ','; + } + if (max > -1) { + str += exports.stringifyReduce(val[i], true); + } + return str + ']'; + } + else if (toStr === '[object Object]') { + // only object is left + keys = objKeys(val).sort(); + max = keys.length; + str = ''; + i = 0; + while (i < max) { + key = keys[i]; + propVal = exports.stringifyReduce(val[key], false); + if (propVal !== undefined) { + if (str) { + str += ','; + } + str += JSON.stringify(key) + ':' + propVal; + } + i++; + } + return '{' + str + '}'; + } + else { + return JSON.stringify(val); + } + } + case 'function': + case 'undefined': + return isArrayProp ? null : undefined; + case 'string': + const reduced = exports.makeShortHash(val); + return JSON.stringify(reduced); + default: + return isFinite(val) ? val : null; + } +}; +exports.replacer = (key, value) => { + const originalObject = value; // this[key] + if (originalObject instanceof Map) { + return { + dataType: 'stringifyReduce_map_2_array', + value: Array.from(originalObject.entries()), + }; + } + else { + return value; + } +}; +exports.reviver = (key, value) => { + if (typeof value === 'object' && value !== null) { + if (value.dataType === 'stringifyReduce_map_2_array') { + return new Map(value.value); + } + } + return value; +}; +exports.reviverExpander = (key, value) => { + if (typeof value === 'object' && value !== null) { + if (value.dataType === 'stringifyReduce_map_2_array') { + return new Map(value.value); + } + } + if (typeof value === 'string' && value.length === 10 && value[4] === 'x') { + let res = value.slice(0, 4) + '0'.repeat(55) + value.slice(5, 5 + 5); + return res; + } + return value; +}; +//# sourceMappingURL=StringifyReduce.js.map \ No newline at end of file diff --git a/build/src/profiler/StringifyReduce.js.map b/build/src/profiler/StringifyReduce.js.map new file mode 100644 index 0000000..7cdccd3 --- /dev/null +++ b/build/src/profiler/StringifyReduce.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StringifyReduce.js","sourceRoot":"","sources":["../../../src/profiler/StringifyReduce.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,CAAC,CAAM,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE;IAC3C,IAAI,CAAC,CAAC,EAAE;QACJ,OAAO,CAAC,CAAA;KACX;IACD,IAAI,CAAC,CAAC,MAAM,GAAG,EAAE,EAAE;QACf,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE,EAAE;YACjB,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;SAC/C;aAAM,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE;YACzB,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;SACjD;aAAM,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE;YACzB,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,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,IAAI,KAAK,CAAC,QAAQ,KAAK,6BAA6B,EAAE;YAClD,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;SAC9B;KACJ;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;QACtE,IAAI,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;QACpE,OAAO,GAAG,CAAA;KACb;IACD,OAAO,KAAK,CAAA;AAChB,CAAC,CAAA"} \ No newline at end of file diff --git a/build/src/profiler/memoryReporting.d.ts b/build/src/profiler/memoryReporting.d.ts new file mode 100644 index 0000000..6645e9f --- /dev/null +++ b/build/src/profiler/memoryReporting.d.ts @@ -0,0 +1,38 @@ +export interface MemoryReporting { +} +export declare let memoryReportingInstance: MemoryReporting; +declare type MemItem = { + category: string; + subcat: string; + itemKey: string; + count: number; +}; +export declare class MemoryReporting { + report: MemItem[]; + shardus: any; + lastCPUTimes: any[]; + statistics: any; + stateManager: any; + cycleCreator: any; + nodeList: any; + handlers: any; + constructor(shardus: any, statistics: any, stateManager: any, cycleCreator: any, nodeList: any); + setStatistics: (statistics: any) => void; + memoryHandler: (req: any, res: any) => Promise; + memoryShortHandler: (req: any, res: any) => Promise; + memoryGcHandler: (req: any, res: any) => void; + scaleFactorHandler: (req: any, res: any) => void; + nodeListHandler: (req: any, res: any) => void; + addNodesToReport: () => void; + getMemoryStringBasic: () => string; + updateCpuPercent: () => void; + addToReport: (category: string, subcat: string, itemKey: string, count: number) => void; + reportToStream: (report: MemItem[], indent: any) => string; + gatherReport: () => void; + gatherStateManagerReport: () => void; + getCPUTimes: () => any[]; + cpuPercent: () => number; + roundTo3decimals: (num: any) => number; + systemProcessReport: () => void; +} +export {}; diff --git a/build/src/profiler/memoryReporting.js b/build/src/profiler/memoryReporting.js new file mode 100644 index 0000000..b4e8ecd --- /dev/null +++ b/build/src/profiler/memoryReporting.js @@ -0,0 +1,228 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MemoryReporting = exports.memoryReportingInstance = void 0; +const nestedCounters_1 = require("./nestedCounters"); +const process_1 = require("process"); +const StringifyReduce_1 = require("./StringifyReduce"); +const os = require('os'); +const process = require('process'); +const { makeShortHash, replyResult } = require('../utils/test'); +class MemoryReporting { + constructor(shardus, statistics, stateManager, cycleCreator, nodeList) { + this.setStatistics = (statistics) => { + this.statistics = statistics; + }; + this.memoryHandler = async (req, res) => { + let toMB = 1 / 1000000; + let report = process.memoryUsage(); + let result = ''; + result += `System Memory Report. Timestamp: ${Date.now()}\n`; + result += `rss: ${(report.rss * toMB).toFixed(2)} MB\n`; + result += `heapTotal: ${(report.heapTotal * toMB).toFixed(2)} MB\n`; + result += `heapUsed: ${(report.heapUsed * toMB).toFixed(2)} MB\n`; + result += `external: ${(report.external * toMB).toFixed(2)} MB\n`; + result += `arrayBuffers: ${(report.arrayBuffers * toMB).toFixed(2)} MB\n\n\n`; + this.gatherReport(); + result += this.reportToStream(this.report, 0); + replyResult(res, result); + }; + this.memoryShortHandler = async (req, res) => { + nestedCounters_1.nestedCountersInstance.countRareEvent('test', `memory-short`); // only here to so we can test the rare event counter system + let toMB = 1 / 1000000; + let report = process.memoryUsage(); + let result = ''; + result += `System Memory Report. Timestamp: ${Date.now()}\n`; + result += `rss: ${(report.rss * toMB).toFixed(2)} MB\n`; + result += `heapTotal: ${(report.heapTotal * toMB).toFixed(2)} MB\n`; + result += `heapUsed: ${(report.heapUsed * toMB).toFixed(2)} MB\n`; + result += `external: ${(report.external * toMB).toFixed(2)} MB\n`; + result += `arrayBuffers: ${(report.arrayBuffers * toMB).toFixed(2)} MB\n`; + replyResult(res, result); + }; + this.memoryGcHandler = (req, res) => { + let result = ''; + result += `System Memory Report. Timestamp: ${Date.now()}\n`; + try { + if (global.gc) { + global.gc(); + result += 'garbage collected!'; + } + else { + result += 'No access to global.gc. run with node --expose-gc'; + } + } + catch (e) { + result += 'ex:No access to global.gc. run with node --expose-gc'; + } + replyResult(res, result); + }; + this.scaleFactorHandler = (req, res) => { + let result = ''; + result += `Scale debug Timestamp: ${Date.now()}\n`; + try { + if (this.cycleCreator) + result += `CycleAutoScale. ${this.cycleCreator.scaleFactor}`; + } + catch (e) { + result += JSON.stringify(e); + } + replyResult(res, result); + }; + this.nodeListHandler = (req, res) => { + let result = ''; + this.report = []; + this.addNodesToReport(); + result += '\n'; + result += this.reportToStream(this.report, 0); + result += '\n'; + replyResult(res, result); + }; + this.addNodesToReport = () => { + if (this.nodeList && this.nodeList.activeByIdOrder) { + let allNodeIds = []; + for (let node of this.nodeList.activeByIdOrder) { + allNodeIds.push(makeShortHash(node.id)); + } + this.addToReport('P2P', 'Nodelist', `${StringifyReduce_1.stringifyReduce(allNodeIds)}`, 1); + } + }; + this.getMemoryStringBasic = () => { + let toMB = 1 / 1000000; + let report = process.memoryUsage(); + let outStr = `rss: ${(report.rss * toMB).toFixed(2)} MB`; + //todo integrate this into the main stats tsv + if (this.shardus && this.shardus.stateManager) { + let numActiveNodes = this.nodeList.activeByIdOrder.length; + let queueCount = this.shardus.stateManager.transactionQueue.newAcceptedTxQueue.length; + let archiveQueueCount = this.shardus.stateManager.transactionQueue.archivedQueueEntries.length; + outStr += ` nds:${numActiveNodes} qCt:${queueCount} aAr:${archiveQueueCount}`; + } + outStr += '\n'; + return outStr; + }; + this.updateCpuPercent = () => { + let cpuPercent = exports.memoryReportingInstance.cpuPercent(); + this.statistics.setManualStat('cpuPercent', cpuPercent); + }; + this.addToReport = (category, subcat, itemKey, count) => { + let obj = { category, subcat, itemKey, count }; + this.report.push(obj); + }; + this.reportToStream = (report, indent) => { + let outputStr = ''; + let indentText = '___'.repeat(indent); + for (let item of report) { + let { category, subcat, itemKey, count } = item; + let countStr = `${count}`; + outputStr += `${countStr.padStart(10)} ${category} ${subcat} ${itemKey}\n`; + } + return outputStr; + }; + this.gatherReport = () => { + this.report = []; + this.gatherStateManagerReport(); + this.systemProcessReport(); + }; + this.gatherStateManagerReport = () => { + if (this.shardus && this.shardus.stateManager) { + if (this.nodeList.activeByIdOrder) { + let numActiveNodes = this.nodeList.activeByIdOrder.length; + this.addToReport('P2P', 'Nodelist', 'numActiveNodes', numActiveNodes); + } + let cacheCount = this.shardus.stateManager.accountCache.accountsHashCache3.workingHistoryList.accountIDs.length; + this.addToReport('StateManager', 'AccountsCache', 'workingAccounts', cacheCount); + let cacheCount2 = this.shardus.stateManager.accountCache.accountsHashCache3.accountHashMap.size; + this.addToReport('StateManager', 'AccountsCache', 'mainMap', cacheCount2); + let queueCount = this.shardus.stateManager.transactionQueue.newAcceptedTxQueue.length; + this.addToReport('StateManager', 'TXQueue', 'queueCount', queueCount); + let pendingQueueCount = this.shardus.stateManager.transactionQueue.newAcceptedTxQueueTempInjest.length; + this.addToReport('StateManager', 'TXQueue', 'pendingQueueCount', pendingQueueCount); + let archiveQueueCount = this.shardus.stateManager.transactionQueue.archivedQueueEntries.length; + this.addToReport('StateManager', 'TXQueue', 'archiveQueueCount', archiveQueueCount); + for (let syncTracker of this.shardus.stateManager.accountSync.syncTrackers) { + let partition = `${StringifyReduce_1.stringifyReduce(syncTracker.range.low)} - ${StringifyReduce_1.stringifyReduce(syncTracker.range.high)}`; + this.addToReport('StateManager', 'SyncTracker', `isGlobal:${syncTracker.isGlobalSyncTracker} started:${syncTracker.syncStarted} finished:${syncTracker.syncFinished} partition:${partition}`, 1); + } + let inSync = !this.shardus.stateManager.accountPatcher.failedLastTrieSync; + this.addToReport('Patcher', 'insync', `${inSync}`, 1); + this.addToReport('Patcher', 'history', JSON.stringify(this.shardus.stateManager.accountPatcher.syncFailHistory), 1); + this.addToReport('Patcher', 'insync', `${inSync}`, 1); + } + }; + this.getCPUTimes = () => { + const cpus = os.cpus(); + let times = []; + for (let cpu of cpus) { + let timeObj = {}; + let total = 0; + for (const [key, value] of Object.entries(cpu.times)) { + let time = Number(value); + total += time; + timeObj[key] = value; + } + timeObj['total'] = total; + times.push(timeObj); + } + return times; + }; + this.cpuPercent = () => { + let currentTimes = this.getCPUTimes(); + let deltaTimes = []; + let percentTimes = []; + let percentTotal = 0; + for (let i = 0; i < currentTimes.length; i++) { + const currentTimeEntry = currentTimes[i]; + const lastTimeEntry = this.lastCPUTimes[i]; + let deltaTimeObj = {}; + for (const [key, value] of Object.entries(currentTimeEntry)) { + deltaTimeObj[key] = currentTimeEntry[key] - lastTimeEntry[key]; + } + deltaTimes.push(deltaTimeObj); + for (const [key, value] of Object.entries(currentTimeEntry)) { + percentTimes[key] = deltaTimeObj[key] / deltaTimeObj['total']; + } + percentTotal += (percentTimes['user'] || 0); + percentTotal += (percentTimes['nice'] || 0); + percentTotal += (percentTimes['sys'] || 0); + } + this.lastCPUTimes = currentTimes; + return percentTotal / currentTimes.length; + }; + this.roundTo3decimals = (num) => { + return Math.round((num + Number.EPSILON) * 1000) / 1000; + }; + this.systemProcessReport = () => { + this.addToReport('Process', 'CPU', 'cpuPercent', this.roundTo3decimals(this.cpuPercent() * 100)); + let avgCPU = this.statistics.getAverage('cpuPercent'); + this.addToReport('Process', 'CPU', 'cpuAVGPercent', this.roundTo3decimals(avgCPU * 100)); + let multiStats = this.statistics.getMultiStatReport('cpuPercent'); + multiStats.allVals.forEach(function (val, index) { + multiStats.allVals[index] = Math.round(val * 100); + }); + multiStats.min = this.roundTo3decimals(multiStats.min * 100); + multiStats.max = this.roundTo3decimals(multiStats.max * 100); + multiStats.avg = this.roundTo3decimals(multiStats.avg * 100); + this.addToReport('Process', 'CPU', `cpu: ${JSON.stringify(multiStats)}`, 1); + let report = process_1.resourceUsage(); + for (const [key, value] of Object.entries(report)) { + this.addToReport('Process', 'Details', key, value); + } + }; + exports.memoryReportingInstance = this; + this.report = []; + this.shardus = shardus; + this.statistics = statistics; + this.lastCPUTimes = this.getCPUTimes(); + this.stateManager = stateManager; + this.cycleCreator = cycleCreator; + this.nodeList = nodeList; + this.handlers = { + 'memory': this.memoryHandler, + 'memory-short': this.memoryShortHandler, + 'memory-gc': this.memoryGcHandler, + 'scale-factor': this.scaleFactorHandler + }; + } +} +exports.MemoryReporting = MemoryReporting; +//# sourceMappingURL=memoryReporting.js.map \ No newline at end of file diff --git a/build/src/profiler/memoryReporting.js.map b/build/src/profiler/memoryReporting.js.map new file mode 100644 index 0000000..30ef728 --- /dev/null +++ b/build/src/profiler/memoryReporting.js.map @@ -0,0 +1 @@ +{"version":3,"file":"memoryReporting.js","sourceRoot":"","sources":["../../../src/profiler/memoryReporting.ts"],"names":[],"mappings":";;;AAAA,qDAAuD;AACvD,qCAAsC;AACtC,uDAAkD;AAElD,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AACnC,MAAM,EAAC,aAAa,EAAE,WAAW,EAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;AAqB7D,MAAa,eAAe;IAUxB,YAAY,OAAY,EAAE,UAAe,EAAE,YAAiB,EAAE,YAAiB,EAAE,QAAa;QAiB9F,kBAAa,GAAG,CAAC,UAAe,EAAE,EAAE;YAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAChC,CAAC,CAAA;QAED,kBAAa,GAAG,KAAK,EAAE,GAAQ,EAAE,GAAQ,EAAE,EAAE;YACzC,IAAI,IAAI,GAAG,CAAC,GAAG,OAAO,CAAA;YACtB,IAAI,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;YAClC,IAAI,MAAM,GAAG,EAAE,CAAA;YACf,MAAM,IAAI,qCAAqC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAA;YAC7D,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,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A;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,QAAQ,GAAG;YACZ,QAAQ,EAAE,IAAI,CAAC,aAAa;YAC5B,cAAc,EAAE,IAAI,CAAC,kBAAkB;YACvC,WAAW,EAAE,IAAI,CAAC,eAAe;YACjC,cAAc,EAAE,IAAI,CAAC,kBAAkB;SAC1C,CAAA;IACL,CAAC;CAsOJ;AA/PD,0CA+PC"} \ No newline at end of file diff --git a/build/src/profiler/nestedCounters.d.ts b/build/src/profiler/nestedCounters.d.ts new file mode 100644 index 0000000..77bfb3f --- /dev/null +++ b/build/src/profiler/nestedCounters.d.ts @@ -0,0 +1,25 @@ +export interface NestedCounters { +} +declare type CounterMap = Map; +interface CounterNode { + count: number; + subCounters: CounterMap; +} +export declare let nestedCountersInstance: NestedCounters; +export declare class NestedCounters { + eventCounters: Map; + rareEventCounters: Map; + infLoopDebug: boolean; + handlers: any; + crypto: any; + constructor(crypto: any); + counts: (req: any, res: any) => void; + countsReset: (req: any, res: any) => void; + rareCountReset: (req: any, res: any) => void; + debugInfLoop: (req: any, res: any) => void; + countEvent: (category1: string, category2: string, count?: number) => void; + countRareEvent: (category1: string, category2: string, count?: number) => void; + arrayitizeAndSort: (counterMap: CounterMap) => any[]; + printArrayReport: (arrayReport: any, indent?: number) => string; +} +export {}; diff --git a/build/src/profiler/nestedCounters.js b/build/src/profiler/nestedCounters.js new file mode 100644 index 0000000..5ebaaa5 --- /dev/null +++ b/build/src/profiler/nestedCounters.js @@ -0,0 +1,145 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.NestedCounters = exports.nestedCountersInstance = void 0; +const profiler_1 = require("./profiler"); +const StringifyReduce_1 = require("./StringifyReduce"); +const test_1 = require("../utils/test"); +class NestedCounters { + constructor(crypto) { + this.counts = (req, res) => { + profiler_1.profilerInstance.scopedProfileSectionStart('counts'); + let result = ''; + let arrayReport = this.arrayitizeAndSort(this.eventCounters); + result += `${Date.now()}\n`; + result += this.printArrayReport(arrayReport, 0); + test_1.replyResult(res, result); + profiler_1.profilerInstance.scopedProfileSectionEnd('counts'); + }; + this.countsReset = (req, res) => { + this.eventCounters = new Map(); + test_1.replyResult(res, `counts reset ${Date.now()}`); + }; + this.rareCountReset = (req, res) => { + this.rareEventCounters = new Map(); + test_1.replyResult(res, `Rare counts reset ${Date.now()}`); + }; + this.debugInfLoop = (req, res) => { + res.write('starting inf loop, goodbye'); + res.end(); + let counter = 1; + this.infLoopDebug = true; + while (this.infLoopDebug) { + let s = "asdf"; + let s2 = StringifyReduce_1.stringifyReduce({ test: [s, s, s, s, s, s, s] }); + let s3 = StringifyReduce_1.stringifyReduce({ test: [s2, s2, s2, s2, s2, s2, s2] }); + if (this.crypto != null) { + this.crypto.hash(s3); + } + counter++; + } + }; + this.countEvent = (category1, category2, count = 1) => { + let counterMap = this.eventCounters; + let nextNode; + if (!counterMap.has(category1)) { + nextNode = { count: 0, subCounters: new Map() }; + counterMap.set(category1, nextNode); + } + else { + nextNode = counterMap.get(category1); + } + nextNode.count += count; + counterMap = nextNode.subCounters; + //unrolled loop to avoid memory alloc + category1 = category2; + if (counterMap.has(category1) === false) { + nextNode = { count: 0, subCounters: new Map() }; + counterMap.set(category1, nextNode); + } + else { + nextNode = counterMap.get(category1); + } + nextNode.count += count; + counterMap = nextNode.subCounters; + }; + this.countRareEvent = (category1, category2, count = 1) => { + // trigger normal event counter + this.countEvent(category1, category2, count); + // start counting rare event + let counterMap = this.rareEventCounters; + let nextNode; + if (counterMap.has(category1)) { + nextNode = counterMap.get(category1); + } + else { + nextNode = { count: 0, subCounters: new Map() }; + counterMap.set(category1, nextNode); + } + nextNode.count += count; + counterMap = nextNode.subCounters; + //unrolled loop to avoid memory alloc + category1 = category2; + if (counterMap.has(category1) === false) { + nextNode = { count: 0, subCounters: new Map() }; + counterMap.set(category1, nextNode); + } + else { + nextNode = counterMap.get(category1); + } + nextNode.count += count; + counterMap = nextNode.subCounters; + }; + this.arrayitizeAndSort = (counterMap) => { + let array = []; + for (let key of counterMap.keys()) { + let valueObj = counterMap.get(key); + let newValueObj = { key, count: valueObj.count, subArray: null }; + // newValueObj.key = key + array.push(newValueObj); + let subArray = []; + if (valueObj.subCounters != null) { + subArray = this.arrayitizeAndSort(valueObj.subCounters); + } + // if (valueObj.count != null && valueObj.logLen != null) { + // valueObj.avgLen = valueObj.logLen / valueObj.count + // } + newValueObj.subArray = subArray; + // delete valueObj['subCounters'] + } + array.sort((a, b) => b.count - a.count); + return array; + }; + this.printArrayReport = (arrayReport, indent = 0) => { + let outputStr = ''; + let indentText = '___'.repeat(indent); + for (let item of arrayReport) { + let { key, count, subArray, avgLen, logLen } = item; + let countStr = `${count}`; + // stream.write( + // //`${indentText}${key.padEnd(40)}\tcount:\t${countStr}\n` + // `${countStr.padStart(10)} ${indentText} ${key}\n` + // ) + let newLine = `${countStr.padStart(10)} ${indentText} ${key}\n`; + outputStr += newLine; + if (subArray != null && subArray.length > 0) { + outputStr += this.printArrayReport(subArray, indent + 1); + } + } + return outputStr; + }; + // this.sectionTimes = {} + this.eventCounters = new Map(); + this.rareEventCounters = new Map(); + exports.nestedCountersInstance = this; + this.infLoopDebug = false; + this.crypto = crypto; + this.handlers = { + 'counts': this.counts, + 'counts-reset': this.countsReset, + 'reare-counts-reset': this.rareCountReset, + 'debug-inf-loop': this.debugInfLoop + }; + } +} +exports.NestedCounters = NestedCounters; +//# sourceMappingURL=nestedCounters.js.map \ No newline at end of file diff --git a/build/src/profiler/nestedCounters.js.map b/build/src/profiler/nestedCounters.js.map new file mode 100644 index 0000000..32ad4ec --- /dev/null +++ b/build/src/profiler/nestedCounters.js.map @@ -0,0 +1 @@ +{"version":3,"file":"nestedCounters.js","sourceRoot":"","sources":["../../../src/profiler/nestedCounters.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAC3C,uDAAkD;AAClD,wCAA0C;AAc1C,MAAa,cAAc;IAO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EAAC,GAAG,IAAI,CAAA;gBACjD,IAAI,QAAQ,GAAG,GAAG,KAAK,EAAE,CAAA;gBACzB,gBAAgB;gBAChB,gEAAgE;gBAChE,wDAAwD;gBACxD,IAAI;gBACJ,IAAI,OAAO,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,UAAU,IAAI,GAAG,IAAI,CAAA;gBAC/D,SAAS,IAAI,OAAO,CAAA;gBACpB,IAAI,QAAQ,IAAI,IAAI,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;oBACzC,SAAS,IAAI,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,CAAA;iBAC3D;aACJ;YACD,OAAO,SAAS,CAAA;QACpB,CAAC,CAAA;QAlJG,yBAAyB;QACzB,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAA;QAC9B,IAAI,CAAC,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAA;QAClC,8BAAsB,GAAG,IAAI,CAAA;QAC7B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,QAAQ,GAAG;YACZ,QAAQ,EAAE,IAAI,CAAC,MAAM;YACrB,cAAc,EAAE,IAAI,CAAC,WAAW;YAChC,oBAAoB,EAAE,IAAI,CAAC,cAAc;YACzC,gBAAgB,EAAE,IAAI,CAAC,YAAY;SACtC,CAAA;IACL,CAAC;CAuIJ;AA3JD,wCA2JC"} \ No newline at end of file diff --git a/build/src/profiler/profiler.d.ts b/build/src/profiler/profiler.d.ts new file mode 100644 index 0000000..e9052dc --- /dev/null +++ b/build/src/profiler/profiler.d.ts @@ -0,0 +1,34 @@ +export interface NodeLoad { + internal: number; + external: number; +} +export declare let profilerInstance: Profiler; +export declare class Profiler { + sectionTimes: any; + scopedSectionTimes: any; + eventCounters: Map>; + stackHeight: number; + netInternalStackHeight: number; + netExternalStackHeight: number; + statistics: any; + nodeInfo: any; + nodeType: string; + handlers: any; + constructor(nodeType: string); + setStatistics: (statistics: any) => void; + setNodeInfo: (nodeInfo: any) => void; + perfHandler: (req: any, res: any) => void; + perfScopedHandler: (req: any, res: any) => void; + combinedDebugHandler: (req: any, res: any) => Promise; + setStatisticsInstance: (statistics: any) => void; + profileSectionStart: (sectionName: string, internal?: boolean) => void; + profileSectionEnd: (sectionName: string, internal?: boolean) => void; + scopedProfileSectionStart: (sectionName: string, internal?: boolean) => void; + scopedProfileSectionEnd: (sectionName: string, internal?: boolean) => void; + cleanInt: (x: any) => number; + getTotalBusyInternal: () => any; + clearTimes: () => void; + clearScopedTimes: () => void; + printAndClearReport: (delta?: number) => string; + printAndClearScopedReport: (delta?: number) => string; +} diff --git a/build/src/profiler/profiler.js b/build/src/profiler/profiler.js new file mode 100644 index 0000000..30fb8a5 --- /dev/null +++ b/build/src/profiler/profiler.js @@ -0,0 +1,353 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Profiler = exports.profilerInstance = void 0; +const nestedCounters_1 = require("./nestedCounters"); +const memoryReporting_1 = require("./memoryReporting"); +const test_1 = require("../utils/test"); +let profilerSelfReporting = false; +class Profiler { + constructor(nodeType) { + this.setStatistics = (statistics) => { + this.statistics = statistics; + }; + this.setNodeInfo = (nodeInfo) => { + this.nodeInfo = nodeInfo; + }; + this.perfHandler = (req, res) => { + let result = this.printAndClearReport(1); + test_1.replyResult(res, result); + }; + this.perfScopedHandler = (req, res) => { + let result = this.printAndClearScopedReport(1); + test_1.replyResult(res, result); + }; + this.combinedDebugHandler = async (req, res) => { + const waitTime = Number.parseInt(req.query.wait, 10) || 60; + let result = ''; + function writeToResult(str) { + result += str; + } + // hit "counts-reset" endpoint + this.eventCounters = new Map(); + writeToResult(`counts reset at ${new Date()}\n`); + // hit "perf" endpoint to clear perf stats + this.printAndClearReport(1); + if (this.statistics) + this.statistics.clearRing('txProcessed'); + // wait X seconds + await test_1.sleep(waitTime * 1000); + writeToResult(`Results for ${waitTime} sec of sampling...`); + writeToResult(`\n===========================\n`); + // write nodeId, ip and port + writeToResult(`\n=> NODE DETAIL\n`); + writeToResult(`NODE ID: ${this.nodeInfo ? this.nodeInfo.nodeId : 'N/A'}\n`); + writeToResult(`IP: ${this.nodeInfo ? this.nodeInfo.externalIp : 'N/A'}\n`); + writeToResult(`PORT: ${this.nodeInfo ? this.nodeInfo.externalPort : 'N/A'}\n`); + // write "memory" results + let toMB = 1 / 1000000; + let report = process.memoryUsage(); + writeToResult(`\n=> MEMORY RESULTS\n`); + writeToResult(`System Memory Report. Timestamp: ${Date.now()}\n`); + writeToResult(`rss: ${(report.rss * toMB).toFixed(2)} MB\n`); + writeToResult(`heapTotal: ${(report.heapTotal * toMB).toFixed(2)} MB\n`); + writeToResult(`heapUsed: ${(report.heapUsed * toMB).toFixed(2)} MB\n`); + writeToResult(`external: ${(report.external * toMB).toFixed(2)} MB\n`); + writeToResult(`arrayBuffers: ${(report.arrayBuffers * toMB).toFixed(2)} MB\n\n\n`); + memoryReporting_1.memoryReportingInstance.gatherReport(); + writeToResult(memoryReporting_1.memoryReportingInstance.reportToStream(memoryReporting_1.memoryReportingInstance.report, 0)); + if (this.nodeType === 'consensor' && this.statistics) { + const injectedTpsReport = this.statistics.getMultiStatReport('txInjected'); + writeToResult('\n=> Node Injected TPS \n'); + writeToResult(`\n Avg: ${injectedTpsReport.avg} `); + writeToResult(`\n Max: ${injectedTpsReport.max} `); + writeToResult(`\n Vals: ${injectedTpsReport.allVals} `); + this.statistics.clearRing('txInjected'); + const processedTpsReport = this.statistics.getMultiStatReport('txProcessed'); + writeToResult('\n=> Node Processed TPS \n'); + writeToResult(`\n Avg: ${processedTpsReport.avg} `); + writeToResult(`\n Max: ${processedTpsReport.max} `); + writeToResult(`\n Vals: ${processedTpsReport.allVals} `); + this.statistics.clearRing('txProcessed'); + const rejectedTpsReport = this.statistics.getMultiStatReport('txRejected'); + writeToResult('\n=> Node Rejected TPS \n'); + writeToResult(`\n Avg: ${rejectedTpsReport.avg} `); + writeToResult(`\n Max: ${rejectedTpsReport.max} `); + writeToResult(`\n Vals: ${rejectedTpsReport.allVals} `); + this.statistics.clearRing('txRejected'); + const networkTimeoutReport = this.statistics.getMultiStatReport('networkTimeout'); + writeToResult('\n=> Network Timeout / sec \n'); + writeToResult(`\n Avg: ${networkTimeoutReport.avg} `); + writeToResult(`\n Max: ${networkTimeoutReport.max} `); + writeToResult(`\n Vals: ${networkTimeoutReport.allVals} `); + this.statistics.clearRing('networkTimeout'); + const lostNodeTimeoutReport = this.statistics.getMultiStatReport('lostNodeTimeout'); + writeToResult('\n=> LostNode Timeout / sec \n'); + writeToResult(`\n Avg: ${lostNodeTimeoutReport.avg} `); + writeToResult(`\n Max: ${lostNodeTimeoutReport.max} `); + writeToResult(`\n Vals: ${lostNodeTimeoutReport.allVals} `); + this.statistics.clearRing('lostNodeTimeout'); + } + // write "perf" results + writeToResult(`\n=> PERF RESULTS\n`); + writeToResult(this.printAndClearReport(1)); + writeToResult(`\n===========================\n`); + // write scoped-perf results + let scopedPerfResult = this.printAndClearScopedReport(1); + writeToResult(`\n=> SCOPED PERF RESULTS\n`); + writeToResult(scopedPerfResult); + writeToResult(`\n===========================\n`); + // write "counts" results + let arrayReport = nestedCounters_1.nestedCountersInstance.arrayitizeAndSort(nestedCounters_1.nestedCountersInstance.eventCounters); + writeToResult(`\n=> COUNTS RESULTS\n`); + writeToResult(`${Date.now()}\n`); + writeToResult(nestedCounters_1.nestedCountersInstance.printArrayReport(arrayReport, 0)); + writeToResult(`\n===========================\n`); + test_1.replyResult(res, result); + }; + this.setStatisticsInstance = (statistics) => { + this.statistics = statistics; + }; + this.profileSectionStart = (sectionName, internal = false) => { + let section = this.sectionTimes[sectionName]; + if (section != null && section.started === true) { + if (profilerSelfReporting) + nestedCounters_1.nestedCountersInstance.countEvent('profiler-start-error', sectionName); + return; + } + if (section == null) { + let t = BigInt(0); + section = { name: sectionName, total: t, c: 0, internal }; + this.sectionTimes[sectionName] = section; + } + section.start = process.hrtime.bigint(); + section.started = true; + section.c++; + if (internal === false) { + nestedCounters_1.nestedCountersInstance.countEvent('profiler', sectionName); + this.stackHeight++; + if (this.stackHeight === 1) { + this.profileSectionStart('_totalBusy', true); + this.profileSectionStart('_internal_totalBusy', true); + } + if (sectionName === 'net-internl') { + this.netInternalStackHeight++; + if (this.netInternalStackHeight === 1) { + this.profileSectionStart('_internal_net-internl', true); + } + } + if (sectionName === 'net-externl') { + this.netExternalStackHeight++; + if (this.netExternalStackHeight === 1) { + this.profileSectionStart('_internal_net-externl', true); + } + } + } + }; + this.profileSectionEnd = (sectionName, internal = false) => { + let section = this.sectionTimes[sectionName]; + if (section == null || section.started === false) { + if (profilerSelfReporting) + nestedCounters_1.nestedCountersInstance.countEvent('profiler-end-error', sectionName); + return; + } + section.end = process.hrtime.bigint(); + section.total += section.end - section.start; + section.started = false; + if (internal === false) { + if (profilerSelfReporting) + nestedCounters_1.nestedCountersInstance.countEvent('profiler-end', sectionName); + this.stackHeight--; + if (this.stackHeight === 0) { + this.profileSectionEnd('_totalBusy', true); + this.profileSectionEnd('_internal_totalBusy', true); + } + if (sectionName === 'net-internl') { + this.netInternalStackHeight--; + if (this.netInternalStackHeight === 0) { + this.profileSectionEnd('_internal_net-internl', true); + } + } + if (sectionName === 'net-externl') { + this.netExternalStackHeight--; + if (this.netExternalStackHeight === 0) { + this.profileSectionEnd('_internal_net-externl', true); + } + } + } + }; + this.scopedProfileSectionStart = (sectionName, internal = false) => { + let section = this.scopedSectionTimes[sectionName]; + if (section != null && section.started === true) { + return; + } + if (section == null) { + const t = BigInt(0); + const max = BigInt(0); + const min = BigInt(0); + const avg = BigInt(0); + section = { name: sectionName, total: t, max, min, avg, c: 0, internal }; + this.scopedSectionTimes[sectionName] = section; + } + section.start = process.hrtime.bigint(); + section.started = true; + section.c++; + }; + this.scopedProfileSectionEnd = (sectionName, internal = false) => { + const section = this.scopedSectionTimes[sectionName]; + if (section == null || section.started === false) { + if (profilerSelfReporting) + return; + } + section.end = process.hrtime.bigint(); + const duration = section.end - section.start; + section.total += duration; + section.c += 1; + if (duration > section.max) + section.max = duration; + if (duration < section.min) + section.min = duration; + section.avg = section.total / BigInt(section.c); + section.started = false; + }; + this.cleanInt = (x) => { + x = Number(x); + return x >= 0 ? Math.floor(x) : Math.ceil(x); + }; + this.getTotalBusyInternal = () => { + if (profilerSelfReporting) + nestedCounters_1.nestedCountersInstance.countEvent('profiler-note', 'getTotalBusyInternal'); + this.profileSectionEnd('_internal_total', true); + let internalTotalBusy = this.sectionTimes['_internal_totalBusy']; + let internalTotal = this.sectionTimes['_internal_total']; + let internalNetInternl = this.sectionTimes['_internal_net-internl']; + let internalNetExternl = this.sectionTimes['_internal_net-externl']; + let duty = BigInt(0); + let netInternlDuty = BigInt(0); + let netExternlDuty = BigInt(0); + if (internalTotalBusy != null && internalTotal != null) { + if (internalTotal.total > BigInt(0)) { + duty = (BigInt(100) * internalTotalBusy.total) / internalTotal.total; + } + } + if (internalNetInternl != null && internalTotal != null) { + if (internalTotal.total > BigInt(0)) { + netInternlDuty = + (BigInt(100) * internalNetInternl.total) / internalTotal.total; + } + } + if (internalNetExternl != null && internalTotal != null) { + if (internalTotal.total > BigInt(0)) { + netExternlDuty = + (BigInt(100) * internalNetExternl.total) / internalTotal.total; + } + } + this.profileSectionStart('_internal_total', true); + //clear these timers + internalTotal.total = BigInt(0); + internalTotalBusy.total = BigInt(0); + if (internalNetInternl) + internalNetInternl.total = BigInt(0); + if (internalNetExternl) + internalNetExternl.total = BigInt(0); + return { + duty: Number(duty) * 0.01, + netInternlDuty: Number(netInternlDuty) * 0.01, + netExternlDuty: Number(netExternlDuty) * 0.01, + }; + }; + this.clearTimes = () => { + for (let key in this.sectionTimes) { + if (key.startsWith('_internal')) + continue; + if (this.sectionTimes.hasOwnProperty(key)) { + let section = this.sectionTimes[key]; + section.total = BigInt(0); + } + } + }; + this.clearScopedTimes = () => { + for (let key in this.scopedSectionTimes) { + if (this.scopedSectionTimes.hasOwnProperty(key)) { + let section = this.scopedSectionTimes[key]; + section.total = BigInt(0); + section.max = BigInt(0); + section.min = BigInt(0); + section.avg = BigInt(0); + section.c = 0; + } + } + }; + this.printAndClearReport = (delta) => { + this.profileSectionEnd('_total', true); + let result = 'Profile Sections:\n'; + let d1 = this.cleanInt(1e6); // will get us ms + let divider = BigInt(d1); + let totalSection = this.sectionTimes['_total']; + let totalBusySection = this.sectionTimes['_totalBusy']; + let lines = []; + for (let key in this.sectionTimes) { + if (key.startsWith('_internal')) + continue; + if (this.sectionTimes.hasOwnProperty(key)) { + let section = this.sectionTimes[key]; + let duty = BigInt(0); + if (totalSection.total > BigInt(0)) { + duty = (BigInt(100) * section.total) / totalSection.total; + } + let totalMs = section.total / divider; + let dutyStr = `${duty}`.padStart(4); + let totalStr = `${totalMs}`.padStart(13); + let line = `${dutyStr}% ${section.name.padEnd(30)}, ${totalStr}ms, #:${section.c}`; + //section.total = BigInt(0) + lines.push({ line, totalMs }); + } + } + lines.sort((l1, l2) => Number(l2.totalMs - l1.totalMs)); + result = result + lines.map((line) => line.line).join('\n'); + this.clearTimes(); + this.profileSectionStart('_total', true); + return result; + }; + this.printAndClearScopedReport = (delta) => { + let result = 'Scoped Profile Sections:\n'; + let d1 = this.cleanInt(1e6); // will get us ms + let divider = BigInt(d1); + let lines = []; + for (let key in this.scopedSectionTimes) { + if (this.scopedSectionTimes.hasOwnProperty(key)) { + let section = this.scopedSectionTimes[key]; + const percent = BigInt(100); + const avgMs = Number((section.avg * percent) / divider) / 100; + const maxMs = Number((section.max * percent) / divider) / 100; + const minMs = Number((section.min * percent) / divider) / 100; + const totalMs = Number((section.total * percent) / divider) / 100; + let line = `Avg: ${avgMs}ms ${section.name.padEnd(30)}, Max: ${maxMs}ms, Min: ${minMs}ms, Total: ${totalMs}ms, #:${section.c}`; + lines.push({ line, avgMs }); + } + } + lines.sort((l1, l2) => Number(l2.avgMs - l1.avgMs)); + result = result + lines.map((line) => line.line).join('\n'); + this.clearScopedTimes(); + return result; + }; + this.sectionTimes = {}; + this.scopedSectionTimes = {}; + this.eventCounters = new Map(); + this.stackHeight = 0; + this.netInternalStackHeight = 0; + this.netExternalStackHeight = 0; + this.statistics = null; + this.nodeInfo = null; + this.nodeType = nodeType; + exports.profilerInstance = this; + this.handlers = { + 'perf': this.perfHandler, + 'perf-scoped': this.perfScopedHandler, + 'combined-debug': this.combinedDebugHandler + }; + this.profileSectionStart('_total', true); + this.profileSectionStart('_internal_total', true); + } +} +exports.Profiler = Profiler; +//# sourceMappingURL=profiler.js.map \ No newline at end of file diff --git a/build/src/profiler/profiler.js.map b/build/src/profiler/profiler.js.map new file mode 100644 index 0000000..a463a54 --- /dev/null +++ b/build/src/profiler/profiler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"profiler.js","sourceRoot":"","sources":["../../../src/profiler/profiler.ts"],"names":[],"mappings":";;;AAAA,qDAAuD;AACvD,uDAAyD;AACzD,wCAAgD;AAEhD,IAAI,qBAAqB,GAAG,KAAK,CAAA;AASjC,MAAa,QAAQ;IAYjB,YAAY,QAAgB;QAoB5B,kBAAa,GAAG,CAAC,UAAe,EAAE,EAAE;YAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAChC,CAAC,CAAA;QACD,gBAAW,GAAG,CAAC,QAAa,EAAE,EAAE;YAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAC5B,CAAC,CAAA;QACD,gBAAW,GAAG,CAAC,GAAQ,EAAE,GAAQ,EAAE,EAAE;YACjC,IAAI,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAA;YACxC,kBAAW,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAC5B,CAAC,CAAA;QAED,sBAAiB,GAAG,CAAC,GAAQ,EAAE,GAAQ,EAAE,EAAE;YACvC,IAAI,MAAM,GAAG,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAA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C,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAE3D,IAAI,CAAC,gBAAgB,EAAE,CAAA;YACvB,OAAO,MAAM,CAAA;QACjB,CAAC,CAAA;QA5YG,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACtB,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAA;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAA;QAC9B,IAAI,CAAC,WAAW,GAAG,CAAC,CAAA;QACpB,IAAI,CAAC,sBAAsB,GAAG,CAAC,CAAA;QAC/B,IAAI,CAAC,sBAAsB,GAAG,CAAC,CAAA;QAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,wBAAgB,GAAG,IAAI,CAAA;QACvB,IAAI,CAAC,QAAQ,GAAG;YACZ,MAAM,EAAE,IAAI,CAAC,WAAW;YACxB,aAAa,EAAE,IAAI,CAAC,iBAAiB;YACrC,gBAAgB,EAAE,IAAI,CAAC,oBAAoB;SAC9C,CAAA;QACD,IAAI,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QACxC,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAA;IACrD,CAAC;CA4XJ;AA1ZD,4BA0ZC"} \ No newline at end of file diff --git a/build/src/statistics/index.d.ts b/build/src/statistics/index.d.ts new file mode 100644 index 0000000..958b0cf --- /dev/null +++ b/build/src/statistics/index.d.ts @@ -0,0 +1,99 @@ +/// +import { Readable } from 'stream'; +import { EventEmitter } from 'events'; +export declare let statisticsInstance: Statistics; +export interface Statistics { + intervalDuration: number; + context: any; + counterDefs: any[]; + watcherDefs: any; + timerDefs: { + [name: string]: TimerRing; + }; + manualStatDefs: any[]; + interval: NodeJS.Timeout | null; + snapshotWriteFns: any[]; + stream: Readable | null; + streamIsPushable: boolean; + counters: any; + watchers: any; + timers: any; + manualStats: { + [name: string]: ManualRing; + }; +} +export declare class Statistics extends EventEmitter { + constructor(baseDir: string, config: any, { counters, watchers, timers, manualStats, }: { + counters: string[]; + watchers: any; + timers: any; + manualStats: string[]; + }, context: any); + initialize: () => void; + getStream: () => Readable; + writeOnSnapshot: (writeFn: Function, context: any) => void; + startSnapshots: () => void; + stopSnapshots: () => void; + incrementCounter: (counterName: string) => void; + setManualStat: (manualStatName: string, value: number) => void; + getCurrentCount: (counterName: string) => any; + getCounterTotal: (counterName: string) => any; + getWatcherValue: (watcherName: string) => any; + startTimer: (timerName: string, id: string) => void; + stopTimer: (timerName: string, id: string) => void; + getAverage: (name: string) => any; + getMultiStatReport: (name: string) => any; + clearRing: (name: any) => any; + getPreviousElement: (name: string) => any; + _initializeCounters: (counterDefs?: string[]) => { + [key: string]: any; + }; + _initializeWatchers: (watcherDefs: { + [key: string]: Function; + }, context: any) => { + [key: string]: any; + }; + _initializeTimers: (timerDefs?: any) => any; + _initializeManualStats: (counterDefs?: any[]) => { + [key: string]: any; + }; + _takeSnapshot: () => void; + _pushToStream: (data: any) => void; +} +interface Ring { + elements: any[]; + index: number; + length: number; +} +declare class Ring { + constructor(length: number); + multiStats: () => { + min: number; + max: number; + avg: number; + allVals: any[]; + }; + save: (value: any) => void; + average: () => number; + previous: () => any; + clear(): void; +} +interface TimerRing { + ids: any; + ring: Ring; +} +declare class TimerRing { + constructor(length: number); + start: (id: string) => void; + stop: (id: string) => void; + snapshot: () => void; +} +interface ManualRing { + ring: Ring; +} +declare class ManualRing { + constructor(length: number); + manualSetValue: (value: any) => void; + snapshot: () => void; +} +export {}; diff --git a/build/src/statistics/index.js b/build/src/statistics/index.js new file mode 100644 index 0000000..ec2386e --- /dev/null +++ b/build/src/statistics/index.js @@ -0,0 +1,343 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Statistics = exports.statisticsInstance = void 0; +const path = __importStar(require("path")); +const fs = __importStar(require("fs")); +const stream_1 = require("stream"); +const events_1 = require("events"); +const utils = __importStar(require("../utils/test")); +const nestedCounters_1 = require("../profiler/nestedCounters"); +class Statistics extends events_1.EventEmitter { + constructor(baseDir, config, { counters = [], watchers = {}, timers = [], manualStats = [], }, context) { + super(); + this.initialize = () => { + this.counters = this._initializeCounters(this.counterDefs); + this.watchers = this._initializeWatchers(this.watcherDefs, this.context); + this.timers = this._initializeTimers(this.timerDefs); + this.manualStats = this._initializeManualStats(this.manualStatDefs); + }; + this.getStream = () => { + this.stream = new stream_1.Readable(); + this.stream._read = () => { + this.streamIsPushable = true; + }; + return this.stream; + }; + this.writeOnSnapshot = (writeFn, context) => { + this.snapshotWriteFns.push(writeFn.bind(context)); + }; + this.startSnapshots = () => { + const tabSeperatedHeaders = 'Name\tValue\tTime\n'; + this._pushToStream(tabSeperatedHeaders); + if (!this.interval) + this.interval = setInterval(this._takeSnapshot.bind(this), this.intervalDuration); + }; + this.stopSnapshots = () => { + if (this.interval) + clearInterval(this.interval); + this.interval = null; + }; + // Increments the given CounterRing's count + this.incrementCounter = (counterName) => { + const counter = this.counters[counterName]; + if (!counter) + throw new Error(`Counter '${counterName}' is undefined.`); + counter.increment(); + nestedCounters_1.nestedCountersInstance.countEvent('statistics', counterName); + }; + this.setManualStat = (manualStatName, value) => { + const ring = this.manualStats[manualStatName]; + if (!ring) + throw new Error(`manualStat '${manualStatName}' is undefined.`); + ring.manualSetValue(value); + //nestedCountersInstance.countEvent('statistics', manualStatName) + }; + // Returns the current count of the given CounterRing + this.getCurrentCount = (counterName) => { + const counter = this.counters[counterName]; + if (!counter) + throw new Error(`Counter '${counterName}' is undefined.`); + return counter.count; + }; + // Returns the current total of the given CounterRing + this.getCounterTotal = (counterName) => { + const counter = this.counters[counterName]; + if (!counter) + throw new Error(`Counter '${counterName}' is undefined.`); + return counter.total; + }; + // Returns the result of the given WatcherRings watchFn + this.getWatcherValue = (watcherName) => { + const watcher = this.watchers[watcherName]; + if (!watcher) + throw new Error(`Watcher '${watcherName}' is undefined.`); + return watcher.watchFn(); + }; + // Starts an entry for the given id in the given TimerRing + this.startTimer = (timerName, id) => { + const timer = this.timers[timerName]; + if (!timer) + throw new Error(`Timer '${timerName}' is undefined.`); + timer.start(id); + }; + // Stops an entry for the given id in the given TimerRing + this.stopTimer = (timerName, id) => { + const timer = this.timers[timerName]; + if (!timer) + throw new Error(`Timer '${timerName}' is undefined.`); + timer.stop(id); + }; + // Returns the current average of all elements in the given WatcherRing, CounterRing, or TimerRing + this.getAverage = (name) => { + const ringHolder = this.counters[name] || this.watchers[name] || this.timers[name] || this.manualStats[name]; + if (!ringHolder.ring) + throw new Error(`Ring holder '${name}' is undefined.`); + return ringHolder.ring.average(); + }; + this.getMultiStatReport = (name) => { + const ringHolder = this.counters[name] || this.watchers[name] || this.timers[name] || this.manualStats[name]; + if (!ringHolder.ring) + throw new Error(`Ring holder '${name}' is undefined.`); + return ringHolder.ring.multiStats(); + }; + this.clearRing = (name) => { + const ringHolder = this.counters[name] || + this.watchers[name] || + this.timers[name] || + this.manualStats[name]; + if (!ringHolder.ring) + throw new Error(`Ring holder '${name}' is undefined.`); + return ringHolder.ring.clear(); + }; + // Returns the value of the last element of the given WatcherRing, CounterRing, or TimerRing + this.getPreviousElement = (name) => { + const ringHolder = this.counters[name] || this.watchers[name] || this.timers[name]; + if (!ringHolder.ring) + throw new Error(`Ring holder '${name}' is undefined.`); + return ringHolder.ring.previous(); + }; + this._initializeCounters = (counterDefs = []) => { + const counters = {}; + for (const name of counterDefs) { + counters[name] = new CounterRing(60); + } + return counters; + }; + this._initializeWatchers = (watcherDefs = {}, context) => { + const watchers = {}; + for (const name in watcherDefs) { + const watchFn = watcherDefs[name]; + watchers[name] = new WatcherRing(60, watchFn, context); + } + return watchers; + }; + this._initializeTimers = (timerDefs = []) => { + const timers = {}; + for (const name of timerDefs) { + timers[name] = new TimerRing(60); + } + return timers; + }; + this._initializeManualStats = (counterDefs = []) => { + const manualStats = {}; + for (const name of counterDefs) { + manualStats[name] = new ManualRing(60); //should it be a config + } + return manualStats; + }; + this._takeSnapshot = () => { + const time = new Date().toISOString(); + let tabSeperatedValues = ''; + for (const counter in this.counters) { + this.counters[counter].snapshot(); + tabSeperatedValues += `${counter}-average\t${this.getAverage(counter)}\t${time}\n`; + tabSeperatedValues += `${counter}-total\t${this.getCounterTotal(counter)}\t${time}\n`; + } + for (const watcher in this.watchers) { + this.watchers[watcher].snapshot(); + tabSeperatedValues += `${watcher}-average\t${this.getAverage(watcher)}\t${time}\n`; + tabSeperatedValues += `${watcher}-value\t${this.getWatcherValue(watcher)}\t${time}\n`; + } + for (const timer in this.timers) { + this.timers[timer].snapshot(); + tabSeperatedValues += `${timer}-average\t${this.getAverage(timer) / + 1000}\t${time}\n`; + } + for (const writeFn of this.snapshotWriteFns) { + tabSeperatedValues += writeFn(); + } + this._pushToStream(tabSeperatedValues); + this.emit('snapshot'); + }; + this._pushToStream = (data) => { + if (this.stream && this.streamIsPushable) { + this.streamIsPushable = this.stream.push(data); + } + }; + this.intervalDuration = config.interval || 1; + this.intervalDuration = this.intervalDuration * 1000; + this.context = context; + this.counterDefs = counters; + this.watcherDefs = watchers; + this.timerDefs = timers; + this.manualStatDefs = manualStats; + this.initialize(); + this.interval = null; + this.snapshotWriteFns = []; + this.stream = null; + this.streamIsPushable = false; + exports.statisticsInstance = this; + if (config.save) { + // Pipe stream to file + const file = path.join(baseDir, 'statistics.tsv'); + const fileWriteStream = fs.createWriteStream(file); + const statsReadStream = this.getStream(); + statsReadStream.pipe(fileWriteStream); + } + } +} +exports.Statistics = Statistics; +class Ring { + constructor(length) { + this.multiStats = () => { + let sum = 0; + let total = 0; + let min = Number.MAX_VALUE; + let max = Number.MIN_VALUE; + let allVals = []; + for (const element of this.elements) { + if (_exists(element)) { + let val = Number(element); + sum += val; + total++; + if (val < min) { + min = val; + } + if (val > max) { + max = val; + } + allVals.push(val); + } + } + let avg = total > 0 ? sum / total : 0; + return { min, max, avg, allVals }; + }; + this.save = (value) => { + this.elements[this.index] = value; + this.index = ++this.index % this.elements.length; + }; + this.average = () => { + let sum = 0; + let total = 0; + for (const element of this.elements) { + if (_exists(element)) { + sum += Number(element); + total++; + } + } + return total > 0 ? sum / total : 0; + }; + this.previous = () => { + const prevIndex = (this.index < 1 ? this.elements.length : this.index) - 1; + return this.elements[prevIndex] || 0; + }; + this.elements = new Array(length); + this.index = 0; + this.length = length; + } + clear() { + this.elements = new Array(this.length); + this.index = 0; + } +} +class CounterRing { + constructor(length) { + this.increment = () => { + ++this.count; + ++this.total; + }; + this.snapshot = () => { + this.ring.save(this.count); + this.count = 0; + }; + this.count = 0; + this.total = 0; + this.ring = new Ring(length); + } +} +class WatcherRing { + constructor(length, watchFn, context) { + this.snapshot = () => { + const value = this.watchFn(); + this.ring.save(value); + }; + this.watchFn = watchFn.bind(context); + this.ring = new Ring(length); + } +} +class TimerRing { + constructor(length) { + this.start = (id) => { + if (!this.ids[id]) { + this.ids[id] = Date.now(); + } + }; + this.stop = (id) => { + const entry = this.ids[id]; + if (entry) { + delete this.ids[id]; + } + }; + this.snapshot = () => { + // Calc median duration of all entries in ids + const durations = []; + for (const id in this.ids) { + const startTime = this.ids[id]; + const duration = Date.now() - startTime; + utils.insertSorted(durations, duration, (a, b) => a - b); + } + const median = utils.computeMedian(durations, false); + // Save median + this.ring.save(median); + }; + this.ids = {}; + this.ring = new Ring(length); + } +} +class ManualRing { + constructor(length) { + this.manualSetValue = (value) => { + this.ring.save(value); + }; + this.snapshot = () => { + }; + this.ring = new Ring(length); + } +} +/** + * Check for a variable that is not undefined or null + * @param thing The parameter to check + */ +function _exists(thing) { + return typeof thing !== 'undefined' && thing !== null; +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/build/src/statistics/index.js.map b/build/src/statistics/index.js.map new file mode 100644 index 0000000..6eb941f --- /dev/null +++ b/build/src/statistics/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/statistics/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAC5B,uCAAwB;AACxB,mCAA+B;AAC/B,mCAAmC;AACnC,qDAAsC;AACtC,+DAAiE;AAqBjE,MAAa,UAAW,SAAQ,qBAAY;IACxC,YACI,OAAe,EACf,MAAW,EACX,EACI,QAAQ,GAAG,EAAE,EACb,QAAQ,GAAG,EAAE,EACb,MAAM,GAAG,EAAE,EACX,WAAW,GAAG,EAAE,GAMnB,EACD,OAAY;QAEZ,KAAK,EAAE,CAAA;QAwBX,eAAU,GAAG,GAAG,EAAE;YACd,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;YAC1D,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;YACxE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YACpD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;Q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G,CAAC,KAAU,EAAE,EAAE;YAC5B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC,CAAA;QAED,aAAQ,GAAG,GAAG,EAAE;QAChB,CAAC,CAAA;QARG,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAA;IAChC,CAAC;CAQJ;AAGD;;;GAGG;AACH,SAAS,OAAO,CAAC,KAAU;IACvB,OAAO,OAAO,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,IAAI,CAAA;AACzD,CAAC"} \ No newline at end of file diff --git a/build/src/utils/test.d.ts b/build/src/utils/test.d.ts new file mode 100644 index 0000000..e33139e --- /dev/null +++ b/build/src/utils/test.d.ts @@ -0,0 +1,8 @@ +declare type Comparator = (a: E, b: T) => number; +export declare const sleep: (ms: number) => Promise; +export declare function insertSorted(arr: T[], item: T, comparator?: Comparator): void; +export declare const computeMedian: (arr?: any[], sort?: boolean) => any; +export declare function binarySearch>(arr: T[], el: E, comparator?: Comparator): number; +export declare const makeShortHash: (x: any, n?: number) => any; +export declare const replyResult: (res: any, result: any) => void; +export {}; diff --git a/build/src/utils/test.js b/build/src/utils/test.js new file mode 100644 index 0000000..3a0822b --- /dev/null +++ b/build/src/utils/test.js @@ -0,0 +1,95 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.replyResult = exports.makeShortHash = exports.binarySearch = exports.computeMedian = exports.insertSorted = exports.sleep = void 0; +exports.sleep = (ms) => { + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); +}; +function insertSorted(arr, item, comparator) { + let i = binarySearch(arr, item, comparator); + if (i < 0) { + i = -1 - i; + } + arr.splice(i, 0, item); +} +exports.insertSorted = insertSorted; +exports.computeMedian = (arr = [], sort = true) => { + if (sort) { + arr.sort((a, b) => a - b); + } + const len = arr.length; + switch (len) { + case 0: { + return 0; + } + case 1: { + return arr[0]; + } + default: { + const mid = len / 2; + if (len % 2 === 0) { + return arr[mid]; + } + else { + return (arr[Math.floor(mid)] + arr[Math.ceil(mid)]) / 2; + } + } + } +}; +function binarySearch(arr, el, comparator) { + if (comparator == null) { + // Emulate the default Array.sort() comparator + comparator = (a, b) => { + return a.toString() > b.toString() + ? 1 + : a.toString() < b.toString() + ? -1 + : 0; + }; + } + let m = 0; + let n = arr.length - 1; + while (m <= n) { + const k = (n + m) >> 1; + const cmp = comparator(el, arr[k]); + if (cmp > 0) { + m = k + 1; + } + else if (cmp < 0) { + n = k - 1; + } + else { + return k; + } + } + return -m - 1; +} +exports.binarySearch = binarySearch; +exports.makeShortHash = (x, n = 4) => { + if (x) { + if (x.length > 63) { + if (x.length === 64) { + return x.slice(0, n) + 'x' + x.slice(63 - n); + } + else if (x.length === 128) { + return x.slice(0, n) + 'xx' + x.slice(127 - n); + } + else if (x.length === 192) { + return x.slice(0, n) + 'xx' + x.slice(191 - n); + } + } + return x; + } + else { + return x; + } +}; +exports.replyResult = (res, result) => { + if (res.setHeader) + res.setHeader('content-type', 'text/plain'); + else if (res.header) + res.header('content-type', 'text/plain'); + res.send(result); +}; +//# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/build/src/utils/test.js.map b/build/src/utils/test.js.map new file mode 100644 index 0000000..4430b26 --- /dev/null +++ b/build/src/utils/test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"test.js","sourceRoot":"","sources":["../../../src/utils/test.ts"],"names":[],"mappings":";;;AAEa,QAAA,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE;IAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AAED,SAAgB,YAAY,CAAI,GAAQ,EAAE,IAAO,EAAE,UAA0B;IACzE,IAAI,CAAC,GAAG,YAAY,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;IAC3C,IAAI,CAAC,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CAAC,CAAC,MAAM,KAAK,GAAG,EAAE;gBACzB,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;aACjD;SACJ;QACD,OAAO,CAAC,CAAA;KACX;SAAM;QACH,OAAO,CAAC,CAAA;KACX;AACL,CAAC,CAAA;AAEY,QAAA,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;IACvC,IAAI,GAAG,CAAC,SAAS;QAAE,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;SACzD,IAAI,GAAG,CAAC,MAAM;QAAE,GAAG,CAAC,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;IAC7D,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACpB,CAAC,CAAA"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..de99fae --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2505 @@ +{ + "name": "shardus-perf-utils", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@babel/code-frame": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.16.0.tgz", + "integrity": "sha512-IF4EOMEV+bfYwOmNxGzSnjR2EmQod7f1UXOpZM3l4i4o4QNwzjtJAu/HxdjHq0aYBvdqMuQEY1eg0nqW9ZPORA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.16.0" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.15.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz", + "integrity": "sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w==", + "dev": true + }, + "@babel/highlight": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.16.0.tgz", + "integrity": "sha512-t8MH41kUQylBtu2+4IQA3atqevA2lRgqA2wyVB/YiWmsDSuylZZuXOUy9ric30hfzauEFfdsuk/eXTRrGrfd0g==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.15.7", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "@sindresorhus/is": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz", + "integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==", + "dev": true + }, + "@szmarczak/http-timer": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz", + "integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==", + "dev": true, + "requires": { + "defer-to-connect": "^1.0.1" + } + }, + "@types/body-parser": { + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.1.tgz", + "integrity": "sha512-a6bTJ21vFOGIkwM0kzh9Yr89ziVxq4vYH2fQ6N8AeipEzai/cFK6aGMArIkUeIdRIgpwQa+2bXiLuUJCpSf2Cg==", + "dev": true, + "requires": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "@types/connect": { + "version": "3.4.35", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", + "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==", + "dev": true + }, + "@types/express": { + "version": "4.17.13", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.13.tgz", + "integrity": "sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA==", + "dev": true, + "requires": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.18", + "@types/qs": "*", + "@types/serve-static": "*" + } + }, + "@types/express-serve-static-core": { + "version": "4.17.24", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.24.tgz", + "integrity": "sha512-3UJuW+Qxhzwjq3xhwXm2onQcFHn76frIYVbTu+kn24LFxI+dEhdfISDFovPB8VpEgW8oQCTpRuCe+0zJxB7NEA==", + "dev": true, + "requires": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*" + } + }, + "@types/json-schema": { + "version": "7.0.9", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.9.tgz", + "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==", + "dev": true + }, + "@types/mime": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.2.tgz", + "integrity": "sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw==", + "dev": true + }, + "@types/minimist": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz", + "integrity": "sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==", + "dev": true + }, + "@types/node": { + "version": "13.13.52", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==", + "dev": true + }, + "@types/normalize-package-data": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz", + "integrity": "sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==", + "dev": true + }, + "@types/qs": { + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==", + "dev": true + }, + "@types/range-parser": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.4.tgz", + "integrity": "sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==", + "dev": true + }, + "@types/serve-static": { + "version": "1.13.10", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.13.10.tgz", + "integrity": "sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ==", + "dev": true, + "requires": { + "@types/mime": "^1", + "@types/node": "*" + } + }, + "@typescript-eslint/eslint-plugin": { + "version": "2.31.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.31.0.tgz", + "integrity": "sha512-iIC0Pb8qDaoit+m80Ln/aaeu9zKQdOLF4SHcGLarSeY1gurW6aU4JsOPMjKQwXlw70MvWKZQc6S2NamA8SJ/gg==", + "dev": true, + "requires": { + "@typescript-eslint/experimental-utils": "2.31.0", + "functional-red-black-tree": "^1.0.1", + "regexpp": "^3.0.0", + "tsutils": "^3.17.1" + } + }, + "@typescript-eslint/experimental-utils": { + "version": "2.31.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.31.0.tgz", + "integrity": "sha512-MI6IWkutLYQYTQgZ48IVnRXmLR/0Q6oAyJgiOror74arUMh7EWjJkADfirZhRsUMHeLJ85U2iySDwHTSnNi9vA==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "2.31.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^2.0.0" + } + }, + "@typescript-eslint/parser": { + "version": "2.31.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.31.0.tgz", + "integrity": "sha512-uph+w6xUOlyV2DLSC6o+fBDzZ5i7+3/TxAsH4h3eC64tlga57oMb96vVlXoMwjR/nN+xyWlsnxtbDkB46M2EPQ==", + "dev": true, + "requires": { + "@types/eslint-visitor-keys": "^1.0.0", + "@typescript-eslint/experimental-utils": "2.31.0", + "@typescript-eslint/typescript-estree": "2.31.0", + "eslint-visitor-keys": "^1.1.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "2.31.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.31.0.tgz", + "integrity": "sha512-vxW149bXFXXuBrAak0eKHOzbcu9cvi6iNcJDzEtOkRwGHxJG15chiAQAwhLOsk+86p9GTr/TziYvw+H9kMaIgA==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "eslint-visitor-keys": "^1.1.0", + "glob": "^7.1.6", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^6.3.0", + "tsutils": "^3.17.1" + } + }, + "acorn": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", + "dev": true + }, + "acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true + }, + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ansi-align": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz", + "integrity": "sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==", + "dev": true, + "requires": { + "string-width": "^4.1.0" + } + }, + "ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "requires": { + "type-fest": "^0.21.3" + }, + "dependencies": { + "type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true + } + } + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, + "astral-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz", + "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", + "dev": true + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "boxen": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/boxen/-/boxen-4.2.0.tgz", + "integrity": "sha512-eB4uT9RGzg2odpER62bBwSLvUeGC+WbRjjyyFhGsKnc8wp/m0+hQsMUvUe3H2V0D5vw0nBdO1hCJoZo5mKeuIQ==", + "dev": true, + "requires": { + "ansi-align": "^3.0.0", + "camelcase": "^5.3.1", + "chalk": "^3.0.0", + "cli-boxes": "^2.2.0", + "string-width": "^4.1.0", + "term-size": "^2.1.0", + "type-fest": "^0.8.1", + "widest-line": "^3.1.0" + }, + "dependencies": { + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + } + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "cacheable-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/cacheable-request/-/cacheable-request-6.1.0.tgz", + "integrity": "sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg==", + "dev": true, + "requires": { + "clone-response": "^1.0.2", + "get-stream": "^5.1.0", + "http-cache-semantics": "^4.0.0", + "keyv": "^3.0.0", + "lowercase-keys": "^2.0.0", + "normalize-url": "^4.1.0", + "responselike": "^1.0.2" + }, + "dependencies": { + "lowercase-keys": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", + "integrity": "sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==", + "dev": true + } + } + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, + "camelcase-keys": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-6.2.2.tgz", + "integrity": "sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "map-obj": "^4.0.0", + "quick-lru": "^4.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", + "dev": true + }, + "ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", + "dev": true + }, + "cli-boxes": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.1.tgz", + "integrity": "sha512-y4coMcylgSCdVinjiDBuR8PCC2bLjyGTwEmPb9NHR/QaNU6EUOXcTY/s6VjGMD6ENSEaeQYHCY0GNGS5jfMwPw==", + "dev": true + }, + "cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "dev": true, + "requires": { + "restore-cursor": "^3.1.0" + } + }, + "cli-width": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", + "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", + "dev": true + }, + "clone-response": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz", + "integrity": "sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=", + "dev": true, + "requires": { + "mimic-response": "^1.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "configstore": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/configstore/-/configstore-5.0.1.tgz", + "integrity": "sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA==", + "dev": true, + "requires": { + "dot-prop": "^5.2.0", + "graceful-fs": "^4.1.2", + "make-dir": "^3.0.0", + "unique-string": "^2.0.0", + "write-file-atomic": "^3.0.0", + "xdg-basedir": "^4.0.0" + } + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "crypto-random-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", + "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", + "dev": true + }, + "debug": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz", + "integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "decamelize-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/decamelize-keys/-/decamelize-keys-1.1.0.tgz", + "integrity": "sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=", + "dev": true, + "requires": { + "decamelize": "^1.1.0", + "map-obj": "^1.0.0" + }, + "dependencies": { + "map-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", + "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", + "dev": true + } + } + }, + "decompress-response": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz", + "integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=", + "dev": true, + "requires": { + "mimic-response": "^1.0.0" + } + }, + "deep-extend": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", + "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", + "dev": true + }, + "deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true + }, + "defer-to-connect": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/defer-to-connect/-/defer-to-connect-1.1.3.tgz", + "integrity": "sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ==", + "dev": true + }, + "doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "requires": { + "esutils": "^2.0.2" + } + }, + "dot-prop": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", + "integrity": "sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==", + "dev": true, + "requires": { + "is-obj": "^2.0.0" + } + }, + "duplexer3": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", + "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dev": true, + "requires": { + "once": "^1.4.0" + } + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "escape-goat": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/escape-goat/-/escape-goat-2.1.1.tgz", + "integrity": "sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "eslint": { + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", + "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "ajv": "^6.10.0", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", + "esquery": "^1.0.1", + "esutils": "^2.0.2", + "file-entry-cache": "^5.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.0.0", + "globals": "^12.1.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "inquirer": "^7.0.0", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.3.0", + "lodash": "^4.17.14", + "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", + "natural-compare": "^1.4.0", + "optionator": "^0.8.3", + "progress": "^2.0.0", + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", + "table": "^5.2.3", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "eslint-utils": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", + "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "regexpp": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "eslint-config-prettier": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.15.0.tgz", + "integrity": "sha512-a1+kOYLR8wMGustcgAjdydMsQ2A/2ipRPwRKUmfYaSxc9ZPcrku080Ctl6zrZzZNs/U82MjSv+qKREkoq3bJaw==", + "dev": true, + "requires": { + "get-stdin": "^6.0.0" + } + }, + "eslint-plugin-es": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", + "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", + "dev": true, + "requires": { + "eslint-utils": "^2.0.0", + "regexpp": "^3.0.0" + } + }, + "eslint-plugin-node": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", + "integrity": "sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==", + "dev": true, + "requires": { + "eslint-plugin-es": "^3.0.0", + "eslint-utils": "^2.0.0", + "ignore": "^5.1.1", + "minimatch": "^3.0.4", + "resolve": "^1.10.1", + "semver": "^6.1.0" + }, + "dependencies": { + "ignore": { + "version": "5.1.8", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", + "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "dev": true + } + } + }, + "eslint-plugin-prettier": { + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.4.1.tgz", + "integrity": "sha512-htg25EUYUeIhKHXjOinK4BgCcDwtLHjqaxCDsMy5nbnUMkKFvIhMVCp+5GFUXQ4Nr8lBsPqtGAqBenbpFqAA2g==", + "dev": true, + "requires": { + "prettier-linter-helpers": "^1.0.0" + } + }, + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "eslint-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0" + } + }, + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true + }, + "espree": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", + "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", + "dev": true, + "requires": { + "acorn": "^7.1.1", + "acorn-jsx": "^5.2.0", + "eslint-visitor-keys": "^1.1.0" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esquery": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "dev": true, + "requires": { + "estraverse": "^5.1.0" + }, + "dependencies": { + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true + } + } + }, + "esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "requires": { + "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true + } + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, + "esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true + }, + "execa": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz", + "integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.0", + "get-stream": "^5.0.0", + "human-signals": "^1.1.1", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.0", + "onetime": "^5.1.0", + "signal-exit": "^3.0.2", + "strip-final-newline": "^2.0.0" + }, + "dependencies": { + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "dev": true, + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "fast-diff": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "figures": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", + "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "file-entry-cache": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-5.0.1.tgz", + "integrity": "sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g==", + "dev": true, + "requires": { + "flat-cache": "^2.0.1" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "flat-cache": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", + "integrity": "sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA==", + "dev": true, + "requires": { + "flatted": "^2.0.0", + "rimraf": "2.6.3", + "write": "1.0.3" + }, + "dependencies": { + "rimraf": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, + "flatted": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", + "integrity": "sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, + "get-stdin": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true + }, + "get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + }, + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "requires": { + "is-glob": "^4.0.1" + } + }, + "global-dirs": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-2.1.0.tgz", + "integrity": "sha512-MG6kdOUh/xBnyo9cJFeIKkLEc1AyFq42QTU4XiX51i2NEdxLxLWXIjEjmqKeSuKR7pAZjTqUVoT2b2huxVLgYQ==", + "dev": true, + "requires": { + "ini": "1.3.7" + } + }, + "globals": { + "version": "12.4.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", + "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "dev": true, + "requires": { + "type-fest": "^0.8.1" + } + }, + "got": { + "version": "9.6.0", + "resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz", + "integrity": "sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==", + "dev": true, + "requires": { + "@sindresorhus/is": "^0.14.0", + "@szmarczak/http-timer": "^1.1.2", + "cacheable-request": "^6.0.0", + "decompress-response": "^3.3.0", + "duplexer3": "^0.1.4", + "get-stream": "^4.1.0", + "lowercase-keys": "^1.0.1", + "mimic-response": "^1.0.1", + "p-cancelable": "^1.0.0", + "to-readable-stream": "^1.0.0", + "url-parse-lax": "^3.0.0" + }, + "dependencies": { + "get-stream": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", + "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", + "dev": true, + "requires": { + "pump": "^3.0.0" + } + } + } + }, + "graceful-fs": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", + "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", + "dev": true + }, + "gts": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/gts/-/gts-2.0.2.tgz", + "integrity": "sha512-SLytzl2IqKXf6kGULwr07XQ9lVsvjrzFD3OAA7DEfIQYuD+lKBPt/cZ/RYGxaWerY4PTfmnXT7KdxEr9Ec8uHQ==", + "dev": true, + "requires": { + "@typescript-eslint/eslint-plugin": "2.31.0", + "@typescript-eslint/parser": "2.31.0", + "chalk": "^4.0.0", + "eslint": "^6.8.0", + "eslint-config-prettier": "^6.10.1", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^3.1.2", + "execa": "^4.0.0", + "inquirer": "^7.1.0", + "meow": "^7.0.0", + "ncp": "^2.0.0", + "prettier": "^2.0.4", + "rimraf": "^3.0.2", + "update-notifier": "^4.1.0", + "write-file-atomic": "^3.0.3" + } + }, + "hard-rejection": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz", + "integrity": "sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==", + "dev": true + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "has-yarn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/has-yarn/-/has-yarn-2.1.0.tgz", + "integrity": "sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw==", + "dev": true + }, + "hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true + }, + "http-cache-semantics": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", + "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", + "dev": true + }, + "human-signals": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", + "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==", + "dev": true + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true + }, + "import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "requires": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + } + }, + "import-lazy": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", + "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", + "dev": true + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true + }, + "indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "ini": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz", + "integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==", + "dev": true + }, + "inquirer": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", + "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", + "dev": true, + "requires": { + "ansi-escapes": "^4.2.1", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-width": "^3.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.19", + "mute-stream": "0.0.8", + "run-async": "^2.4.0", + "rxjs": "^6.6.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0", + "through": "^2.3.6" + }, + "dependencies": { + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-ci": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", + "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", + "dev": true, + "requires": { + "ci-info": "^2.0.0" + } + }, + "is-core-module": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz", + "integrity": "sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-installed-globally": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.3.2.tgz", + "integrity": "sha512-wZ8x1js7Ia0kecP/CHM/3ABkAmujX7WPvQk6uu3Fly/Mk44pySulQpnHG46OMjHGXApINnV4QhY3SWnECO2z5g==", + "dev": true, + "requires": { + "global-dirs": "^2.0.1", + "is-path-inside": "^3.0.1" + } + }, + "is-npm": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-npm/-/is-npm-4.0.0.tgz", + "integrity": "sha512-96ECIfh9xtDDlPylNPXhzjsykHsMJZ18ASpaWzQyBr4YRTcVjUvzaHayDAES2oU/3KpljhHUjtSRNiDwi0F0ig==", + "dev": true + }, + "is-obj": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-2.0.0.tgz", + "integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==", + "dev": true + }, + "is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true + }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "is-yarn-global": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/is-yarn-global/-/is-yarn-global-0.3.0.tgz", + "integrity": "sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw==", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "json-buffer": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", + "integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=", + "dev": true + }, + "json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, + "keyv": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-3.1.0.tgz", + "integrity": "sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==", + "dev": true, + "requires": { + "json-buffer": "3.0.0" + } + }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true + }, + "latest-version": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-5.1.0.tgz", + "integrity": "sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA==", + "dev": true, + "requires": { + "package-json": "^6.3.0" + } + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "lines-and-columns": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", + "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "lowercase-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", + "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", + "dev": true + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, + "map-obj": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-4.3.0.tgz", + "integrity": "sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==", + "dev": true + }, + "meow": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/meow/-/meow-7.1.1.tgz", + "integrity": "sha512-GWHvA5QOcS412WCo8vwKDlTelGLsCGBVevQB5Kva961rmNfun0PCbv5+xta2kUMFJyR8/oWnn7ddeKdosbAPbA==", + "dev": true, + "requires": { + "@types/minimist": "^1.2.0", + "camelcase-keys": "^6.2.2", + "decamelize-keys": "^1.1.0", + "hard-rejection": "^2.1.0", + "minimist-options": "4.1.0", + "normalize-package-data": "^2.5.0", + "read-pkg-up": "^7.0.1", + "redent": "^3.0.0", + "trim-newlines": "^3.0.0", + "type-fest": "^0.13.1", + "yargs-parser": "^18.1.3" + }, + "dependencies": { + "type-fest": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", + "integrity": "sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==", + "dev": true + } + } + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "mimic-response": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz", + "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", + "dev": true + }, + "min-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", + "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "minimist-options": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/minimist-options/-/minimist-options-4.1.0.tgz", + "integrity": "sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==", + "dev": true, + "requires": { + "arrify": "^1.0.1", + "is-plain-obj": "^1.1.0", + "kind-of": "^6.0.3" + } + }, + "mkdirp": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", + "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", + "dev": true, + "requires": { + "minimist": "^1.2.5" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "mute-stream": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", + "dev": true + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "ncp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", + "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=", + "dev": true + }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "normalize-url": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz", + "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==", + "dev": true + }, + "npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "requires": { + "path-key": "^3.0.0" + }, + "dependencies": { + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + } + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "optionator": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", + "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", + "dev": true, + "requires": { + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.6", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "word-wrap": "~1.2.3" + } + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "p-cancelable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/p-cancelable/-/p-cancelable-1.1.0.tgz", + "integrity": "sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw==", + "dev": true + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "package-json": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/package-json/-/package-json-6.5.0.tgz", + "integrity": "sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ==", + "dev": true, + "requires": { + "got": "^9.6.0", + "registry-auth-token": "^4.0.0", + "registry-url": "^5.0.0", + "semver": "^6.2.0" + } + }, + "parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "requires": { + "callsites": "^3.0.0" + } + }, + "parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "prepend-http": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-2.0.0.tgz", + "integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=", + "dev": true + }, + "prettier": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.4.1.tgz", + "integrity": "sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==", + "dev": true + }, + "prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "requires": { + "fast-diff": "^1.1.2" + } + }, + "progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true + }, + "pump": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "dev": true, + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "pupa": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/pupa/-/pupa-2.1.1.tgz", + "integrity": "sha512-l1jNAspIBSFqbT+y+5FosojNpVpF94nlI+wDUpqP9enwOTfHx9f0gh5nB96vl+6yTpsJsypeNrwfzPrKuHB41A==", + "dev": true, + "requires": { + "escape-goat": "^2.0.0" + } + }, + "quick-lru": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-4.0.1.tgz", + "integrity": "sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==", + "dev": true + }, + "rc": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", + "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", + "dev": true, + "requires": { + "deep-extend": "^0.6.0", + "ini": "~1.3.0", + "minimist": "^1.2.0", + "strip-json-comments": "~2.0.1" + }, + "dependencies": { + "strip-json-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true + } + } + }, + "read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "requires": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "dependencies": { + "type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true + } + } + }, + "read-pkg-up": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", + "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", + "dev": true, + "requires": { + "find-up": "^4.1.0", + "read-pkg": "^5.2.0", + "type-fest": "^0.8.1" + } + }, + "redent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-3.0.0.tgz", + "integrity": "sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==", + "dev": true, + "requires": { + "indent-string": "^4.0.0", + "strip-indent": "^3.0.0" + } + }, + "regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "dev": true + }, + "registry-auth-token": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-4.2.1.tgz", + "integrity": "sha512-6gkSb4U6aWJB4SF2ZvLb76yCBjcvufXBqvvEx1HbmKPkutswjW1xNVRY0+daljIYRbogN7O0etYSlbiaEQyMyw==", + "dev": true, + "requires": { + "rc": "^1.2.8" + } + }, + "registry-url": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/registry-url/-/registry-url-5.1.0.tgz", + "integrity": "sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw==", + "dev": true, + "requires": { + "rc": "^1.2.8" + } + }, + "resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "requires": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + } + }, + "resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true + }, + "responselike": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/responselike/-/responselike-1.0.2.tgz", + "integrity": "sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=", + "dev": true, + "requires": { + "lowercase-keys": "^1.0.0" + } + }, + "restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "dev": true, + "requires": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + } + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "run-async": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", + "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "dev": true + }, + "rxjs": { + "version": "6.6.7", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", + "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "semver-diff": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/semver-diff/-/semver-diff-3.1.1.tgz", + "integrity": "sha512-GX0Ix/CJcHyB8c4ykpHGIAvLyOwOobtM/8d+TQkAd81/bEjgPHrfba41Vpesr7jX/t8Uh+R3EX9eAS5be+jQYg==", + "dev": true, + "requires": { + "semver": "^6.3.0" + } + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "signal-exit": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.5.tgz", + "integrity": "sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ==", + "dev": true + }, + "slice-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-2.1.0.tgz", + "integrity": "sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.0", + "astral-regex": "^1.0.0", + "is-fullwidth-code-point": "^2.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + } + } + }, + "spdx-correct": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", + "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.10", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.10.tgz", + "integrity": "sha512-oie3/+gKf7QtpitB0LYLETe+k8SifzsX4KixvpOsbI6S0kRiRQ5MKOio8eMSAKQ17N06+wdEOXRiId+zOxo0hA==", + "dev": true + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "dependencies": { + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "dev": true, + "requires": { + "ansi-regex": "^4.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "dev": true + } + } + }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true + }, + "strip-indent": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-3.0.0.tgz", + "integrity": "sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==", + "dev": true, + "requires": { + "min-indent": "^1.0.0" + } + }, + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "table": { + "version": "5.4.6", + "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", + "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", + "dev": true, + "requires": { + "ajv": "^6.10.2", + "lodash": "^4.17.14", + "slice-ansi": "^2.1.0", + "string-width": "^3.0.0" + }, + "dependencies": { + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "dev": true + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "dev": true, + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + } + } + }, + "term-size": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/term-size/-/term-size-2.2.1.tgz", + "integrity": "sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==", + "dev": true + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.2" + } + }, + "to-readable-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz", + "integrity": "sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q==", + "dev": true + }, + "trim-newlines": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", + "integrity": "sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==", + "dev": true + }, + "tslib": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", + "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", + "dev": true + }, + "tsutils": { + "version": "3.21.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", + "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2" + } + }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dev": true, + "requires": { + "is-typedarray": "^1.0.0" + } + }, + "typescript": { + "version": "3.9.10", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz", + "integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==", + "dev": true + }, + "unique-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", + "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", + "dev": true, + "requires": { + "crypto-random-string": "^2.0.0" + } + }, + "update-notifier": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-4.1.3.tgz", + "integrity": "sha512-Yld6Z0RyCYGB6ckIjffGOSOmHXj1gMeE7aROz4MG+XMkmixBX4jUngrGXNYz7wPKBmtoD4MnBa2Anu7RSKht/A==", + "dev": true, + "requires": { + "boxen": "^4.2.0", + "chalk": "^3.0.0", + "configstore": "^5.0.1", + "has-yarn": "^2.1.0", + "import-lazy": "^2.1.0", + "is-ci": "^2.0.0", + "is-installed-globally": "^0.3.1", + "is-npm": "^4.0.0", + "is-yarn-global": "^0.3.0", + "latest-version": "^5.0.0", + "pupa": "^2.0.1", + "semver-diff": "^3.1.1", + "xdg-basedir": "^4.0.0" + }, + "dependencies": { + "chalk": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + } + } + }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "url-parse-lax": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-3.0.0.tgz", + "integrity": "sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=", + "dev": true, + "requires": { + "prepend-http": "^2.0.0" + } + }, + "v8-compile-cache": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", + "dev": true + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "widest-line": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz", + "integrity": "sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==", + "dev": true, + "requires": { + "string-width": "^4.0.0" + } + }, + "word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/write/-/write-1.0.3.tgz", + "integrity": "sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1" + } + }, + "write-file-atomic": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" + } + }, + "xdg-basedir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", + "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==", + "dev": true + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..27a7702 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "shardus-perf-utils", + "version": "1.0.0", + "description": "Utility to measure performance in shardus codebases", + "main": "./build/src/index.js", + "types": "./build/src/index.d.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "lint": "gts lint", + "clean": "gts clean", + "compile": "tsc -p .", + "fix": "gts fix", + "prepare": "npm run compile", + "pretest": "npm run compile", + "posttest": "npm run lint" + }, + "author": "thantsintoe", + "license": "ISC", + "devDependencies": { + "@types/express": "^4.17.3", + "@types/node": "^13.9.0", + "gts": "^2.0.0", + "typescript": "^3.9.10" + } +} diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..e860f39 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,5 @@ +module.exports = { + singleQuote: true, + trailingComma: 'es5', + semi: false +}; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..ca7a18e --- /dev/null +++ b/src/index.ts @@ -0,0 +1,6 @@ +let profiler = require('./profiler/profiler') +let nestedCounters = require('./profiler/nestedCounters') +let memoryReporting = require('./profiler/memoryReporting') +let statistics = require('./statistics/index') + +export default {...profiler, ...nestedCounters, ...memoryReporting, ...statistics} diff --git a/src/profiler/StringifyReduce.ts b/src/profiler/StringifyReduce.ts new file mode 100644 index 0000000..e6c129e --- /dev/null +++ b/src/profiler/StringifyReduce.ts @@ -0,0 +1,127 @@ +export const makeShortHash = (x: any, n = 4) => { + if (!x) { + return x + } + if (x.length > 63) { + if (x.length === 64) { + return x.slice(0, n) + 'x' + x.slice(63 - n) + } else if (x.length === 128) { + return x.slice(0, n) + 'xx' + x.slice(127 - n) + } else if (x.length === 192) { + return x.slice(0, n) + 'xx' + x.slice(191 - n) + } + } + return x +} + +const objToString = Object.prototype.toString +const objKeys = + ((obj: any) => { + const keys = [] + // tslint:disable-next-line: forin + for (const name in obj) { + keys.push(name) + } + return keys + }) || Object.keys + +export const stringifyReduce = (val: any, isArrayProp?: boolean): any => { + let i, max, str, keys, key, propVal, toStr + if (val === true) { + return 'true' + } + if (val === false) { + return 'false' + } + switch (typeof val) { + case 'object': + if (val === null) { + return null + } else if (val.toJSON && typeof val.toJSON === 'function') { + return stringifyReduce(val.toJSON(), isArrayProp) + } else if (val instanceof Map) { + // let mapContainer = {stringifyReduce_map_2_array:[...val.entries()]} + // return stringifyReduce(mapContainer) + let mapContainer = { + dataType: 'stringifyReduce_map_2_array', + value: Array.from(val.entries()), // or with spread: value: [...originalObject] + } + return stringifyReduce(mapContainer) + } else { + toStr = objToString.call(val) + if (toStr === '[object Array]') { + str = '[' + max = val.length - 1 + for (i = 0; i < max; i++) { + str += stringifyReduce(val[i], true) + ',' + } + if (max > -1) { + str += stringifyReduce(val[i], true) + } + return str + ']' + } else if (toStr === '[object Object]') { + // only object is left + keys = objKeys(val).sort() + max = keys.length + str = '' + i = 0 + while (i < max) { + key = keys[i] + propVal = stringifyReduce(val[key], false) + if (propVal !== undefined) { + if (str) { + str += ',' + } + str += JSON.stringify(key) + ':' + propVal + } + i++ + } + return '{' + str + '}' + } else { + return JSON.stringify(val) + } + } + case 'function': + case 'undefined': + return isArrayProp ? null : undefined + case 'string': + const reduced = makeShortHash(val) + return JSON.stringify(reduced) + default: + return isFinite(val) ? val : null + } +} + +export const replacer = (key: any, value: any) => { + const originalObject = value // this[key] + if (originalObject instanceof Map) { + return { + dataType: 'stringifyReduce_map_2_array', + value: Array.from(originalObject.entries()), // or with spread: value: [...originalObject] + } + } else { + return value + } +} + +export const reviver = (key: any, value: any) => { + if (typeof value === 'object' && value !== null) { + if (value.dataType === 'stringifyReduce_map_2_array') { + return new Map(value.value) + } + } + return value +} + +export const reviverExpander = (key: any, value: any) => { + if (typeof value === 'object' && value !== null) { + if (value.dataType === 'stringifyReduce_map_2_array') { + return new Map(value.value) + } + } + if (typeof value === 'string' && value.length === 10 && value[4] === 'x') { + let res = value.slice(0, 4) + '0'.repeat(55) + value.slice(5, 5 + 5) + return res + } + return value +} diff --git a/src/profiler/memoryReporting.ts b/src/profiler/memoryReporting.ts new file mode 100644 index 0000000..7fc405b --- /dev/null +++ b/src/profiler/memoryReporting.ts @@ -0,0 +1,283 @@ +import {nestedCountersInstance} from './nestedCounters' +import {resourceUsage} from 'process'; +import {stringifyReduce} from "./StringifyReduce"; + +const os = require('os'); +const process = require('process'); +const {makeShortHash, replyResult} = require('../utils/test') + +export interface MemoryReporting { +} + +type CounterMap = Map + +interface CounterNode { + count: number + subCounters: CounterMap +} + +export let memoryReportingInstance: MemoryReporting + +type MemItem = { + category: string + subcat: string + itemKey: string + count: number +} + +export class MemoryReporting { + report: MemItem[] + shardus: any + lastCPUTimes: any[] + statistics: any + stateManager: any + cycleCreator: any + nodeList: any + handlers: any + + constructor(shardus: any, statistics: any, stateManager: any, cycleCreator: any, nodeList: any) { + memoryReportingInstance = this + this.report = [] + this.shardus = shardus + this.statistics = statistics + this.lastCPUTimes = this.getCPUTimes() + this.stateManager = stateManager + this.cycleCreator = cycleCreator + this.nodeList = nodeList + this.handlers = { + 'memory': this.memoryHandler, + 'memory-short': this.memoryShortHandler, + 'memory-gc': this.memoryGcHandler, + 'scale-factor': this.scaleFactorHandler + } + } + + setStatistics = (statistics: any) => { + this.statistics = statistics + } + + memoryHandler = async (req: any, res: any) => { + let toMB = 1 / 1000000 + let report = process.memoryUsage() + let result = '' + result += `System Memory Report. Timestamp: ${Date.now()}\n` + result += `rss: ${(report.rss * toMB).toFixed(2)} MB\n` + result += `heapTotal: ${(report.heapTotal * toMB).toFixed(2)} MB\n` + result += `heapUsed: ${(report.heapUsed * toMB).toFixed(2)} MB\n` + result += `external: ${(report.external * toMB).toFixed(2)} MB\n` + result += `arrayBuffers: ${(report.arrayBuffers * toMB).toFixed(2)} MB\n\n\n` + this.gatherReport() + result += this.reportToStream(this.report, 0) + replyResult(res, result) + } + + memoryShortHandler = async (req: any, res: any) => { + nestedCountersInstance.countRareEvent('test', `memory-short`) // only here to so we can test the rare event counter system + let toMB = 1 / 1000000 + let report = process.memoryUsage() + let result = '' + result += `System Memory Report. Timestamp: ${Date.now()}\n` + result += `rss: ${(report.rss * toMB).toFixed(2)} MB\n` + result += `heapTotal: ${(report.heapTotal * toMB).toFixed(2)} MB\n` + result += `heapUsed: ${(report.heapUsed * toMB).toFixed(2)} MB\n` + result += `external: ${(report.external * toMB).toFixed(2)} MB\n` + result += `arrayBuffers: ${(report.arrayBuffers * toMB).toFixed(2)} MB\n` + replyResult(res, result) + } + + memoryGcHandler = (req: any, res: any) => { + let result = '' + result += `System Memory Report. Timestamp: ${Date.now()}\n` + try { + if (global.gc) { + global.gc(); + result += 'garbage collected!' + } else { + result += 'No access to global.gc. run with node --expose-gc' + } + } catch (e) { + result += 'ex:No access to global.gc. run with node --expose-gc' + } + replyResult(res, result) + } + + scaleFactorHandler = (req: any, res: any) => { + let result = '' + result += `Scale debug Timestamp: ${Date.now()}\n` + try { + if(this.cycleCreator) result += `CycleAutoScale. ${this.cycleCreator.scaleFactor}` + } catch (e) { + result += JSON.stringify(e) + } + replyResult(res, result) + } + + nodeListHandler = (req: any, res: any) => { + let result = '' + this.report = [] + this.addNodesToReport() + result += '\n' + result += this.reportToStream(this.report, 0) + result += '\n' + replyResult(res, result) + } + + addNodesToReport = () => { + if (this.nodeList && this.nodeList.activeByIdOrder) { + let allNodeIds = [] + for (let node of this.nodeList.activeByIdOrder) { + allNodeIds.push(makeShortHash(node.id)) + } + this.addToReport('P2P', 'Nodelist', `${stringifyReduce(allNodeIds)}`, 1) + } + } + + getMemoryStringBasic = () => { + let toMB = 1 / 1000000 + let report = process.memoryUsage() + let outStr = `rss: ${(report.rss * toMB).toFixed(2)} MB` + //todo integrate this into the main stats tsv + if (this.shardus && this.shardus.stateManager) { + let numActiveNodes = this.nodeList.activeByIdOrder.length + let queueCount = this.shardus.stateManager.transactionQueue.newAcceptedTxQueue.length + let archiveQueueCount = this.shardus.stateManager.transactionQueue.archivedQueueEntries.length + outStr += ` nds:${numActiveNodes} qCt:${queueCount} aAr:${archiveQueueCount}` + } + outStr += '\n' + return outStr + } + + updateCpuPercent = () => { + let cpuPercent = memoryReportingInstance.cpuPercent() + this.statistics.setManualStat('cpuPercent', cpuPercent) + } + + + + addToReport = (category: string, subcat: string, itemKey: string, count: number) => { + let obj = {category, subcat, itemKey, count} + this.report.push(obj) + } + + reportToStream = (report: MemItem[], indent) => { + let outputStr = '' + let indentText = '___'.repeat(indent) + for (let item of report) { + let {category, subcat, itemKey, count} = item + let countStr = `${count}` + outputStr += `${countStr.padStart(10)} ${category} ${subcat} ${itemKey}\n` + } + return outputStr + } + + gatherReport = () => { + this.report = [] + this.gatherStateManagerReport() + this.systemProcessReport() + } + + gatherStateManagerReport = () => { + if (this.shardus && this.shardus.stateManager) { + if (this.nodeList.activeByIdOrder) { + let numActiveNodes = this.nodeList.activeByIdOrder.length + this.addToReport('P2P', 'Nodelist', 'numActiveNodes', numActiveNodes) + } + let cacheCount = this.shardus.stateManager.accountCache.accountsHashCache3.workingHistoryList.accountIDs.length + this.addToReport('StateManager', 'AccountsCache', 'workingAccounts', cacheCount) + let cacheCount2 = this.shardus.stateManager.accountCache.accountsHashCache3.accountHashMap.size + this.addToReport('StateManager', 'AccountsCache', 'mainMap', cacheCount2) + + let queueCount = this.shardus.stateManager.transactionQueue.newAcceptedTxQueue.length + this.addToReport('StateManager', 'TXQueue', 'queueCount', queueCount) + let pendingQueueCount = this.shardus.stateManager.transactionQueue.newAcceptedTxQueueTempInjest.length + this.addToReport('StateManager', 'TXQueue', 'pendingQueueCount', pendingQueueCount) + let archiveQueueCount = this.shardus.stateManager.transactionQueue.archivedQueueEntries.length + this.addToReport('StateManager', 'TXQueue', 'archiveQueueCount', archiveQueueCount) + + for (let syncTracker of this.shardus.stateManager.accountSync.syncTrackers) { + let partition = `${stringifyReduce(syncTracker.range.low)} - ${stringifyReduce(syncTracker.range.high)}` + this.addToReport('StateManager', 'SyncTracker', `isGlobal:${syncTracker.isGlobalSyncTracker} started:${syncTracker.syncStarted} finished:${syncTracker.syncFinished} partition:${partition}`, 1) + } + + let inSync = !this.shardus.stateManager.accountPatcher.failedLastTrieSync + this.addToReport('Patcher', 'insync', `${inSync}`, 1) + this.addToReport('Patcher', 'history', JSON.stringify(this.shardus.stateManager.accountPatcher.syncFailHistory), 1) + + this.addToReport('Patcher', 'insync', `${inSync}`, 1) + } + } + + getCPUTimes = () => { + const cpus = os.cpus(); + let times = [] + + for (let cpu of cpus) { + let timeObj = {} + let total = 0 + for (const [key, value] of Object.entries(cpu.times)) { + let time = Number(value) + total += time + timeObj[key] = value + } + timeObj['total'] = total + + times.push(timeObj) + } + return times + } + + cpuPercent = () => { + let currentTimes = this.getCPUTimes() + let deltaTimes = [] + let percentTimes = [] + let percentTotal = 0 + + for (let i = 0; i < currentTimes.length; i++) { + const currentTimeEntry = currentTimes[i]; + const lastTimeEntry = this.lastCPUTimes[i] + let deltaTimeObj = {} + for (const [key, value] of Object.entries(currentTimeEntry)) { + deltaTimeObj[key] = currentTimeEntry[key] - lastTimeEntry[key] + } + deltaTimes.push(deltaTimeObj) + + for (const [key, value] of Object.entries(currentTimeEntry)) { + percentTimes[key] = deltaTimeObj[key] / deltaTimeObj['total'] + } + + percentTotal += (percentTimes['user'] || 0) + percentTotal += (percentTimes['nice'] || 0) + percentTotal += (percentTimes['sys'] || 0) + } + this.lastCPUTimes = currentTimes + return percentTotal / currentTimes.length + } + + roundTo3decimals = (num) => { + return Math.round((num + Number.EPSILON) * 1000) / 1000 + } + + systemProcessReport = () => { + this.addToReport('Process', 'CPU', 'cpuPercent', this.roundTo3decimals(this.cpuPercent() * 100)) + + let avgCPU = this.statistics.getAverage('cpuPercent') + this.addToReport('Process', 'CPU', 'cpuAVGPercent', this.roundTo3decimals(avgCPU * 100)) + let multiStats = this.statistics.getMultiStatReport('cpuPercent') + + multiStats.allVals.forEach(function (val, index) { + multiStats.allVals[index] = Math.round(val * 100); + }) + multiStats.min = this.roundTo3decimals(multiStats.min * 100) + multiStats.max = this.roundTo3decimals(multiStats.max * 100) + multiStats.avg = this.roundTo3decimals(multiStats.avg * 100) + + this.addToReport('Process', 'CPU', `cpu: ${JSON.stringify(multiStats)}`, 1) + + let report = resourceUsage() + for (const [key, value] of Object.entries(report)) { + this.addToReport('Process', 'Details', key, value) + } + + } + +} diff --git a/src/profiler/nestedCounters.ts b/src/profiler/nestedCounters.ts new file mode 100644 index 0000000..bd4828c --- /dev/null +++ b/src/profiler/nestedCounters.ts @@ -0,0 +1,172 @@ +import {profilerInstance} from './profiler' +import {stringifyReduce} from "./StringifyReduce"; +import {replyResult} from "../utils/test"; + +export interface NestedCounters { +} + +type CounterMap = Map + +interface CounterNode { + count: number + subCounters: CounterMap +} + +export let nestedCountersInstance: NestedCounters + +export class NestedCounters { + eventCounters: Map + rareEventCounters: Map + infLoopDebug: boolean + handlers: any + crypto: any + + constructor(crypto: any) { + // this.sectionTimes = {} + this.eventCounters = new Map() + this.rareEventCounters = new Map() + nestedCountersInstance = this + this.infLoopDebug = false + this.crypto = crypto + this.handlers = { + 'counts': this.counts, + 'counts-reset': this.countsReset, + 'reare-counts-reset': this.rareCountReset, + 'debug-inf-loop': this.debugInfLoop + } + } + + counts = (req: any, res: any) => { + profilerInstance.scopedProfileSectionStart('counts') + let result = '' + let arrayReport = this.arrayitizeAndSort(this.eventCounters) + result += `${Date.now()}\n` + + result += this.printArrayReport(arrayReport, 0) + replyResult(res, result) + profilerInstance.scopedProfileSectionEnd('counts') + } + countsReset = (req: any, res: any) => { + this.eventCounters = new Map() + replyResult(res, `counts reset ${Date.now()}`) + } + rareCountReset = (req: any, res: any) => { + this.rareEventCounters = new Map() + replyResult(res, `Rare counts reset ${Date.now()}`) + } + debugInfLoop = (req: any, res: any) => { + res.write('starting inf loop, goodbye') + res.end() + let counter = 1 + this.infLoopDebug = true + while (this.infLoopDebug) { + let s = "asdf" + let s2 = stringifyReduce({test: [s, s, s, s, s, s, s]}) + let s3 = stringifyReduce({test: [s2, s2, s2, s2, s2, s2, s2]}) + if (this.crypto != null) { + this.crypto.hash(s3) + } + counter++ + } + } + + countEvent = (category1: string, category2: string, count: number = 1) => { + let counterMap: CounterMap = this.eventCounters + + let nextNode: CounterNode + + if (!counterMap.has(category1)) { + nextNode = {count: 0, subCounters: new Map()} + counterMap.set(category1, nextNode) + } else { + nextNode = counterMap.get(category1) + } + nextNode.count += count + counterMap = nextNode.subCounters + + //unrolled loop to avoid memory alloc + category1 = category2 + if (counterMap.has(category1) === false) { + nextNode = {count: 0, subCounters: new Map()} + counterMap.set(category1, nextNode) + } else { + nextNode = counterMap.get(category1) + } + nextNode.count += count + counterMap = nextNode.subCounters + } + + countRareEvent = (category1: string, category2: string, count: number = 1) => { + // trigger normal event counter + this.countEvent(category1, category2, count) + + // start counting rare event + let counterMap: CounterMap = this.rareEventCounters + + let nextNode: CounterNode + if (counterMap.has(category1)) { + nextNode = counterMap.get(category1) + } else { + nextNode = {count: 0, subCounters: new Map()} + counterMap.set(category1, nextNode) + } + nextNode.count += count + counterMap = nextNode.subCounters + + //unrolled loop to avoid memory alloc + category1 = category2 + if (counterMap.has(category1) === false) { + nextNode = {count: 0, subCounters: new Map()} + counterMap.set(category1, nextNode) + } else { + nextNode = counterMap.get(category1) + } + nextNode.count += count + counterMap = nextNode.subCounters + } + + arrayitizeAndSort = (counterMap: CounterMap) => { + let array = [] + for (let key of counterMap.keys()) { + let valueObj = counterMap.get(key) + + let newValueObj = {key, count: valueObj.count, subArray: null} + // newValueObj.key = key + array.push(newValueObj) + + let subArray = [] + if (valueObj.subCounters != null) { + subArray = this.arrayitizeAndSort(valueObj.subCounters) + } + + // if (valueObj.count != null && valueObj.logLen != null) { + // valueObj.avgLen = valueObj.logLen / valueObj.count + // } + + newValueObj.subArray = subArray + // delete valueObj['subCounters'] + } + + array.sort((a, b) => b.count - a.count) + return array + } + + printArrayReport = (arrayReport, indent = 0): string => { + let outputStr = '' + let indentText = '___'.repeat(indent) + for (let item of arrayReport) { + let {key, count, subArray, avgLen, logLen} = item + let countStr = `${count}` + // stream.write( + // //`${indentText}${key.padEnd(40)}\tcount:\t${countStr}\n` + // `${countStr.padStart(10)} ${indentText} ${key}\n` + // ) + let newLine = `${countStr.padStart(10)} ${indentText} ${key}\n` + outputStr += newLine + if (subArray != null && subArray.length > 0) { + outputStr += this.printArrayReport(subArray, indent + 1) + } + } + return outputStr + } +} diff --git a/src/profiler/profiler.ts b/src/profiler/profiler.ts new file mode 100644 index 0000000..290a672 --- /dev/null +++ b/src/profiler/profiler.ts @@ -0,0 +1,424 @@ +import {nestedCountersInstance} from './nestedCounters' +import {memoryReportingInstance} from './memoryReporting' +import {sleep, replyResult} from '../utils/test' + +let profilerSelfReporting = false + +export interface NodeLoad { + internal: number + external: number +} + +export let profilerInstance: Profiler + +export class Profiler { + sectionTimes: any + scopedSectionTimes: any + eventCounters: Map> + stackHeight: number + netInternalStackHeight: number + netExternalStackHeight: number + statistics: any + nodeInfo: any + nodeType: string + handlers: any + + constructor(nodeType: string) { + this.sectionTimes = {} + this.scopedSectionTimes = {} + this.eventCounters = new Map() + this.stackHeight = 0 + this.netInternalStackHeight = 0 + this.netExternalStackHeight = 0 + this.statistics = null + this.nodeInfo = null + this.nodeType = nodeType + profilerInstance = this + this.handlers = { + 'perf': this.perfHandler, + 'perf-scoped': this.perfScopedHandler, + 'combined-debug': this.combinedDebugHandler + } + this.profileSectionStart('_total', true) + this.profileSectionStart('_internal_total', true) + } + + setStatistics = (statistics: any) => { + this.statistics = statistics + } + setNodeInfo = (nodeInfo: any) => { + this.nodeInfo = nodeInfo + } + perfHandler = (req: any, res: any) => { + let result = this.printAndClearReport(1) + replyResult(res, result) + } + + perfScopedHandler = (req: any, res: any) => { + let result = this.printAndClearScopedReport(1) + replyResult(res, result) + } + + + combinedDebugHandler = async (req: any, res: any) => { + const waitTime = Number.parseInt(req.query.wait as string, 10) || 60 + + let result = '' + + function writeToResult(str) { + result += str + } + + // hit "counts-reset" endpoint + this.eventCounters = new Map() + writeToResult(`counts reset at ${new Date()}\n`) + + // hit "perf" endpoint to clear perf stats + this.printAndClearReport(1) + + if (this.statistics) this.statistics.clearRing('txProcessed') + + // wait X seconds + await sleep(waitTime * 1000) + writeToResult(`Results for ${waitTime} sec of sampling...`) + writeToResult(`\n===========================\n`) + + // write nodeId, ip and port + writeToResult(`\n=> NODE DETAIL\n`) + writeToResult(`NODE ID: ${this.nodeInfo ? this.nodeInfo.nodeId : 'N/A'}\n`) + writeToResult(`IP: ${this.nodeInfo ? this.nodeInfo.externalIp : 'N/A'}\n`) + writeToResult(`PORT: ${this.nodeInfo ? this.nodeInfo.externalPort : 'N/A'}\n`) + + // write "memory" results + let toMB = 1 / 1000000 + let report = process.memoryUsage() + writeToResult(`\n=> MEMORY RESULTS\n`) + writeToResult(`System Memory Report. Timestamp: ${Date.now()}\n`) + writeToResult(`rss: ${(report.rss * toMB).toFixed(2)} MB\n`) + writeToResult(`heapTotal: ${(report.heapTotal * toMB).toFixed(2)} MB\n`) + writeToResult(`heapUsed: ${(report.heapUsed * toMB).toFixed(2)} MB\n`) + writeToResult(`external: ${(report.external * toMB).toFixed(2)} MB\n`) + writeToResult(`arrayBuffers: ${(report.arrayBuffers * toMB).toFixed(2)} MB\n\n\n`) + memoryReportingInstance.gatherReport() + writeToResult(memoryReportingInstance.reportToStream(memoryReportingInstance.report, 0)) + + if (this.nodeType === 'consensor' && this.statistics) { + const injectedTpsReport = this.statistics.getMultiStatReport('txInjected') + writeToResult('\n=> Node Injected TPS \n') + writeToResult(`\n Avg: ${injectedTpsReport.avg} `) + writeToResult(`\n Max: ${injectedTpsReport.max} `) + writeToResult(`\n Vals: ${injectedTpsReport.allVals} `) + this.statistics.clearRing('txInjected') + + const processedTpsReport = this.statistics.getMultiStatReport('txProcessed') + writeToResult('\n=> Node Processed TPS \n') + writeToResult(`\n Avg: ${processedTpsReport.avg} `) + writeToResult(`\n Max: ${processedTpsReport.max} `) + writeToResult(`\n Vals: ${processedTpsReport.allVals} `) + this.statistics.clearRing('txProcessed') + + const rejectedTpsReport = this.statistics.getMultiStatReport('txRejected') + writeToResult('\n=> Node Rejected TPS \n') + writeToResult(`\n Avg: ${rejectedTpsReport.avg} `) + writeToResult(`\n Max: ${rejectedTpsReport.max} `) + writeToResult(`\n Vals: ${rejectedTpsReport.allVals} `) + this.statistics.clearRing('txRejected') + + const networkTimeoutReport = this.statistics.getMultiStatReport('networkTimeout') + writeToResult('\n=> Network Timeout / sec \n') + writeToResult(`\n Avg: ${networkTimeoutReport.avg} `) + writeToResult(`\n Max: ${networkTimeoutReport.max} `) + writeToResult(`\n Vals: ${networkTimeoutReport.allVals} `) + this.statistics.clearRing('networkTimeout') + + const lostNodeTimeoutReport = this.statistics.getMultiStatReport('lostNodeTimeout') + writeToResult('\n=> LostNode Timeout / sec \n') + writeToResult(`\n Avg: ${lostNodeTimeoutReport.avg} `) + writeToResult(`\n Max: ${lostNodeTimeoutReport.max} `) + writeToResult(`\n Vals: ${lostNodeTimeoutReport.allVals} `) + this.statistics.clearRing('lostNodeTimeout') + } + + // write "perf" results + writeToResult(`\n=> PERF RESULTS\n`) + writeToResult(this.printAndClearReport(1)) + writeToResult(`\n===========================\n`) + + // write scoped-perf results + let scopedPerfResult = this.printAndClearScopedReport(1) + writeToResult(`\n=> SCOPED PERF RESULTS\n`) + writeToResult(scopedPerfResult) + writeToResult(`\n===========================\n`) + + // write "counts" results + let arrayReport = nestedCountersInstance.arrayitizeAndSort(nestedCountersInstance.eventCounters) + writeToResult(`\n=> COUNTS RESULTS\n`) + writeToResult(`${Date.now()}\n`) + writeToResult(nestedCountersInstance.printArrayReport(arrayReport, 0)) + writeToResult(`\n===========================\n`) + + replyResult(res, result) + } + + setStatisticsInstance = (statistics: any) => { + this.statistics = statistics + } + + profileSectionStart = (sectionName: string, internal = false) => { + let section = this.sectionTimes[sectionName] + + if (section != null && section.started === true) { + if (profilerSelfReporting) + nestedCountersInstance.countEvent('profiler-start-error', sectionName) + return + } + + if (section == null) { + let t = BigInt(0) + section = {name: sectionName, total: t, c: 0, internal} + this.sectionTimes[sectionName] = section + } + + section.start = process.hrtime.bigint() + section.started = true + section.c++ + + if (internal === false) { + nestedCountersInstance.countEvent('profiler', sectionName) + + this.stackHeight++ + if (this.stackHeight === 1) { + this.profileSectionStart('_totalBusy', true) + this.profileSectionStart('_internal_totalBusy', true) + } + if (sectionName === 'net-internl') { + this.netInternalStackHeight++ + if (this.netInternalStackHeight === 1) { + this.profileSectionStart('_internal_net-internl', true) + } + } + if (sectionName === 'net-externl') { + this.netExternalStackHeight++ + if (this.netExternalStackHeight === 1) { + this.profileSectionStart('_internal_net-externl', true) + } + } + } + } + + profileSectionEnd = (sectionName: string, internal = false) => { + let section = this.sectionTimes[sectionName] + if (section == null || section.started === false) { + if (profilerSelfReporting) + nestedCountersInstance.countEvent('profiler-end-error', sectionName) + return + } + + section.end = process.hrtime.bigint() + section.total += section.end - section.start + section.started = false + + if (internal === false) { + if (profilerSelfReporting) + nestedCountersInstance.countEvent('profiler-end', sectionName) + + this.stackHeight-- + if (this.stackHeight === 0) { + this.profileSectionEnd('_totalBusy', true) + this.profileSectionEnd('_internal_totalBusy', true) + } + if (sectionName === 'net-internl') { + this.netInternalStackHeight-- + if (this.netInternalStackHeight === 0) { + this.profileSectionEnd('_internal_net-internl', true) + } + } + if (sectionName === 'net-externl') { + this.netExternalStackHeight-- + if (this.netExternalStackHeight === 0) { + this.profileSectionEnd('_internal_net-externl', true) + } + } + } + } + + scopedProfileSectionStart = (sectionName: string, internal = false) => { + let section = this.scopedSectionTimes[sectionName] + + if (section != null && section.started === true) { + return + } + + if (section == null) { + const t = BigInt(0) + const max = BigInt(0) + const min = BigInt(0) + const avg = BigInt(0) + section = {name: sectionName, total: t, max, min, avg, c: 0, internal} + this.scopedSectionTimes[sectionName] = section + } + + section.start = process.hrtime.bigint() + section.started = true + section.c++ + } + + scopedProfileSectionEnd = (sectionName: string, internal = false) => { + const section = this.scopedSectionTimes[sectionName] + if (section == null || section.started === false) { + if (profilerSelfReporting) return + } + + section.end = process.hrtime.bigint() + + const duration = section.end - section.start + section.total += duration + section.c += 1 + if (duration > section.max) section.max = duration + if (duration < section.min) section.min = duration + section.avg = section.total / BigInt(section.c) + section.started = false + } + + cleanInt = (x: any) => { + x = Number(x) + return x >= 0 ? Math.floor(x) : Math.ceil(x) + } + + getTotalBusyInternal = (): any => { + if (profilerSelfReporting) + nestedCountersInstance.countEvent('profiler-note', 'getTotalBusyInternal') + + this.profileSectionEnd('_internal_total', true) + let internalTotalBusy = this.sectionTimes['_internal_totalBusy'] + let internalTotal = this.sectionTimes['_internal_total'] + let internalNetInternl = this.sectionTimes['_internal_net-internl'] + let internalNetExternl = this.sectionTimes['_internal_net-externl'] + let duty = BigInt(0) + let netInternlDuty = BigInt(0) + let netExternlDuty = BigInt(0) + if (internalTotalBusy != null && internalTotal != null) { + if (internalTotal.total > BigInt(0)) { + duty = (BigInt(100) * internalTotalBusy.total) / internalTotal.total + } + } + if (internalNetInternl != null && internalTotal != null) { + if (internalTotal.total > BigInt(0)) { + netInternlDuty = + (BigInt(100) * internalNetInternl.total) / internalTotal.total + } + } + if (internalNetExternl != null && internalTotal != null) { + if (internalTotal.total > BigInt(0)) { + netExternlDuty = + (BigInt(100) * internalNetExternl.total) / internalTotal.total + } + } + this.profileSectionStart('_internal_total', true) + +//clear these timers + internalTotal.total = BigInt(0) + internalTotalBusy.total = BigInt(0) + if (internalNetInternl) internalNetInternl.total = BigInt(0) + if (internalNetExternl) internalNetExternl.total = BigInt(0) + + return { + duty: Number(duty) * 0.01, + netInternlDuty: Number(netInternlDuty) * 0.01, + netExternlDuty: Number(netExternlDuty) * 0.01, + } + } + + clearTimes = () => { + for (let key in this.sectionTimes) { + if (key.startsWith('_internal')) continue + + if (this.sectionTimes.hasOwnProperty(key)) { + let section = this.sectionTimes[key] + section.total = BigInt(0) + } + } + } + clearScopedTimes = () => { + for (let key in this.scopedSectionTimes) { + if (this.scopedSectionTimes.hasOwnProperty(key)) { + let section = this.scopedSectionTimes[key] + section.total = BigInt(0) + section.max = BigInt(0) + section.min = BigInt(0) + section.avg = BigInt(0) + section.c = 0 + } + } + } + + printAndClearReport = (delta?: number): string => { + this.profileSectionEnd('_total', true) + + let result = 'Profile Sections:\n' + let d1 = this.cleanInt(1e6) // will get us ms + let divider = BigInt(d1) + + let totalSection = this.sectionTimes['_total'] + let totalBusySection = this.sectionTimes['_totalBusy'] + + let lines = [] + for (let key in this.sectionTimes) { + if (key.startsWith('_internal')) continue + + if (this.sectionTimes.hasOwnProperty(key)) { + let section = this.sectionTimes[key] + + let duty = BigInt(0) + if (totalSection.total > BigInt(0)) { + duty = (BigInt(100) * section.total) / totalSection.total + } + let totalMs = section.total / divider + let dutyStr = `${duty}`.padStart(4) + let totalStr = `${totalMs}`.padStart(13) + let line = `${dutyStr}% ${section.name.padEnd(30)}, ${totalStr}ms, #:${ + section.c + }` + //section.total = BigInt(0) + + lines.push({line, totalMs}) + } + } + + lines.sort((l1, l2) => Number(l2.totalMs - l1.totalMs)) + + result = result + lines.map((line) => line.line).join('\n') + + this.clearTimes() + + this.profileSectionStart('_total', true) + return result + } + + printAndClearScopedReport = (delta?: number): string => { + let result = 'Scoped Profile Sections:\n' + let d1 = this.cleanInt(1e6) // will get us ms + let divider = BigInt(d1) + + let lines = [] + for (let key in this.scopedSectionTimes) { + if (this.scopedSectionTimes.hasOwnProperty(key)) { + let section = this.scopedSectionTimes[key] + const percent = BigInt(100) + const avgMs = Number((section.avg * percent) / divider) / 100 + const maxMs = Number((section.max * percent) / divider) / 100 + const minMs = Number((section.min * percent) / divider) / 100 + const totalMs = Number((section.total * percent) / divider) / 100 + let line = `Avg: ${avgMs}ms ${section.name.padEnd(30)}, Max: ${maxMs}ms, Min: ${minMs}ms, Total: ${totalMs}ms, #:${ + section.c + }` + lines.push({line, avgMs}) + } + } + lines.sort((l1, l2) => Number(l2.avgMs - l1.avgMs)) + result = result + lines.map((line) => line.line).join('\n') + + this.clearScopedTimes() + return result + } +} diff --git a/src/statistics/index.ts b/src/statistics/index.ts new file mode 100644 index 0000000..40539f7 --- /dev/null +++ b/src/statistics/index.ts @@ -0,0 +1,433 @@ +import * as path from 'path' +import * as fs from 'fs' +import {Readable} from 'stream' +import {EventEmitter} from 'events' +import * as utils from '../utils/test' +import {nestedCountersInstance} from '../profiler/nestedCounters' + +export let statisticsInstance: Statistics + +export interface Statistics { + intervalDuration: number + context: any + counterDefs: any[] + watcherDefs: any + timerDefs: { [name: string]: TimerRing } + manualStatDefs: any[] + interval: NodeJS.Timeout | null + snapshotWriteFns: any[] + stream: Readable | null + streamIsPushable: boolean + counters: any + watchers: any + timers: any + manualStats: { [name: string]: ManualRing } +} + +export class Statistics extends EventEmitter { + constructor( + baseDir: string, + config: any, + { + counters = [], + watchers = {}, + timers = [], + manualStats = [], + }: { + counters: string[] + watchers: any + timers: any + manualStats: string[] + }, + context: any + ) { + super() + this.intervalDuration = config.interval || 1 + this.intervalDuration = this.intervalDuration * 1000 + this.context = context + this.counterDefs = counters + this.watcherDefs = watchers + this.timerDefs = timers + this.manualStatDefs = manualStats + this.initialize() + + this.interval = null + this.snapshotWriteFns = [] + this.stream = null + this.streamIsPushable = false + statisticsInstance = this + if (config.save) { + // Pipe stream to file + const file = path.join(baseDir, 'statistics.tsv') + const fileWriteStream = fs.createWriteStream(file) + const statsReadStream = this.getStream() + statsReadStream.pipe(fileWriteStream) + } + } + + initialize = () => { + this.counters = this._initializeCounters(this.counterDefs) + this.watchers = this._initializeWatchers(this.watcherDefs, this.context) + this.timers = this._initializeTimers(this.timerDefs) + this.manualStats = this._initializeManualStats(this.manualStatDefs) + } + + getStream = () => { + this.stream = new Readable() + this.stream._read = () => { + this.streamIsPushable = true + } + return this.stream + } + + writeOnSnapshot = (writeFn: Function, context: any) => { + this.snapshotWriteFns.push(writeFn.bind(context)) + } + + startSnapshots = () => { + const tabSeperatedHeaders = 'Name\tValue\tTime\n' + this._pushToStream(tabSeperatedHeaders) + if (!this.interval) + this.interval = setInterval( + this._takeSnapshot.bind(this), + this.intervalDuration + ) + } + + stopSnapshots = () => { + if (this.interval) clearInterval(this.interval) + this.interval = null + } + + // Increments the given CounterRing's count + incrementCounter = (counterName: string) => { + const counter = this.counters[counterName] + if (!counter) throw new Error(`Counter '${counterName}' is undefined.`) + counter.increment() + nestedCountersInstance.countEvent('statistics', counterName) + } + + setManualStat = (manualStatName: string, value: number) => { + const ring = this.manualStats[manualStatName] + if (!ring) throw new Error(`manualStat '${manualStatName}' is undefined.`) + ring.manualSetValue(value) + //nestedCountersInstance.countEvent('statistics', manualStatName) + } + + // Returns the current count of the given CounterRing + getCurrentCount = (counterName: string) => { + const counter = this.counters[counterName] + if (!counter) throw new Error(`Counter '${counterName}' is undefined.`) + return counter.count + } + + // Returns the current total of the given CounterRing + getCounterTotal = (counterName: string) => { + const counter = this.counters[counterName] + if (!counter) throw new Error(`Counter '${counterName}' is undefined.`) + return counter.total + } + + // Returns the result of the given WatcherRings watchFn + getWatcherValue = (watcherName: string) => { + const watcher = this.watchers[watcherName] + if (!watcher) throw new Error(`Watcher '${watcherName}' is undefined.`) + return watcher.watchFn() + } + + // Starts an entry for the given id in the given TimerRing + startTimer = (timerName: string, id: string) => { + const timer = this.timers[timerName] + if (!timer) throw new Error(`Timer '${timerName}' is undefined.`) + timer.start(id) + } + + // Stops an entry for the given id in the given TimerRing + stopTimer = (timerName: string, id: string) => { + const timer = this.timers[timerName] + if (!timer) throw new Error(`Timer '${timerName}' is undefined.`) + timer.stop(id) + } + + // Returns the current average of all elements in the given WatcherRing, CounterRing, or TimerRing + getAverage = (name: string) => { + const ringHolder = + this.counters[name] || this.watchers[name] || this.timers[name] || this.manualStats[name] + if (!ringHolder.ring) throw new Error(`Ring holder '${name}' is undefined.`) + return ringHolder.ring.average() + } + + + getMultiStatReport = (name: string) => { + const ringHolder = + this.counters[name] || this.watchers[name] || this.timers[name] || this.manualStats[name] + if (!ringHolder.ring) throw new Error(`Ring holder '${name}' is undefined.`) + + return ringHolder.ring.multiStats() + } + + clearRing = (name) => { + const ringHolder = + this.counters[name] || + this.watchers[name] || + this.timers[name] || + this.manualStats[name] + if (!ringHolder.ring) throw new Error(`Ring holder '${name}' is undefined.`) + return ringHolder.ring.clear() + } + + // Returns the value of the last element of the given WatcherRing, CounterRing, or TimerRing + getPreviousElement = (name: string) => { + const ringHolder = + this.counters[name] || this.watchers[name] || this.timers[name] + if (!ringHolder.ring) throw new Error(`Ring holder '${name}' is undefined.`) + return ringHolder.ring.previous() + } + + _initializeCounters = (counterDefs: string[] = []) => { + const counters: { [key: string]: any } = {} + for (const name of counterDefs) { + counters[name] = new CounterRing(60) + } + return counters + } + + _initializeWatchers = (watcherDefs: { [key: string]: Function } = {}, context: any) => { + const watchers: { [key: string]: any } = {} + for (const name in watcherDefs) { + const watchFn = watcherDefs[name] + watchers[name] = new WatcherRing(60, watchFn, context) + } + return watchers + } + + _initializeTimers = (timerDefs: any = []): any => { + const timers: { [key: string]: any } = {} + for (const name of timerDefs) { + timers[name] = new TimerRing(60) + } + return timers + } + + _initializeManualStats = (counterDefs: any[] = []) => { + const manualStats: { [key: string]: any } = {} + for (const name of counterDefs) { + manualStats[name] = new ManualRing(60) //should it be a config + } + return manualStats + } + + _takeSnapshot = () => { + const time = new Date().toISOString() + let tabSeperatedValues = '' + + for (const counter in this.counters) { + this.counters[counter].snapshot() + tabSeperatedValues += `${counter}-average\t${this.getAverage( + counter + )}\t${time}\n` + tabSeperatedValues += `${counter}-total\t${this.getCounterTotal( + counter + )}\t${time}\n` + } + for (const watcher in this.watchers) { + this.watchers[watcher].snapshot() + tabSeperatedValues += `${watcher}-average\t${this.getAverage( + watcher + )}\t${time}\n` + tabSeperatedValues += `${watcher}-value\t${this.getWatcherValue( + watcher + )}\t${time}\n` + } + for (const timer in this.timers) { + this.timers[timer].snapshot() + tabSeperatedValues += `${timer}-average\t${this.getAverage(timer) / + 1000}\t${time}\n` + } + + for (const writeFn of this.snapshotWriteFns) { + tabSeperatedValues += writeFn() + } + + this._pushToStream(tabSeperatedValues) + this.emit('snapshot') + } + + _pushToStream = (data: any) => { + if (this.stream && this.streamIsPushable) { + this.streamIsPushable = this.stream.push(data) + } + } +} + +interface Ring { + elements: any[] + index: number + length: number +} + +class Ring { + constructor(length: number) { + this.elements = new Array(length) + this.index = 0 + this.length = length + } + + multiStats = () => { + let sum = 0 + let total = 0 + let min = Number.MAX_VALUE + let max = Number.MIN_VALUE + let allVals = [] + for (const element of this.elements) { + if (_exists(element)) { + let val = Number(element) + sum += val + total++ + + if (val < min) { + min = val + } + if (val > max) { + max = val + } + allVals.push(val) + } + } + let avg = total > 0 ? sum / total : 0 + return {min, max, avg, allVals} + } + + save = (value: any) => { + this.elements[this.index] = value + this.index = ++this.index % this.elements.length + } + + average = () => { + let sum = 0 + let total = 0 + for (const element of this.elements) { + if (_exists(element)) { + sum += Number(element) + total++ + } + } + return total > 0 ? sum / total : 0 + } + + previous = () => { + const prevIndex = (this.index < 1 ? this.elements.length : this.index) - 1 + return this.elements[prevIndex] || 0 + } + + clear() { + this.elements = new Array(this.length) + this.index = 0 + } +} + +interface CounterRing { + count: number + total: number + ring: Ring +} + +class CounterRing { + constructor(length: number) { + this.count = 0 + this.total = 0 + this.ring = new Ring(length) + } + + increment = () => { + ++this.count + ++this.total + } + + snapshot = () => { + this.ring.save(this.count) + this.count = 0 + } +} + +interface WatcherRing { + watchFn: () => any + ring: Ring +} + +class WatcherRing { + constructor(length: number, watchFn: Function, context: any) { + this.watchFn = watchFn.bind(context) + this.ring = new Ring(length) + } + + snapshot = () => { + const value = this.watchFn() + this.ring.save(value) + } +} + +interface TimerRing { + ids: any + ring: Ring +} + +class TimerRing { + constructor(length: number) { + this.ids = {} + this.ring = new Ring(length) + } + + start = (id: string) => { + if (!this.ids[id]) { + this.ids[id] = Date.now() + } + } + + stop = (id: string) => { + const entry = this.ids[id] + if (entry) { + delete this.ids[id] + } + } + + snapshot = () => { + // Calc median duration of all entries in ids + const durations: number[] = [] + for (const id in this.ids) { + const startTime = this.ids[id] + const duration = Date.now() - startTime + utils.insertSorted(durations, duration, (a: any, b: any) => a - b) + } + const median = utils.computeMedian(durations, false) + // Save median + this.ring.save(median) + } +} + +interface ManualRing { + + ring: Ring +} + +class ManualRing { + constructor(length: number) { + this.ring = new Ring(length) + } + + manualSetValue = (value: any) => { + this.ring.save(value) + } + + snapshot = () => { + } +} + + +/** + * Check for a variable that is not undefined or null + * @param thing The parameter to check + */ +function _exists(thing: any) { + return typeof thing !== 'undefined' && thing !== null +} diff --git a/src/utils/test.ts b/src/utils/test.ts new file mode 100644 index 0000000..03502f0 --- /dev/null +++ b/src/utils/test.ts @@ -0,0 +1,92 @@ +type Comparator = (a: E, b: T) => number + +export const sleep = (ms: number) => { + return new Promise((resolve) => { + setTimeout(resolve, ms) + }) +} + +export function insertSorted(arr: T[], item: T, comparator?: Comparator) { + let i = binarySearch(arr, item, comparator) + if (i < 0) { + i = -1 - i + } + arr.splice(i, 0, item) +} + +export const computeMedian = (arr = [], sort = true) => { + if (sort) { + arr.sort((a, b) => a - b) + } + const len = arr.length + switch (len) { + case 0: { + return 0 + } + case 1: { + return arr[0] + } + default: { + const mid = len / 2 + if (len % 2 === 0) { + return arr[mid] + } else { + return (arr[Math.floor(mid)] + arr[Math.ceil(mid)]) / 2 + } + } + } +} + +export function binarySearch>( + arr: T[], + el: E, + comparator?: Comparator +) { + if (comparator == null) { + // Emulate the default Array.sort() comparator + comparator = (a, b) => { + return a.toString() > b.toString() + ? 1 + : a.toString() < b.toString() + ? -1 + : 0 + } + } + let m = 0 + let n = arr.length - 1 + while (m <= n) { + const k = (n + m) >> 1 + const cmp = comparator(el, arr[k]) + if (cmp > 0) { + m = k + 1 + } else if (cmp < 0) { + n = k - 1 + } else { + return k + } + } + return -m - 1 +} + +export const makeShortHash = (x, n = 4) => { + if (x) { + if (x.length > 63) { + if (x.length === 64) { + return x.slice(0, n) + 'x' + x.slice(63 - n) + } else if (x.length === 128) { + return x.slice(0, n) + 'xx' + x.slice(127 - n) + } else if (x.length === 192) { + return x.slice(0, n) + 'xx' + x.slice(191 - n) + } + } + return x + } else { + return x + } +} + +export const replyResult = (res, result) => { + if (res.setHeader) res.setHeader('content-type', 'text/plain') + else if (res.header) res.header('content-type', 'text/plain') + res.send(result) +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..a4ac115 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "allowUnreachableCode": false, + "allowUnusedLabels": false, + "declaration": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es2016"], + "module": "commonjs", + "noFallthroughCasesInSwitch": true, + "pretty": true, + "sourceMap": true, + "target": "es2017", + "rootDir": ".", + "outDir": "build", + "allowJs": true, + "resolveJsonModule": true, + "noEmitOnError": false, + "strict": false, + "noImplicitAny": false, + "strictNullChecks": false, + "noImplicitReturns": false, + "noImplicitThis": false, + "esModuleInterop": true + }, + "exclude": [ + "build", + "node_modules" + ], + "include": [ + "src/**/*.js", + "src/**/*.ts", + "src/**/*.json" + ] +} diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..27872a1 --- /dev/null +++ b/tslint.json @@ -0,0 +1,8 @@ +{ + "extends": "gts/tslint.json", + "linterOptions": { + "exclude": [ + "**/*.json" + ] + } +}