standard-log 13.3.1 → 13.3.3
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/CHANGELOG.md +989 -0
- package/cjs/log_store.d.ts.map +1 -1
- package/cjs/log_store.js +7 -7
- package/cjs/log_store.js.map +1 -1
- package/cjs/memory.d.ts.map +1 -1
- package/cjs/memory.js +1 -2
- package/cjs/memory.js.map +1 -1
- package/cjs/platform.browser.js +2 -2
- package/cjs/platform.browser.js.map +1 -1
- package/cjs/platform.js +2 -2
- package/cjs/platform.js.map +1 -1
- package/cjs/record.d.ts +9 -0
- package/cjs/record.d.ts.map +1 -0
- package/cjs/record.js +15 -0
- package/cjs/record.js.map +1 -0
- package/cjs/standard_log.ctx.js +1 -1
- package/cjs/standard_log.ctx.js.map +1 -1
- package/cjs/standard_log.d.ts.map +1 -1
- package/cjs/standard_log.js +4 -3
- package/cjs/standard_log.js.map +1 -1
- package/cjs/types.d.ts +5 -2
- package/cjs/types.d.ts.map +1 -1
- package/dist/standard-log.esm.js +22 -97
- package/dist/standard-log.esm.js.map +1 -1
- package/dist/standard-log.iife.js +22 -97
- package/dist/standard-log.iife.js.map +1 -1
- package/esm/log_store.d.ts.map +1 -1
- package/esm/log_store.js +4 -4
- package/esm/log_store.js.map +1 -1
- package/esm/memory.d.ts.map +1 -1
- package/esm/memory.js +1 -2
- package/esm/memory.js.map +1 -1
- package/esm/platform.browser.js +1 -1
- package/esm/platform.browser.js.map +1 -1
- package/esm/platform.js +1 -1
- package/esm/platform.js.map +1 -1
- package/esm/record.d.ts +9 -0
- package/esm/record.d.ts.map +1 -0
- package/esm/record.js +14 -0
- package/esm/record.js.map +1 -0
- package/esm/standard_log.ctx.js +1 -1
- package/esm/standard_log.ctx.js.map +1 -1
- package/esm/standard_log.d.ts.map +1 -1
- package/esm/standard_log.js +2 -1
- package/esm/standard_log.js.map +1 -1
- package/esm/types.d.ts +5 -2
- package/esm/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/ts/log_store.ts +4 -6
- package/ts/memory.ts +1 -2
- package/ts/platform.browser.ts +1 -1
- package/ts/platform.ts +1 -1
- package/ts/record.ts +9 -0
- package/ts/standard_log.ctx.ts +1 -1
- package/ts/standard_log.ts +2 -1
- package/ts/types.ts +5 -3
package/cjs/log_store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log_store.d.ts","names":[],"sources":["../ts/log_store.ts"],"mappings":";;wBAKgB,eAAe,mBAAmB,gBACjD,SAAS,SAAS,mBAAmB,MACnC;iBAUc;EAChB,SAAS,eAAe;EACxB,mBAAmB,eAAe;EAClC,WAAW;EACX,UAAU;EACV,eAAe,kBAAkB;;iBAGjB;EAChB,eAAe;;wBAGA,cAAc,SAAS;
|
|
1
|
+
{"version":3,"file":"log_store.d.ts","names":[],"sources":["../ts/log_store.ts"],"mappings":";;wBAKgB,eAAe,mBAAmB,gBACjD,SAAS,SAAS,mBAAmB,MACnC;iBAUc;EAChB,SAAS,eAAe;EACxB,mBAAmB,eAAe;EAClC,WAAW;EACX,UAAU;EACV,eAAe,kBAAkB;;iBAGjB;EAChB,eAAe;;wBAGA,cAAc,SAAS;EAcrC,QAAO;EAGP,SAAQ;EAGR"}
|
package/cjs/log_store.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_log_levels = require("./log_levels.js");
|
|
3
|
+
const require_record = require("./record.js");
|
|
3
4
|
const require_console = require("./console.js");
|
|
4
|
-
let type_plus = require("type-plus");
|
|
5
5
|
//#region ts/log_store.ts
|
|
6
6
|
function createLogStore(options) {
|
|
7
7
|
return {
|
|
8
|
-
loggers:
|
|
9
|
-
nonConsoleLoggers:
|
|
8
|
+
loggers: require_record.record(),
|
|
9
|
+
nonConsoleLoggers: require_record.record(),
|
|
10
10
|
reporters: options.reporters || [require_console.createConsoleLogReporter()],
|
|
11
11
|
logLevel: options.logLevel,
|
|
12
12
|
logLevelStore: logLevelStore(options)
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
function logLevelStore(options) {
|
|
16
|
-
const customLevels = options.customLevels ||
|
|
16
|
+
const customLevels = options.customLevels || require_record.record();
|
|
17
17
|
const store = {
|
|
18
18
|
customLevels,
|
|
19
|
-
customLevelsReverse:
|
|
19
|
+
customLevelsReverse: Object.keys(customLevels).reduce((p, k) => {
|
|
20
20
|
p[customLevels[k]] = k;
|
|
21
21
|
return p;
|
|
22
22
|
}, {})
|
|
@@ -29,13 +29,13 @@ function logLevelStore(options) {
|
|
|
29
29
|
return store.customLevels[name] ?? require_log_levels.toLogLevel(name);
|
|
30
30
|
},
|
|
31
31
|
getAllLevels() {
|
|
32
|
-
return
|
|
32
|
+
return Object.keys(require_log_levels.logLevels).reduce((result, name) => {
|
|
33
33
|
if (name !== "none" && name !== "all") result.push({
|
|
34
34
|
name,
|
|
35
35
|
level: require_log_levels.logLevels[name]
|
|
36
36
|
});
|
|
37
37
|
return result;
|
|
38
|
-
},
|
|
38
|
+
}, Object.keys(store.customLevels).map((name) => ({
|
|
39
39
|
name,
|
|
40
40
|
level: store.customLevels[name]
|
|
41
41
|
})));
|
package/cjs/log_store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log_store.js","names":["record","createConsoleLogReporter","
|
|
1
|
+
{"version":3,"file":"log_store.js","names":["record","createConsoleLogReporter","toLogLevelName","toLogLevel","logLevels"],"sources":["../ts/log_store.ts"],"sourcesContent":["import { createConsoleLogReporter } from './console.js'\nimport { logLevels, toLogLevel, toLogLevelName } from './log_levels.js'\nimport { record } from './record.js'\nimport type { Logger, LogLevel, LogMethodNames, LogReporter, StandardLogOptions } from './types.js'\n\nexport function createLogStore<N extends string = LogMethodNames>(\n\toptions: Required<StandardLogOptions<N>>\n): LogStore {\n\treturn {\n\t\tloggers: record(),\n\t\tnonConsoleLoggers: record(),\n\t\treporters: options.reporters || [createConsoleLogReporter()],\n\t\tlogLevel: options.logLevel,\n\t\tlogLevelStore: logLevelStore(options)\n\t}\n}\n\nexport interface LogStore {\n\tloggers: Record<string, Logger>\n\tnonConsoleLoggers: Record<string, Logger>\n\treporters: LogReporter[]\n\tlogLevel: LogLevel\n\tlogLevelStore: ReturnType<typeof logLevelStore>\n}\n\nexport interface LogLevelStoreOptions {\n\tcustomLevels?: Record<string, number>\n}\n\nexport function logLevelStore(options: LogLevelStoreOptions) {\n\tconst customLevels = options.customLevels || record()\n\n\tconst store = {\n\t\tcustomLevels,\n\t\tcustomLevelsReverse: Object.keys(customLevels).reduce(\n\t\t\t(p, k) => {\n\t\t\t\tp[customLevels[k]] = k\n\t\t\t\treturn p\n\t\t\t},\n\t\t\t{} as Record<number, string>\n\t\t)\n\t}\n\treturn {\n\t\tgetName(level: number) {\n\t\t\treturn store.customLevelsReverse[level] ?? toLogLevelName(level)\n\t\t},\n\t\tgetLevel(name: string) {\n\t\t\treturn store.customLevels[name] ?? toLogLevel(name)\n\t\t},\n\t\tgetAllLevels() {\n\t\t\treturn (Object.keys(logLevels) as Array<keyof typeof logLevels>).reduce(\n\t\t\t\t(result, name) => {\n\t\t\t\t\tif (name !== 'none' && name !== 'all') result.push({ name, level: logLevels[name] })\n\n\t\t\t\t\treturn result\n\t\t\t\t},\n\t\t\t\tObject.keys(store.customLevels).map(name => ({ name, level: store.customLevels[name] }))\n\t\t\t)\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAKA,SAAgB,eACf,SACW;CACX,OAAO;EACN,SAASA,eAAAA,OAAO;EAChB,mBAAmBA,eAAAA,OAAO;EAC1B,WAAW,QAAQ,aAAa,CAACC,gBAAAA,yBAAyB,CAAC;EAC3D,UAAU,QAAQ;EAClB,eAAe,cAAc,OAAO;CACrC;AACD;AAcA,SAAgB,cAAc,SAA+B;CAC5D,MAAM,eAAe,QAAQ,gBAAgBD,eAAAA,OAAO;CAEpD,MAAM,QAAQ;EACb;EACA,qBAAqB,OAAO,KAAK,YAAY,CAAC,CAAC,QAC7C,GAAG,MAAM;GACT,EAAE,aAAa,MAAM;GACrB,OAAO;EACR,GACA,CAAC,CACF;CACD;CACA,OAAO;EACN,QAAQ,OAAe;GACtB,OAAO,MAAM,oBAAoB,UAAUE,mBAAAA,eAAe,KAAK;EAChE;EACA,SAAS,MAAc;GACtB,OAAO,MAAM,aAAa,SAASC,mBAAAA,WAAW,IAAI;EACnD;EACA,eAAe;GACd,OAAQ,OAAO,KAAKC,mBAAAA,SAAS,CAAC,CAAmC,QAC/D,QAAQ,SAAS;IACjB,IAAI,SAAS,UAAU,SAAS,OAAO,OAAO,KAAK;KAAE;KAAM,OAAOA,mBAAAA,UAAU;IAAM,CAAC;IAEnF,OAAO;GACR,GACA,OAAO,KAAK,MAAM,YAAY,CAAC,CAAC,KAAI,UAAS;IAAE;IAAM,OAAO,MAAM,aAAa;GAAM,EAAE,CACxF;EACD;CACD;AACD"}
|
package/cjs/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","names":[],"sources":["../ts/memory.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"memory.d.ts","names":[],"sources":["../ts/memory.ts"],"mappings":";;YAMY,oBAAoB,YAAY;EAC3C,MAAM;;;;;EAKN;EACA;EACA;EACA;EACA;EACA;;YAGW,qBAAqB,aAAa;wBAE9B,mBAAmB,MAAM;wBAazB,wBAAwB,UAAU,mBAAmB,YAAY;wBA+CjE,mCACf,UAAU,mBAAmB,YAC3B"}
|
package/cjs/memory.js
CHANGED
|
@@ -3,7 +3,6 @@ const require_formatter = require("./formatter.js");
|
|
|
3
3
|
const require_platform = require("./platform.js");
|
|
4
4
|
const require_console = require("./console.js");
|
|
5
5
|
let unpartial = require("unpartial");
|
|
6
|
-
let type_plus = require("type-plus");
|
|
7
6
|
//#region ts/memory.ts
|
|
8
7
|
function toMessageWithLevel(logs) {
|
|
9
8
|
return logs.map(require_platform.toInspectLogEntry).map((log) => `${require_formatter.formatLogLevel(log.level)} ${log.args.join(" ")}`).join("\n").replace(/^\(WARN\) already configured for test, ignoring config\(\) call\n/, "");
|
|
@@ -12,7 +11,7 @@ function createMemoryLogReporter(options) {
|
|
|
12
11
|
return Object.freeze(buildMemoryReporter((0, unpartial.unpartial)({ id: "memory" }, options)));
|
|
13
12
|
}
|
|
14
13
|
function buildMemoryReporter(options) {
|
|
15
|
-
const { id, formatter, filter } = (0,
|
|
14
|
+
const { id, formatter, filter } = (0, unpartial.required)({
|
|
16
15
|
id: "memory",
|
|
17
16
|
formatter: (e) => e
|
|
18
17
|
}, options);
|
package/cjs/memory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","names":["toInspectLogEntry","formatLogLevel","required","createConsoleLogReporter"],"sources":["../ts/memory.ts"],"sourcesContent":["import { required
|
|
1
|
+
{"version":3,"file":"memory.js","names":["toInspectLogEntry","formatLogLevel","required","createConsoleLogReporter"],"sources":["../ts/memory.ts"],"sourcesContent":["import { required, unpartial } from 'unpartial'\nimport { createConsoleLogReporter } from './console.js'\nimport { formatLogLevel } from './formatter.js'\nimport { toInspectLogEntry } from './platform.js'\nimport type { LogEntry, LogFormatter, LogReporter, LogReporterOptions } from './types.js'\n\nexport type MemoryLogReporter = LogReporter<LogEntry> & {\n\tlogs: LogEntry[]\n\t/**\n\t * Gets a simple log message for testing.\n\t * The message only contains arguments for each log entry.\n\t */\n\tgetLogMessage(): string\n\tgetLogMessages(): string[]\n\tgetLogMessageWithLevel(): string\n\tgetLogMessagesWithLevel(): string[]\n\tgetLogMessagesWithIdAndLevel(): string[]\n\temit(): void\n}\n\nexport type MemoryLogFormatter = LogFormatter<LogEntry>\n\nexport function toMessageWithLevel(logs: LogEntry[]) {\n\treturn (\n\t\tlogs\n\t\t\t.map(toInspectLogEntry)\n\t\t\t.map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t\t.join('\\n')\n\t\t\t// if it has more than this log,\n\t\t\t// we assume it is running under tests,\n\t\t\t// and remove this log to simplify testing.\n\t\t\t.replace(/^\\(WARN\\) already configured for test, ignoring config\\(\\) call\\n/, '')\n\t)\n}\n\nexport function createMemoryLogReporter(options?: LogReporterOptions<LogEntry>): MemoryLogReporter {\n\treturn Object.freeze(buildMemoryReporter(unpartial({ id: 'memory' }, options)))\n}\n\nfunction buildMemoryReporter(options?: LogReporterOptions<LogEntry>) {\n\tconst { id, formatter, filter } = required({ id: 'memory', formatter: (e: LogEntry) => e }, options)\n\tconst logs: LogEntry[] = []\n\treturn {\n\t\tid,\n\t\tget formatter() {\n\t\t\treturn formatter\n\t\t},\n\t\tget filter() {\n\t\t\treturn filter\n\t\t},\n\t\tlogs,\n\t\twrite(entry: LogEntry) {\n\t\t\tif (filter && !filter(entry)) return\n\t\t\tlogs.push(formatter(entry))\n\t\t},\n\t\tgetLogMessage() {\n\t\t\treturn this.getLogMessages().join('\\n')\n\t\t},\n\t\tgetLogMessages() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => log.args.join(' '))\n\t\t},\n\t\tgetLogMessagesWithLevel() {\n\t\t\treturn logs.map(toInspectLogEntry).map(log => `${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessagesWithIdAndLevel() {\n\t\t\treturn logs\n\t\t\t\t.map(toInspectLogEntry)\n\t\t\t\t.map(log => `${log.id} ${formatLogLevel(log.level)} ${log.args.join(' ')}`)\n\t\t},\n\t\tgetLogMessageWithLevel() {\n\t\t\treturn toMessageWithLevel(logs)\n\t\t},\n\t\t/**\n\t\t * emit the saved log to console for easy debugging\n\t\t */\n\t\temit() {\n\t\t\tconst reporter = createConsoleLogReporter()\n\t\t\tlogs.forEach(l => reporter.write(l))\n\t\t}\n\t}\n}\n\nexport function createMemoryWithConsoleLogReporter(\n\toptions?: LogReporterOptions<LogEntry>\n): MemoryLogReporter {\n\treturn Object.freeze(\n\t\tObject.assign(buildMemoryReporter(unpartial({ id: 'memory-with-console' }, options)), {\n\t\t\tisConsoleReporter: true\n\t\t})\n\t)\n}\n"],"mappings":";;;;;;AAsBA,SAAgB,mBAAmB,MAAkB;CACpD,OACC,KACE,IAAIA,iBAAAA,iBAAiB,CAAC,CACtB,KAAI,QAAO,GAAGC,kBAAAA,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG,CAAC,CAChE,KAAK,IAAI,CAAC,CAIV,QAAQ,qEAAqE,EAAE;AAEnF;AAEA,SAAgB,wBAAwB,SAA2D;CAClG,OAAO,OAAO,OAAO,qBAAA,GAAoB,UAAA,UAAA,CAAU,EAAE,IAAI,SAAS,GAAG,OAAO,CAAC,CAAC;AAC/E;AAEA,SAAS,oBAAoB,SAAwC;CACpE,MAAM,EAAE,IAAI,WAAW,YAAA,GAAWC,UAAAA,SAAAA,CAAS;EAAE,IAAI;EAAU,YAAY,MAAgB;CAAE,GAAG,OAAO;CACnG,MAAM,OAAmB,CAAC;CAC1B,OAAO;EACN;EACA,IAAI,YAAY;GACf,OAAO;EACR;EACA,IAAI,SAAS;GACZ,OAAO;EACR;EACA;EACA,MAAM,OAAiB;GACtB,IAAI,UAAU,CAAC,OAAO,KAAK,GAAG;GAC9B,KAAK,KAAK,UAAU,KAAK,CAAC;EAC3B;EACA,gBAAgB;GACf,OAAO,KAAK,eAAe,CAAC,CAAC,KAAK,IAAI;EACvC;EACA,iBAAiB;GAChB,OAAO,KAAK,IAAIF,iBAAAA,iBAAiB,CAAC,CAAC,KAAI,QAAO,IAAI,KAAK,KAAK,GAAG,CAAC;EACjE;EACA,0BAA0B;GACzB,OAAO,KAAK,IAAIA,iBAAAA,iBAAiB,CAAC,CAAC,KAAI,QAAO,GAAGC,kBAAAA,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG;EACnG;EACA,+BAA+B;GAC9B,OAAO,KACL,IAAID,iBAAAA,iBAAiB,CAAC,CACtB,KAAI,QAAO,GAAG,IAAI,GAAG,GAAGC,kBAAAA,eAAe,IAAI,KAAK,EAAE,GAAG,IAAI,KAAK,KAAK,GAAG,GAAG;EAC5E;EACA,yBAAyB;GACxB,OAAO,mBAAmB,IAAI;EAC/B;;;;EAIA,OAAO;GACN,MAAM,WAAWE,gBAAAA,yBAAyB;GAC1C,KAAK,SAAQ,MAAK,SAAS,MAAM,CAAC,CAAC;EACpC;CACD;AACD;AAEA,SAAgB,mCACf,SACoB;CACpB,OAAO,OAAO,OACb,OAAO,OAAO,qBAAA,GAAoB,UAAA,UAAA,CAAU,EAAE,IAAI,sBAAsB,GAAG,OAAO,CAAC,GAAG,EACrF,mBAAmB,KACpB,CAAC,CACF;AACD"}
|
package/cjs/platform.browser.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
2
|
+
const require_record = require("./record.js");
|
|
3
3
|
//#region ts/platform.browser.ts
|
|
4
4
|
const toInspectLogEntry = (e) => e;
|
|
5
|
-
const polyfill =
|
|
5
|
+
const polyfill = require_record.record();
|
|
6
6
|
//#endregion
|
|
7
7
|
exports.polyfill = polyfill;
|
|
8
8
|
exports.toInspectLogEntry = toInspectLogEntry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.browser.js","names":["record"],"sources":["../ts/platform.browser.ts"],"sourcesContent":["import { record } from '
|
|
1
|
+
{"version":3,"file":"platform.browser.js","names":["record"],"sources":["../ts/platform.browser.ts"],"sourcesContent":["import { record } from './record.js'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => e\n\nexport const polyfill: { console?: ConsoleLike } = record()\n"],"mappings":";;;AAGA,MAAa,qBAAqB,MAAgB;AAElD,MAAa,WAAsCA,eAAAA,OAAO"}
|
package/cjs/platform.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_record = require("./record.js");
|
|
2
3
|
let node_util = require("node:util");
|
|
3
|
-
let type_plus = require("type-plus");
|
|
4
4
|
//#region ts/platform.ts
|
|
5
5
|
const toInspectLogEntry = (e) => (e.args = e.args.map((value) => typeof value === "object" && value !== null ? (0, node_util.inspect)(value) : value), e);
|
|
6
|
-
const polyfill =
|
|
6
|
+
const polyfill = require_record.record();
|
|
7
7
|
//#endregion
|
|
8
8
|
exports.polyfill = polyfill;
|
|
9
9
|
exports.toInspectLogEntry = toInspectLogEntry;
|
package/cjs/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","names":["inspect","record"],"sources":["../ts/platform.ts"],"sourcesContent":["import { inspect } from 'node:util'\nimport { record } from '
|
|
1
|
+
{"version":3,"file":"platform.js","names":["inspect","record"],"sources":["../ts/platform.ts"],"sourcesContent":["import { inspect } from 'node:util'\nimport { record } from './record.js'\nimport type { ConsoleLike, LogEntry } from './types.js'\n\nexport const toInspectLogEntry = (e: LogEntry) => (\n\t(e.args = e.args.map(value => (typeof value === 'object' && value !== null ? inspect(value) : value))), e\n)\n\nexport const polyfill: { console?: ConsoleLike } = record()\n"],"mappings":";;;;AAIA,MAAa,qBAAqB,OAChC,EAAE,OAAO,EAAE,KAAK,KAAI,UAAU,OAAO,UAAU,YAAY,UAAU,QAAA,GAAOA,UAAAA,QAAAA,CAAQ,KAAK,IAAI,KAAM,GAAI;AAGzG,MAAa,WAAsCC,eAAAA,OAAO"}
|
package/cjs/record.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region ts/record.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a prototype-less object, optionally seeded with `value`.
|
|
4
|
+
*
|
|
5
|
+
* Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function record<R extends Record<any, any>>(value?: R): R;
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","names":[],"sources":["../ts/record.ts"],"mappings":";;;;;;wBAKgB,OAAO,UAAU,kBAAkB,QAAQ,IAAI"}
|
package/cjs/record.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region ts/record.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a prototype-less object, optionally seeded with `value`.
|
|
5
|
+
*
|
|
6
|
+
* Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.
|
|
7
|
+
*/
|
|
8
|
+
function record(value) {
|
|
9
|
+
const r = Object.create(null);
|
|
10
|
+
return value ? Object.assign(r, value) : r;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.record = record;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","names":[],"sources":["../ts/record.ts"],"sourcesContent":["/**\n * Creates a prototype-less object, optionally seeded with `value`.\n *\n * Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.\n */\nexport function record<R extends Record<any, any>>(value?: R): R {\n\tconst r = Object.create(null)\n\treturn value ? Object.assign(r, value) : r\n}\n"],"mappings":";;;;;;;AAKA,SAAgB,OAAmC,OAAc;CAChE,MAAM,IAAI,OAAO,OAAO,IAAI;CAC5B,OAAO,QAAQ,OAAO,OAAO,GAAG,KAAK,IAAI;AAC1C"}
|
package/cjs/standard_log.ctx.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.ctx.js","names":["record"],"sources":["../ts/standard_log.ctx.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"standard_log.ctx.js","names":["record"],"sources":["../ts/standard_log.ctx.ts"],"sourcesContent":["import type { LogStore } from './log_store.js'\nimport { record } from './record.js'\nimport type { LogMethodNames, StandardLogInstance } from './types.js'\n\nexport const ctx: {\n\tconfigured?: boolean\n\tgsl?: { store: LogStore; standardLog: StandardLogInstance<LogMethodNames> }\n} = record()\n"],"mappings":";;AAIA,MAAa,2BAGTA,CAAAA,CAAAA,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.d.ts","names":[],"sources":["../ts/standard_log.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"standard_log.d.ts","names":[],"sources":["../ts/standard_log.ts"],"mappings":";;;iBAciB,YAAY,mBAAmB,wBAAwB,SAAS,oBAAoB;wBAErF,kBAAkB,mBAAmB,gBACpD,UAAU,mBAAmB,KAC3B,YAAY;wBAeC,yBAAyB,mBAAmB,gBAC3D,UAAU,mBAAmB;EACzB,OAAO;EAAU,aAAa,YAAY;;;;;wBA4D/B,aAAa,GAAG,aAAa,GAAG,KAAK,WAAW,MAAM,WAAW;YASrE,UAAU,mBAAmB,mBACxC,YACA,UAAU,kBACN,OAAO,iBAAiB;wBAEb,UAAU,mBAAmB,gBAAgB,YAAY,UAAU,gBAAa,OAAA,IAAA;wBAUhF,aAAa,SAAS,KAAK"}
|
package/cjs/standard_log.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_log_levels = require("./log_levels.js");
|
|
3
|
+
const require_record = require("./record.js");
|
|
3
4
|
const require_log_store = require("./log_store.js");
|
|
4
5
|
const require_logger = require("./logger.js");
|
|
5
6
|
const require_standard_log_ctx = require("./standard_log.ctx.js");
|
|
6
|
-
let
|
|
7
|
+
let unpartial = require("unpartial");
|
|
7
8
|
//#region ts/standard_log.ts
|
|
8
9
|
function createStandardLog(options) {
|
|
9
10
|
const closure = createStandardLogClosure(options);
|
|
@@ -13,7 +14,7 @@ function createStandardLog(options) {
|
|
|
13
14
|
}
|
|
14
15
|
function noop() {}
|
|
15
16
|
function createStandardLogClosure(options) {
|
|
16
|
-
const store = require_log_store.createLogStore((0,
|
|
17
|
+
const store = require_log_store.createLogStore((0, unpartial.required)({ logLevel: require_log_levels.logLevels.info }, options));
|
|
17
18
|
const nonConsoleReporters = options?.reporters?.filter((r) => !r.isConsoleReporter).map((r) => r.id) ?? [];
|
|
18
19
|
const logMethods = require_log_levels.DEFAULT_LOG_METHOD_NAMES.concat(Object.keys(options?.customLevels ?? {})).concat([
|
|
19
20
|
"on",
|
|
@@ -60,7 +61,7 @@ function createDummyLogger(logMethods) {
|
|
|
60
61
|
return logMethods.reduce((p, m) => {
|
|
61
62
|
p[m] = noop;
|
|
62
63
|
return p;
|
|
63
|
-
},
|
|
64
|
+
}, require_record.record());
|
|
64
65
|
}
|
|
65
66
|
function suppressLogs(block, ...logs) {
|
|
66
67
|
const origLevels = logs.map((l) => l.level);
|
package/cjs/standard_log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard_log.js","names":["ctx","createLogStore","required","logLevels","DEFAULT_LOG_METHOD_NAMES","createLogger","record"],"sources":["../ts/standard_log.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"standard_log.js","names":["ctx","createLogStore","required","logLevels","DEFAULT_LOG_METHOD_NAMES","createLogger","record"],"sources":["../ts/standard_log.ts"],"sourcesContent":["import { required } from 'unpartial'\nimport { DEFAULT_LOG_METHOD_NAMES, logLevels } from './log_levels.js'\nimport { createLogStore, type LogStore } from './log_store.js'\nimport { createLogger } from './logger.js'\nimport { record } from './record.js'\nimport { ctx } from './standard_log.ctx.js'\nimport type {\n\tLogger,\n\tLoggerOptions,\n\tLogMethodNames,\n\tStandardLogInstance,\n\tStandardLogOptions\n} from './types.js'\n\nexport interface StandardLog<N extends string = LogMethodNames> extends Readonly<StandardLogInstance<N>> {}\n\nexport function createStandardLog<N extends string = LogMethodNames>(\n\toptions?: StandardLogOptions<N>\n): StandardLog<N> {\n\tconst closure = createStandardLogClosure(options)\n\tif (options?.reporters?.some(r => !r.id)) {\n\t\tconst log = closure.standardLog.getLogger('standard-log')\n\t\tlog.critical(\n\t\t\t`Detected reporter with empty id. This is not allowed as it will create problems with feature like 'getNonConsoleLogger()'. Please add an id to your reporter.`\n\t\t)\n\t}\n\n\tif (!ctx.gsl) ctx.gsl = closure as any\n\treturn closure.standardLog\n}\n\nfunction noop() {}\n\nexport function createStandardLogClosure<N extends string = LogMethodNames>(\n\toptions?: StandardLogOptions<N>\n): { store: LogStore; standardLog: StandardLog<N> } {\n\t// TODO reporter.id must not be empty\n\tconst store = createLogStore(required({ logLevel: logLevels.info }, options))\n\tconst nonConsoleReporters = options?.reporters?.filter(r => !r.isConsoleReporter).map(r => r.id) ?? []\n\tconst logMethods = DEFAULT_LOG_METHOD_NAMES.concat(Object.keys(options?.customLevels ?? {})).concat([\n\t\t'on',\n\t\t'count',\n\t\t'write'\n\t])\n\treturn {\n\t\tstore,\n\t\tstandardLog: {\n\t\t\tget logLevel() {\n\t\t\t\treturn store.logLevel\n\t\t\t},\n\n\t\t\ttoLogLevelName(level: number) {\n\t\t\t\treturn store.logLevelStore.getName(level)\n\t\t\t},\n\t\t\ttoLogLevel(name: string) {\n\t\t\t\treturn store.logLevelStore.getLevel(name)\n\t\t\t},\n\t\t\tgetLogger(id: string, options?: LoggerOptions) {\n\t\t\t\tif (store.loggers[id]) return store.loggers[id] as any\n\t\t\t\treturn (store.loggers[id] = createLogger(store, id, { ssf: this.getLogger, ...options }) as any)\n\t\t\t},\n\t\t\tgetNonConsoleLogger(id, options?) {\n\t\t\t\tif (store.nonConsoleLoggers[id]) return store.nonConsoleLoggers[id] as any\n\n\t\t\t\tif (store.loggers[id]) {\n\t\t\t\t\tconst log = this.getLogger('standard-log')\n\t\t\t\t\tlog.warn(`attempt to create a non-console logger with existing id ('${id}'), ignoring`)\n\t\t\t\t\treturn (store.nonConsoleLoggers[id] = createDummyLogger(logMethods))\n\t\t\t\t}\n\n\t\t\t\treturn (store.nonConsoleLoggers[id] =\n\t\t\t\t\tnonConsoleReporters.length === 0\n\t\t\t\t\t\t? createDummyLogger(logMethods)\n\t\t\t\t\t\t: createLogger(store, id, {\n\t\t\t\t\t\t\t\tssf: this.getNonConsoleLogger,\n\t\t\t\t\t\t\t\t...options,\n\t\t\t\t\t\t\t\twriteTo(reporterId) {\n\t\t\t\t\t\t\t\t\treturn nonConsoleReporters.indexOf(reporterId) >= 0\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}))\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction createDummyLogger(logMethods: string[]) {\n\treturn logMethods.reduce((p, m) => {\n\t\tp[m] = noop\n\t\treturn p\n\t}, record()) as Logger\n}\n\n/**\n * Suppress logging within the code block.\n */\nexport function suppressLogs<R>(block: () => R, log: Logger, ...logs: Logger[]): R\nexport function suppressLogs<R>(block: () => R, ...logs: Logger[]): R {\n\tconst origLevels = logs.map(l => l.level)\n\tlogs.forEach(l => (l.level = logLevels.none))\n\tconst result = block()\n\tlogs.forEach((l, i) => (l.level = origLevels[i]))\n\treturn result\n}\n\nexport type GetLogger<N extends string = LogMethodNames> = (\n\tid: string,\n\toptions?: LoggerOptions\n) => Logger<LogMethodNames | N>\n\nexport function getLogger<N extends string = LogMethodNames>(id: string, options?: LoggerOptions) {\n\treturn getGlobalSL<N>().getLogger(id, options)\n}\n\nfunction getGlobalSL<N extends string = LogMethodNames>(): StandardLogInstance<N> {\n\tif (!ctx.gsl) ctx.gsl = createStandardLogClosure()\n\n\treturn ctx.gsl!.standardLog as StandardLogInstance<N>\n}\n\nexport function configGlobal(options: Omit<StandardLogOptions, 'customLevels'>) {\n\tif (ctx.configured) {\n\t\tconst log = ctx.gsl!.standardLog.getLogger('standard-log')\n\t\tlog.warn(\n\t\t\t'configGlobal() is being called more than once. Please make sure this is expected. Application should use `createStandardLog()` most of the time.'\n\t\t)\n\t}\n\n\tif (ctx.gsl) {\n\t\tif (options.logLevel) {\n\t\t\tctx.gsl.store.logLevel = options.logLevel\n\t\t}\n\t\tif (options.reporters) {\n\t\t\tconst reporters = ctx.gsl.store.reporters\n\t\t\treporters.length = 0\n\t\t\treporters.push(...options.reporters)\n\t\t}\n\t} else {\n\t\tctx.gsl = createStandardLogClosure(options)\n\t}\n\tctx.configured = true\n}\n"],"mappings":"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"}
|
package/cjs/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { StackTraceMeta } from "@just-func/types";
|
|
2
1
|
//#region ts/types.d.ts
|
|
3
2
|
export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames> = {
|
|
4
3
|
/**
|
|
@@ -19,7 +18,11 @@ export type StandardLogOptions<CustomLevelNames extends string = LogMethodNames>
|
|
|
19
18
|
logLevel?: number;
|
|
20
19
|
reporters?: LogReporter[];
|
|
21
20
|
};
|
|
22
|
-
export interface LoggerOptions
|
|
21
|
+
export interface LoggerOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Stack start function: the stack trace is adjusted to start from this function.
|
|
24
|
+
*/
|
|
25
|
+
ssf?: (...args: any[]) => any;
|
|
23
26
|
level?: number;
|
|
24
27
|
writeTo?: LogReporter | ReporterFilter;
|
|
25
28
|
}
|
package/cjs/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../ts/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../ts/types.ts"],"mappings":";YAAY,mBAAmB,kCAAkC;;;;;;;;;;;;;;;EAehE,eAAe,OAAO;EACtB;EACA,YAAY;;iBAGI;;;;EAIhB,UAAU;EACV;EACA,UAAU,cAAc;;YAGb,OAAO,mBAAmB;WAC5B;;;;EAIT;;;;;EAKA,SAAS;EACT,GAAG,gBAAgB,GAAG,aAAa;;;;EAInC,MAAM,OAAO;OACP,KAAK,IAAI;;;;YAKJ;YAYA;EACX;EACA;EAEA;EACA,WAAW;;YAGA,gBAAgB;YAEhB,eAAe,KAAK,WAAW;YAE/B,0BAA0B,WAAW;iBAEhC,oBAAoB,mBAAmB;;;;EAIvD;;;;EAIA,eAAe;;;;EAIf,WAAW,MAAM;;;;;;;;;;EAUjB,UAAU,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;;;;;;EAY3D,oBAAoB,YAAY,UAAU,gBAAgB,OAAO,IAAI;;;;;;;YAQ1D,aAAa,cAAc,OAAO,aAAa;;;;YAK/C,aAAa,OAAO;YAEpB;EAAkB;EAAc;;iBAE3B,YAAY;WACnB;;;;;WAKA,WAAW,aAAa;;;;WAIxB,SAAS;;;;;WAKT;EACT,MAAM,OAAO;;YAGF,mBAAmB;EAC9B;;;;;EAKA,YAAY,aAAa;;;;EAIzB,SAAS;;YAGE;iBAEK;EAChB,SAAS;EACT,QAAQ;EACR,QAAQ;EACR,SAAS"}
|
package/dist/standard-log.esm.js
CHANGED
|
@@ -22,6 +22,22 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region ../../node_modules/.pnpm/unpartial@1.0.8/node_modules/unpartial/esm/index.js
|
|
25
|
+
function required(source1, source2, source3) {
|
|
26
|
+
return merge([
|
|
27
|
+
source1,
|
|
28
|
+
source2,
|
|
29
|
+
source3
|
|
30
|
+
], (p, e) => {
|
|
31
|
+
return {
|
|
32
|
+
...p,
|
|
33
|
+
...e
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function merge(entries, reducer) {
|
|
38
|
+
if (entries[0] === void 0 || entries[0] === null) return entries[0];
|
|
39
|
+
return entries.filter((x) => !!x).reduce(reducer, {});
|
|
40
|
+
}
|
|
25
41
|
function unpartial(s1, s2, s3) {
|
|
26
42
|
if (s1 === void 0 || s1 === null) return s1;
|
|
27
43
|
return [
|
|
@@ -305,108 +321,17 @@ function consoleFormatter({ args }) {
|
|
|
305
321
|
return args;
|
|
306
322
|
}
|
|
307
323
|
//#endregion
|
|
308
|
-
//#region
|
|
309
|
-
/**
|
|
310
|
-
* `Array.prototype.map` over the *keys* of `subject`. Returns an array of the
|
|
311
|
-
* callback results in `Object.keys()` order -- an array, not a record.
|
|
312
|
-
*
|
|
313
|
-
* @example
|
|
314
|
-
* ```ts
|
|
315
|
-
* const r = mapKey({ a: 1, b: 2 }, (k, i) => `${String(k)}${i}`)
|
|
316
|
-
* // r === ['a0', 'b1']
|
|
317
|
-
*
|
|
318
|
-
* const r = mapKey({ a: 1, b: 2 }, (k, _i, _a, s) => s[k])
|
|
319
|
-
* // r === [1, 2]
|
|
320
|
-
* ```
|
|
321
|
-
*/
|
|
322
|
-
function mapKey(subject, predicate, thisArg) {
|
|
323
|
-
return Object.keys(subject).map(function(k, i, a) {
|
|
324
|
-
return predicate.apply(this, [
|
|
325
|
-
k,
|
|
326
|
-
i,
|
|
327
|
-
a,
|
|
328
|
-
subject
|
|
329
|
-
]);
|
|
330
|
-
}, thisArg);
|
|
331
|
-
}
|
|
332
|
-
//#endregion
|
|
333
|
-
//#region ../../node_modules/.pnpm/type-plus@8.0.0-beta.12_typescript@7.0.2/node_modules/type-plus/esm/object/reduce-key.js
|
|
324
|
+
//#region ts/record.ts
|
|
334
325
|
/**
|
|
335
|
-
*
|
|
336
|
-
* `Object.keys()` order.
|
|
337
|
-
*
|
|
338
|
-
* The callback receives the accumulator, the key, the index, the whole key
|
|
339
|
-
* array and `subject` itself, so the value is reachable as `subject[key]`
|
|
340
|
-
* without closing over it.
|
|
326
|
+
* Creates a prototype-less object, optionally seeded with `value`.
|
|
341
327
|
*
|
|
342
|
-
*
|
|
343
|
-
* properties are skipped.
|
|
344
|
-
*
|
|
345
|
-
* @example
|
|
346
|
-
* ```ts
|
|
347
|
-
* const r = reduceByKey({ a: 1, b: 2 }, (acc, k) => acc + String(k), '')
|
|
348
|
-
* // r === 'ab'
|
|
349
|
-
*
|
|
350
|
-
* const sum = reduceByKey({ a: 1, b: 2 }, (acc, k, _i, _a, s) => acc + s[k], 0)
|
|
351
|
-
* // sum === 3
|
|
352
|
-
* ```
|
|
328
|
+
* Inlined from `type-plus` so the CJS build does not `require()` the ESM-only `type-plus`.
|
|
353
329
|
*/
|
|
354
|
-
function reduceByKey(subject, callbackfn, initialValue) {
|
|
355
|
-
return Object.keys(subject).reduce((p, k, i, a) => callbackfn(p, k, i, a, subject), initialValue);
|
|
356
|
-
}
|
|
357
|
-
//#endregion
|
|
358
|
-
//#region ../../node_modules/.pnpm/type-plus@8.0.0-beta.12_typescript@7.0.2/node_modules/type-plus/esm/object/record.js
|
|
359
330
|
function record(value) {
|
|
360
331
|
const r = Object.create(null);
|
|
361
332
|
return value ? Object.assign(r, value) : r;
|
|
362
333
|
}
|
|
363
334
|
//#endregion
|
|
364
|
-
//#region ../../node_modules/.pnpm/unpartial@1.0.7/node_modules/unpartial/esm/index.js
|
|
365
|
-
function required$1(source1, source2, source3) {
|
|
366
|
-
return merge([
|
|
367
|
-
source1,
|
|
368
|
-
source2,
|
|
369
|
-
source3
|
|
370
|
-
], (p, e) => {
|
|
371
|
-
return {
|
|
372
|
-
...p,
|
|
373
|
-
...e
|
|
374
|
-
};
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
function merge(entries, reducer) {
|
|
378
|
-
if (entries[0] === void 0 || entries[0] === null) return entries[0];
|
|
379
|
-
return entries.filter((x) => !!x).reduce(reducer, {});
|
|
380
|
-
}
|
|
381
|
-
//#endregion
|
|
382
|
-
//#region ../../node_modules/.pnpm/type-plus@8.0.0-beta.12_typescript@7.0.2/node_modules/type-plus/esm/unpartial.js
|
|
383
|
-
/**
|
|
384
|
-
* 🦴 *utilities*
|
|
385
|
-
*
|
|
386
|
-
* Merges up to three partial objects, left to right, into one value typed as
|
|
387
|
-
* the intersection of their full types. Re-exported from the
|
|
388
|
-
* [`unpartial`](https://github.com/unional/unpartial) package.
|
|
389
|
-
*
|
|
390
|
-
* The merge is shallow: each source is spread over the previous result, so a
|
|
391
|
-
* later source replaces a nested object instead of merging into it. A key the
|
|
392
|
-
* later source sets to `undefined` overwrites the earlier value. `null` and
|
|
393
|
-
* `undefined` sources are skipped. If `source1` is `null` or `undefined`, it
|
|
394
|
-
* is returned as is.
|
|
395
|
-
*
|
|
396
|
-
* Use `requiredDeep()` to merge nested objects.
|
|
397
|
-
*
|
|
398
|
-
* @example
|
|
399
|
-
* ```ts
|
|
400
|
-
* type Options = { a: number; b: { x: number; y?: number } }
|
|
401
|
-
* const defaults: Options = { a: 1, b: { x: 1, y: 1 } }
|
|
402
|
-
*
|
|
403
|
-
* const r = required<Options>(defaults, { b: { x: 2 } })
|
|
404
|
-
* // r === { a: 1, b: { x: 2 } }
|
|
405
|
-
* // typeof r === Options
|
|
406
|
-
* ```
|
|
407
|
-
*/
|
|
408
|
-
const required = required$1;
|
|
409
|
-
//#endregion
|
|
410
335
|
//#region ts/platform.browser.ts
|
|
411
336
|
const toInspectLogEntry = (e) => e;
|
|
412
337
|
const polyfill = record();
|
|
@@ -822,7 +747,7 @@ function logLevelStore(options) {
|
|
|
822
747
|
const customLevels = options.customLevels || record();
|
|
823
748
|
const store = {
|
|
824
749
|
customLevels,
|
|
825
|
-
customLevelsReverse:
|
|
750
|
+
customLevelsReverse: Object.keys(customLevels).reduce((p, k) => {
|
|
826
751
|
p[customLevels[k]] = k;
|
|
827
752
|
return p;
|
|
828
753
|
}, {})
|
|
@@ -835,13 +760,13 @@ function logLevelStore(options) {
|
|
|
835
760
|
return store.customLevels[name] ?? toLogLevel(name);
|
|
836
761
|
},
|
|
837
762
|
getAllLevels() {
|
|
838
|
-
return
|
|
763
|
+
return Object.keys(logLevels).reduce((result, name) => {
|
|
839
764
|
if (name !== "none" && name !== "all") result.push({
|
|
840
765
|
name,
|
|
841
766
|
level: logLevels[name]
|
|
842
767
|
});
|
|
843
768
|
return result;
|
|
844
|
-
},
|
|
769
|
+
}, Object.keys(store.customLevels).map((name) => ({
|
|
845
770
|
name,
|
|
846
771
|
level: store.customLevels[name]
|
|
847
772
|
})));
|