@bemoje/profiler 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +22 -31
- package/lib/index.cjs.map +1 -0
- package/lib/index.js +22 -31
- package/lib/index.js.map +1 -0
- package/package.json +6 -4
package/lib/index.cjs
CHANGED
|
@@ -33,10 +33,7 @@ var FunctionProfiler = class _FunctionProfiler {
|
|
|
33
33
|
* Average execution time in nanoseconds
|
|
34
34
|
*/
|
|
35
35
|
get avgTimeNs() {
|
|
36
|
-
|
|
37
|
-
return void 0;
|
|
38
|
-
}
|
|
39
|
-
return Math.floor(this.totalTimeNs / this.calls);
|
|
36
|
+
return this.calls && this.totalTimeNs ? Math.floor(this.totalTimeNs / this.calls) : void 0;
|
|
40
37
|
}
|
|
41
38
|
/**
|
|
42
39
|
* Get the result of the profiling
|
|
@@ -687,7 +684,7 @@ var TimeoutWeakMap = class {
|
|
|
687
684
|
};
|
|
688
685
|
function memoizeSync(arg = {}) {
|
|
689
686
|
const opts = typeof arg === "object" ? arg : {
|
|
690
|
-
maxAge: typeof arg === "number" ? arg : enhancedMs.ms(arg)
|
|
687
|
+
maxAge: typeof arg === "number" ? arg : enhancedMs.ms(arg) ?? 0
|
|
691
688
|
};
|
|
692
689
|
return /* @__PURE__ */ __name(function decorator(target, key, descriptor) {
|
|
693
690
|
if (!descriptor) {
|
|
@@ -715,7 +712,7 @@ function memoizeSync(arg = {}) {
|
|
|
715
712
|
__name(memoizeSync, "memoizeSync");
|
|
716
713
|
function lazyProp(targetOrTimeout, key, descriptor) {
|
|
717
714
|
if (typeof targetOrTimeout === "number" || typeof targetOrTimeout === "string") {
|
|
718
|
-
const maxAge = typeof targetOrTimeout === "number" ? targetOrTimeout : enhancedMs.ms(targetOrTimeout);
|
|
715
|
+
const maxAge = typeof targetOrTimeout === "number" ? targetOrTimeout : enhancedMs.ms(targetOrTimeout) ?? 0;
|
|
719
716
|
return createLazyPropDecorator(new TimeoutWeakMap(maxAge));
|
|
720
717
|
} else {
|
|
721
718
|
const decorator = createLazyPropDecorator(/* @__PURE__ */ new WeakMap());
|
|
@@ -743,13 +740,22 @@ __name(createLazyPropDecorator, "createLazyPropDecorator");
|
|
|
743
740
|
// ../table/src/TableFormatter.ts
|
|
744
741
|
function _ts_decorate(decorators, target, key, desc) {
|
|
745
742
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
746
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
747
|
-
|
|
743
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
744
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
745
|
+
} else {
|
|
746
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
747
|
+
if (d = decorators[i]) {
|
|
748
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
748
752
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
749
753
|
}
|
|
750
754
|
__name(_ts_decorate, "_ts_decorate");
|
|
751
|
-
function _ts_metadata(
|
|
752
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
755
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
756
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
757
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
758
|
+
}
|
|
753
759
|
}
|
|
754
760
|
__name(_ts_metadata, "_ts_metadata");
|
|
755
761
|
var TableFormatter = class _TableFormatter {
|
|
@@ -808,15 +814,7 @@ var TableFormatter = class _TableFormatter {
|
|
|
808
814
|
}
|
|
809
815
|
get formattedRows() {
|
|
810
816
|
const result = this.stringsTable.map((row, r) => row.map((cell, c) => this.formatCell(cell, c, r)));
|
|
811
|
-
|
|
812
|
-
return result;
|
|
813
|
-
}
|
|
814
|
-
return result.map((row, r) => {
|
|
815
|
-
if (!this.options.grayOutRow(this.table[r])) {
|
|
816
|
-
return row;
|
|
817
|
-
}
|
|
818
|
-
return row.map((cell) => this.options.color.separator(colors__default.default.stripColor(cell)));
|
|
819
|
-
});
|
|
817
|
+
return this.options.color && this.options.grayOutRow ? result.map((row, r) => this.options.grayOutRow(this.table[r]) ? row.map((cell) => this.options.color.separator(colors__default.default.stripColor(cell))) : row) : result;
|
|
820
818
|
}
|
|
821
819
|
get formattedLines() {
|
|
822
820
|
const lines = this.formattedRows.map((row) => row.join(this.columnSeparatorFormatted));
|
|
@@ -901,10 +899,7 @@ var TableFormatter = class _TableFormatter {
|
|
|
901
899
|
}
|
|
902
900
|
formatNumber(cell, originalCell, c) {
|
|
903
901
|
cell = this.alignRight(cell, c);
|
|
904
|
-
|
|
905
|
-
return this.options.color.negativeNumber(cell);
|
|
906
|
-
}
|
|
907
|
-
return this.options.color.positiveNumber(cell);
|
|
902
|
+
return (originalCell ?? 0) < 0 ? this.options.color.negativeNumber(cell) : this.options.color.positiveNumber(cell);
|
|
908
903
|
}
|
|
909
904
|
alignLeft(cell, c) {
|
|
910
905
|
return cell.padEnd(this.columnWidths[c], " ");
|
|
@@ -1020,10 +1015,7 @@ var Profiler = class _Profiler {
|
|
|
1020
1015
|
throw new Error(`Function must have a name:
|
|
1021
1016
|
${func.toString()}`);
|
|
1022
1017
|
}
|
|
1023
|
-
|
|
1024
|
-
return profilerWrap(func, new FunctionProfiler(new StandaloneFunctionIdentifier(func)));
|
|
1025
|
-
}
|
|
1026
|
-
return func;
|
|
1018
|
+
return _Profiler.enabled ? profilerWrap(func, new FunctionProfiler(new StandaloneFunctionIdentifier(func))) : func;
|
|
1027
1019
|
}
|
|
1028
1020
|
static getResults(options) {
|
|
1029
1021
|
const results = _Profiler.data.map((profiler) => [
|
|
@@ -1036,10 +1028,7 @@ ${func.toString()}`);
|
|
|
1036
1028
|
const sortValue2 = /* @__PURE__ */ __name((entry) => entry[1][sortKey2] ?? -1, "sortValue2");
|
|
1037
1029
|
return results.sort((a, b) => {
|
|
1038
1030
|
const comparision = sortValue1(a) - sortValue1(b);
|
|
1039
|
-
|
|
1040
|
-
return comparision;
|
|
1041
|
-
}
|
|
1042
|
-
return sortValue2(a) - sortValue2(b);
|
|
1031
|
+
return comparision === 0 ? sortValue2(a) - sortValue2(b) : comparision;
|
|
1043
1032
|
});
|
|
1044
1033
|
}
|
|
1045
1034
|
static printResults(options) {
|
|
@@ -1085,3 +1074,5 @@ ${func.toString()}`);
|
|
|
1085
1074
|
};
|
|
1086
1075
|
|
|
1087
1076
|
exports.Profiler = Profiler;
|
|
1077
|
+
//# sourceMappingURL=index.cjs.map
|
|
1078
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/internal/FunctionProfiler/FunctionProfiler.ts","../../../object/src/setNonEnumerable.ts","../../src/internal/FunctionIdentifier/AbstractFunctionIdentifier.ts","../../src/internal/FunctionIdentifier/AbstractMethodIdentifier.ts","../../src/internal/FunctionIdentifier/ModuleMethodIdentifier.ts","../../src/internal/ProfilerFactory/ModuleMethodProfilerFactory.ts","../../../fn/src/setNameAndLength.ts","../../../fn/src/functionSpy.ts","../../../fn/src/setName.ts","../../../fn/src/wrapMethods.ts","../../src/internal/FunctionProfiler/profilerWrap.ts","../../src/internal/ProfilerWrapMethodsStrategy/ProfilerWrapMethodsStrategy.ts","../../src/internal/FunctionIdentifier/PrototypeMethodIdentifier.ts","../../src/internal/ProfilerFactory/PrototypeMethodProfilerFactory.ts","../../src/internal/FunctionIdentifier/StandaloneFunctionIdentifier.ts","../../src/internal/FunctionIdentifier/StaticMethodIdentifier.ts","../../src/internal/ProfilerFactory/StaticMethodProfilerFactory.ts","../../../number/src/NumberFormatter.ts","../../../decorators/src/assertDescriptorValueIsFunction.ts","../../../map/src/mapGetOrDefault.ts","../../../map/src/TimeoutWeakMap.ts","../../../decorators/src/memoizeSync.ts","../../../decorators/src/lazyProp.ts","../../../table/src/TableFormatter.ts","../../src/Profiler/Profiler.ts"],"names":["FunctionProfiler","instances","calls","totalTimeNs","minTimeNs","maxTimeNs","id","push","avgTimeNs","Math","floor","undefined","getResult","totalTimeUs","nsToUs","avgTimeUs","minTimeUs","maxTimeUs","onInvoke","process","hrtime","bigint","onReturn","t0","retval","add","t1","elapsed","Number","min","max","ns","round","inspect","custom","toJSON","setNonEnumerable","object","properties","prop","Object","defineProperty","enumerable","AbstractFunctionIdentifier","target","name","AbstractMethodIdentifier","key","type","keytoString","isSymbol","description","methodName","parentName","ModuleMethodIdentifier","targetType","ModuleMethodProfilerFactory","moduleName","createProfiler","methodType","setNameAndLength","source","lengthDelta","defineProperties","configurable","value","length","functionSpy","func","spy","options","async","wrapSync","isAsyncFunction","wrapAsync","wrapMaybeAsync","ignore","args","apply","data","Promise","then","setName","wrapMethods","strat","des","iterateMethods","filter","onMethod","orig","wrapped","onGetter","get","onSetter","set","Reflect","ownKeys","getOwnPropertyDescriptor","isFunction","profilerWrap","profiler","Profiler","enabled","ProfilerWrapMethodsStrategy","profilerFactory","ignoreKeys","Set","has","method","getter","setter","PrototypeMethodIdentifier","PrototypeMethodProfilerFactory","StandaloneFunctionIdentifier","StaticMethodIdentifier","StaticMethodProfilerFactory","locales","Map","NumberFormatter","precision","thousandSeparator","decimalSeparator","defineLocale","locale","getLocales","result","entry","entries","sep","Error","Array","from","keys","format","number","negative","split","abs","toString","decimals","padEnd","i","parse","string","replaceAll","replace","map","s","parseInt","join","n","descriptor","Function","prototype","TypeError","JSON","stringify","assertDescriptorValueIsFunction","mapGetOrDefault","factory","TimeoutWeakMap","wmap","WeakMap","timeoutMs","vt","timeout","refresh","setTimeout","delete","unref","clearTimeout","load","update","getOrDefault","memoizeSync","arg","opts","maxAge","ms","decorator","instancesShareCache","deleteProperty","memoizee","memoized","lazyProp","targetOrTimeout","createLazyPropDecorator","call","TableFormatter","defaults","columnSeparator","headerRowSeparator","grayOutRow","color","separator","colors","dim","gray","columnHeader","cyan","rowHeader","green","positiveNumber","yellow","negativeNumber","booleanTrue","magenta","booleanFalse","table","handleOptions","numberColumnPrecisions","reduce","acc","row","cell","c","isInteger","digits","stringsTable","cellToString","columnWidths","tableWidth","separatorsWidth","columnsWidth","width","columnSeparatorFormatted","headerRowSeparatorLineFormatted","formattedRows","r","formatCell","stripColor","formattedLines","lines","splice","headersLine","defaultColorsNoop","isArray","originalCell","formatNil","formatString","formatBoolean","formatNumber","alignLeft","isColumnHeader","isRowHeader","padded","alignRight","padStart","slice","class","targetOrOptions","classStatic","ignoreStaticKeys","classPrototype","ignorePrototypeKeys","module","fn","nameOrFunc","maybeFunc","getResults","results","sortkey1","sortBy","sortValue1","sortKey2","sortValue2","sort","a","b","comparision","printResults","headers","rows","stats","formatter","noColor","console","log","forEach","line","depth","compact","fromEntries"],"mappings":";;;;;;;;;;;;;;;;;AAOO,IAAMA,gBAAAA,GAAN,MAAMA,iBAAAA,CAAAA;EALb;;;;AAME,EAAA,OAAOC,YAAwC,EAAA;EAC/CC,KAAAA,GAAQ,CAAA;AACRC,EAAAA,WAAAA;AACAC,EAAAA,SAAAA;AACAC,EAAAA,SAAAA;AAEA,EAAA,WAAA,CAAqBC,EAAAA,EAAmC;SAAnCA,EAAAA,GAAAA,EAAAA;AACnBN,IAAAA,iBAAAA,CAAiBC,SAAAA,CAAUM,KAAK,IAAI,CAAA;AACtC,EAAA;;;;AAKA,EAAA,IAAIC,SAAAA,GAAgC;AAClC,IAAA,OAAO,IAAA,CAAKN,KAAAA,IAAS,IAAA,CAAKC,WAAAA,GAAcM,IAAAA,CAAKC,MAAM,IAAA,CAAKP,WAAAA,GAAc,IAAA,CAAKD,KAAK,CAAA,GAAIS,MAAAA;AACtF,EAAA;;;;EAKAC,SAAAA,GAAoC;AAClC,IAAA,OAAO;AACLV,MAAAA,KAAAA,EAAO,IAAA,CAAKA,KAAAA;AACZW,MAAAA,WAAAA,EAAa,KAAKV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AAC1Cf,MAAAA,KAAAA,EAAO,CAAC3H,OAAAA,EAAS6M,OAAAA;AACjBnF,MAAAA,UAAAA,kBAAY,MAAA,CAAA,CAACqB,GAAAA,KAAQA,GAAAA,CAAI,CAAA,MAAO,CAAA,EAApB,YAAA;KACd,CAAA;AAEA+D,IAAAA,OAAAA,CAAQC,GAAAA,EAAG;AACXH,IAAAA,SAAAA,CAAU3C,eAAe+C,OAAAA,CAAQ,CAACC,SAASH,OAAAA,CAAQC,GAAAA,CAAIE,IAAAA,CAAAA,CAAAA;AACvDH,IAAAA,OAAAA,CAAQC,GAAAA,EAAG;AACb,EAAA;AAEA,EAAA,QAAQpP,aAAQC,MAAM,CAAA,CAAEsP,KAAAA,EAAgBlN,OAAAA,GAA0B,EAAC,EAAG;AACpEA,IAAAA,OAAAA,CAAQmN,OAAAA,GAAU,IAAA;AAClB,IAAA,OAAOjP,MAAAA,CAAOkP,WAAAA,CAAY,IAAA,CAAKvB,UAAAA,EAAU,CAAA;AAC3C,EAAA;AAEA,EAAA,OAAOhO,MAAAA,GAAS;AACd,IAAA,OAAO,KAAKgO,UAAAA,EAAU;AACxB,EAAA;AACF","file":"index.cjs","sourcesContent":["import { AbstractFunctionIdentifier } from '../FunctionIdentifier/AbstractFunctionIdentifier'\nimport type { IFunctionSpyStrategy } from '@mono/fn'\nimport { inspect } from 'util'\n\n/**\n * Profiler for functions, measuring execution time and call counts.\n */\nexport class FunctionProfiler<T extends object> implements IFunctionSpyStrategy<T, bigint> {\n static instances: FunctionProfiler<object>[] = []\n calls = 0\n totalTimeNs?: number\n minTimeNs?: number\n maxTimeNs?: number\n\n constructor(readonly id: AbstractFunctionIdentifier<T>) {\n FunctionProfiler.instances.push(this)\n }\n\n /**\n * Average execution time in nanoseconds\n */\n get avgTimeNs(): number | undefined {\n return this.calls && this.totalTimeNs ? Math.floor(this.totalTimeNs / this.calls) : undefined\n }\n\n /**\n * Get the result of the profiling\n */\n getResult(): FunctionProfilerResult {\n return {\n calls: this.calls,\n totalTimeUs: this.totalTimeNs ? this.nsToUs(this.totalTimeNs) : undefined,\n avgTimeUs: this.avgTimeNs ? this.nsToUs(this.avgTimeNs) : undefined,\n minTimeUs: this.minTimeNs == null ? this.minTimeNs : this.nsToUs(this.minTimeNs),\n maxTimeUs: this.maxTimeNs == null ? this.maxTimeNs : this.nsToUs(this.maxTimeNs),\n }\n }\n\n /**\n * @see IFunctionSpyStrategy.onInvoke\n */\n onInvoke(): bigint {\n return process.hrtime.bigint()\n }\n\n /**\n * @see IFunctionSpyStrategy.onReturn\n */\n onReturn<Ret>(t0: bigint, retval: Ret): Ret {\n this.add(t0, process.hrtime.bigint())\n return retval\n }\n\n /**\n * Add a new time measurement\n */\n protected add(t0: bigint, t1: bigint) {\n const elapsed = Number(t1 - t0)\n this.calls++\n this.totalTimeNs = (this.totalTimeNs ?? 0) + elapsed\n this.minTimeNs = Math.min(this.minTimeNs ?? elapsed, elapsed)\n this.maxTimeNs = Math.max(this.maxTimeNs ?? elapsed, elapsed)\n }\n\n /**\n * Nanoseconds to microseconds\n */\n protected nsToUs(ns: number): number {\n return Math.round(ns / 1000)\n }\n\n public [inspect.custom]() {\n return this.getResult()\n }\n\n toJSON() {\n return this.getResult()\n }\n}\n\nexport type FunctionProfilerResult = {\n /**\n * Number of method calls\n */\n calls: number\n\n /**\n * Total execution time in microseconds\n */\n totalTimeUs?: number\n\n /**\n * Total execution time in microseconds\n */\n avgTimeUs?: number\n\n /**\n * Fastest execution time in microseconds\n */\n minTimeUs?: number\n\n /**\n * Slowest execution time in microseconds\n */\n maxTimeUs?: number\n}\n","/**\n * Sets the specified properties of an object as non-enumerable.\n */\nexport function setNonEnumerable<T extends object>(object: T, ...properties: string[]): T {\n for (const prop of properties) {\n Object.defineProperty(object, prop, { enumerable: false })\n }\n return object\n}\n","import type { FunctionPrototype } from '@mono/types'\nimport type { FunctionType } from './types'\nimport type { TargetType } from './types'\nimport { inspect } from 'util'\nimport { setNonEnumerable } from '@mono/object'\n\n/**\n * Abstract base class for identifying and naming functions in profiling contexts.\n */\nexport abstract class AbstractFunctionIdentifier<T extends FunctionPrototype | object> {\n abstract readonly targetType: TargetType\n abstract readonly type: FunctionType\n abstract readonly name: string\n\n constructor(readonly target: T) {\n setNonEnumerable(this, 'target')\n }\n\n toJSON() {\n return this.name\n }\n\n public [inspect.custom]() {\n return this.name\n }\n}\n","import { AbstractFunctionIdentifier } from './AbstractFunctionIdentifier'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { MethodTargetType } from './types'\nimport type { MethodType } from './types'\nimport { isSymbol } from 'es-toolkit/predicate'\nimport { setNonEnumerable } from '@mono/object'\n\n/**\n * Abstract base class for identifying and naming method functions in profiling contexts.\n */\nexport abstract class AbstractMethodIdentifier<\n T extends object | FunctionPrototype,\n> extends AbstractFunctionIdentifier<T> {\n abstract override readonly targetType: MethodTargetType\n abstract readonly parentName: string | undefined\n constructor(\n target: T,\n readonly key: string | symbol,\n readonly type: MethodType = 'method'\n ) {\n super(target)\n setNonEnumerable(this, 'type', 'key')\n }\n keytoString() {\n return isSymbol(this.key) ? `[${this.key.description}]` : this.key\n }\n get methodName(): string {\n if (this.type === 'method') {\n return `${this.keytoString()}()`\n }\n if (this.type === 'get') {\n return this.keytoString()\n }\n return `${this.keytoString()}[set]`\n }\n get name(): string {\n return this.parentName + (isSymbol(this.key) ? '' : '.') + this.methodName\n }\n}\n","import { AbstractMethodIdentifier } from './AbstractMethodIdentifier'\nimport type { MethodTargetType } from './types'\nimport type { MethodType } from './types'\nimport { setNonEnumerable } from '@mono/object'\n\n/**\n * Identifies methods within module objects for profiling purposes.\n */\nexport class ModuleMethodIdentifier extends AbstractMethodIdentifier<object> {\n constructor(\n readonly parentName: string,\n target: object,\n key: string | symbol,\n type: MethodType = 'method'\n ) {\n super(target, key, type)\n setNonEnumerable(this, 'parentName')\n }\n override get targetType(): MethodTargetType {\n return 'module'\n }\n}\n","import { FunctionProfiler } from '../FunctionProfiler/FunctionProfiler'\nimport type { IProfilerFactory } from './IProfilerFactory'\nimport type { MethodType } from '../FunctionIdentifier/types'\nimport { ModuleMethodIdentifier } from '../FunctionIdentifier/ModuleMethodIdentifier'\n\n/**\n * Factory for creating profilers for module method functions using the Factory pattern.\n */\nexport class ModuleMethodProfilerFactory implements IProfilerFactory<object> {\n constructor(\n readonly moduleName: string,\n readonly target: object\n ) {}\n\n createProfiler(key: string | symbol, methodType: MethodType): FunctionProfiler<object> {\n return new FunctionProfiler(new ModuleMethodIdentifier(this.moduleName, this.target, key, methodType))\n }\n}\n","import type { Any } from '@mono/types'\n\n/**\n * Preserves the name and length of a function or class constructor\n */\nexport function setNameAndLength<\n S extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n F extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n>(source: S, target: F, lengthDelta = 0): F {\n return Object.defineProperties(target, {\n name: { configurable: true, value: source.name }, //\n length: { configurable: true, value: source.length + lengthDelta },\n })\n}\n","import type { Any } from '@mono/types'\nimport type { AnyAsyncFunction } from '@mono/types'\nimport type { TFunction } from '@mono/types'\nimport { isAsyncFunction } from 'util/types'\nimport { setNameAndLength } from './setNameAndLength'\n\n/**\n * Wraps a function so that the given @see IFunctionSpyStrategy will be applied.\n * @param func The function to wrap.\n * @param spy The strategy to apply.\n * @param options Options.\n */\nexport function functionSpy<T, Data>(\n func: TFunction,\n spy: IFunctionSpyStrategy<T, Data>,\n options: FunctionSpyOptions<T, Data> = {}\n) {\n if (options.async === false) {\n return wrapSync(func, spy, options)\n } else if (options.async || isAsyncFunction(func)) {\n return wrapAsync(func, spy, options)\n } else {\n return wrapMaybeAsync(func, spy, options)\n }\n}\n\nexport interface FunctionSpyOptions<T, Data> {\n /**\n * Whether the function is async.\n * If provided, execution is a bit faster.\n */\n async?: boolean\n\n /**\n * Predicate function that determines whether to skip the spy's actions for a given function call.\n */\n ignore?: IgnorePredicate<T, Data>\n}\n\n/**\n * @see functionSpy\n */\nexport interface IFunctionSpyStrategy<T, Data> {\n /**\n * Action to perform before the function is invoked.\n * @param thisContext The context in which the function is invoked.\n * @param args The arguments passed to the function. Modify this array to change the arguments passed to the function.\n * @returns Data to be passed to @see onReturn.\n */\n onInvoke<Args extends Any[]>(thisContext: T, args: Args): Data\n\n /**\n * Action to perform before the function returns.\n * @param data The data returned by @see onInvoke.\n * @param retval The return value of the function.\n * @returns The value to be returned by the wrapped function.\n */\n onReturn<Ret>(data: Data, retval: Ret): Ret\n}\n\nfunction wrapMaybeAsync<T, Data>(\n func: TFunction,\n spy: IFunctionSpyStrategy<T, Data>,\n options: { ignore?: IgnorePredicate<T, Data> } = {}\n) {\n const ignore = options.ignore\n if (ignore && ignore(func, spy)) {\n return func\n }\n return setNameAndLength(func, function (this: T, ...args: any[]) {\n if (ignore && ignore(func, spy, this)) {\n return func.apply(this, args)\n }\n const data = spy.onInvoke(this, args)\n const retval = func.apply(this, args)\n return retval instanceof Promise\n ? retval.then((retval) => spy.onReturn(data, retval))\n : spy.onReturn(data, retval)\n })\n}\n\nfunction wrapSync<T, Data>(\n func: TFunction,\n spy: IFunctionSpyStrategy<T, Data>,\n options: { ignore?: IgnorePredicate<T, Data> } = {}\n) {\n const ignore = options.ignore\n if (ignore && ignore(func, spy)) {\n return func\n }\n return setNameAndLength(func, function (this: T, ...args: any[]) {\n if (ignore && ignore(func, spy, this)) {\n return func.apply(this, args)\n }\n const data = spy.onInvoke(this, args)\n const retval = func.apply(this, args)\n return spy.onReturn(data, retval)\n })\n}\n\nfunction wrapAsync<T, Data>(\n func: AnyAsyncFunction,\n spy: IFunctionSpyStrategy<T, Data>,\n options: { ignore?: IgnorePredicate<T, Data> } = {}\n) {\n const ignore = options.ignore\n if (ignore && ignore(func, spy)) {\n return func\n }\n return setNameAndLength(func, async function (this: T, ...args: any[]) {\n if (ignore && ignore(func, spy, this)) {\n return await func.apply(this, args)\n }\n const data = spy.onInvoke(this, args)\n const retval = await func.apply(this, args)\n return spy.onReturn(data, retval)\n })\n}\n\nexport type IgnorePredicate<T, Data> = (\n func: TFunction,\n spy: IFunctionSpyStrategy<T, Data>,\n thisContext?: T\n) => boolean\n","/**\n * Set the name of a function.\n */\nexport function setName<T extends object>(name: string | { name: string }, target: T): T {\n return Object.defineProperty(target, 'name', {\n value: typeof name === 'string' ? name : name.name,\n configurable: true,\n enumerable: false,\n })\n}\n","import type { AnyFunction } from '@mono/types'\nimport type { AnyGetter } from '@mono/types'\nimport type { AnySetter } from '@mono/types'\nimport { isFunction } from 'es-toolkit/predicate'\nimport { setNameAndLength } from './setNameAndLength'\n\n/**\n * Wrap methods, getters and setters of an object with custom logic.\n */\nexport function wrapMethods<T extends object>(target: T, strat: WrapMethodsStrategy<T>) {\n for (const [key, type, des] of iterateMethods(target)) {\n if (strat.filter && !strat.filter(target, key, type, des)) {\n continue\n }\n switch (type) {\n case 'method': {\n if (!strat.onMethod) {\n continue\n }\n const orig = des.value!\n const wrapped = strat.onMethod(target, key, orig)\n if (!wrapped) {\n continue\n }\n Object.defineProperty(target, key, {\n value: setNameAndLength(orig, wrapped),\n configurable: des.configurable,\n enumerable: des.enumerable,\n })\n\n break\n }\n case 'get': {\n if (!strat.onGetter) {\n continue\n }\n const orig = des.get!\n const wrapped = strat.onGetter(target, key, orig)\n if (!wrapped) {\n continue\n }\n Object.defineProperty(target, key, {\n get: setNameAndLength(orig, wrapped),\n configurable: des.configurable,\n enumerable: des.enumerable,\n })\n\n break\n }\n case 'set': {\n if (!strat.onSetter) {\n continue\n }\n const orig = des.set!\n const wrapped = strat.onSetter(target, key, orig)\n if (!wrapped) {\n continue\n }\n Object.defineProperty(target, key, {\n set: setNameAndLength(orig, wrapped),\n configurable: des.configurable,\n enumerable: des.enumerable,\n })\n\n break\n }\n // No default\n }\n }\n return target\n}\n\nfunction* iterateMethods<T extends object>(\n target: T\n): Generator<[string | symbol, DescriptorMethodType, PropertyDescriptor]> {\n for (const key of Reflect.ownKeys(target)) {\n const des = Object.getOwnPropertyDescriptor(target, key)\n if (!des || des.configurable === false) {\n continue\n }\n if (isFunction(des.value)) {\n yield [key, 'method', des]\n } else {\n if (isFunction(des.get)) {\n yield [key, 'get', des]\n }\n if (isFunction(des.set)) {\n yield [key, 'set', des]\n }\n }\n }\n}\n\nexport type DescriptorMethodType = 'get' | 'set' | 'method'\n\nexport type MethodFilter<T extends object = object> = (\n target: T,\n key: string | symbol,\n type: DescriptorMethodType,\n descriptor: PropertyDescriptor\n) => boolean\n\nexport type MethodWrapper<T extends object = object> = (\n target: T,\n key: string | symbol,\n method: AnyFunction\n) => AnyFunction | undefined\n\nexport type GetterWrapper<T extends object = object> = (\n target: T,\n key: string | symbol,\n getter: AnyGetter\n) => AnyGetter | undefined\n\nexport type SetterWrapper<T extends object = object> = (\n target: T,\n key: string | symbol,\n setter: AnySetter\n) => AnySetter | undefined\n\nexport interface WrapMethodsStrategy<T extends object = object> {\n filter?: MethodFilter<T>\n onGetter?: GetterWrapper<T>\n onSetter?: SetterWrapper<T>\n onMethod?: MethodWrapper<T>\n}\n","import { FunctionProfiler } from './FunctionProfiler'\nimport { Profiler } from '../../Profiler/Profiler'\nimport type { TFunction } from '@mono/types'\nimport { functionSpy } from '@mono/fn'\n\n/**\n * Wraps a function with a @see FunctionProfiler.\n */\nexport function profilerWrap<T extends object>(func: TFunction, profiler: FunctionProfiler<T>) {\n const ignore = () => !Profiler.enabled\n return profiler.id.type === 'get' || profiler.id.type === 'set'\n ? functionSpy(func, profiler, { ignore, async: false })\n : functionSpy(func, profiler, { ignore })\n}\n","import type { AnyFunction } from '@mono/types'\nimport type { AnyGetter } from '@mono/types'\nimport type { AnySetter } from '@mono/types'\nimport type { IProfilerFactory } from '../ProfilerFactory/IProfilerFactory'\nimport type { TFunction } from '@mono/types'\nimport type { WrapMethodsStrategy } from '@mono/fn'\nimport { profilerWrap } from '../FunctionProfiler/profilerWrap'\n\n/**\n * Strategy for wrapping object methods with profiling capabilities using the Strategy pattern.\n */\nexport class ProfilerWrapMethodsStrategy<Target extends object> implements WrapMethodsStrategy<Target> {\n readonly profilerFactory: IProfilerFactory<Target>\n readonly ignoreKeys: Set<string | symbol>\n\n constructor(profilerFactory: IProfilerFactory<Target>, ignoreKeys?: Iterable<string | symbol>) {\n this.profilerFactory = profilerFactory\n this.ignoreKeys = new Set(ignoreKeys)\n }\n\n filter<T extends Target>(target: T, key: string | symbol): boolean {\n if (key === 'constructor') {\n return false\n }\n if (this.ignoreKeys.has(key)) {\n return false\n }\n return true\n }\n\n onMethod<T extends Target>(target: T, key: string | symbol, method: AnyFunction) {\n return profilerWrap(method as TFunction, this.profilerFactory.createProfiler(key, 'method'))\n }\n\n onGetter<T extends Target>(target: T, key: string | symbol, getter: AnyGetter) {\n return profilerWrap(getter, this.profilerFactory.createProfiler(key, 'get')) as AnyGetter\n }\n\n onSetter<T extends Target>(target: T, key: string | symbol, setter: AnySetter) {\n return profilerWrap(setter, this.profilerFactory.createProfiler(key, 'set')) as AnySetter\n }\n}\n","import { AbstractMethodIdentifier } from './AbstractMethodIdentifier'\nimport type { AnyConstructor } from '@mono/types'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { MethodTargetType } from './types'\n\n/**\n * Identifies methods on class prototypes for profiling purposes.\n */\nexport class PrototypeMethodIdentifier extends AbstractMethodIdentifier<{\n constructor: FunctionPrototype | AnyConstructor\n}> {\n override get targetType(): MethodTargetType {\n return 'prototype'\n }\n override get parentName(): string {\n return `${this.target.constructor.name}.${this.targetType}`\n }\n}\n","import { FunctionProfiler } from '../FunctionProfiler/FunctionProfiler'\nimport type { IProfilerFactory } from './IProfilerFactory'\nimport type { MethodType } from '../FunctionIdentifier/types'\nimport { PrototypeMethodIdentifier } from '../FunctionIdentifier/PrototypeMethodIdentifier'\n\n/**\n * Factory for creating profilers for prototype method functions using the Factory pattern.\n */\nexport class PrototypeMethodProfilerFactory implements IProfilerFactory<object> {\n constructor(readonly target: object) {}\n\n createProfiler(key: string | symbol, methodType: MethodType): FunctionProfiler<object> {\n return new FunctionProfiler(new PrototypeMethodIdentifier(this.target, key, methodType))\n }\n}\n","import { AbstractFunctionIdentifier } from './AbstractFunctionIdentifier'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { FunctionType } from './types'\nimport type { TargetType } from './types'\n\n/**\n * Identifies standalone functions for profiling purposes.\n */\nexport class StandaloneFunctionIdentifier extends AbstractFunctionIdentifier<FunctionPrototype> {\n override get targetType(): TargetType {\n return 'standalone'\n }\n override get type(): FunctionType {\n return 'function'\n }\n override get name(): string {\n return `${this.target.name}()`\n }\n}\n","import { AbstractMethodIdentifier } from './AbstractMethodIdentifier'\nimport type { AnyConstructor } from '@mono/types'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { MethodTargetType } from './types'\n\n/**\n * Identifies static methods on classes for profiling purposes.\n */\nexport class StaticMethodIdentifier extends AbstractMethodIdentifier<FunctionPrototype | AnyConstructor> {\n override get targetType(): MethodTargetType {\n return 'static'\n }\n override get parentName(): string {\n return this.target.name\n }\n}\n","import { FunctionProfiler } from '../FunctionProfiler/FunctionProfiler'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { IProfilerFactory } from './IProfilerFactory'\nimport type { MethodType } from '../FunctionIdentifier/types'\nimport { StaticMethodIdentifier } from '../FunctionIdentifier/StaticMethodIdentifier'\n\n/**\n * Factory for creating profilers for static method functions using the Factory pattern.\n */\nexport class StaticMethodProfilerFactory implements IProfilerFactory<FunctionPrototype> {\n constructor(readonly target: FunctionPrototype) {}\n\n createProfiler(key: string | symbol, methodType: MethodType): FunctionProfiler<FunctionPrototype> {\n return new FunctionProfiler(new StaticMethodIdentifier(this.target, key, methodType))\n }\n}\n","import { round } from './round'\n\nconst locales: Map<string, [string, string]> = new Map([\n ['en-US', [',', '.']],\n ['da-DK', ['.', ',']],\n])\n\n/**\n * A utility class for formatting and parsing numbers with locale-specific separators.\n *\n * This class allows for customizing thousand and decimal separators, setting precision\n * for decimal places, and supports different locales for international number formatting.\n *\n * @example\n * ```typescript\n * // Create a formatter with 2 decimal places\n * const formatter = new NumberFormatter(2);\n *\n * // Format a number\n * formatter.format(1234.56); // \"1,234.56\"\n *\n * // Parse a formatted string\n * formatter.parse(\"1,234.56\"); // 1234.56\n *\n * // Use a different locale\n * formatter.locale(\"fr\").format(1234.56); // \"1 234,56\" (assuming French locale is defined)\n * ```\n *\n * @remarks\n * The class maintains a static registry of locales with their respective thousand and decimal separators.\n * Before using a locale, it must be defined using the `defineLocale` static method.\n */\nexport class NumberFormatter {\n // The number of decimals to round to.\n public precision: number\n\n // The character to use as thousand separator.\n public thousandSeparator = ','\n\n // The character to use as decimal separator.\n public decimalSeparator = '.'\n\n /**\n * Create a new number formatter.\n * @param precision The number of decimals to round to.\n */\n constructor(precision = 2) {\n this.precision = precision\n }\n\n /**\n * Set separator strings for a given locale.\n */\n static defineLocale(locale: string, thousandSeparator: string, decimalSeparator: string): void {\n locales.set(locale, [thousandSeparator, decimalSeparator])\n }\n\n /**\n * Returns a copy of the locales map.\n */\n static getLocales(): Map<string, [string, string]> {\n const result = new Map<string, [string, string]>()\n for (const entry of locales.entries()) {\n result.set(entry[0], [entry[1][0], entry[1][1]])\n }\n return result\n }\n\n /**\n * Set the locale for the number formatter.\n */\n locale(locale: string): this {\n const sep = locales.get(locale)\n if (!sep) {\n throw new Error(`Invalid locale: ${locale}. Valid: ${Array.from(locales.keys())}}.`)\n }\n this.thousandSeparator = sep[0]\n this.decimalSeparator = sep[1]\n return this\n }\n\n /**\n * Format a number to a string.\n */\n format(number: number): string {\n const negative = number >= 0 ? '' : '-'\n const split = Math.abs(round(number, this.precision)).toString().split('.')\n const decimals = this.precision ? this.decimalSeparator + (split[1] || '').padEnd(this.precision, '0') : ''\n let result = ''\n for (let i = 0; i < split[0].length; i++) {\n if (i % 3 === 0 && i !== 0) {\n result = this.thousandSeparator + result\n }\n result = split[0][split[0].length - i - 1] + result\n }\n return negative + result + decimals\n }\n\n /**\n * Parse a formatted string to a number.\n */\n parse(string: string): number {\n string = string\n .replaceAll(this.thousandSeparator, '')\n .replace(this.decimalSeparator, '.')\n .replaceAll(/[^\\d.-]/g, '')\n .split('.')\n .map((s) => parseInt(s))\n .join('.')\n const n = Number(string)\n return n\n }\n}\n","/**\n * Asserts that a property descriptor contains a function value.\n */\nexport default function assertDescriptorValueIsFunction(key: string, descriptor: PropertyDescriptor) {\n if (!(typeof descriptor.value === 'function' && descriptor.value !== Function.prototype)) {\n throw new TypeError(`\"value\" not a function for ${key} with descriptor: ${JSON.stringify(descriptor)}.`)\n }\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Gets a value from a map or creates it using a factory function if it doesn't exist.\n */\nexport function mapGetOrDefault<K, V, T extends GenericMap<K, V, 'get' | 'has' | 'set'>>(\n map: T,\n key: K,\n factory: (key: K, map: T) => V\n): V {\n let value = map.get(key)\n if (value !== undefined || map.has(key)) {\n return value as V\n }\n value = factory(key, map)\n map.set(key, value)\n return value\n}\n","/**\n * A WeakMap with automatic timeout-based expiry for entries.\n *\n * Entries are automatically removed after a specified timeout period.\n * Accessing an entry refreshes its timeout, extending its lifetime.\n * This is useful for caching scenarios where you want automatic cleanup\n * of unused entries while keeping frequently accessed ones alive.\n */\nexport class TimeoutWeakMap<K extends object, V> {\n protected readonly wmap = new WeakMap<K, [V, NodeJS.Timeout]>()\n\n /**\n * @param timeoutMs Default timeout in milliseconds for entries\n */\n constructor(readonly timeoutMs: number) {}\n\n /**\n * Retrieves the value for the given key and refreshes its timeout.\n *\n * @param key The key to retrieve\n * @returns The value if found, undefined otherwise\n */\n get(key: K): V | undefined {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return undefined\n }\n const [value, timeout] = vt\n timeout.refresh()\n return value\n }\n\n /**\n * Sets a key-value pair with an optional custom timeout.\n *\n * @param key The key to set\n * @param value The value to associate with the key\n * @param timeoutMs Optional timeout override for this entry\n * @returns This instance for chaining\n */\n set(key: K, value: V, timeoutMs?: number): this {\n this.wmap.set(key, [\n value,\n setTimeout(() => {\n this.delete(key)\n }, timeoutMs ?? this.timeoutMs).unref(),\n ])\n return this\n }\n\n /**\n * Removes a key-value pair and clears its timeout.\n *\n * @param key The key to delete\n * @returns True if the key existed and was deleted, false otherwise\n */\n delete(key: K): boolean {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return false\n }\n const timeout = vt[1]\n clearTimeout(timeout)\n return this.wmap.delete(key)\n }\n\n /**\n * Checks if a key exists in the map.\n * Does not refresh the timeout.\n *\n * @param key The key to check\n * @returns True if the key exists, false otherwise\n */\n has(key: K): boolean {\n return this.wmap.has(key)\n }\n\n /**\n * Loads multiple key-value pairs into the map.\n *\n * @param entries Iterable of key-value pairs to load\n * @param timeoutMs Optional timeout override for all entries\n * @returns This instance for chaining\n */\n load(entries: Iterable<[K, V]>, timeoutMs?: number): this {\n for (const [key, value] of entries) {\n this.set(key, value, timeoutMs)\n }\n return this\n }\n\n /**\n * Updates an existing value or creates a new one using an update function.\n *\n * @param key The key to update\n * @param update Function that receives the current value and returns the new value\n * @returns This instance for chaining\n */\n update(key: K, update: (value: V | undefined, key: K, map: this) => V): this {\n return this.set(key, update(this.get(key), key, this))\n }\n\n /**\n * Gets a value or creates it using a factory function if it doesn't exist.\n * Refreshes timeout if the value exists.\n *\n * @param key The key to get or create\n * @param factory Function to create the value if it doesn't exist\n * @param timeoutMs Optional timeout override for new entries\n * @returns The existing or newly created value\n */\n getOrDefault(key: K, factory: (key: K, map: this) => V, timeoutMs?: number): V {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (vt) {\n const [value, timeout] = vt\n timeout.refresh()\n return value\n } else {\n const value = factory(key, this)\n this.set(key, value, timeoutMs)\n return value\n }\n }\n}\n","import type { MemoizeSyncOptions } from './types.internal'\nimport type { SomeSyncFunction } from './types.internal'\nimport assertDescriptorValueIsFunction from './assertDescriptorValueIsFunction'\nimport { mapGetOrDefault } from '@mono/map'\nimport memoizee from 'memoizee'\nimport { ms } from 'enhanced-ms'\n\n/**\n * Decorator to memoize a sync method.\n * @param maxAge The maximum age of the memoized value as number (ms) or descriptive string (e.g. '10 min'). Uses 'ms' library: https://github.com/zeit/ms\n */\nexport function memoizeSync(\n maxAge?: number | string\n): (target: object, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor\n\n/**\n * Decorator to memoize a sync method.\n * @param options The options for memoization.\n */\nexport function memoizeSync(\n options: MemoizeSyncOptions\n): (target: object, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor\n\n//\nexport function memoizeSync(arg: (number | string) | MemoizeSyncOptions = {}) {\n const opts = typeof arg === 'object' ? arg : { maxAge: typeof arg === 'number' ? arg : (ms(arg) ?? 0) }\n\n return function decorator(target: unknown, key: string, descriptor?: PropertyDescriptor) {\n if (!descriptor) {\n throw new TypeError('descriptor is undefined')\n }\n const orig = descriptor.value\n assertDescriptorValueIsFunction(key, descriptor)\n const options = { length: false, ...opts } as memoizee.Options<SomeSyncFunction>\n\n if (opts.instancesShareCache) {\n Reflect.deleteProperty(options, 'instancesShareCache')\n descriptor.value = memoizee(orig, options)\n } else {\n const wmap = new WeakMap()\n descriptor.value = function (...args: any[]) {\n const memoized = mapGetOrDefault(wmap, this, () => memoizee(orig, options))\n return memoized.apply(this, args)\n }\n }\n\n return descriptor\n }\n}\n","import type { GenericMap } from '@mono/types'\nimport { TimeoutWeakMap } from '@mono/map'\nimport { isFunction } from 'es-toolkit/predicate'\nimport { mapGetOrDefault } from '@mono/map'\nimport { memoizeSync } from './memoizeSync'\nimport { ms } from 'enhanced-ms'\n\n/**\n * Decorator to memoize a method or getter accessor property.\n */\nexport function lazyProp(target: object, key: string, descriptor: PropertyDescriptor): PropertyDescriptor\n\n/**\n * Decorator to temporarily memoize a method or getter accessor property.\n * @param maxAge The maximum age of the memoized value as number (ms) or descriptive string (e.g. '10 min'). Uses 'ms' library: https://github.com/zeit/ms\n */\nexport function lazyProp(\n maxAge: number | string\n): (target: object, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor\n\n//\nexport function lazyProp(\n targetOrTimeout: object | number | string,\n key?: string,\n descriptor?: PropertyDescriptor\n) {\n if (typeof targetOrTimeout === 'number' || typeof targetOrTimeout === 'string') {\n const maxAge = typeof targetOrTimeout === 'number' ? targetOrTimeout : (ms(targetOrTimeout) ?? 0)\n return createLazyPropDecorator(new TimeoutWeakMap(maxAge))\n } else {\n const decorator = createLazyPropDecorator(new WeakMap())\n return decorator(targetOrTimeout, key!, descriptor!)\n }\n}\n\nfunction createLazyPropDecorator<K extends object, V>(map: GenericMap<K, V, 'get' | 'set' | 'has'>) {\n return function (target: object, key: string, descriptor: PropertyDescriptor) {\n const { get, value } = descriptor\n\n if (isFunction(get)) {\n descriptor.get = function () {\n return mapGetOrDefault(map, this as K, () => get.call(this))\n }\n return descriptor\n }\n\n if (isFunction(value)) {\n return memoizeSync()(target, key, descriptor)\n }\n\n throw new TypeError('neither \"get\" nor \"value\" are functions')\n }\n}\n","import { NumberFormatter } from '@mono/number'\nimport colors from 'ansi-colors'\nimport { lazyProp } from '@mono/decorators'\n\n/**\n * Options for @see formatTable\n */\nexport interface FormatTableOptions {\n /**\n * Whether to use colors in the output.\n * @default false\n */\n color?: boolean | Partial<FormatTableColors>\n\n /**\n * The string used to separate columns.\n * @default ' | '\n */\n columnSeparator?: string\n\n /**\n * The string used to separate the header row from the rest of the table.\n * @default '-'\n */\n headerRowSeparator?: string\n\n /**\n * An optional function that returns `true` if a row should be grayed out.\n */\n grayOutRow?: (row: (Primitive | Primitive[])[]) => boolean\n}\n\n/**\n * Formats a 2D array representing a table.\n */\nexport class TableFormatter {\n static readonly defaults: FormatTableOptionsMerged = {\n columnSeparator: ' | ',\n headerRowSeparator: '-',\n grayOutRow: undefined,\n color: {\n separator: colors.dim.gray,\n columnHeader: colors.cyan,\n rowHeader: (s: string) => s,\n string: colors.green,\n positiveNumber: colors.yellow,\n negativeNumber: colors.yellow,\n booleanTrue: colors.magenta,\n booleanFalse: colors.magenta,\n },\n }\n\n readonly table: (Primitive | Primitive[])[][]\n readonly options: FormatTableOptionsMerged\n\n constructor(table: (Primitive | Primitive[])[][], options?: FormatTableOptions) {\n this.table = table\n this.options = this.handleOptions(options)\n }\n\n @lazyProp\n get numberColumnPrecisions(): (number | undefined)[] {\n return this.table.reduce(\n (acc: (number | undefined)[], row) =>\n row.map((cell, c) => {\n if (typeof cell !== 'number') {\n return\n }\n if (Number.isInteger(cell)) {\n return 0\n }\n const digits = cell.toString().split('.')[1].length\n return Math.max(acc[c] || 0, digits)\n }),\n []\n ) as (number | undefined)[]\n }\n\n @lazyProp\n get stringsTable(): string[][] {\n return this.table.map((row) => row.map((cell, c) => this.cellToString(cell, c)))\n }\n\n @lazyProp\n get columnWidths(): number[] {\n return this.stringsTable.reduce(\n (acc: number[], row) => row.map((cell, c) => Math.max(acc[c] || 0, cell.length)),\n [] as number[]\n )\n }\n\n @lazyProp\n get tableWidth(): number {\n const separatorsWidth = (this.columnWidths.length - 1) * this.options.columnSeparator.length\n const columnsWidth = this.columnWidths.reduce((acc, width) => acc + width, 0)\n return columnsWidth + separatorsWidth\n }\n\n @lazyProp\n get columnSeparatorFormatted() {\n return this.options.color.separator(this.options.columnSeparator)\n }\n\n @lazyProp\n get headerRowSeparatorLineFormatted() {\n return this.options.color.separator(''.padEnd(this.tableWidth, this.options.headerRowSeparator))\n }\n\n @lazyProp\n get formattedRows(): string[][] {\n const result = this.stringsTable.map((row, r) => row.map((cell, c) => this.formatCell(cell, c, r)))\n\n return this.options.color && this.options.grayOutRow\n ? result.map((row, r) =>\n this.options.grayOutRow!(this.table[r])\n ? row.map((cell) => this.options.color.separator(colors.stripColor(cell)))\n : row\n )\n : result\n }\n\n @lazyProp\n get formattedLines() {\n const lines = this.formattedRows.map((row) => row.join(this.columnSeparatorFormatted))\n lines.splice(1, 0, this.headerRowSeparatorLineFormatted)\n const headersLine = lines[0]\n lines.push(this.headerRowSeparatorLineFormatted)\n lines.push(headersLine)\n return lines\n }\n\n toString() {\n return this.formattedLines.join('\\n')\n }\n\n protected handleOptions(options: FormatTableOptions = {}): FormatTableOptionsMerged {\n options = { ...options }\n if (!options.columnSeparator) {\n options.columnSeparator = TableFormatter.defaults.columnSeparator\n }\n if (!options.headerRowSeparator) {\n options.headerRowSeparator = TableFormatter.defaults.headerRowSeparator\n }\n options.color = options.color\n ? options.color === true\n ? TableFormatter.defaults.color\n : { ...TableFormatter.defaults.color, ...options.color }\n : defaultColorsNoop\n return options as FormatTableOptionsMerged\n }\n\n protected cellToString(cell: Primitive | Primitive[], c: number) {\n if (cell == null) {\n return ''\n } else if (typeof cell === 'string') {\n return cell\n } else if (typeof cell === 'boolean') {\n return cell.toString()\n } else if (typeof cell === 'number') {\n return new NumberFormatter(this.numberColumnPrecisions[c] ?? 0).format(cell)\n } else if (Array.isArray(cell)) {\n return `[${cell.join(', ')}]`\n } else {\n throw new TypeError(`Unexpected cell value type: ${typeof cell}`)\n }\n }\n\n protected formatCell(cell: string, c: number, r: number): string {\n const originalCell = this.table[r][c]\n if (originalCell == null) {\n return this.formatNil(cell, c)\n } else if (typeof originalCell === 'string') {\n return this.formatString(cell, r, c)\n } else if (typeof originalCell === 'boolean') {\n return this.formatBoolean(cell, c)\n } else if (typeof originalCell === 'number') {\n return this.formatNumber(cell, originalCell, c)\n } else if (Array.isArray(originalCell)) {\n return this.formatString(cell, r, c)\n } else {\n throw new TypeError(`Unexpected cell value type: ${typeof originalCell}`)\n }\n }\n\n protected formatNil(cell: string, c: number) {\n return this.alignLeft(cell, c)\n }\n\n protected formatString(cell: string, r: number, c: number) {\n cell = this.alignLeft(cell, c)\n if (this.isColumnHeader(r)) {\n return this.options.color.columnHeader(cell)\n }\n if (this.isRowHeader(c)) {\n return this.options.color.rowHeader(cell)\n }\n return this.options.color.string(cell)\n }\n\n protected formatBoolean(cell: string, c: number) {\n const padded = this.alignLeft(cell, c)\n if (cell === 'true') {\n return this.options.color.booleanTrue(padded)\n }\n if (cell === 'false') {\n return this.options.color.booleanFalse(padded)\n }\n throw new Error(`Unexpected boolean representation: ${cell}`)\n }\n\n protected formatNumber(cell: string, originalCell: number | undefined, c: number) {\n cell = this.alignRight(cell, c)\n return (originalCell ?? 0) < 0\n ? this.options.color.negativeNumber(cell)\n : this.options.color.positiveNumber(cell)\n }\n\n protected alignLeft(cell: string, c: number) {\n return cell.padEnd(this.columnWidths[c], ' ')\n }\n\n protected alignRight(cell: string, c: number) {\n return cell.padStart(this.columnWidths[c], ' ')\n }\n\n protected isColumnHeader(r: number) {\n return r === 0\n }\n\n protected isRowHeader(c: number) {\n return c === 0\n }\n}\n\nexport interface FormatTableColors {\n separator: (s: string) => string\n columnHeader: (s: string) => string\n rowHeader: (s: string) => string\n string: (s: string) => string\n positiveNumber: (s: string) => string\n negativeNumber: (s: string) => string\n booleanTrue: (s: string) => string\n booleanFalse: (s: string) => string\n}\n\ninterface FormatTableOptionsMerged {\n color: FormatTableColors\n columnSeparator: string\n headerRowSeparator: string\n grayOutRow?: (row: (Primitive | Primitive[])[]) => boolean\n}\n\nconst defaultColorsNoop: FormatTableColors = {\n separator: (s: string) => s,\n columnHeader: (s: string) => s,\n rowHeader: (s: string) => s,\n string: (s: string) => s,\n positiveNumber: (s: string) => s,\n negativeNumber: (s: string) => s,\n booleanTrue: (s: string) => s,\n booleanFalse: (s: string) => s,\n}\n\ntype Primitive = string | number | boolean | undefined | null\n","import { FunctionProfiler } from '../internal/FunctionProfiler/FunctionProfiler'\nimport type { FunctionProfilerResult } from '../internal/FunctionProfiler/FunctionProfiler'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { InspectOptions } from 'util'\nimport { ModuleMethodProfilerFactory } from '../internal/ProfilerFactory/ModuleMethodProfilerFactory'\nimport { ProfilerWrapMethodsStrategy } from '../internal/ProfilerWrapMethodsStrategy/ProfilerWrapMethodsStrategy'\nimport { PrototypeMethodProfilerFactory } from '../internal/ProfilerFactory/PrototypeMethodProfilerFactory'\nimport { StandaloneFunctionIdentifier } from '../internal/FunctionIdentifier/StandaloneFunctionIdentifier'\nimport { StaticMethodProfilerFactory } from '../internal/ProfilerFactory/StaticMethodProfilerFactory'\nimport type { TFunction } from '@mono/types'\nimport { TableFormatter } from '@mono/table'\nimport { inspect } from 'util'\nimport { isFunction } from 'es-toolkit/predicate'\nimport { profilerWrap } from '../internal/FunctionProfiler/profilerWrap'\nimport { setName } from '@mono/fn'\nimport { wrapMethods } from '@mono/fn'\n\n/**\n * A utility class for profiling functions, classes, and modules to measure execution time and other performance metrics.\n *\n * @remarks\n * The Profiler provides various static methods to wrap functions, classes, and modules with profiling functionality.\n * This allows for detailed performance monitoring, including metrics like total execution time, average execution time,\n * minimum and maximum execution times, and call counts.\n *\n * Profiling can be enabled or disabled globally using the `enabled` static property.\n */\nexport class Profiler {\n static enabled: boolean = true\n\n static get data() {\n return FunctionProfiler.instances.slice()\n }\n\n /**\n * Class profiling\n */\n static class<T extends FunctionPrototype & { profiler?: ProfilerClassOptions }>(\n target: T,\n options?: ProfilerClassOptions\n ): T\n\n /**\n * Class profiling decorator\n */\n static class<T extends FunctionPrototype & { profiler?: ProfilerClassOptions }>(\n options: ProfilerClassOptions\n ): (target: T) => T\n\n /**\n *\n */\n static class<T extends FunctionPrototype & { profiler?: ProfilerClassOptions }>(\n targetOrOptions: T | ProfilerClassOptions,\n options?: ProfilerClassOptions\n ) {\n if (isFunction(targetOrOptions)) {\n const target = targetOrOptions\n Profiler.classStatic(target, options?.ignoreStaticKeys)\n Profiler.classPrototype(target, options?.ignorePrototypeKeys)\n return target\n } else {\n return (target: T) => Profiler.class(target, targetOrOptions as ProfilerClassOptions | undefined)\n }\n }\n\n static classStatic<T extends FunctionPrototype & { profiler?: ProfilerClassOptions }>(\n target: T,\n ignoreKeys?: Iterable<string | symbol>\n ) {\n if (Profiler.enabled) {\n wrapMethods(\n target,\n new ProfilerWrapMethodsStrategy(new StaticMethodProfilerFactory(target), [\n ...(ignoreKeys ?? []),\n ...(target.profiler?.ignoreStaticKeys ?? []),\n ])\n )\n }\n return target\n }\n\n static classPrototype<T extends FunctionPrototype & { profiler?: ProfilerClassOptions }>(\n target: T,\n ignoreKeys?: Iterable<string | symbol>\n ) {\n if (Profiler.enabled) {\n wrapMethods(\n target.prototype,\n new ProfilerWrapMethodsStrategy(new PrototypeMethodProfilerFactory(target.prototype), [\n ...(ignoreKeys ?? []),\n ...(target.profiler?.ignorePrototypeKeys ?? []),\n ])\n )\n }\n return target\n }\n\n static module<T extends object>(target: T, moduleName: string, ignoreKeys?: Iterable<string | symbol>) {\n if (Profiler.enabled) {\n wrapMethods(\n target,\n new ProfilerWrapMethodsStrategy(new ModuleMethodProfilerFactory(moduleName, target), ignoreKeys)\n )\n }\n return target\n }\n\n static fn<T extends TFunction>(func: T): T\n static fn<T extends TFunction>(name: string, func: T): T\n static fn<T extends TFunction>(nameOrFunc: T, maybeFunc?: T) {\n const func: T = isFunction(nameOrFunc) ? nameOrFunc : setName(nameOrFunc, maybeFunc as T)\n if (!func.name) {\n throw new Error(`Function must have a name:\\n${func.toString()}`)\n }\n return Profiler.enabled\n ? profilerWrap(func, new FunctionProfiler(new StandaloneFunctionIdentifier(func)))\n : func\n }\n\n static getResults(options?: GetProfilerResultsOptions): ProfilerResultReadableEntry[] {\n const results: ProfilerResultReadableEntry[] = Profiler.data.map((profiler) => [\n profiler.id.name,\n profiler.getResult(),\n ])\n\n const sortkey1 = options?.sortBy ?? ('calls' as keyof FunctionProfilerResult)\n const sortValue1 = (entry: ProfilerResultReadableEntry) => entry[1][sortkey1] ?? -1\n\n const sortKey2: keyof FunctionProfilerResult = sortkey1 === 'calls' ? 'totalTimeUs' : 'calls'\n const sortValue2 = (entry: ProfilerResultReadableEntry) => entry[1][sortKey2] ?? -1\n\n return results.sort((a: ProfilerResultReadableEntry, b: ProfilerResultReadableEntry) => {\n const comparision = sortValue1(a) - sortValue1(b)\n return comparision === 0 ? sortValue2(a) - sortValue2(b) : comparision\n })\n }\n\n static printResults(options?: PrintProfilerResultsOptions) {\n let entries = this.getResults(options)\n if (options?.update) {\n entries = options.update(entries)\n }\n\n const headers = ['Execution time (microseconds)', 'calls', 'total', 'avg', 'min', 'max']\n const rows = entries.map(([method, stats]) => [\n method,\n stats.calls,\n stats.totalTimeUs,\n stats.avgTimeUs,\n stats.minTimeUs,\n stats.maxTimeUs,\n ])\n const table = [headers, ...rows] as (string | number)[][]\n\n const formatter = new TableFormatter(table, {\n color: !options?.noColor,\n grayOutRow: (row) => row[1] === 0,\n })\n\n console.log()\n formatter.formattedLines.forEach((line) => console.log(line))\n console.log()\n }\n\n static [inspect.custom](depth?: number, options: InspectOptions = {}) {\n options.compact = true\n return Object.fromEntries(this.getResults())\n }\n\n static toJSON() {\n return this.getResults()\n }\n}\n\ntype ProfilerClassOptions = {\n ignoreStaticKeys?: Iterable<string | symbol>\n ignorePrototypeKeys?: Iterable<string | symbol>\n}\n\ntype GetProfilerResultsOptions = { sortBy?: keyof FunctionProfilerResult }\n\ntype PrintProfilerResultsOptions = {\n sortBy?: keyof FunctionProfilerResult\n update?: (entries: ProfilerResultReadableEntry[]) => ProfilerResultReadableEntry[]\n noColor?: boolean\n}\n\ntype ProfilerResultReadableEntry = [string, FunctionProfilerResult]\n"]}
|
package/lib/index.js
CHANGED
|
@@ -26,10 +26,7 @@ var FunctionProfiler = class _FunctionProfiler {
|
|
|
26
26
|
* Average execution time in nanoseconds
|
|
27
27
|
*/
|
|
28
28
|
get avgTimeNs() {
|
|
29
|
-
|
|
30
|
-
return void 0;
|
|
31
|
-
}
|
|
32
|
-
return Math.floor(this.totalTimeNs / this.calls);
|
|
29
|
+
return this.calls && this.totalTimeNs ? Math.floor(this.totalTimeNs / this.calls) : void 0;
|
|
33
30
|
}
|
|
34
31
|
/**
|
|
35
32
|
* Get the result of the profiling
|
|
@@ -680,7 +677,7 @@ var TimeoutWeakMap = class {
|
|
|
680
677
|
};
|
|
681
678
|
function memoizeSync(arg = {}) {
|
|
682
679
|
const opts = typeof arg === "object" ? arg : {
|
|
683
|
-
maxAge: typeof arg === "number" ? arg : ms(arg)
|
|
680
|
+
maxAge: typeof arg === "number" ? arg : ms(arg) ?? 0
|
|
684
681
|
};
|
|
685
682
|
return /* @__PURE__ */ __name(function decorator(target, key, descriptor) {
|
|
686
683
|
if (!descriptor) {
|
|
@@ -708,7 +705,7 @@ function memoizeSync(arg = {}) {
|
|
|
708
705
|
__name(memoizeSync, "memoizeSync");
|
|
709
706
|
function lazyProp(targetOrTimeout, key, descriptor) {
|
|
710
707
|
if (typeof targetOrTimeout === "number" || typeof targetOrTimeout === "string") {
|
|
711
|
-
const maxAge = typeof targetOrTimeout === "number" ? targetOrTimeout : ms(targetOrTimeout);
|
|
708
|
+
const maxAge = typeof targetOrTimeout === "number" ? targetOrTimeout : ms(targetOrTimeout) ?? 0;
|
|
712
709
|
return createLazyPropDecorator(new TimeoutWeakMap(maxAge));
|
|
713
710
|
} else {
|
|
714
711
|
const decorator = createLazyPropDecorator(/* @__PURE__ */ new WeakMap());
|
|
@@ -736,13 +733,22 @@ __name(createLazyPropDecorator, "createLazyPropDecorator");
|
|
|
736
733
|
// ../table/src/TableFormatter.ts
|
|
737
734
|
function _ts_decorate(decorators, target, key, desc) {
|
|
738
735
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
739
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
740
|
-
|
|
736
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
737
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
738
|
+
} else {
|
|
739
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
740
|
+
if (d = decorators[i]) {
|
|
741
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
}
|
|
741
745
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
742
746
|
}
|
|
743
747
|
__name(_ts_decorate, "_ts_decorate");
|
|
744
|
-
function _ts_metadata(
|
|
745
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
748
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
749
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
750
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
751
|
+
}
|
|
746
752
|
}
|
|
747
753
|
__name(_ts_metadata, "_ts_metadata");
|
|
748
754
|
var TableFormatter = class _TableFormatter {
|
|
@@ -801,15 +807,7 @@ var TableFormatter = class _TableFormatter {
|
|
|
801
807
|
}
|
|
802
808
|
get formattedRows() {
|
|
803
809
|
const result = this.stringsTable.map((row, r) => row.map((cell, c) => this.formatCell(cell, c, r)));
|
|
804
|
-
|
|
805
|
-
return result;
|
|
806
|
-
}
|
|
807
|
-
return result.map((row, r) => {
|
|
808
|
-
if (!this.options.grayOutRow(this.table[r])) {
|
|
809
|
-
return row;
|
|
810
|
-
}
|
|
811
|
-
return row.map((cell) => this.options.color.separator(colors.stripColor(cell)));
|
|
812
|
-
});
|
|
810
|
+
return this.options.color && this.options.grayOutRow ? result.map((row, r) => this.options.grayOutRow(this.table[r]) ? row.map((cell) => this.options.color.separator(colors.stripColor(cell))) : row) : result;
|
|
813
811
|
}
|
|
814
812
|
get formattedLines() {
|
|
815
813
|
const lines = this.formattedRows.map((row) => row.join(this.columnSeparatorFormatted));
|
|
@@ -894,10 +892,7 @@ var TableFormatter = class _TableFormatter {
|
|
|
894
892
|
}
|
|
895
893
|
formatNumber(cell, originalCell, c) {
|
|
896
894
|
cell = this.alignRight(cell, c);
|
|
897
|
-
|
|
898
|
-
return this.options.color.negativeNumber(cell);
|
|
899
|
-
}
|
|
900
|
-
return this.options.color.positiveNumber(cell);
|
|
895
|
+
return (originalCell ?? 0) < 0 ? this.options.color.negativeNumber(cell) : this.options.color.positiveNumber(cell);
|
|
901
896
|
}
|
|
902
897
|
alignLeft(cell, c) {
|
|
903
898
|
return cell.padEnd(this.columnWidths[c], " ");
|
|
@@ -1013,10 +1008,7 @@ var Profiler = class _Profiler {
|
|
|
1013
1008
|
throw new Error(`Function must have a name:
|
|
1014
1009
|
${func.toString()}`);
|
|
1015
1010
|
}
|
|
1016
|
-
|
|
1017
|
-
return profilerWrap(func, new FunctionProfiler(new StandaloneFunctionIdentifier(func)));
|
|
1018
|
-
}
|
|
1019
|
-
return func;
|
|
1011
|
+
return _Profiler.enabled ? profilerWrap(func, new FunctionProfiler(new StandaloneFunctionIdentifier(func))) : func;
|
|
1020
1012
|
}
|
|
1021
1013
|
static getResults(options) {
|
|
1022
1014
|
const results = _Profiler.data.map((profiler) => [
|
|
@@ -1029,10 +1021,7 @@ ${func.toString()}`);
|
|
|
1029
1021
|
const sortValue2 = /* @__PURE__ */ __name((entry) => entry[1][sortKey2] ?? -1, "sortValue2");
|
|
1030
1022
|
return results.sort((a, b) => {
|
|
1031
1023
|
const comparision = sortValue1(a) - sortValue1(b);
|
|
1032
|
-
|
|
1033
|
-
return comparision;
|
|
1034
|
-
}
|
|
1035
|
-
return sortValue2(a) - sortValue2(b);
|
|
1024
|
+
return comparision === 0 ? sortValue2(a) - sortValue2(b) : comparision;
|
|
1036
1025
|
});
|
|
1037
1026
|
}
|
|
1038
1027
|
static printResults(options) {
|
|
@@ -1078,3 +1067,5 @@ ${func.toString()}`);
|
|
|
1078
1067
|
};
|
|
1079
1068
|
|
|
1080
1069
|
export { Profiler };
|
|
1070
|
+
//# sourceMappingURL=index.js.map
|
|
1071
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/internal/FunctionProfiler/FunctionProfiler.ts","../../../object/src/setNonEnumerable.ts","../../src/internal/FunctionIdentifier/AbstractFunctionIdentifier.ts","../../src/internal/FunctionIdentifier/AbstractMethodIdentifier.ts","../../src/internal/FunctionIdentifier/ModuleMethodIdentifier.ts","../../src/internal/ProfilerFactory/ModuleMethodProfilerFactory.ts","../../../fn/src/setNameAndLength.ts","../../../fn/src/functionSpy.ts","../../../fn/src/setName.ts","../../../fn/src/wrapMethods.ts","../../src/internal/FunctionProfiler/profilerWrap.ts","../../src/internal/ProfilerWrapMethodsStrategy/ProfilerWrapMethodsStrategy.ts","../../src/internal/FunctionIdentifier/PrototypeMethodIdentifier.ts","../../src/internal/ProfilerFactory/PrototypeMethodProfilerFactory.ts","../../src/internal/FunctionIdentifier/StandaloneFunctionIdentifier.ts","../../src/internal/FunctionIdentifier/StaticMethodIdentifier.ts","../../src/internal/ProfilerFactory/StaticMethodProfilerFactory.ts","../../../number/src/NumberFormatter.ts","../../../decorators/src/assertDescriptorValueIsFunction.ts","../../../map/src/mapGetOrDefault.ts","../../../map/src/TimeoutWeakMap.ts","../../../decorators/src/memoizeSync.ts","../../../decorators/src/lazyProp.ts","../../../table/src/TableFormatter.ts","../../src/Profiler/Profiler.ts"],"names":["FunctionProfiler","instances","calls","totalTimeNs","minTimeNs","maxTimeNs","id","push","avgTimeNs","Math","floor","undefined","getResult","totalTimeUs","nsToUs","avgTimeUs","minTimeUs","maxTimeUs","onInvoke","process","hrtime","bigint","onReturn","t0","retval","add","t1","elapsed","Number","min","max","ns","round","inspect","custom","toJSON","setNonEnumerable","object","properties","prop","Object","defineProperty","enumerable","AbstractFunctionIdentifier","target","name","AbstractMethodIdentifier","key","type","keytoString","isSymbol","description","methodName","parentName","ModuleMethodIdentifier","targetType","ModuleMethodProfilerFactory","moduleName","createProfiler","methodType","setNameAndLength","source","lengthDelta","defineProperties","configurable","value","length","functionSpy","func","spy","options","async","wrapSync","isAsyncFunction","wrapAsync","wrapMaybeAsync","ignore","args","apply","data","Promise","then","setName","wrapMethods","strat","des","iterateMethods","filter","onMethod","orig","wrapped","onGetter","get","onSetter","set","Reflect","ownKeys","getOwnPropertyDescriptor","isFunction","profilerWrap","profiler","Profiler","enabled","ProfilerWrapMethodsStrategy","profilerFactory","ignoreKeys","Set","has","method","getter","setter","PrototypeMethodIdentifier","PrototypeMethodProfilerFactory","StandaloneFunctionIdentifier","StaticMethodIdentifier","StaticMethodProfilerFactory","locales","Map","NumberFormatter","precision","thousandSeparator","decimalSeparator","defineLocale","locale","getLocales","result","entry","entries","sep","Error","Array","from","keys","format","number","negative","split","abs","toString","decimals","padEnd","i","parse","string","replaceAll","replace","map","s","parseInt","join","n","descriptor","Function","prototype","TypeError","JSON","stringify","assertDescriptorValueIsFunction","mapGetOrDefault","factory","TimeoutWeakMap","wmap","WeakMap","timeoutMs","vt","timeout","refresh","setTimeout","delete","unref","clearTimeout","load","update","getOrDefault","memoizeSync","arg","opts","maxAge","ms","decorator","instancesShareCache","deleteProperty","memoizee","memoized","lazyProp","targetOrTimeout","createLazyPropDecorator","call","TableFormatter","defaults","columnSeparator","headerRowSeparator","grayOutRow","color","separator","colors","dim","gray","columnHeader","cyan","rowHeader","green","positiveNumber","yellow","negativeNumber","booleanTrue","magenta","booleanFalse","table","handleOptions","numberColumnPrecisions","reduce","acc","row","cell","c","isInteger","digits","stringsTable","cellToString","columnWidths","tableWidth","separatorsWidth","columnsWidth","width","columnSeparatorFormatted","headerRowSeparatorLineFormatted","formattedRows","r","formatCell","stripColor","formattedLines","lines","splice","headersLine","defaultColorsNoop","isArray","originalCell","formatNil","formatString","formatBoolean","formatNumber","alignLeft","isColumnHeader","isRowHeader","padded","alignRight","padStart","slice","class","targetOrOptions","classStatic","ignoreStaticKeys","classPrototype","ignorePrototypeKeys","module","fn","nameOrFunc","maybeFunc","getResults","results","sortkey1","sortBy","sortValue1","sortKey2","sortValue2","sort","a","b","comparision","printResults","headers","rows","stats","formatter","noColor","console","log","forEach","line","depth","compact","fromEntries"],"mappings":";;;;;;;;;;AAOO,IAAMA,gBAAAA,GAAN,MAAMA,iBAAAA,CAAAA;EALb;;;;AAME,EAAA,OAAOC,YAAwC,EAAA;EAC/CC,KAAAA,GAAQ,CAAA;AACRC,EAAAA,WAAAA;AACAC,EAAAA,SAAAA;AACAC,EAAAA,SAAAA;AAEA,EAAA,WAAA,CAAqBC,EAAAA,EAAmC;SA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QmB,GAAAA,CAAI,CAAC,CAACtC,MAAAA,EAAQqK,KAAAA,CAAAA,KAAW;AAC5CrK,MAAAA,MAAAA;MACAqK,KAAAA,CAAM/Q,KAAAA;MACN+Q,KAAAA,CAAMpQ,WAAAA;MACNoQ,KAAAA,CAAMlQ,SAAAA;MACNkQ,KAAAA,CAAMjQ,SAAAA;MACNiQ,KAAAA,CAAMhQ;AACP,KAAA,CAAA;AACD,IAAA,MAAM+L,KAAAA,GAAQ;AAAC+D,MAAAA,OAAAA;AAAYC,MAAAA,GAAAA;;AAE3B,IAAA,MAAME,SAAAA,GAAY,IAAItF,cAAAA,CAAeoB,KAAAA,EAAO;AAC1Cf,MAAAA,KAAAA,EAAO,CAAC3H,OAAAA,EAAS6M,OAAAA;AACjBnF,MAAAA,UAAAA,kBAAY,MAAA,CAAA,CAACqB,GAAAA,KAAQA,GAAAA,CAAI,CAAA,MAAO,CAAA,EAApB,YAAA;KACd,CAAA;AAEA+D,IAAAA,OAAAA,CAAQC,GAAAA,EAAG;AACXH,IAAAA,SAAAA,CAAU3C,eAAe+C,OAAAA,CAAQ,CAACC,SAASH,OAAAA,CAAQC,GAAAA,CAAIE,IAAAA,CAAAA,CAAAA;AACvDH,IAAAA,OAAAA,CAAQC,GAAAA,EAAG;AACb,EAAA;AAEA,EAAA,QAAQpP,QAAQC,MAAM,CAAA,CAAEsP,KAAAA,EAAgBlN,OAAAA,GAA0B,EAAC,EAAG;AACpEA,IAAAA,OAAAA,CAAQmN,OAAAA,GAAU,IAAA;AAClB,IAAA,OAAOjP,MAAAA,CAAOkP,WAAAA,CAAY,IAAA,CAAKvB,UAAAA,EAAU,CAAA;AAC3C,EAAA;AAEA,EAAA,OAAOhO,MAAAA,GAAS;AACd,IAAA,OAAO,KAAKgO,UAAAA,EAAU;AACxB,EAAA;AACF","file":"index.js","sourcesContent":["import { AbstractFunctionIdentifier } from '../FunctionIdentifier/AbstractFunctionIdentifier'\nimport type { IFunctionSpyStrategy } from '@mono/fn'\nimport { inspect } from 'util'\n\n/**\n * Profiler for functions, measuring execution time and call counts.\n */\nexport class FunctionProfiler<T extends object> implements IFunctionSpyStrategy<T, bigint> {\n static instances: FunctionProfiler<object>[] = []\n calls = 0\n totalTimeNs?: number\n minTimeNs?: number\n maxTimeNs?: number\n\n constructor(readonly id: AbstractFunctionIdentifier<T>) {\n FunctionProfiler.instances.push(this)\n }\n\n /**\n * Average execution time in nanoseconds\n */\n get avgTimeNs(): number | undefined {\n return this.calls && this.totalTimeNs ? Math.floor(this.totalTimeNs / this.calls) : undefined\n }\n\n /**\n * Get the result of the profiling\n */\n getResult(): FunctionProfilerResult {\n return {\n calls: this.calls,\n totalTimeUs: this.totalTimeNs ? this.nsToUs(this.totalTimeNs) : undefined,\n avgTimeUs: this.avgTimeNs ? this.nsToUs(this.avgTimeNs) : undefined,\n minTimeUs: this.minTimeNs == null ? this.minTimeNs : this.nsToUs(this.minTimeNs),\n maxTimeUs: this.maxTimeNs == null ? this.maxTimeNs : this.nsToUs(this.maxTimeNs),\n }\n }\n\n /**\n * @see IFunctionSpyStrategy.onInvoke\n */\n onInvoke(): bigint {\n return process.hrtime.bigint()\n }\n\n /**\n * @see IFunctionSpyStrategy.onReturn\n */\n onReturn<Ret>(t0: bigint, retval: Ret): Ret {\n this.add(t0, process.hrtime.bigint())\n return retval\n }\n\n /**\n * Add a new time measurement\n */\n protected add(t0: bigint, t1: bigint) {\n const elapsed = Number(t1 - t0)\n this.calls++\n this.totalTimeNs = (this.totalTimeNs ?? 0) + elapsed\n this.minTimeNs = Math.min(this.minTimeNs ?? elapsed, elapsed)\n this.maxTimeNs = Math.max(this.maxTimeNs ?? elapsed, elapsed)\n }\n\n /**\n * Nanoseconds to microseconds\n */\n protected nsToUs(ns: number): number {\n return Math.round(ns / 1000)\n }\n\n public [inspect.custom]() {\n return this.getResult()\n }\n\n toJSON() {\n return this.getResult()\n }\n}\n\nexport type FunctionProfilerResult = {\n /**\n * Number of method calls\n */\n calls: number\n\n /**\n * Total execution time in microseconds\n */\n totalTimeUs?: number\n\n /**\n * Total execution time in microseconds\n */\n avgTimeUs?: number\n\n /**\n * Fastest execution time in microseconds\n */\n minTimeUs?: number\n\n /**\n * Slowest execution time in microseconds\n */\n maxTimeUs?: number\n}\n","/**\n * Sets the specified properties of an object as non-enumerable.\n */\nexport function setNonEnumerable<T extends object>(object: T, ...properties: string[]): T {\n for (const prop of properties) {\n Object.defineProperty(object, prop, { enumerable: false })\n }\n return object\n}\n","import type { FunctionPrototype } from '@mono/types'\nimport type { FunctionType } from './types'\nimport type { TargetType } from './types'\nimport { inspect } from 'util'\nimport { setNonEnumerable } from '@mono/object'\n\n/**\n * Abstract base class for identifying and naming functions in profiling contexts.\n */\nexport abstract class AbstractFunctionIdentifier<T extends FunctionPrototype | object> {\n abstract readonly targetType: TargetType\n abstract readonly type: FunctionType\n abstract readonly name: string\n\n constructor(readonly target: T) {\n setNonEnumerable(this, 'target')\n }\n\n toJSON() {\n return this.name\n }\n\n public [inspect.custom]() {\n return this.name\n }\n}\n","import { AbstractFunctionIdentifier } from './AbstractFunctionIdentifier'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { MethodTargetType } from './types'\nimport type { MethodType } from './types'\nimport { isSymbol } from 'es-toolkit/predicate'\nimport { setNonEnumerable } from '@mono/object'\n\n/**\n * Abstract base class for identifying and naming method functions in profiling contexts.\n */\nexport abstract class AbstractMethodIdentifier<\n T extends object | FunctionPrototype,\n> extends AbstractFunctionIdentifier<T> {\n abstract override readonly targetType: MethodTargetType\n abstract readonly parentName: string | undefined\n constructor(\n target: T,\n readonly key: string | symbol,\n readonly type: MethodType = 'method'\n ) {\n super(target)\n setNonEnumerable(this, 'type', 'key')\n }\n keytoString() {\n return isSymbol(this.key) ? `[${this.key.description}]` : this.key\n }\n get methodName(): string {\n if (this.type === 'method') {\n return `${this.keytoString()}()`\n }\n if (this.type === 'get') {\n return this.keytoString()\n }\n return `${this.keytoString()}[set]`\n }\n get name(): string {\n return this.parentName + (isSymbol(this.key) ? '' : '.') + this.methodName\n }\n}\n","import { AbstractMethodIdentifier } from './AbstractMethodIdentifier'\nimport type { MethodTargetType } from './types'\nimport type { MethodType } from './types'\nimport { setNonEnumerable } from '@mono/object'\n\n/**\n * Identifies methods within module objects for profiling purposes.\n */\nexport class ModuleMethodIdentifier extends AbstractMethodIdentifier<object> {\n constructor(\n readonly parentName: string,\n target: object,\n key: string | symbol,\n type: MethodType = 'method'\n ) {\n super(target, key, type)\n setNonEnumerable(this, 'parentName')\n }\n override get targetType(): MethodTargetType {\n return 'module'\n }\n}\n","import { FunctionProfiler } from '../FunctionProfiler/FunctionProfiler'\nimport type { IProfilerFactory } from './IProfilerFactory'\nimport type { MethodType } from '../FunctionIdentifier/types'\nimport { ModuleMethodIdentifier } from '../FunctionIdentifier/ModuleMethodIdentifier'\n\n/**\n * Factory for creating profilers for module method functions using the Factory pattern.\n */\nexport class ModuleMethodProfilerFactory implements IProfilerFactory<object> {\n constructor(\n readonly moduleName: string,\n readonly target: object\n ) {}\n\n createProfiler(key: string | symbol, methodType: MethodType): FunctionProfiler<object> {\n return new FunctionProfiler(new ModuleMethodIdentifier(this.moduleName, this.target, key, methodType))\n }\n}\n","import type { Any } from '@mono/types'\n\n/**\n * Preserves the name and length of a function or class constructor\n */\nexport function setNameAndLength<\n S extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n F extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n>(source: S, target: F, lengthDelta = 0): F {\n return Object.defineProperties(target, {\n name: { configurable: true, value: source.name }, //\n length: { configurable: true, value: source.length + lengthDelta },\n })\n}\n","import type { Any } from '@mono/types'\nimport type { AnyAsyncFunction } from '@mono/types'\nimport type { TFunction } from '@mono/types'\nimport { isAsyncFunction } from 'util/types'\nimport { setNameAndLength } from './setNameAndLength'\n\n/**\n * Wraps a function so that the given @see IFunctionSpyStrategy will be applied.\n * @param func The function to wrap.\n * @param spy The strategy to apply.\n * @param options Options.\n */\nexport function functionSpy<T, Data>(\n func: TFunction,\n spy: IFunctionSpyStrategy<T, Data>,\n options: FunctionSpyOptions<T, Data> = {}\n) {\n if (options.async === false) {\n return wrapSync(func, spy, options)\n } else if (options.async || isAsyncFunction(func)) {\n return wrapAsync(func, spy, options)\n } else {\n return wrapMaybeAsync(func, spy, options)\n }\n}\n\nexport interface FunctionSpyOptions<T, Data> {\n /**\n * Whether the function is async.\n * If provided, execution is a bit faster.\n */\n async?: boolean\n\n /**\n * Predicate function that determines whether to skip the spy's actions for a given function call.\n */\n ignore?: IgnorePredicate<T, Data>\n}\n\n/**\n * @see functionSpy\n */\nexport interface IFunctionSpyStrategy<T, Data> {\n /**\n * Action to perform before the function is invoked.\n * @param thisContext The context in which the function is invoked.\n * @param args The arguments passed to the function. Modify this array to change the arguments passed to the function.\n * @returns Data to be passed to @see onReturn.\n */\n onInvoke<Args extends Any[]>(thisContext: T, args: Args): Data\n\n /**\n * Action to perform before the function returns.\n * @param data The data returned by @see onInvoke.\n * @param retval The return value of the function.\n * @returns The value to be returned by the wrapped function.\n */\n onReturn<Ret>(data: Data, retval: Ret): Ret\n}\n\nfunction wrapMaybeAsync<T, Data>(\n func: TFunction,\n spy: IFunctionSpyStrategy<T, Data>,\n options: { ignore?: IgnorePredicate<T, Data> } = {}\n) {\n const ignore = options.ignore\n if (ignore && ignore(func, spy)) {\n return func\n }\n return setNameAndLength(func, function (this: T, ...args: any[]) {\n if (ignore && ignore(func, spy, this)) {\n return func.apply(this, args)\n }\n const data = spy.onInvoke(this, args)\n const retval = func.apply(this, args)\n return retval instanceof Promise\n ? retval.then((retval) => spy.onReturn(data, retval))\n : spy.onReturn(data, retval)\n })\n}\n\nfunction wrapSync<T, Data>(\n func: TFunction,\n spy: IFunctionSpyStrategy<T, Data>,\n options: { ignore?: IgnorePredicate<T, Data> } = {}\n) {\n const ignore = options.ignore\n if (ignore && ignore(func, spy)) {\n return func\n }\n return setNameAndLength(func, function (this: T, ...args: any[]) {\n if (ignore && ignore(func, spy, this)) {\n return func.apply(this, args)\n }\n const data = spy.onInvoke(this, args)\n const retval = func.apply(this, args)\n return spy.onReturn(data, retval)\n })\n}\n\nfunction wrapAsync<T, Data>(\n func: AnyAsyncFunction,\n spy: IFunctionSpyStrategy<T, Data>,\n options: { ignore?: IgnorePredicate<T, Data> } = {}\n) {\n const ignore = options.ignore\n if (ignore && ignore(func, spy)) {\n return func\n }\n return setNameAndLength(func, async function (this: T, ...args: any[]) {\n if (ignore && ignore(func, spy, this)) {\n return await func.apply(this, args)\n }\n const data = spy.onInvoke(this, args)\n const retval = await func.apply(this, args)\n return spy.onReturn(data, retval)\n })\n}\n\nexport type IgnorePredicate<T, Data> = (\n func: TFunction,\n spy: IFunctionSpyStrategy<T, Data>,\n thisContext?: T\n) => boolean\n","/**\n * Set the name of a function.\n */\nexport function setName<T extends object>(name: string | { name: string }, target: T): T {\n return Object.defineProperty(target, 'name', {\n value: typeof name === 'string' ? name : name.name,\n configurable: true,\n enumerable: false,\n })\n}\n","import type { AnyFunction } from '@mono/types'\nimport type { AnyGetter } from '@mono/types'\nimport type { AnySetter } from '@mono/types'\nimport { isFunction } from 'es-toolkit/predicate'\nimport { setNameAndLength } from './setNameAndLength'\n\n/**\n * Wrap methods, getters and setters of an object with custom logic.\n */\nexport function wrapMethods<T extends object>(target: T, strat: WrapMethodsStrategy<T>) {\n for (const [key, type, des] of iterateMethods(target)) {\n if (strat.filter && !strat.filter(target, key, type, des)) {\n continue\n }\n switch (type) {\n case 'method': {\n if (!strat.onMethod) {\n continue\n }\n const orig = des.value!\n const wrapped = strat.onMethod(target, key, orig)\n if (!wrapped) {\n continue\n }\n Object.defineProperty(target, key, {\n value: setNameAndLength(orig, wrapped),\n configurable: des.configurable,\n enumerable: des.enumerable,\n })\n\n break\n }\n case 'get': {\n if (!strat.onGetter) {\n continue\n }\n const orig = des.get!\n const wrapped = strat.onGetter(target, key, orig)\n if (!wrapped) {\n continue\n }\n Object.defineProperty(target, key, {\n get: setNameAndLength(orig, wrapped),\n configurable: des.configurable,\n enumerable: des.enumerable,\n })\n\n break\n }\n case 'set': {\n if (!strat.onSetter) {\n continue\n }\n const orig = des.set!\n const wrapped = strat.onSetter(target, key, orig)\n if (!wrapped) {\n continue\n }\n Object.defineProperty(target, key, {\n set: setNameAndLength(orig, wrapped),\n configurable: des.configurable,\n enumerable: des.enumerable,\n })\n\n break\n }\n // No default\n }\n }\n return target\n}\n\nfunction* iterateMethods<T extends object>(\n target: T\n): Generator<[string | symbol, DescriptorMethodType, PropertyDescriptor]> {\n for (const key of Reflect.ownKeys(target)) {\n const des = Object.getOwnPropertyDescriptor(target, key)\n if (!des || des.configurable === false) {\n continue\n }\n if (isFunction(des.value)) {\n yield [key, 'method', des]\n } else {\n if (isFunction(des.get)) {\n yield [key, 'get', des]\n }\n if (isFunction(des.set)) {\n yield [key, 'set', des]\n }\n }\n }\n}\n\nexport type DescriptorMethodType = 'get' | 'set' | 'method'\n\nexport type MethodFilter<T extends object = object> = (\n target: T,\n key: string | symbol,\n type: DescriptorMethodType,\n descriptor: PropertyDescriptor\n) => boolean\n\nexport type MethodWrapper<T extends object = object> = (\n target: T,\n key: string | symbol,\n method: AnyFunction\n) => AnyFunction | undefined\n\nexport type GetterWrapper<T extends object = object> = (\n target: T,\n key: string | symbol,\n getter: AnyGetter\n) => AnyGetter | undefined\n\nexport type SetterWrapper<T extends object = object> = (\n target: T,\n key: string | symbol,\n setter: AnySetter\n) => AnySetter | undefined\n\nexport interface WrapMethodsStrategy<T extends object = object> {\n filter?: MethodFilter<T>\n onGetter?: GetterWrapper<T>\n onSetter?: SetterWrapper<T>\n onMethod?: MethodWrapper<T>\n}\n","import { FunctionProfiler } from './FunctionProfiler'\nimport { Profiler } from '../../Profiler/Profiler'\nimport type { TFunction } from '@mono/types'\nimport { functionSpy } from '@mono/fn'\n\n/**\n * Wraps a function with a @see FunctionProfiler.\n */\nexport function profilerWrap<T extends object>(func: TFunction, profiler: FunctionProfiler<T>) {\n const ignore = () => !Profiler.enabled\n return profiler.id.type === 'get' || profiler.id.type === 'set'\n ? functionSpy(func, profiler, { ignore, async: false })\n : functionSpy(func, profiler, { ignore })\n}\n","import type { AnyFunction } from '@mono/types'\nimport type { AnyGetter } from '@mono/types'\nimport type { AnySetter } from '@mono/types'\nimport type { IProfilerFactory } from '../ProfilerFactory/IProfilerFactory'\nimport type { TFunction } from '@mono/types'\nimport type { WrapMethodsStrategy } from '@mono/fn'\nimport { profilerWrap } from '../FunctionProfiler/profilerWrap'\n\n/**\n * Strategy for wrapping object methods with profiling capabilities using the Strategy pattern.\n */\nexport class ProfilerWrapMethodsStrategy<Target extends object> implements WrapMethodsStrategy<Target> {\n readonly profilerFactory: IProfilerFactory<Target>\n readonly ignoreKeys: Set<string | symbol>\n\n constructor(profilerFactory: IProfilerFactory<Target>, ignoreKeys?: Iterable<string | symbol>) {\n this.profilerFactory = profilerFactory\n this.ignoreKeys = new Set(ignoreKeys)\n }\n\n filter<T extends Target>(target: T, key: string | symbol): boolean {\n if (key === 'constructor') {\n return false\n }\n if (this.ignoreKeys.has(key)) {\n return false\n }\n return true\n }\n\n onMethod<T extends Target>(target: T, key: string | symbol, method: AnyFunction) {\n return profilerWrap(method as TFunction, this.profilerFactory.createProfiler(key, 'method'))\n }\n\n onGetter<T extends Target>(target: T, key: string | symbol, getter: AnyGetter) {\n return profilerWrap(getter, this.profilerFactory.createProfiler(key, 'get')) as AnyGetter\n }\n\n onSetter<T extends Target>(target: T, key: string | symbol, setter: AnySetter) {\n return profilerWrap(setter, this.profilerFactory.createProfiler(key, 'set')) as AnySetter\n }\n}\n","import { AbstractMethodIdentifier } from './AbstractMethodIdentifier'\nimport type { AnyConstructor } from '@mono/types'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { MethodTargetType } from './types'\n\n/**\n * Identifies methods on class prototypes for profiling purposes.\n */\nexport class PrototypeMethodIdentifier extends AbstractMethodIdentifier<{\n constructor: FunctionPrototype | AnyConstructor\n}> {\n override get targetType(): MethodTargetType {\n return 'prototype'\n }\n override get parentName(): string {\n return `${this.target.constructor.name}.${this.targetType}`\n }\n}\n","import { FunctionProfiler } from '../FunctionProfiler/FunctionProfiler'\nimport type { IProfilerFactory } from './IProfilerFactory'\nimport type { MethodType } from '../FunctionIdentifier/types'\nimport { PrototypeMethodIdentifier } from '../FunctionIdentifier/PrototypeMethodIdentifier'\n\n/**\n * Factory for creating profilers for prototype method functions using the Factory pattern.\n */\nexport class PrototypeMethodProfilerFactory implements IProfilerFactory<object> {\n constructor(readonly target: object) {}\n\n createProfiler(key: string | symbol, methodType: MethodType): FunctionProfiler<object> {\n return new FunctionProfiler(new PrototypeMethodIdentifier(this.target, key, methodType))\n }\n}\n","import { AbstractFunctionIdentifier } from './AbstractFunctionIdentifier'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { FunctionType } from './types'\nimport type { TargetType } from './types'\n\n/**\n * Identifies standalone functions for profiling purposes.\n */\nexport class StandaloneFunctionIdentifier extends AbstractFunctionIdentifier<FunctionPrototype> {\n override get targetType(): TargetType {\n return 'standalone'\n }\n override get type(): FunctionType {\n return 'function'\n }\n override get name(): string {\n return `${this.target.name}()`\n }\n}\n","import { AbstractMethodIdentifier } from './AbstractMethodIdentifier'\nimport type { AnyConstructor } from '@mono/types'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { MethodTargetType } from './types'\n\n/**\n * Identifies static methods on classes for profiling purposes.\n */\nexport class StaticMethodIdentifier extends AbstractMethodIdentifier<FunctionPrototype | AnyConstructor> {\n override get targetType(): MethodTargetType {\n return 'static'\n }\n override get parentName(): string {\n return this.target.name\n }\n}\n","import { FunctionProfiler } from '../FunctionProfiler/FunctionProfiler'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { IProfilerFactory } from './IProfilerFactory'\nimport type { MethodType } from '../FunctionIdentifier/types'\nimport { StaticMethodIdentifier } from '../FunctionIdentifier/StaticMethodIdentifier'\n\n/**\n * Factory for creating profilers for static method functions using the Factory pattern.\n */\nexport class StaticMethodProfilerFactory implements IProfilerFactory<FunctionPrototype> {\n constructor(readonly target: FunctionPrototype) {}\n\n createProfiler(key: string | symbol, methodType: MethodType): FunctionProfiler<FunctionPrototype> {\n return new FunctionProfiler(new StaticMethodIdentifier(this.target, key, methodType))\n }\n}\n","import { round } from './round'\n\nconst locales: Map<string, [string, string]> = new Map([\n ['en-US', [',', '.']],\n ['da-DK', ['.', ',']],\n])\n\n/**\n * A utility class for formatting and parsing numbers with locale-specific separators.\n *\n * This class allows for customizing thousand and decimal separators, setting precision\n * for decimal places, and supports different locales for international number formatting.\n *\n * @example\n * ```typescript\n * // Create a formatter with 2 decimal places\n * const formatter = new NumberFormatter(2);\n *\n * // Format a number\n * formatter.format(1234.56); // \"1,234.56\"\n *\n * // Parse a formatted string\n * formatter.parse(\"1,234.56\"); // 1234.56\n *\n * // Use a different locale\n * formatter.locale(\"fr\").format(1234.56); // \"1 234,56\" (assuming French locale is defined)\n * ```\n *\n * @remarks\n * The class maintains a static registry of locales with their respective thousand and decimal separators.\n * Before using a locale, it must be defined using the `defineLocale` static method.\n */\nexport class NumberFormatter {\n // The number of decimals to round to.\n public precision: number\n\n // The character to use as thousand separator.\n public thousandSeparator = ','\n\n // The character to use as decimal separator.\n public decimalSeparator = '.'\n\n /**\n * Create a new number formatter.\n * @param precision The number of decimals to round to.\n */\n constructor(precision = 2) {\n this.precision = precision\n }\n\n /**\n * Set separator strings for a given locale.\n */\n static defineLocale(locale: string, thousandSeparator: string, decimalSeparator: string): void {\n locales.set(locale, [thousandSeparator, decimalSeparator])\n }\n\n /**\n * Returns a copy of the locales map.\n */\n static getLocales(): Map<string, [string, string]> {\n const result = new Map<string, [string, string]>()\n for (const entry of locales.entries()) {\n result.set(entry[0], [entry[1][0], entry[1][1]])\n }\n return result\n }\n\n /**\n * Set the locale for the number formatter.\n */\n locale(locale: string): this {\n const sep = locales.get(locale)\n if (!sep) {\n throw new Error(`Invalid locale: ${locale}. Valid: ${Array.from(locales.keys())}}.`)\n }\n this.thousandSeparator = sep[0]\n this.decimalSeparator = sep[1]\n return this\n }\n\n /**\n * Format a number to a string.\n */\n format(number: number): string {\n const negative = number >= 0 ? '' : '-'\n const split = Math.abs(round(number, this.precision)).toString().split('.')\n const decimals = this.precision ? this.decimalSeparator + (split[1] || '').padEnd(this.precision, '0') : ''\n let result = ''\n for (let i = 0; i < split[0].length; i++) {\n if (i % 3 === 0 && i !== 0) {\n result = this.thousandSeparator + result\n }\n result = split[0][split[0].length - i - 1] + result\n }\n return negative + result + decimals\n }\n\n /**\n * Parse a formatted string to a number.\n */\n parse(string: string): number {\n string = string\n .replaceAll(this.thousandSeparator, '')\n .replace(this.decimalSeparator, '.')\n .replaceAll(/[^\\d.-]/g, '')\n .split('.')\n .map((s) => parseInt(s))\n .join('.')\n const n = Number(string)\n return n\n }\n}\n","/**\n * Asserts that a property descriptor contains a function value.\n */\nexport default function assertDescriptorValueIsFunction(key: string, descriptor: PropertyDescriptor) {\n if (!(typeof descriptor.value === 'function' && descriptor.value !== Function.prototype)) {\n throw new TypeError(`\"value\" not a function for ${key} with descriptor: ${JSON.stringify(descriptor)}.`)\n }\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Gets a value from a map or creates it using a factory function if it doesn't exist.\n */\nexport function mapGetOrDefault<K, V, T extends GenericMap<K, V, 'get' | 'has' | 'set'>>(\n map: T,\n key: K,\n factory: (key: K, map: T) => V\n): V {\n let value = map.get(key)\n if (value !== undefined || map.has(key)) {\n return value as V\n }\n value = factory(key, map)\n map.set(key, value)\n return value\n}\n","/**\n * A WeakMap with automatic timeout-based expiry for entries.\n *\n * Entries are automatically removed after a specified timeout period.\n * Accessing an entry refreshes its timeout, extending its lifetime.\n * This is useful for caching scenarios where you want automatic cleanup\n * of unused entries while keeping frequently accessed ones alive.\n */\nexport class TimeoutWeakMap<K extends object, V> {\n protected readonly wmap = new WeakMap<K, [V, NodeJS.Timeout]>()\n\n /**\n * @param timeoutMs Default timeout in milliseconds for entries\n */\n constructor(readonly timeoutMs: number) {}\n\n /**\n * Retrieves the value for the given key and refreshes its timeout.\n *\n * @param key The key to retrieve\n * @returns The value if found, undefined otherwise\n */\n get(key: K): V | undefined {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return undefined\n }\n const [value, timeout] = vt\n timeout.refresh()\n return value\n }\n\n /**\n * Sets a key-value pair with an optional custom timeout.\n *\n * @param key The key to set\n * @param value The value to associate with the key\n * @param timeoutMs Optional timeout override for this entry\n * @returns This instance for chaining\n */\n set(key: K, value: V, timeoutMs?: number): this {\n this.wmap.set(key, [\n value,\n setTimeout(() => {\n this.delete(key)\n }, timeoutMs ?? this.timeoutMs).unref(),\n ])\n return this\n }\n\n /**\n * Removes a key-value pair and clears its timeout.\n *\n * @param key The key to delete\n * @returns True if the key existed and was deleted, false otherwise\n */\n delete(key: K): boolean {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return false\n }\n const timeout = vt[1]\n clearTimeout(timeout)\n return this.wmap.delete(key)\n }\n\n /**\n * Checks if a key exists in the map.\n * Does not refresh the timeout.\n *\n * @param key The key to check\n * @returns True if the key exists, false otherwise\n */\n has(key: K): boolean {\n return this.wmap.has(key)\n }\n\n /**\n * Loads multiple key-value pairs into the map.\n *\n * @param entries Iterable of key-value pairs to load\n * @param timeoutMs Optional timeout override for all entries\n * @returns This instance for chaining\n */\n load(entries: Iterable<[K, V]>, timeoutMs?: number): this {\n for (const [key, value] of entries) {\n this.set(key, value, timeoutMs)\n }\n return this\n }\n\n /**\n * Updates an existing value or creates a new one using an update function.\n *\n * @param key The key to update\n * @param update Function that receives the current value and returns the new value\n * @returns This instance for chaining\n */\n update(key: K, update: (value: V | undefined, key: K, map: this) => V): this {\n return this.set(key, update(this.get(key), key, this))\n }\n\n /**\n * Gets a value or creates it using a factory function if it doesn't exist.\n * Refreshes timeout if the value exists.\n *\n * @param key The key to get or create\n * @param factory Function to create the value if it doesn't exist\n * @param timeoutMs Optional timeout override for new entries\n * @returns The existing or newly created value\n */\n getOrDefault(key: K, factory: (key: K, map: this) => V, timeoutMs?: number): V {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (vt) {\n const [value, timeout] = vt\n timeout.refresh()\n return value\n } else {\n const value = factory(key, this)\n this.set(key, value, timeoutMs)\n return value\n }\n }\n}\n","import type { MemoizeSyncOptions } from './types.internal'\nimport type { SomeSyncFunction } from './types.internal'\nimport assertDescriptorValueIsFunction from './assertDescriptorValueIsFunction'\nimport { mapGetOrDefault } from '@mono/map'\nimport memoizee from 'memoizee'\nimport { ms } from 'enhanced-ms'\n\n/**\n * Decorator to memoize a sync method.\n * @param maxAge The maximum age of the memoized value as number (ms) or descriptive string (e.g. '10 min'). Uses 'ms' library: https://github.com/zeit/ms\n */\nexport function memoizeSync(\n maxAge?: number | string\n): (target: object, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor\n\n/**\n * Decorator to memoize a sync method.\n * @param options The options for memoization.\n */\nexport function memoizeSync(\n options: MemoizeSyncOptions\n): (target: object, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor\n\n//\nexport function memoizeSync(arg: (number | string) | MemoizeSyncOptions = {}) {\n const opts = typeof arg === 'object' ? arg : { maxAge: typeof arg === 'number' ? arg : (ms(arg) ?? 0) }\n\n return function decorator(target: unknown, key: string, descriptor?: PropertyDescriptor) {\n if (!descriptor) {\n throw new TypeError('descriptor is undefined')\n }\n const orig = descriptor.value\n assertDescriptorValueIsFunction(key, descriptor)\n const options = { length: false, ...opts } as memoizee.Options<SomeSyncFunction>\n\n if (opts.instancesShareCache) {\n Reflect.deleteProperty(options, 'instancesShareCache')\n descriptor.value = memoizee(orig, options)\n } else {\n const wmap = new WeakMap()\n descriptor.value = function (...args: any[]) {\n const memoized = mapGetOrDefault(wmap, this, () => memoizee(orig, options))\n return memoized.apply(this, args)\n }\n }\n\n return descriptor\n }\n}\n","import type { GenericMap } from '@mono/types'\nimport { TimeoutWeakMap } from '@mono/map'\nimport { isFunction } from 'es-toolkit/predicate'\nimport { mapGetOrDefault } from '@mono/map'\nimport { memoizeSync } from './memoizeSync'\nimport { ms } from 'enhanced-ms'\n\n/**\n * Decorator to memoize a method or getter accessor property.\n */\nexport function lazyProp(target: object, key: string, descriptor: PropertyDescriptor): PropertyDescriptor\n\n/**\n * Decorator to temporarily memoize a method or getter accessor property.\n * @param maxAge The maximum age of the memoized value as number (ms) or descriptive string (e.g. '10 min'). Uses 'ms' library: https://github.com/zeit/ms\n */\nexport function lazyProp(\n maxAge: number | string\n): (target: object, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor\n\n//\nexport function lazyProp(\n targetOrTimeout: object | number | string,\n key?: string,\n descriptor?: PropertyDescriptor\n) {\n if (typeof targetOrTimeout === 'number' || typeof targetOrTimeout === 'string') {\n const maxAge = typeof targetOrTimeout === 'number' ? targetOrTimeout : (ms(targetOrTimeout) ?? 0)\n return createLazyPropDecorator(new TimeoutWeakMap(maxAge))\n } else {\n const decorator = createLazyPropDecorator(new WeakMap())\n return decorator(targetOrTimeout, key!, descriptor!)\n }\n}\n\nfunction createLazyPropDecorator<K extends object, V>(map: GenericMap<K, V, 'get' | 'set' | 'has'>) {\n return function (target: object, key: string, descriptor: PropertyDescriptor) {\n const { get, value } = descriptor\n\n if (isFunction(get)) {\n descriptor.get = function () {\n return mapGetOrDefault(map, this as K, () => get.call(this))\n }\n return descriptor\n }\n\n if (isFunction(value)) {\n return memoizeSync()(target, key, descriptor)\n }\n\n throw new TypeError('neither \"get\" nor \"value\" are functions')\n }\n}\n","import { NumberFormatter } from '@mono/number'\nimport colors from 'ansi-colors'\nimport { lazyProp } from '@mono/decorators'\n\n/**\n * Options for @see formatTable\n */\nexport interface FormatTableOptions {\n /**\n * Whether to use colors in the output.\n * @default false\n */\n color?: boolean | Partial<FormatTableColors>\n\n /**\n * The string used to separate columns.\n * @default ' | '\n */\n columnSeparator?: string\n\n /**\n * The string used to separate the header row from the rest of the table.\n * @default '-'\n */\n headerRowSeparator?: string\n\n /**\n * An optional function that returns `true` if a row should be grayed out.\n */\n grayOutRow?: (row: (Primitive | Primitive[])[]) => boolean\n}\n\n/**\n * Formats a 2D array representing a table.\n */\nexport class TableFormatter {\n static readonly defaults: FormatTableOptionsMerged = {\n columnSeparator: ' | ',\n headerRowSeparator: '-',\n grayOutRow: undefined,\n color: {\n separator: colors.dim.gray,\n columnHeader: colors.cyan,\n rowHeader: (s: string) => s,\n string: colors.green,\n positiveNumber: colors.yellow,\n negativeNumber: colors.yellow,\n booleanTrue: colors.magenta,\n booleanFalse: colors.magenta,\n },\n }\n\n readonly table: (Primitive | Primitive[])[][]\n readonly options: FormatTableOptionsMerged\n\n constructor(table: (Primitive | Primitive[])[][], options?: FormatTableOptions) {\n this.table = table\n this.options = this.handleOptions(options)\n }\n\n @lazyProp\n get numberColumnPrecisions(): (number | undefined)[] {\n return this.table.reduce(\n (acc: (number | undefined)[], row) =>\n row.map((cell, c) => {\n if (typeof cell !== 'number') {\n return\n }\n if (Number.isInteger(cell)) {\n return 0\n }\n const digits = cell.toString().split('.')[1].length\n return Math.max(acc[c] || 0, digits)\n }),\n []\n ) as (number | undefined)[]\n }\n\n @lazyProp\n get stringsTable(): string[][] {\n return this.table.map((row) => row.map((cell, c) => this.cellToString(cell, c)))\n }\n\n @lazyProp\n get columnWidths(): number[] {\n return this.stringsTable.reduce(\n (acc: number[], row) => row.map((cell, c) => Math.max(acc[c] || 0, cell.length)),\n [] as number[]\n )\n }\n\n @lazyProp\n get tableWidth(): number {\n const separatorsWidth = (this.columnWidths.length - 1) * this.options.columnSeparator.length\n const columnsWidth = this.columnWidths.reduce((acc, width) => acc + width, 0)\n return columnsWidth + separatorsWidth\n }\n\n @lazyProp\n get columnSeparatorFormatted() {\n return this.options.color.separator(this.options.columnSeparator)\n }\n\n @lazyProp\n get headerRowSeparatorLineFormatted() {\n return this.options.color.separator(''.padEnd(this.tableWidth, this.options.headerRowSeparator))\n }\n\n @lazyProp\n get formattedRows(): string[][] {\n const result = this.stringsTable.map((row, r) => row.map((cell, c) => this.formatCell(cell, c, r)))\n\n return this.options.color && this.options.grayOutRow\n ? result.map((row, r) =>\n this.options.grayOutRow!(this.table[r])\n ? row.map((cell) => this.options.color.separator(colors.stripColor(cell)))\n : row\n )\n : result\n }\n\n @lazyProp\n get formattedLines() {\n const lines = this.formattedRows.map((row) => row.join(this.columnSeparatorFormatted))\n lines.splice(1, 0, this.headerRowSeparatorLineFormatted)\n const headersLine = lines[0]\n lines.push(this.headerRowSeparatorLineFormatted)\n lines.push(headersLine)\n return lines\n }\n\n toString() {\n return this.formattedLines.join('\\n')\n }\n\n protected handleOptions(options: FormatTableOptions = {}): FormatTableOptionsMerged {\n options = { ...options }\n if (!options.columnSeparator) {\n options.columnSeparator = TableFormatter.defaults.columnSeparator\n }\n if (!options.headerRowSeparator) {\n options.headerRowSeparator = TableFormatter.defaults.headerRowSeparator\n }\n options.color = options.color\n ? options.color === true\n ? TableFormatter.defaults.color\n : { ...TableFormatter.defaults.color, ...options.color }\n : defaultColorsNoop\n return options as FormatTableOptionsMerged\n }\n\n protected cellToString(cell: Primitive | Primitive[], c: number) {\n if (cell == null) {\n return ''\n } else if (typeof cell === 'string') {\n return cell\n } else if (typeof cell === 'boolean') {\n return cell.toString()\n } else if (typeof cell === 'number') {\n return new NumberFormatter(this.numberColumnPrecisions[c] ?? 0).format(cell)\n } else if (Array.isArray(cell)) {\n return `[${cell.join(', ')}]`\n } else {\n throw new TypeError(`Unexpected cell value type: ${typeof cell}`)\n }\n }\n\n protected formatCell(cell: string, c: number, r: number): string {\n const originalCell = this.table[r][c]\n if (originalCell == null) {\n return this.formatNil(cell, c)\n } else if (typeof originalCell === 'string') {\n return this.formatString(cell, r, c)\n } else if (typeof originalCell === 'boolean') {\n return this.formatBoolean(cell, c)\n } else if (typeof originalCell === 'number') {\n return this.formatNumber(cell, originalCell, c)\n } else if (Array.isArray(originalCell)) {\n return this.formatString(cell, r, c)\n } else {\n throw new TypeError(`Unexpected cell value type: ${typeof originalCell}`)\n }\n }\n\n protected formatNil(cell: string, c: number) {\n return this.alignLeft(cell, c)\n }\n\n protected formatString(cell: string, r: number, c: number) {\n cell = this.alignLeft(cell, c)\n if (this.isColumnHeader(r)) {\n return this.options.color.columnHeader(cell)\n }\n if (this.isRowHeader(c)) {\n return this.options.color.rowHeader(cell)\n }\n return this.options.color.string(cell)\n }\n\n protected formatBoolean(cell: string, c: number) {\n const padded = this.alignLeft(cell, c)\n if (cell === 'true') {\n return this.options.color.booleanTrue(padded)\n }\n if (cell === 'false') {\n return this.options.color.booleanFalse(padded)\n }\n throw new Error(`Unexpected boolean representation: ${cell}`)\n }\n\n protected formatNumber(cell: string, originalCell: number | undefined, c: number) {\n cell = this.alignRight(cell, c)\n return (originalCell ?? 0) < 0\n ? this.options.color.negativeNumber(cell)\n : this.options.color.positiveNumber(cell)\n }\n\n protected alignLeft(cell: string, c: number) {\n return cell.padEnd(this.columnWidths[c], ' ')\n }\n\n protected alignRight(cell: string, c: number) {\n return cell.padStart(this.columnWidths[c], ' ')\n }\n\n protected isColumnHeader(r: number) {\n return r === 0\n }\n\n protected isRowHeader(c: number) {\n return c === 0\n }\n}\n\nexport interface FormatTableColors {\n separator: (s: string) => string\n columnHeader: (s: string) => string\n rowHeader: (s: string) => string\n string: (s: string) => string\n positiveNumber: (s: string) => string\n negativeNumber: (s: string) => string\n booleanTrue: (s: string) => string\n booleanFalse: (s: string) => string\n}\n\ninterface FormatTableOptionsMerged {\n color: FormatTableColors\n columnSeparator: string\n headerRowSeparator: string\n grayOutRow?: (row: (Primitive | Primitive[])[]) => boolean\n}\n\nconst defaultColorsNoop: FormatTableColors = {\n separator: (s: string) => s,\n columnHeader: (s: string) => s,\n rowHeader: (s: string) => s,\n string: (s: string) => s,\n positiveNumber: (s: string) => s,\n negativeNumber: (s: string) => s,\n booleanTrue: (s: string) => s,\n booleanFalse: (s: string) => s,\n}\n\ntype Primitive = string | number | boolean | undefined | null\n","import { FunctionProfiler } from '../internal/FunctionProfiler/FunctionProfiler'\nimport type { FunctionProfilerResult } from '../internal/FunctionProfiler/FunctionProfiler'\nimport type { FunctionPrototype } from '@mono/types'\nimport type { InspectOptions } from 'util'\nimport { ModuleMethodProfilerFactory } from '../internal/ProfilerFactory/ModuleMethodProfilerFactory'\nimport { ProfilerWrapMethodsStrategy } from '../internal/ProfilerWrapMethodsStrategy/ProfilerWrapMethodsStrategy'\nimport { PrototypeMethodProfilerFactory } from '../internal/ProfilerFactory/PrototypeMethodProfilerFactory'\nimport { StandaloneFunctionIdentifier } from '../internal/FunctionIdentifier/StandaloneFunctionIdentifier'\nimport { StaticMethodProfilerFactory } from '../internal/ProfilerFactory/StaticMethodProfilerFactory'\nimport type { TFunction } from '@mono/types'\nimport { TableFormatter } from '@mono/table'\nimport { inspect } from 'util'\nimport { isFunction } from 'es-toolkit/predicate'\nimport { profilerWrap } from '../internal/FunctionProfiler/profilerWrap'\nimport { setName } from '@mono/fn'\nimport { wrapMethods } from '@mono/fn'\n\n/**\n * A utility class for profiling functions, classes, and modules to measure execution time and other performance metrics.\n *\n * @remarks\n * The Profiler provides various static methods to wrap functions, classes, and modules with profiling functionality.\n * This allows for detailed performance monitoring, including metrics like total execution time, average execution time,\n * minimum and maximum execution times, and call counts.\n *\n * Profiling can be enabled or disabled globally using the `enabled` static property.\n */\nexport class Profiler {\n static enabled: boolean = true\n\n static get data() {\n return FunctionProfiler.instances.slice()\n }\n\n /**\n * Class profiling\n */\n static class<T extends FunctionPrototype & { profiler?: ProfilerClassOptions }>(\n target: T,\n options?: ProfilerClassOptions\n ): T\n\n /**\n * Class profiling decorator\n */\n static class<T extends FunctionPrototype & { profiler?: ProfilerClassOptions }>(\n options: ProfilerClassOptions\n ): (target: T) => T\n\n /**\n *\n */\n static class<T extends FunctionPrototype & { profiler?: ProfilerClassOptions }>(\n targetOrOptions: T | ProfilerClassOptions,\n options?: ProfilerClassOptions\n ) {\n if (isFunction(targetOrOptions)) {\n const target = targetOrOptions\n Profiler.classStatic(target, options?.ignoreStaticKeys)\n Profiler.classPrototype(target, options?.ignorePrototypeKeys)\n return target\n } else {\n return (target: T) => Profiler.class(target, targetOrOptions as ProfilerClassOptions | undefined)\n }\n }\n\n static classStatic<T extends FunctionPrototype & { profiler?: ProfilerClassOptions }>(\n target: T,\n ignoreKeys?: Iterable<string | symbol>\n ) {\n if (Profiler.enabled) {\n wrapMethods(\n target,\n new ProfilerWrapMethodsStrategy(new StaticMethodProfilerFactory(target), [\n ...(ignoreKeys ?? []),\n ...(target.profiler?.ignoreStaticKeys ?? []),\n ])\n )\n }\n return target\n }\n\n static classPrototype<T extends FunctionPrototype & { profiler?: ProfilerClassOptions }>(\n target: T,\n ignoreKeys?: Iterable<string | symbol>\n ) {\n if (Profiler.enabled) {\n wrapMethods(\n target.prototype,\n new ProfilerWrapMethodsStrategy(new PrototypeMethodProfilerFactory(target.prototype), [\n ...(ignoreKeys ?? []),\n ...(target.profiler?.ignorePrototypeKeys ?? []),\n ])\n )\n }\n return target\n }\n\n static module<T extends object>(target: T, moduleName: string, ignoreKeys?: Iterable<string | symbol>) {\n if (Profiler.enabled) {\n wrapMethods(\n target,\n new ProfilerWrapMethodsStrategy(new ModuleMethodProfilerFactory(moduleName, target), ignoreKeys)\n )\n }\n return target\n }\n\n static fn<T extends TFunction>(func: T): T\n static fn<T extends TFunction>(name: string, func: T): T\n static fn<T extends TFunction>(nameOrFunc: T, maybeFunc?: T) {\n const func: T = isFunction(nameOrFunc) ? nameOrFunc : setName(nameOrFunc, maybeFunc as T)\n if (!func.name) {\n throw new Error(`Function must have a name:\\n${func.toString()}`)\n }\n return Profiler.enabled\n ? profilerWrap(func, new FunctionProfiler(new StandaloneFunctionIdentifier(func)))\n : func\n }\n\n static getResults(options?: GetProfilerResultsOptions): ProfilerResultReadableEntry[] {\n const results: ProfilerResultReadableEntry[] = Profiler.data.map((profiler) => [\n profiler.id.name,\n profiler.getResult(),\n ])\n\n const sortkey1 = options?.sortBy ?? ('calls' as keyof FunctionProfilerResult)\n const sortValue1 = (entry: ProfilerResultReadableEntry) => entry[1][sortkey1] ?? -1\n\n const sortKey2: keyof FunctionProfilerResult = sortkey1 === 'calls' ? 'totalTimeUs' : 'calls'\n const sortValue2 = (entry: ProfilerResultReadableEntry) => entry[1][sortKey2] ?? -1\n\n return results.sort((a: ProfilerResultReadableEntry, b: ProfilerResultReadableEntry) => {\n const comparision = sortValue1(a) - sortValue1(b)\n return comparision === 0 ? sortValue2(a) - sortValue2(b) : comparision\n })\n }\n\n static printResults(options?: PrintProfilerResultsOptions) {\n let entries = this.getResults(options)\n if (options?.update) {\n entries = options.update(entries)\n }\n\n const headers = ['Execution time (microseconds)', 'calls', 'total', 'avg', 'min', 'max']\n const rows = entries.map(([method, stats]) => [\n method,\n stats.calls,\n stats.totalTimeUs,\n stats.avgTimeUs,\n stats.minTimeUs,\n stats.maxTimeUs,\n ])\n const table = [headers, ...rows] as (string | number)[][]\n\n const formatter = new TableFormatter(table, {\n color: !options?.noColor,\n grayOutRow: (row) => row[1] === 0,\n })\n\n console.log()\n formatter.formattedLines.forEach((line) => console.log(line))\n console.log()\n }\n\n static [inspect.custom](depth?: number, options: InspectOptions = {}) {\n options.compact = true\n return Object.fromEntries(this.getResults())\n }\n\n static toJSON() {\n return this.getResults()\n }\n}\n\ntype ProfilerClassOptions = {\n ignoreStaticKeys?: Iterable<string | symbol>\n ignorePrototypeKeys?: Iterable<string | symbol>\n}\n\ntype GetProfilerResultsOptions = { sortBy?: keyof FunctionProfilerResult }\n\ntype PrintProfilerResultsOptions = {\n sortBy?: keyof FunctionProfilerResult\n update?: (entries: ProfilerResultReadableEntry[]) => ProfilerResultReadableEntry[]\n noColor?: boolean\n}\n\ntype ProfilerResultReadableEntry = [string, FunctionProfilerResult]\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/profiler",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "Performance profiling utilities for measuring execution time of functions, class methods, and modules.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ansi-colors": "^4.1.3",
|
|
12
|
-
"es-toolkit": "^1.
|
|
13
|
-
"enhanced-ms": "^
|
|
12
|
+
"es-toolkit": "^1.53.2",
|
|
13
|
+
"enhanced-ms": "^5.0.0",
|
|
14
14
|
"memoizee": "^0.4.17"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
@@ -29,7 +29,9 @@
|
|
|
29
29
|
"./lib/index.js",
|
|
30
30
|
"./lib/index.d.ts",
|
|
31
31
|
"./lib/index.cjs",
|
|
32
|
-
"./lib/index.d.cts"
|
|
32
|
+
"./lib/index.d.cts",
|
|
33
|
+
"./lib/index.js.map",
|
|
34
|
+
"./lib/index.cjs.map"
|
|
33
35
|
],
|
|
34
36
|
"exports": {
|
|
35
37
|
".": {
|