nightingale-formatter 12.1.4 → 13.0.0
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 +22 -0
- package/README.md +4 -0
- package/dist/{formatObject.d.ts → definitions/formatObject.d.ts} +2 -2
- package/dist/definitions/formatObject.d.ts.map +1 -0
- package/dist/definitions/formatObject.test.d.ts +2 -0
- package/dist/definitions/formatObject.test.d.ts.map +1 -0
- package/dist/{formatRecordToString.d.ts → definitions/formatRecordToString.d.ts} +0 -0
- package/dist/definitions/formatRecordToString.d.ts.map +1 -0
- package/dist/{index.d.ts → definitions/index.d.ts} +0 -0
- package/dist/definitions/index.d.ts.map +1 -0
- package/dist/definitions/index.test.d.ts +2 -0
- package/dist/definitions/index.test.d.ts.map +1 -0
- package/dist/definitions/levelToStyles.d.ts +3 -0
- package/dist/definitions/levelToStyles.d.ts.map +1 -0
- package/dist/definitions/levelToSymbol.d.ts +3 -0
- package/dist/definitions/levelToSymbol.d.ts.map +1 -0
- package/dist/definitions/styleToHexColor.d.ts +3 -0
- package/dist/definitions/styleToHexColor.d.ts.map +1 -0
- package/dist/{styleToHtmlStyle.d.ts → definitions/styleToHtmlStyle.d.ts} +1 -1
- package/dist/definitions/styleToHtmlStyle.d.ts.map +1 -0
- package/dist/index-browser.es.js +49 -105
- package/dist/index-browser.es.js.map +1 -1
- package/dist/index-browsermodern.es.js +8 -55
- package/dist/index-browsermodern.es.js.map +1 -1
- package/dist/{index-node14.mjs → index-node16.mjs} +9 -56
- package/dist/{index-node14.cjs.map → index-node16.mjs.map} +1 -1
- package/package.json +24 -41
- package/dist/formatObject.d.ts.map +0 -1
- package/dist/formatRecordToString.d.ts.map +0 -1
- package/dist/index-browser.cjs.js +0 -593
- package/dist/index-browser.cjs.js.map +0 -1
- package/dist/index-node14.cjs +0 -580
- package/dist/index-node14.mjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/levelToStyles.d.ts +0 -3
- package/dist/levelToStyles.d.ts.map +0 -1
- package/dist/levelToSymbol.d.ts +0 -3
- package/dist/levelToSymbol.d.ts.map +0 -1
- package/dist/styleToHexColor.d.ts +0 -3
- package/dist/styleToHexColor.d.ts.map +0 -1
- package/dist/styleToHtmlStyle.d.ts.map +0 -1
- package/rollup.config.mjs +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [13.0.0](https://github.com/christophehurpeau/nightingale/compare/v12.1.4...v13.0.0) (2022-11-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Code Refactoring
|
|
10
|
+
|
|
11
|
+
* drop node 14 and cjs ([9a8ca06](https://github.com/christophehurpeau/nightingale/commit/9a8ca064449ddc0d69e26543e21c2d522536c50a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* build for node 16 ([30ae3e9](https://github.com/christophehurpeau/nightingale/commit/30ae3e9c455dbad793c2f704b9d860069dc80c32))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* dropped node 14 and cjs
|
|
22
|
+
* drop node 14
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [12.1.4](https://github.com/christophehurpeau/nightingale/compare/v12.1.3...v12.1.4) (2022-02-05)
|
|
7
29
|
|
|
8
30
|
|
package/README.md
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<a href="https://npmjs.org/package/nightingale-formatter"><img src="https://img.shields.io/npm/v/nightingale-formatter.svg?style=flat-square"></a>
|
|
11
|
+
<a href="https://npmjs.org/package/nightingale-formatter"><img src="https://img.shields.io/npm/dw/nightingale-formatter.svg?style=flat-square"></a>
|
|
12
|
+
<a href="https://npmjs.org/package/nightingale-formatter"><img src="https://img.shields.io/node/v/nightingale-formatter.svg?style=flat-square"></a>
|
|
13
|
+
<a href="https://npmjs.org/package/nightingale-formatter"><img src="https://img.shields.io/npm/types/nightingale-formatter.svg?style=flat-square"></a>
|
|
14
|
+
<a href="https://codecov.io/gh/christophehurpeau/nightingale"><img src="https://img.shields.io/codecov/c/github/christophehurpeau/nightingale/master.svg?style=flat-square"></a>
|
|
11
15
|
</p>
|
|
12
16
|
|
|
13
17
|
## Install
|
|
@@ -3,7 +3,7 @@ export interface FormatObjectOptions {
|
|
|
3
3
|
padding?: string;
|
|
4
4
|
maxDepth?: number;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
export
|
|
6
|
+
export type StyleFn = (styles: Styles, value: string) => string;
|
|
7
|
+
export type ObjectStyles<Keys extends string = string> = Record<Keys, Styles>;
|
|
8
8
|
export declare function formatObject(object: Record<string, unknown>, styleFn?: StyleFn, objectStyles?: ObjectStyles, { padding, maxDepth }?: FormatObjectOptions): string;
|
|
9
9
|
//# sourceMappingURL=formatObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatObject.d.ts","sourceRoot":"","sources":["../../src/formatObject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AAEhE,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAya9E,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,GAAE,OAAmB,EAC5B,YAAY,CAAC,EAAE,YAAY,EAC3B,EAAE,OAAc,EAAE,QAAa,EAAE,GAAE,mBAAwB,GAC1D,MAAM,CAkBR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatObject.test.d.ts","sourceRoot":"","sources":["../../src/formatObject.test.ts"],"names":[],"mappings":""}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatRecordToString.d.ts","sourceRoot":"","sources":["../../src/formatRecordToString.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,gBAAgB,CAAC;AAK5D,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,QAAQ,EACrD,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EACpB,KAAK,EAAE,OAAO,GACb,MAAM,CAyDR"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levelToStyles.d.ts","sourceRoot":"","sources":["../../src/levelToStyles.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAE/D,eAAO,MAAM,aAAa,EAAE,aAS3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levelToSymbol.d.ts","sourceRoot":"","sources":["../../src/levelToSymbol.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7D,eAAO,MAAM,aAAa,EAAE,aAS3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleToHexColor.d.ts","sourceRoot":"","sources":["../../src/styleToHexColor.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE/D,eAAO,MAAM,eAAe,EAAE,eAI7B,CAAC"}
|
|
@@ -2,7 +2,7 @@ export interface HtmlStyle {
|
|
|
2
2
|
readonly open: string;
|
|
3
3
|
readonly close: string;
|
|
4
4
|
}
|
|
5
|
-
export
|
|
5
|
+
export type StyleToHtmlStyle = Readonly<Record<string, HtmlStyle>>;
|
|
6
6
|
export declare const styleToHtmlStyleThemeLight: StyleToHtmlStyle;
|
|
7
7
|
export declare const styleToHtmlStyleThemeDark: StyleToHtmlStyle;
|
|
8
8
|
//# sourceMappingURL=styleToHtmlStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleToHtmlStyle.d.ts","sourceRoot":"","sources":["../../src/styleToHtmlStyle.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAEnE,eAAO,MAAM,0BAA0B,EAAE,gBAgDxC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,gBAOvC,CAAC"}
|
package/dist/index-browser.es.js
CHANGED
|
@@ -128,10 +128,10 @@ var styleToHtmlStyleThemeDark = _extends({}, styleToHtmlStyleThemeLight, {
|
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
/* eslint-disable max-lines, @typescript-eslint/no-use-before-define */
|
|
131
|
+
|
|
131
132
|
var noStyleFn = function noStyleFn(styles, value) {
|
|
132
133
|
return value;
|
|
133
134
|
};
|
|
134
|
-
|
|
135
135
|
function tryStringify(arg) {
|
|
136
136
|
try {
|
|
137
137
|
return JSON.stringify(arg).replace(/\\n/g, '\n');
|
|
@@ -139,21 +139,18 @@ function tryStringify(arg) {
|
|
|
139
139
|
return '[Circular]';
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
|
|
143
142
|
var sameRawFormattedValue = function sameRawFormattedValue(value) {
|
|
144
143
|
return {
|
|
145
144
|
stringValue: value,
|
|
146
145
|
formattedValue: value
|
|
147
146
|
};
|
|
148
147
|
};
|
|
149
|
-
|
|
150
148
|
function internalFormatValue(value, styleFn, styles, _ref) {
|
|
151
149
|
var padding = _ref.padding,
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
depth = _ref.depth,
|
|
151
|
+
maxDepth = _ref.maxDepth,
|
|
152
|
+
objects = _ref.objects;
|
|
155
153
|
var typeofValue = typeof value;
|
|
156
|
-
|
|
157
154
|
if (!styles) {
|
|
158
155
|
if (value == null) {
|
|
159
156
|
styles = ['cyan'];
|
|
@@ -162,32 +159,25 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
162
159
|
case 'undefined':
|
|
163
160
|
styles = ['cyan'];
|
|
164
161
|
break;
|
|
165
|
-
|
|
166
162
|
case 'boolean':
|
|
167
163
|
styles = ['green'];
|
|
168
164
|
break;
|
|
169
|
-
|
|
170
165
|
case 'number':
|
|
171
166
|
styles = ['yellow'];
|
|
172
167
|
break;
|
|
173
|
-
|
|
174
168
|
case 'bigint':
|
|
175
169
|
styles = ['red'];
|
|
176
170
|
break;
|
|
177
|
-
|
|
178
171
|
case 'string':
|
|
179
172
|
styles = ['orange'];
|
|
180
173
|
break;
|
|
181
|
-
|
|
182
174
|
case 'symbol':
|
|
183
175
|
styles = ['magenta'];
|
|
184
176
|
break;
|
|
185
177
|
}
|
|
186
178
|
}
|
|
187
179
|
}
|
|
188
|
-
|
|
189
180
|
var stringValue;
|
|
190
|
-
|
|
191
181
|
if (value === null) {
|
|
192
182
|
stringValue = 'null';
|
|
193
183
|
} else if (value === undefined) {
|
|
@@ -222,7 +212,6 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
222
212
|
stringValue = stack != null && stack.startsWith(value.message) ? stack : value.message + "\n" + (stack || '');
|
|
223
213
|
} else if (value instanceof Map) {
|
|
224
214
|
var name = value.constructor.name;
|
|
225
|
-
|
|
226
215
|
if (depth >= maxDepth) {
|
|
227
216
|
stringValue = "{" + name + "...}";
|
|
228
217
|
} else {
|
|
@@ -239,7 +228,6 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
239
228
|
stringValue = value.toString();
|
|
240
229
|
} else if (value instanceof Set) {
|
|
241
230
|
var _name = value.constructor.name;
|
|
242
|
-
|
|
243
231
|
if (depth >= maxDepth) {
|
|
244
232
|
stringValue = "{" + _name + "...}";
|
|
245
233
|
} else {
|
|
@@ -257,88 +245,78 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
257
245
|
} else {
|
|
258
246
|
stringValue = tryStringify(value);
|
|
259
247
|
}
|
|
260
|
-
|
|
261
248
|
var formattedValue = styleFn(styles, stringValue);
|
|
262
249
|
return {
|
|
263
250
|
stringValue: stringValue,
|
|
264
251
|
formattedValue: formattedValue
|
|
265
252
|
};
|
|
266
253
|
}
|
|
267
|
-
|
|
268
254
|
var separator = ',';
|
|
269
|
-
|
|
270
255
|
var internalFormatKey = function internalFormatKey(key, styleFn) {
|
|
271
256
|
return {
|
|
272
257
|
stringKey: key + ": ",
|
|
273
258
|
formattedKey: styleFn(['gray-light', 'bold'], key + ":") + " "
|
|
274
259
|
};
|
|
275
260
|
};
|
|
276
|
-
|
|
277
261
|
var internalNoKey = function internalNoKey() {
|
|
278
262
|
return {
|
|
279
263
|
stringKey: '',
|
|
280
264
|
formattedKey: ''
|
|
281
265
|
};
|
|
282
266
|
};
|
|
283
|
-
|
|
284
267
|
var internalFormatMapKey = function internalFormatMapKey(key, styleFn, internalFormatParams) {
|
|
285
268
|
var _internalFormatValue = internalFormatValue(key, noStyleFn, undefined, internalFormatParams),
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
269
|
+
stringValue = _internalFormatValue.stringValue,
|
|
270
|
+
formattedValue = _internalFormatValue.formattedValue;
|
|
289
271
|
return {
|
|
290
272
|
stringKey: stringValue + " => ",
|
|
291
273
|
formattedKey: styleFn(['gray-light', 'bold'], formattedValue + ":") + " "
|
|
292
274
|
};
|
|
293
275
|
};
|
|
294
|
-
|
|
295
276
|
var internalFormatIterator = function internalFormatIterator(values, styleFn, objectStyles, _ref2, _ref3) {
|
|
296
277
|
var padding = _ref2.padding,
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
278
|
+
depth = _ref2.depth,
|
|
279
|
+
maxDepth = _ref2.maxDepth,
|
|
280
|
+
objects = _ref2.objects;
|
|
300
281
|
var prefix = _ref3.prefix,
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
282
|
+
suffix = _ref3.suffix,
|
|
283
|
+
_ref3$prefixSuffixSpa = _ref3.prefixSuffixSpace,
|
|
284
|
+
prefixSuffixSpace = _ref3$prefixSuffixSpa === void 0 ? ' ' : _ref3$prefixSuffixSpa,
|
|
285
|
+
formatKey = _ref3.formatKey;
|
|
305
286
|
var breakLine = false;
|
|
306
|
-
|
|
307
287
|
var formattedSeparator = function formattedSeparator() {
|
|
308
288
|
return styleFn(['gray'], separator);
|
|
309
289
|
};
|
|
310
|
-
|
|
311
290
|
var valuesMaxIndex = values.length - 1;
|
|
312
291
|
var formattedValues = values.map(function (_ref4, index) {
|
|
313
292
|
var key = _ref4.key,
|
|
314
|
-
|
|
293
|
+
value = _ref4.value;
|
|
315
294
|
var internalFormatParams = {
|
|
316
295
|
padding: padding,
|
|
317
296
|
depth: depth + 1,
|
|
318
297
|
maxDepth: maxDepth,
|
|
319
298
|
objects: objects
|
|
320
|
-
};
|
|
299
|
+
};
|
|
321
300
|
|
|
301
|
+
// key must be formatted before value (browser-formatter needs order)
|
|
322
302
|
var _formatKey = formatKey(key, styleFn, internalFormatParams),
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
303
|
+
stringKey = _formatKey.stringKey,
|
|
304
|
+
formattedKey = _formatKey.formattedKey;
|
|
326
305
|
var _internalFormatValue2 = internalFormatValue(value, styleFn, key && objectStyles ? objectStyles[key] : undefined, internalFormatParams),
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
306
|
+
stringValue = _internalFormatValue2.stringValue,
|
|
307
|
+
formattedValue = _internalFormatValue2.formattedValue;
|
|
330
308
|
if (stringValue && (stringValue.length > 80 || stringValue.includes('\n'))) {
|
|
331
309
|
breakLine = true;
|
|
332
310
|
stringValue = stringValue.replace(/\n/g, "\n" + padding);
|
|
333
311
|
formattedValue = formattedValue.replace(/\n/g, "\n" + padding);
|
|
334
312
|
}
|
|
335
|
-
|
|
336
313
|
return {
|
|
337
314
|
stringValue: stringKey + stringValue + (index === valuesMaxIndex ? '' : separator),
|
|
338
|
-
formattedValue: formattedKey + formattedValue + (index === valuesMaxIndex ? '' : formattedSeparator())
|
|
339
|
-
|
|
315
|
+
formattedValue: formattedKey + formattedValue + (index === valuesMaxIndex ? '' : formattedSeparator())
|
|
316
|
+
// note: we need to format the separator for each values for browser-formatter
|
|
340
317
|
};
|
|
341
318
|
});
|
|
319
|
+
|
|
342
320
|
return {
|
|
343
321
|
stringValue: prefix + formattedValues.map(breakLine ? function (v) {
|
|
344
322
|
return "\n" + padding + v.stringValue;
|
|
@@ -352,23 +330,18 @@ var internalFormatIterator = function internalFormatIterator(values, styleFn, ob
|
|
|
352
330
|
}).join(breakLine ? '' : ' ') + (breakLine ? ',\n' : prefixSuffixSpace) + suffix
|
|
353
331
|
};
|
|
354
332
|
};
|
|
355
|
-
|
|
356
333
|
function internalFormatObject(object, styleFn, objectStyles, _ref5) {
|
|
357
334
|
var padding = _ref5.padding,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
335
|
+
depth = _ref5.depth,
|
|
336
|
+
maxDepth = _ref5.maxDepth,
|
|
337
|
+
objects = _ref5.objects;
|
|
362
338
|
if (objects.has(object)) {
|
|
363
339
|
return sameRawFormattedValue('{Circular Object}');
|
|
364
340
|
}
|
|
365
|
-
|
|
366
341
|
var keys = Object.keys(object);
|
|
367
|
-
|
|
368
342
|
if (keys.length === 0) {
|
|
369
343
|
return sameRawFormattedValue('{}');
|
|
370
344
|
}
|
|
371
|
-
|
|
372
345
|
objects.add(object);
|
|
373
346
|
var result = internalFormatIterator(keys.map(function (key) {
|
|
374
347
|
return {
|
|
@@ -385,26 +358,21 @@ function internalFormatObject(object, styleFn, objectStyles, _ref5) {
|
|
|
385
358
|
suffix: '}',
|
|
386
359
|
formatKey: internalFormatKey
|
|
387
360
|
});
|
|
388
|
-
objects
|
|
361
|
+
objects["delete"](object);
|
|
389
362
|
return result;
|
|
390
363
|
}
|
|
391
|
-
|
|
392
364
|
function internalFormatMap(name, map, styleFn, _ref6) {
|
|
393
365
|
var padding = _ref6.padding,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
366
|
+
depth = _ref6.depth,
|
|
367
|
+
maxDepth = _ref6.maxDepth,
|
|
368
|
+
objects = _ref6.objects;
|
|
398
369
|
if (objects.has(map)) {
|
|
399
370
|
return sameRawFormattedValue("{Circular " + name + "}");
|
|
400
371
|
}
|
|
401
|
-
|
|
402
372
|
var keys = [].concat(map.keys());
|
|
403
|
-
|
|
404
373
|
if (keys.length === 0) {
|
|
405
374
|
return sameRawFormattedValue(name + " {}");
|
|
406
375
|
}
|
|
407
|
-
|
|
408
376
|
objects.add(map);
|
|
409
377
|
var result = internalFormatIterator(keys.map(function (key) {
|
|
410
378
|
return {
|
|
@@ -421,24 +389,20 @@ function internalFormatMap(name, map, styleFn, _ref6) {
|
|
|
421
389
|
suffix: '}',
|
|
422
390
|
formatKey: internalFormatMapKey
|
|
423
391
|
});
|
|
424
|
-
objects
|
|
392
|
+
objects["delete"](map);
|
|
425
393
|
return result;
|
|
426
394
|
}
|
|
427
|
-
|
|
428
395
|
function internalFormatArray(array, styleFn, _ref7) {
|
|
429
396
|
var padding = _ref7.padding,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
397
|
+
depth = _ref7.depth,
|
|
398
|
+
maxDepth = _ref7.maxDepth,
|
|
399
|
+
objects = _ref7.objects;
|
|
434
400
|
if (objects.has(array)) {
|
|
435
401
|
return sameRawFormattedValue('{Circular Array}');
|
|
436
402
|
}
|
|
437
|
-
|
|
438
403
|
if (array.length === 0) {
|
|
439
404
|
return sameRawFormattedValue('[]');
|
|
440
405
|
}
|
|
441
|
-
|
|
442
406
|
objects.add(array);
|
|
443
407
|
var result = internalFormatIterator(array.map(function (value) {
|
|
444
408
|
return {
|
|
@@ -456,26 +420,21 @@ function internalFormatArray(array, styleFn, _ref7) {
|
|
|
456
420
|
prefixSuffixSpace: '',
|
|
457
421
|
formatKey: internalNoKey
|
|
458
422
|
});
|
|
459
|
-
objects
|
|
423
|
+
objects["delete"](array);
|
|
460
424
|
return result;
|
|
461
425
|
}
|
|
462
|
-
|
|
463
426
|
function internalFormatSet(name, set, styleFn, _ref8) {
|
|
464
427
|
var padding = _ref8.padding,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
428
|
+
depth = _ref8.depth,
|
|
429
|
+
maxDepth = _ref8.maxDepth,
|
|
430
|
+
objects = _ref8.objects;
|
|
469
431
|
if (objects.has(set)) {
|
|
470
432
|
return sameRawFormattedValue("{Circular " + name + "}");
|
|
471
433
|
}
|
|
472
|
-
|
|
473
434
|
var values = [].concat(set.values());
|
|
474
|
-
|
|
475
435
|
if (values.length === 0) {
|
|
476
436
|
return sameRawFormattedValue(name + " []");
|
|
477
437
|
}
|
|
478
|
-
|
|
479
438
|
objects.add(set);
|
|
480
439
|
var result = internalFormatIterator(values.map(function (value) {
|
|
481
440
|
return {
|
|
@@ -492,45 +451,38 @@ function internalFormatSet(name, set, styleFn, _ref8) {
|
|
|
492
451
|
suffix: ']',
|
|
493
452
|
formatKey: internalNoKey
|
|
494
453
|
});
|
|
495
|
-
objects
|
|
454
|
+
objects["delete"](set);
|
|
496
455
|
return result;
|
|
497
456
|
}
|
|
498
|
-
|
|
499
457
|
function formatObject(object, styleFn, objectStyles, _temp) {
|
|
500
458
|
if (styleFn === void 0) {
|
|
501
459
|
styleFn = noStyleFn;
|
|
502
460
|
}
|
|
503
|
-
|
|
504
461
|
var _ref9 = _temp === void 0 ? {} : _temp,
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
462
|
+
_ref9$padding = _ref9.padding,
|
|
463
|
+
padding = _ref9$padding === void 0 ? ' ' : _ref9$padding,
|
|
464
|
+
_ref9$maxDepth = _ref9.maxDepth,
|
|
465
|
+
maxDepth = _ref9$maxDepth === void 0 ? 10 : _ref9$maxDepth;
|
|
510
466
|
var _internalFormatObject = internalFormatObject(object, styleFn, objectStyles, {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
467
|
+
padding: padding,
|
|
468
|
+
maxDepth: maxDepth,
|
|
469
|
+
depth: 0,
|
|
470
|
+
objects: new Set()
|
|
471
|
+
}),
|
|
472
|
+
result = _internalFormatObject.formattedValue;
|
|
518
473
|
if (result === '{}') {
|
|
519
474
|
return '';
|
|
520
475
|
}
|
|
521
|
-
|
|
522
476
|
return result;
|
|
523
477
|
}
|
|
524
478
|
|
|
525
479
|
function formatRecordToString(record, style) {
|
|
526
480
|
var parts = [];
|
|
527
|
-
|
|
528
481
|
if (record.displayName) {
|
|
529
482
|
parts.push(style(['gray-light'], record.displayName));
|
|
530
483
|
} else if (record.key) {
|
|
531
484
|
parts.push(style(['gray-light'], record.key));
|
|
532
485
|
}
|
|
533
|
-
|
|
534
486
|
if (record.datetime) {
|
|
535
487
|
parts.push(style(['gray', 'bold'], record.datetime.toTimeString().split(' ')[0]));
|
|
536
488
|
/* new Date().toFormat('HH24:MI:SS') */
|
|
@@ -538,7 +490,6 @@ function formatRecordToString(record, style) {
|
|
|
538
490
|
|
|
539
491
|
var message = record.symbol || levelToSymbol[record.level];
|
|
540
492
|
var styles = record.styles || levelToStyles[record.level];
|
|
541
|
-
|
|
542
493
|
if (record.message) {
|
|
543
494
|
if (message) {
|
|
544
495
|
message += " " + record.message;
|
|
@@ -546,29 +497,22 @@ function formatRecordToString(record, style) {
|
|
|
546
497
|
message = record.message;
|
|
547
498
|
}
|
|
548
499
|
}
|
|
549
|
-
|
|
550
500
|
if (message) {
|
|
551
501
|
if (styles) {
|
|
552
502
|
message = style(styles, message);
|
|
553
503
|
}
|
|
554
|
-
|
|
555
504
|
parts.push(message);
|
|
556
505
|
}
|
|
557
|
-
|
|
558
506
|
var formatRecordObject = function formatRecordObject(key, object, objectStyles) {
|
|
559
507
|
if (!object) {
|
|
560
508
|
return;
|
|
561
509
|
}
|
|
562
|
-
|
|
563
510
|
var stringObject = formatObject(object, style, objectStyles);
|
|
564
|
-
|
|
565
511
|
if (!stringObject) {
|
|
566
512
|
return;
|
|
567
513
|
}
|
|
568
|
-
|
|
569
514
|
parts.push(stringObject);
|
|
570
515
|
};
|
|
571
|
-
|
|
572
516
|
formatRecordObject('metadata', record.metadata, record.metadataStyles);
|
|
573
517
|
formatRecordObject('extra', record.extra, undefined);
|
|
574
518
|
formatRecordObject('context', record.context, undefined);
|