nightingale-formatter 12.1.4 → 14.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 +41 -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/definitions/formatRecordToString.d.ts.map +1 -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 +51 -104
- package/dist/index-browser.es.js.map +1 -1
- package/dist/index-browsermodern.es.js +9 -56
- package/dist/index-browsermodern.es.js.map +1 -1
- package/dist/{index-node14.mjs → index-node18.mjs} +9 -56
- package/dist/{index-node14.mjs.map → index-node18.mjs.map} +1 -1
- package/package.json +33 -49
- 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.cjs.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/dist/{formatRecordToString.d.ts → definitions/formatRecordToString.d.ts} +0 -0
- /package/dist/{index.d.ts → definitions/index.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,47 @@
|
|
|
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
|
+
## [14.0.0](https://github.com/christophehurpeau/nightingale/compare/v13.0.0...v14.0.0) (2023-06-30)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **deps:** require node 18
|
|
12
|
+
* requires node 18
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* requires node 18 ([4452b11](https://github.com/christophehurpeau/nightingale/commit/4452b116188e58c293be85e462e04922f7ad51f0))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Miscellaneous Chores
|
|
20
|
+
|
|
21
|
+
* **deps:** update dependency @pob/root to v8 ([#760](https://github.com/christophehurpeau/nightingale/issues/760)) ([22dc3cc](https://github.com/christophehurpeau/nightingale/commit/22dc3cceabdfd465d04ee36fec8fdac31febab69))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [13.0.0](https://github.com/christophehurpeau/nightingale/compare/v12.1.4...v13.0.0) (2022-11-19)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Code Refactoring
|
|
29
|
+
|
|
30
|
+
* drop node 14 and cjs ([9a8ca06](https://github.com/christophehurpeau/nightingale/commit/9a8ca064449ddc0d69e26543e21c2d522536c50a))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* build for node 16 ([30ae3e9](https://github.com/christophehurpeau/nightingale/commit/30ae3e9c455dbad793c2f704b9d860069dc80c32))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### BREAKING CHANGES
|
|
39
|
+
|
|
40
|
+
* dropped node 14 and cjs
|
|
41
|
+
* drop node 14
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
6
47
|
## [12.1.4](https://github.com/christophehurpeau/nightingale/compare/v12.1.3...v12.1.4) (2022-02-05)
|
|
7
48
|
|
|
8
49
|
|
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":""}
|
|
@@ -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"}
|
|
@@ -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,21 @@ 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,
|
|
153
|
+
stack,
|
|
154
|
+
name,
|
|
155
|
+
_name;
|
|
155
156
|
var typeofValue = typeof value;
|
|
156
|
-
|
|
157
157
|
if (!styles) {
|
|
158
158
|
if (value == null) {
|
|
159
159
|
styles = ['cyan'];
|
|
@@ -162,32 +162,25 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
162
162
|
case 'undefined':
|
|
163
163
|
styles = ['cyan'];
|
|
164
164
|
break;
|
|
165
|
-
|
|
166
165
|
case 'boolean':
|
|
167
166
|
styles = ['green'];
|
|
168
167
|
break;
|
|
169
|
-
|
|
170
168
|
case 'number':
|
|
171
169
|
styles = ['yellow'];
|
|
172
170
|
break;
|
|
173
|
-
|
|
174
171
|
case 'bigint':
|
|
175
172
|
styles = ['red'];
|
|
176
173
|
break;
|
|
177
|
-
|
|
178
174
|
case 'string':
|
|
179
175
|
styles = ['orange'];
|
|
180
176
|
break;
|
|
181
|
-
|
|
182
177
|
case 'symbol':
|
|
183
178
|
styles = ['magenta'];
|
|
184
179
|
break;
|
|
185
180
|
}
|
|
186
181
|
}
|
|
187
182
|
}
|
|
188
|
-
|
|
189
183
|
var stringValue;
|
|
190
|
-
|
|
191
184
|
if (value === null) {
|
|
192
185
|
stringValue = 'null';
|
|
193
186
|
} else if (value === undefined) {
|
|
@@ -218,11 +211,10 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
218
211
|
});
|
|
219
212
|
}
|
|
220
213
|
} else if (value instanceof Error) {
|
|
221
|
-
|
|
214
|
+
stack = value.stack;
|
|
222
215
|
stringValue = stack != null && stack.startsWith(value.message) ? stack : value.message + "\n" + (stack || '');
|
|
223
216
|
} else if (value instanceof Map) {
|
|
224
|
-
|
|
225
|
-
|
|
217
|
+
name = value.constructor.name;
|
|
226
218
|
if (depth >= maxDepth) {
|
|
227
219
|
stringValue = "{" + name + "...}";
|
|
228
220
|
} else {
|
|
@@ -238,8 +230,7 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
238
230
|
} else if (typeofValue === 'symbol') {
|
|
239
231
|
stringValue = value.toString();
|
|
240
232
|
} else if (value instanceof Set) {
|
|
241
|
-
|
|
242
|
-
|
|
233
|
+
_name = value.constructor.name;
|
|
243
234
|
if (depth >= maxDepth) {
|
|
244
235
|
stringValue = "{" + _name + "...}";
|
|
245
236
|
} else {
|
|
@@ -257,88 +248,78 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
257
248
|
} else {
|
|
258
249
|
stringValue = tryStringify(value);
|
|
259
250
|
}
|
|
260
|
-
|
|
261
251
|
var formattedValue = styleFn(styles, stringValue);
|
|
262
252
|
return {
|
|
263
253
|
stringValue: stringValue,
|
|
264
254
|
formattedValue: formattedValue
|
|
265
255
|
};
|
|
266
256
|
}
|
|
267
|
-
|
|
268
257
|
var separator = ',';
|
|
269
|
-
|
|
270
258
|
var internalFormatKey = function internalFormatKey(key, styleFn) {
|
|
271
259
|
return {
|
|
272
260
|
stringKey: key + ": ",
|
|
273
261
|
formattedKey: styleFn(['gray-light', 'bold'], key + ":") + " "
|
|
274
262
|
};
|
|
275
263
|
};
|
|
276
|
-
|
|
277
264
|
var internalNoKey = function internalNoKey() {
|
|
278
265
|
return {
|
|
279
266
|
stringKey: '',
|
|
280
267
|
formattedKey: ''
|
|
281
268
|
};
|
|
282
269
|
};
|
|
283
|
-
|
|
284
270
|
var internalFormatMapKey = function internalFormatMapKey(key, styleFn, internalFormatParams) {
|
|
285
271
|
var _internalFormatValue = internalFormatValue(key, noStyleFn, undefined, internalFormatParams),
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
272
|
+
stringValue = _internalFormatValue.stringValue,
|
|
273
|
+
formattedValue = _internalFormatValue.formattedValue;
|
|
289
274
|
return {
|
|
290
275
|
stringKey: stringValue + " => ",
|
|
291
276
|
formattedKey: styleFn(['gray-light', 'bold'], formattedValue + ":") + " "
|
|
292
277
|
};
|
|
293
278
|
};
|
|
294
|
-
|
|
295
279
|
var internalFormatIterator = function internalFormatIterator(values, styleFn, objectStyles, _ref2, _ref3) {
|
|
296
280
|
var padding = _ref2.padding,
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
281
|
+
depth = _ref2.depth,
|
|
282
|
+
maxDepth = _ref2.maxDepth,
|
|
283
|
+
objects = _ref2.objects;
|
|
300
284
|
var prefix = _ref3.prefix,
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
285
|
+
suffix = _ref3.suffix,
|
|
286
|
+
_ref3$prefixSuffixSpa = _ref3.prefixSuffixSpace,
|
|
287
|
+
prefixSuffixSpace = _ref3$prefixSuffixSpa === void 0 ? ' ' : _ref3$prefixSuffixSpa,
|
|
288
|
+
formatKey = _ref3.formatKey;
|
|
305
289
|
var breakLine = false;
|
|
306
|
-
|
|
307
290
|
var formattedSeparator = function formattedSeparator() {
|
|
308
291
|
return styleFn(['gray'], separator);
|
|
309
292
|
};
|
|
310
|
-
|
|
311
293
|
var valuesMaxIndex = values.length - 1;
|
|
312
294
|
var formattedValues = values.map(function (_ref4, index) {
|
|
313
295
|
var key = _ref4.key,
|
|
314
|
-
|
|
296
|
+
value = _ref4.value;
|
|
315
297
|
var internalFormatParams = {
|
|
316
298
|
padding: padding,
|
|
317
299
|
depth: depth + 1,
|
|
318
300
|
maxDepth: maxDepth,
|
|
319
301
|
objects: objects
|
|
320
|
-
};
|
|
302
|
+
};
|
|
321
303
|
|
|
304
|
+
// key must be formatted before value (browser-formatter needs order)
|
|
322
305
|
var _formatKey = formatKey(key, styleFn, internalFormatParams),
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
306
|
+
stringKey = _formatKey.stringKey,
|
|
307
|
+
formattedKey = _formatKey.formattedKey;
|
|
326
308
|
var _internalFormatValue2 = internalFormatValue(value, styleFn, key && objectStyles ? objectStyles[key] : undefined, internalFormatParams),
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
309
|
+
stringValue = _internalFormatValue2.stringValue,
|
|
310
|
+
formattedValue = _internalFormatValue2.formattedValue;
|
|
330
311
|
if (stringValue && (stringValue.length > 80 || stringValue.includes('\n'))) {
|
|
331
312
|
breakLine = true;
|
|
332
313
|
stringValue = stringValue.replace(/\n/g, "\n" + padding);
|
|
333
314
|
formattedValue = formattedValue.replace(/\n/g, "\n" + padding);
|
|
334
315
|
}
|
|
335
|
-
|
|
336
316
|
return {
|
|
337
317
|
stringValue: stringKey + stringValue + (index === valuesMaxIndex ? '' : separator),
|
|
338
|
-
formattedValue: formattedKey + formattedValue + (index === valuesMaxIndex ? '' : formattedSeparator())
|
|
339
|
-
|
|
318
|
+
formattedValue: formattedKey + formattedValue + (index === valuesMaxIndex ? '' : formattedSeparator())
|
|
319
|
+
// note: we need to format the separator for each values for browser-formatter
|
|
340
320
|
};
|
|
341
321
|
});
|
|
322
|
+
|
|
342
323
|
return {
|
|
343
324
|
stringValue: prefix + formattedValues.map(breakLine ? function (v) {
|
|
344
325
|
return "\n" + padding + v.stringValue;
|
|
@@ -352,23 +333,18 @@ var internalFormatIterator = function internalFormatIterator(values, styleFn, ob
|
|
|
352
333
|
}).join(breakLine ? '' : ' ') + (breakLine ? ',\n' : prefixSuffixSpace) + suffix
|
|
353
334
|
};
|
|
354
335
|
};
|
|
355
|
-
|
|
356
336
|
function internalFormatObject(object, styleFn, objectStyles, _ref5) {
|
|
357
337
|
var padding = _ref5.padding,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
338
|
+
depth = _ref5.depth,
|
|
339
|
+
maxDepth = _ref5.maxDepth,
|
|
340
|
+
objects = _ref5.objects;
|
|
362
341
|
if (objects.has(object)) {
|
|
363
342
|
return sameRawFormattedValue('{Circular Object}');
|
|
364
343
|
}
|
|
365
|
-
|
|
366
344
|
var keys = Object.keys(object);
|
|
367
|
-
|
|
368
345
|
if (keys.length === 0) {
|
|
369
346
|
return sameRawFormattedValue('{}');
|
|
370
347
|
}
|
|
371
|
-
|
|
372
348
|
objects.add(object);
|
|
373
349
|
var result = internalFormatIterator(keys.map(function (key) {
|
|
374
350
|
return {
|
|
@@ -388,23 +364,18 @@ function internalFormatObject(object, styleFn, objectStyles, _ref5) {
|
|
|
388
364
|
objects.delete(object);
|
|
389
365
|
return result;
|
|
390
366
|
}
|
|
391
|
-
|
|
392
367
|
function internalFormatMap(name, map, styleFn, _ref6) {
|
|
393
368
|
var padding = _ref6.padding,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
369
|
+
depth = _ref6.depth,
|
|
370
|
+
maxDepth = _ref6.maxDepth,
|
|
371
|
+
objects = _ref6.objects;
|
|
398
372
|
if (objects.has(map)) {
|
|
399
373
|
return sameRawFormattedValue("{Circular " + name + "}");
|
|
400
374
|
}
|
|
401
|
-
|
|
402
375
|
var keys = [].concat(map.keys());
|
|
403
|
-
|
|
404
376
|
if (keys.length === 0) {
|
|
405
377
|
return sameRawFormattedValue(name + " {}");
|
|
406
378
|
}
|
|
407
|
-
|
|
408
379
|
objects.add(map);
|
|
409
380
|
var result = internalFormatIterator(keys.map(function (key) {
|
|
410
381
|
return {
|
|
@@ -424,21 +395,17 @@ function internalFormatMap(name, map, styleFn, _ref6) {
|
|
|
424
395
|
objects.delete(map);
|
|
425
396
|
return result;
|
|
426
397
|
}
|
|
427
|
-
|
|
428
398
|
function internalFormatArray(array, styleFn, _ref7) {
|
|
429
399
|
var padding = _ref7.padding,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
400
|
+
depth = _ref7.depth,
|
|
401
|
+
maxDepth = _ref7.maxDepth,
|
|
402
|
+
objects = _ref7.objects;
|
|
434
403
|
if (objects.has(array)) {
|
|
435
404
|
return sameRawFormattedValue('{Circular Array}');
|
|
436
405
|
}
|
|
437
|
-
|
|
438
406
|
if (array.length === 0) {
|
|
439
407
|
return sameRawFormattedValue('[]');
|
|
440
408
|
}
|
|
441
|
-
|
|
442
409
|
objects.add(array);
|
|
443
410
|
var result = internalFormatIterator(array.map(function (value) {
|
|
444
411
|
return {
|
|
@@ -459,23 +426,18 @@ function internalFormatArray(array, styleFn, _ref7) {
|
|
|
459
426
|
objects.delete(array);
|
|
460
427
|
return result;
|
|
461
428
|
}
|
|
462
|
-
|
|
463
429
|
function internalFormatSet(name, set, styleFn, _ref8) {
|
|
464
430
|
var padding = _ref8.padding,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
431
|
+
depth = _ref8.depth,
|
|
432
|
+
maxDepth = _ref8.maxDepth,
|
|
433
|
+
objects = _ref8.objects;
|
|
469
434
|
if (objects.has(set)) {
|
|
470
435
|
return sameRawFormattedValue("{Circular " + name + "}");
|
|
471
436
|
}
|
|
472
|
-
|
|
473
437
|
var values = [].concat(set.values());
|
|
474
|
-
|
|
475
438
|
if (values.length === 0) {
|
|
476
439
|
return sameRawFormattedValue(name + " []");
|
|
477
440
|
}
|
|
478
|
-
|
|
479
441
|
objects.add(set);
|
|
480
442
|
var result = internalFormatIterator(values.map(function (value) {
|
|
481
443
|
return {
|
|
@@ -495,42 +457,35 @@ function internalFormatSet(name, set, styleFn, _ref8) {
|
|
|
495
457
|
objects.delete(set);
|
|
496
458
|
return result;
|
|
497
459
|
}
|
|
498
|
-
|
|
499
460
|
function formatObject(object, styleFn, objectStyles, _temp) {
|
|
500
461
|
if (styleFn === void 0) {
|
|
501
462
|
styleFn = noStyleFn;
|
|
502
463
|
}
|
|
503
|
-
|
|
504
464
|
var _ref9 = _temp === void 0 ? {} : _temp,
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
465
|
+
_ref9$padding = _ref9.padding,
|
|
466
|
+
padding = _ref9$padding === void 0 ? ' ' : _ref9$padding,
|
|
467
|
+
_ref9$maxDepth = _ref9.maxDepth,
|
|
468
|
+
maxDepth = _ref9$maxDepth === void 0 ? 10 : _ref9$maxDepth;
|
|
510
469
|
var _internalFormatObject = internalFormatObject(object, styleFn, objectStyles, {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
470
|
+
padding: padding,
|
|
471
|
+
maxDepth: maxDepth,
|
|
472
|
+
depth: 0,
|
|
473
|
+
objects: new Set()
|
|
474
|
+
}),
|
|
475
|
+
result = _internalFormatObject.formattedValue;
|
|
518
476
|
if (result === '{}') {
|
|
519
477
|
return '';
|
|
520
478
|
}
|
|
521
|
-
|
|
522
479
|
return result;
|
|
523
480
|
}
|
|
524
481
|
|
|
525
482
|
function formatRecordToString(record, style) {
|
|
526
483
|
var parts = [];
|
|
527
|
-
|
|
528
484
|
if (record.displayName) {
|
|
529
485
|
parts.push(style(['gray-light'], record.displayName));
|
|
530
486
|
} else if (record.key) {
|
|
531
487
|
parts.push(style(['gray-light'], record.key));
|
|
532
488
|
}
|
|
533
|
-
|
|
534
489
|
if (record.datetime) {
|
|
535
490
|
parts.push(style(['gray', 'bold'], record.datetime.toTimeString().split(' ')[0]));
|
|
536
491
|
/* new Date().toFormat('HH24:MI:SS') */
|
|
@@ -538,7 +493,6 @@ function formatRecordToString(record, style) {
|
|
|
538
493
|
|
|
539
494
|
var message = record.symbol || levelToSymbol[record.level];
|
|
540
495
|
var styles = record.styles || levelToStyles[record.level];
|
|
541
|
-
|
|
542
496
|
if (record.message) {
|
|
543
497
|
if (message) {
|
|
544
498
|
message += " " + record.message;
|
|
@@ -546,29 +500,22 @@ function formatRecordToString(record, style) {
|
|
|
546
500
|
message = record.message;
|
|
547
501
|
}
|
|
548
502
|
}
|
|
549
|
-
|
|
550
503
|
if (message) {
|
|
551
504
|
if (styles) {
|
|
552
505
|
message = style(styles, message);
|
|
553
506
|
}
|
|
554
|
-
|
|
555
507
|
parts.push(message);
|
|
556
508
|
}
|
|
557
|
-
|
|
558
509
|
var formatRecordObject = function formatRecordObject(key, object, objectStyles) {
|
|
559
510
|
if (!object) {
|
|
560
511
|
return;
|
|
561
512
|
}
|
|
562
|
-
|
|
563
513
|
var stringObject = formatObject(object, style, objectStyles);
|
|
564
|
-
|
|
565
514
|
if (!stringObject) {
|
|
566
515
|
return;
|
|
567
516
|
}
|
|
568
|
-
|
|
569
517
|
parts.push(stringObject);
|
|
570
518
|
};
|
|
571
|
-
|
|
572
519
|
formatRecordObject('metadata', record.metadata, record.metadataStyles);
|
|
573
520
|
formatRecordObject('extra', record.extra, undefined);
|
|
574
521
|
formatRecordObject('context', record.context, undefined);
|