@alterior/logging 3.13.3 → 3.14.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.
Files changed (44) hide show
  1. package/dist/index.d.ts +4 -4
  2. package/dist/index.js +7 -7
  3. package/dist/inspect.d.ts +28 -28
  4. package/dist/inspect.js +344 -345
  5. package/dist/inspect.js.map +1 -1
  6. package/dist/inspect.test.d.ts +1 -1
  7. package/dist/logger.d.ts +145 -145
  8. package/dist/logger.js +331 -331
  9. package/dist/logger.js.map +1 -1
  10. package/dist/logger.test.d.ts +1 -1
  11. package/dist/logger.test.js.map +1 -1
  12. package/dist/logging.module.d.ts +17 -17
  13. package/dist/logging.module.js +28 -28
  14. package/dist/logging.module.js.map +1 -1
  15. package/dist/test.d.ts +1 -1
  16. package/dist/trace.d.ts +60 -60
  17. package/dist/trace.js +214 -215
  18. package/dist/trace.js.map +1 -1
  19. package/dist/trace.test.d.ts +1 -1
  20. package/dist/trace.test.js.map +1 -1
  21. package/dist.esm/index.d.ts +4 -4
  22. package/dist.esm/index.js +4 -4
  23. package/dist.esm/inspect.d.ts +28 -28
  24. package/dist.esm/inspect.js +339 -339
  25. package/dist.esm/inspect.js.map +1 -1
  26. package/dist.esm/inspect.test.d.ts +1 -1
  27. package/dist.esm/logger.d.ts +145 -145
  28. package/dist.esm/logger.js +323 -323
  29. package/dist.esm/logger.js.map +1 -1
  30. package/dist.esm/logger.test.d.ts +1 -1
  31. package/dist.esm/logger.test.js.map +1 -1
  32. package/dist.esm/logging.module.d.ts +17 -17
  33. package/dist.esm/logging.module.js +25 -25
  34. package/dist.esm/logging.module.js.map +1 -1
  35. package/dist.esm/test.d.ts +1 -1
  36. package/dist.esm/trace.d.ts +60 -60
  37. package/dist.esm/trace.js +208 -208
  38. package/dist.esm/trace.js.map +1 -1
  39. package/dist.esm/trace.test.d.ts +1 -1
  40. package/dist.esm/trace.test.js.map +1 -1
  41. package/package.json +10 -10
  42. package/tsconfig.esm.tsbuildinfo +1 -0
  43. package/tsconfig.json +0 -2
  44. package/tsconfig.tsbuildinfo +1 -5735
@@ -1,340 +1,340 @@
1
- /**
2
- * Module exports.
3
- */
4
- import { ConsoleColors } from '@alterior/common';
5
- /**
6
- * Echos the value of a value. Trys to print the value out
7
- * in the best way possible given the different types.
8
- *
9
- * @param {Object} obj The object to print out.
10
- * @param {Object} opts Optional options object that alters the output.
11
- * @license MIT (© Joyent)
12
- */
13
- /* legacy: obj, showHidden, depth, colors*/
14
- export function inspect(obj, opts) {
15
- var ctx = {
16
- seen: [],
17
- stylize: stylizeNothing
18
- };
19
- if (opts)
20
- Object.assign(ctx, opts);
21
- // set default options
22
- if (isUndefined(ctx.showHidden))
23
- ctx.showHidden = false;
24
- if (isUndefined(ctx.depth))
25
- ctx.depth = 2;
26
- if (isUndefined(ctx.colors))
27
- ctx.colors = false;
28
- if (isUndefined(ctx.customInspect))
29
- ctx.customInspect = true;
30
- if (ctx.colors)
31
- ctx.stylize = stylizeWithConsoleColors;
32
- return formatValue(ctx, obj, ctx.depth);
33
- }
34
- // Don't use 'blue' not visible on cmd.exe
35
- const CONSOLE_COLOR_STYLES = {
36
- 'special': 'cyan',
37
- 'number': 'yellow',
38
- 'boolean': 'yellow',
39
- 'undefined': 'grey',
40
- 'null': 'bold',
41
- 'string': 'green',
42
- 'date': 'magenta',
43
- // "name": intentionally not styling
44
- 'regexp': 'red'
45
- };
46
- /**
47
- * Pass the string through with no stylization.
48
- */
49
- export function stylizeNothing(str, styleType) {
50
- return str;
51
- }
52
- function isBoolean(arg) {
53
- return typeof arg === 'boolean';
54
- }
55
- function isUndefined(arg) {
56
- return arg === void 0;
57
- }
58
- /**
59
- * Use console colors to style the string. Suitable for output to
60
- * terminals with ANSI color support.
61
- */
62
- export function stylizeWithConsoleColors(str, styleType) {
63
- var style = CONSOLE_COLOR_STYLES[styleType];
64
- return style ? ConsoleColors[style](str) : str;
65
- }
66
- function isFunction(arg) {
67
- return typeof arg === 'function';
68
- }
69
- function isString(arg) {
70
- return typeof arg === 'string';
71
- }
72
- function isNumber(arg) {
73
- return typeof arg === 'number';
74
- }
75
- function isNull(arg) {
76
- return arg === null;
77
- }
78
- function hasOwn(obj, prop) {
79
- return Object.prototype.hasOwnProperty.call(obj, prop);
80
- }
81
- function isRegExp(re) {
82
- return isObject(re) && objectToString(re) === '[object RegExp]';
83
- }
84
- function isObject(arg) {
85
- return typeof arg === 'object' && arg !== null;
86
- }
87
- function isError(e) {
88
- return isObject(e) &&
89
- (objectToString(e) === '[object Error]' || e instanceof Error);
90
- }
91
- function isDate(d) {
92
- return isObject(d) && objectToString(d) === '[object Date]';
93
- }
94
- function objectToString(o) {
95
- return Object.prototype.toString.call(o);
96
- }
97
- function arrayToHash(array) {
98
- var hash = {};
99
- array.forEach(function (val, idx) {
100
- hash[val] = true;
101
- });
102
- return hash;
103
- }
104
- function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
105
- var output = [];
106
- for (var i = 0, l = value.length; i < l; ++i) {
107
- if (hasOwn(value, String(i))) {
108
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
109
- }
110
- else {
111
- output.push('');
112
- }
113
- }
114
- keys.forEach(function (key) {
115
- if (!key.match(/^\d+$/)) {
116
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
117
- }
118
- });
119
- return output;
120
- }
121
- function formatError(value) {
122
- return '[' + Error.prototype.toString.call(value) + ']';
123
- }
124
- function formatValue(ctx, value, recurseTimes) {
125
- // Provide a hook for user-specified inspect functions.
126
- // Check that value is an object with an inspect function on it
127
- if (ctx.customInspect &&
128
- value &&
129
- isFunction(value.inspect) &&
130
- // Filter out the util module, it's inspect function is special
131
- value.inspect !== inspect &&
132
- // Also filter out any prototype objects using the circular check.
133
- !(value.constructor && value.constructor.prototype === value)) {
134
- var ret = value.inspect(recurseTimes, ctx);
135
- if (!isString(ret)) {
136
- ret = formatValue(ctx, ret, recurseTimes);
137
- }
138
- return ret;
139
- }
140
- // Primitive types cannot have properties
141
- var primitive = formatPrimitive(ctx, value);
142
- if (primitive) {
143
- return primitive;
144
- }
145
- // Look up the keys of the object.
146
- var keys = Object.keys(value);
147
- var visibleKeys = arrayToHash(keys);
148
- try {
149
- if (ctx.showHidden && Object.getOwnPropertyNames) {
150
- keys = Object.getOwnPropertyNames(value);
151
- }
152
- }
153
- catch (e) {
154
- // ignore
155
- }
156
- // IE doesn't make error fields non-enumerable
157
- // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
158
- if (isError(value)
159
- && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
160
- return formatError(value);
161
- }
162
- // Some type of object without properties can be shortcutted.
163
- if (keys.length === 0) {
164
- if (isFunction(value)) {
165
- var name = value.name ? ': ' + value.name : '';
166
- return ctx.stylize('[Function' + name + ']', 'special');
167
- }
168
- if (isRegExp(value)) {
169
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
170
- }
171
- if (isDate(value)) {
172
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
173
- }
174
- if (isError(value)) {
175
- return formatError(value);
176
- }
177
- }
178
- var base = '', array = false, braces = ['{', '}'];
179
- // Make Array say that they are Array
180
- if (Array.isArray(value)) {
181
- array = true;
182
- braces = ['[', ']'];
183
- }
184
- // Make functions say that they are functions
185
- if (isFunction(value)) {
186
- var n = value.name ? ': ' + value.name : '';
187
- base = ' [Function' + n + ']';
188
- }
189
- // Make RegExps say that they are RegExps
190
- if (isRegExp(value)) {
191
- base = ' ' + RegExp.prototype.toString.call(value);
192
- }
193
- // Make dates with properties first say the date
194
- if (isDate(value)) {
195
- base = ' ' + Date.prototype.toUTCString.call(value);
196
- }
197
- // Make error with message first say the error
198
- if (isError(value)) {
199
- base = ' ' + formatError(value);
200
- }
201
- if (keys.length === 0 && (!array || value.length == 0)) {
202
- return braces[0] + base + braces[1];
203
- }
204
- if (recurseTimes < 0) {
205
- if (isRegExp(value)) {
206
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
207
- }
208
- else {
209
- return ctx.stylize('[Object]', 'special');
210
- }
211
- }
212
- ctx.seen.push(value);
213
- var output;
214
- if (array) {
215
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
216
- }
217
- else {
218
- output = keys.map(function (key) {
219
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
220
- });
221
- }
222
- ctx.seen.pop();
223
- return reduceToSingleString(output, base, braces);
224
- }
225
- function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
226
- var name, str, desc;
227
- desc = { value: void 0 };
228
- try {
229
- // ie6 › navigator.toString
230
- // throws Error: Object doesn't support this property or method
231
- desc.value = value[key];
232
- }
233
- catch (e) {
234
- // ignore
235
- }
236
- try {
237
- // ie10 › Object.getOwnPropertyDescriptor(window.location, 'hash')
238
- // throws TypeError: Object doesn't support this action
239
- if (Object.getOwnPropertyDescriptor) {
240
- desc = Object.getOwnPropertyDescriptor(value, key) || desc;
241
- }
242
- }
243
- catch (e) {
244
- // ignore
245
- }
246
- if (desc.get) {
247
- if (desc.set) {
248
- str = ctx.stylize('[Getter/Setter]', 'special');
249
- }
250
- else {
251
- str = ctx.stylize('[Getter]', 'special');
252
- }
253
- }
254
- else {
255
- if (desc.set) {
256
- str = ctx.stylize('[Setter]', 'special');
257
- }
258
- }
259
- if (!hasOwn(visibleKeys, key)) {
260
- name = '[' + key + ']';
261
- }
262
- if (!str) {
263
- if (ctx.seen.indexOf(desc.value) < 0) {
264
- if (isNull(recurseTimes)) {
265
- str = formatValue(ctx, desc.value, null);
266
- }
267
- else {
268
- str = formatValue(ctx, desc.value, recurseTimes - 1);
269
- }
270
- if (str.indexOf('\n') > -1) {
271
- if (array) {
272
- str = str.split('\n').map(function (line) {
273
- return ' ' + line;
274
- }).join('\n').substr(2);
275
- }
276
- else {
277
- str = '\n' + str.split('\n').map(function (line) {
278
- return ' ' + line;
279
- }).join('\n');
280
- }
281
- }
282
- }
283
- else {
284
- str = ctx.stylize('[Circular]', 'special');
285
- }
286
- }
287
- if (isUndefined(name)) {
288
- if (array && key.match(/^\d+$/)) {
289
- return str;
290
- }
291
- name = JSON.stringify('' + key);
292
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
293
- name = name.substr(1, name.length - 2);
294
- name = ctx.stylize(name, 'name');
295
- }
296
- else {
297
- name = name.replace(/'/g, "\\'")
298
- .replace(/\\"/g, '"')
299
- .replace(/(^"|"$)/g, "'");
300
- name = ctx.stylize(name, 'string');
301
- }
302
- }
303
- return name + ': ' + str;
304
- }
305
- function formatPrimitive(ctx, value) {
306
- if (isUndefined(value))
307
- return ctx.stylize('undefined', 'undefined');
308
- if (isString(value)) {
309
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
310
- .replace(/'/g, "\\'")
311
- .replace(/\\"/g, '"') + '\'';
312
- return ctx.stylize(simple, 'string');
313
- }
314
- if (isNumber(value))
315
- return ctx.stylize('' + value, 'number');
316
- if (isBoolean(value))
317
- return ctx.stylize('' + value, 'boolean');
318
- // For some reason typeof null is "object", so special case here.
319
- if (isNull(value))
320
- return ctx.stylize('null', 'null');
321
- }
322
- function reduceToSingleString(output, base, braces) {
323
- var numLinesEst = 0;
324
- var length = output.reduce(function (prev, cur) {
325
- numLinesEst++;
326
- if (cur.indexOf('\n') >= 0)
327
- numLinesEst++;
328
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
329
- }, 0);
330
- if (length > 60) {
331
- return braces[0] +
332
- (base === '' ? '' : base + '\n ') +
333
- ' ' +
334
- output.join(',\n ') +
335
- ' ' +
336
- braces[1];
337
- }
338
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
339
- }
1
+ /**
2
+ * Module exports.
3
+ */
4
+ import { ConsoleColors } from '@alterior/common';
5
+ /**
6
+ * Echos the value of a value. Trys to print the value out
7
+ * in the best way possible given the different types.
8
+ *
9
+ * @param {Object} obj The object to print out.
10
+ * @param {Object} opts Optional options object that alters the output.
11
+ * @license MIT (© Joyent)
12
+ */
13
+ /* legacy: obj, showHidden, depth, colors*/
14
+ export function inspect(obj, opts) {
15
+ var ctx = {
16
+ seen: [],
17
+ stylize: stylizeNothing
18
+ };
19
+ if (opts)
20
+ Object.assign(ctx, opts);
21
+ // set default options
22
+ if (isUndefined(ctx.showHidden))
23
+ ctx.showHidden = false;
24
+ if (isUndefined(ctx.depth))
25
+ ctx.depth = 2;
26
+ if (isUndefined(ctx.colors))
27
+ ctx.colors = false;
28
+ if (isUndefined(ctx.customInspect))
29
+ ctx.customInspect = true;
30
+ if (ctx.colors)
31
+ ctx.stylize = stylizeWithConsoleColors;
32
+ return formatValue(ctx, obj, ctx.depth);
33
+ }
34
+ // Don't use 'blue' not visible on cmd.exe
35
+ const CONSOLE_COLOR_STYLES = {
36
+ 'special': 'cyan',
37
+ 'number': 'yellow',
38
+ 'boolean': 'yellow',
39
+ 'undefined': 'grey',
40
+ 'null': 'bold',
41
+ 'string': 'green',
42
+ 'date': 'magenta',
43
+ // "name": intentionally not styling
44
+ 'regexp': 'red'
45
+ };
46
+ /**
47
+ * Pass the string through with no stylization.
48
+ */
49
+ export function stylizeNothing(str, styleType) {
50
+ return str;
51
+ }
52
+ function isBoolean(arg) {
53
+ return typeof arg === 'boolean';
54
+ }
55
+ function isUndefined(arg) {
56
+ return arg === void 0;
57
+ }
58
+ /**
59
+ * Use console colors to style the string. Suitable for output to
60
+ * terminals with ANSI color support.
61
+ */
62
+ export function stylizeWithConsoleColors(str, styleType) {
63
+ var style = CONSOLE_COLOR_STYLES[styleType];
64
+ return style ? ConsoleColors[style](str) : str;
65
+ }
66
+ function isFunction(arg) {
67
+ return typeof arg === 'function';
68
+ }
69
+ function isString(arg) {
70
+ return typeof arg === 'string';
71
+ }
72
+ function isNumber(arg) {
73
+ return typeof arg === 'number';
74
+ }
75
+ function isNull(arg) {
76
+ return arg === null;
77
+ }
78
+ function hasOwn(obj, prop) {
79
+ return Object.prototype.hasOwnProperty.call(obj, prop);
80
+ }
81
+ function isRegExp(re) {
82
+ return isObject(re) && objectToString(re) === '[object RegExp]';
83
+ }
84
+ function isObject(arg) {
85
+ return typeof arg === 'object' && arg !== null;
86
+ }
87
+ function isError(e) {
88
+ return isObject(e) &&
89
+ (objectToString(e) === '[object Error]' || e instanceof Error);
90
+ }
91
+ function isDate(d) {
92
+ return isObject(d) && objectToString(d) === '[object Date]';
93
+ }
94
+ function objectToString(o) {
95
+ return Object.prototype.toString.call(o);
96
+ }
97
+ function arrayToHash(array) {
98
+ var hash = {};
99
+ array.forEach(function (val, idx) {
100
+ hash[val] = true;
101
+ });
102
+ return hash;
103
+ }
104
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
105
+ var output = [];
106
+ for (var i = 0, l = value.length; i < l; ++i) {
107
+ if (hasOwn(value, String(i))) {
108
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
109
+ }
110
+ else {
111
+ output.push('');
112
+ }
113
+ }
114
+ keys.forEach(function (key) {
115
+ if (!key.match(/^\d+$/)) {
116
+ output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
117
+ }
118
+ });
119
+ return output;
120
+ }
121
+ function formatError(value) {
122
+ return '[' + Error.prototype.toString.call(value) + ']';
123
+ }
124
+ function formatValue(ctx, value, recurseTimes) {
125
+ // Provide a hook for user-specified inspect functions.
126
+ // Check that value is an object with an inspect function on it
127
+ if (ctx.customInspect &&
128
+ value &&
129
+ isFunction(value.inspect) &&
130
+ // Filter out the util module, it's inspect function is special
131
+ value.inspect !== inspect &&
132
+ // Also filter out any prototype objects using the circular check.
133
+ !(value.constructor && value.constructor.prototype === value)) {
134
+ var ret = value.inspect(recurseTimes, ctx);
135
+ if (!isString(ret)) {
136
+ ret = formatValue(ctx, ret, recurseTimes);
137
+ }
138
+ return ret;
139
+ }
140
+ // Primitive types cannot have properties
141
+ var primitive = formatPrimitive(ctx, value);
142
+ if (primitive) {
143
+ return primitive;
144
+ }
145
+ // Look up the keys of the object.
146
+ var keys = Object.keys(value);
147
+ var visibleKeys = arrayToHash(keys);
148
+ try {
149
+ if (ctx.showHidden && Object.getOwnPropertyNames) {
150
+ keys = Object.getOwnPropertyNames(value);
151
+ }
152
+ }
153
+ catch (e) {
154
+ // ignore
155
+ }
156
+ // IE doesn't make error fields non-enumerable
157
+ // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
158
+ if (isError(value)
159
+ && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
160
+ return formatError(value);
161
+ }
162
+ // Some type of object without properties can be shortcutted.
163
+ if (keys.length === 0) {
164
+ if (isFunction(value)) {
165
+ var name = value.name ? ': ' + value.name : '';
166
+ return ctx.stylize('[Function' + name + ']', 'special');
167
+ }
168
+ if (isRegExp(value)) {
169
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
170
+ }
171
+ if (isDate(value)) {
172
+ return ctx.stylize(Date.prototype.toString.call(value), 'date');
173
+ }
174
+ if (isError(value)) {
175
+ return formatError(value);
176
+ }
177
+ }
178
+ var base = '', array = false, braces = ['{', '}'];
179
+ // Make Array say that they are Array
180
+ if (Array.isArray(value)) {
181
+ array = true;
182
+ braces = ['[', ']'];
183
+ }
184
+ // Make functions say that they are functions
185
+ if (isFunction(value)) {
186
+ var n = value.name ? ': ' + value.name : '';
187
+ base = ' [Function' + n + ']';
188
+ }
189
+ // Make RegExps say that they are RegExps
190
+ if (isRegExp(value)) {
191
+ base = ' ' + RegExp.prototype.toString.call(value);
192
+ }
193
+ // Make dates with properties first say the date
194
+ if (isDate(value)) {
195
+ base = ' ' + Date.prototype.toUTCString.call(value);
196
+ }
197
+ // Make error with message first say the error
198
+ if (isError(value)) {
199
+ base = ' ' + formatError(value);
200
+ }
201
+ if (keys.length === 0 && (!array || value.length == 0)) {
202
+ return braces[0] + base + braces[1];
203
+ }
204
+ if (recurseTimes < 0) {
205
+ if (isRegExp(value)) {
206
+ return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
207
+ }
208
+ else {
209
+ return ctx.stylize('[Object]', 'special');
210
+ }
211
+ }
212
+ ctx.seen.push(value);
213
+ var output;
214
+ if (array) {
215
+ output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
216
+ }
217
+ else {
218
+ output = keys.map(function (key) {
219
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
220
+ });
221
+ }
222
+ ctx.seen.pop();
223
+ return reduceToSingleString(output, base, braces);
224
+ }
225
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
226
+ var name, str, desc;
227
+ desc = { value: void 0 };
228
+ try {
229
+ // ie6 › navigator.toString
230
+ // throws Error: Object doesn't support this property or method
231
+ desc.value = value[key];
232
+ }
233
+ catch (e) {
234
+ // ignore
235
+ }
236
+ try {
237
+ // ie10 › Object.getOwnPropertyDescriptor(window.location, 'hash')
238
+ // throws TypeError: Object doesn't support this action
239
+ if (Object.getOwnPropertyDescriptor) {
240
+ desc = Object.getOwnPropertyDescriptor(value, key) || desc;
241
+ }
242
+ }
243
+ catch (e) {
244
+ // ignore
245
+ }
246
+ if (desc.get) {
247
+ if (desc.set) {
248
+ str = ctx.stylize('[Getter/Setter]', 'special');
249
+ }
250
+ else {
251
+ str = ctx.stylize('[Getter]', 'special');
252
+ }
253
+ }
254
+ else {
255
+ if (desc.set) {
256
+ str = ctx.stylize('[Setter]', 'special');
257
+ }
258
+ }
259
+ if (!hasOwn(visibleKeys, key)) {
260
+ name = '[' + key + ']';
261
+ }
262
+ if (!str) {
263
+ if (ctx.seen.indexOf(desc.value) < 0) {
264
+ if (isNull(recurseTimes)) {
265
+ str = formatValue(ctx, desc.value, null);
266
+ }
267
+ else {
268
+ str = formatValue(ctx, desc.value, recurseTimes - 1);
269
+ }
270
+ if (str.indexOf('\n') > -1) {
271
+ if (array) {
272
+ str = str.split('\n').map(function (line) {
273
+ return ' ' + line;
274
+ }).join('\n').substr(2);
275
+ }
276
+ else {
277
+ str = '\n' + str.split('\n').map(function (line) {
278
+ return ' ' + line;
279
+ }).join('\n');
280
+ }
281
+ }
282
+ }
283
+ else {
284
+ str = ctx.stylize('[Circular]', 'special');
285
+ }
286
+ }
287
+ if (isUndefined(name)) {
288
+ if (array && key.match(/^\d+$/)) {
289
+ return str;
290
+ }
291
+ name = JSON.stringify('' + key);
292
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
293
+ name = name.substr(1, name.length - 2);
294
+ name = ctx.stylize(name, 'name');
295
+ }
296
+ else {
297
+ name = name.replace(/'/g, "\\'")
298
+ .replace(/\\"/g, '"')
299
+ .replace(/(^"|"$)/g, "'");
300
+ name = ctx.stylize(name, 'string');
301
+ }
302
+ }
303
+ return name + ': ' + str;
304
+ }
305
+ function formatPrimitive(ctx, value) {
306
+ if (isUndefined(value))
307
+ return ctx.stylize('undefined', 'undefined');
308
+ if (isString(value)) {
309
+ var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
310
+ .replace(/'/g, "\\'")
311
+ .replace(/\\"/g, '"') + '\'';
312
+ return ctx.stylize(simple, 'string');
313
+ }
314
+ if (isNumber(value))
315
+ return ctx.stylize('' + value, 'number');
316
+ if (isBoolean(value))
317
+ return ctx.stylize('' + value, 'boolean');
318
+ // For some reason typeof null is "object", so special case here.
319
+ if (isNull(value))
320
+ return ctx.stylize('null', 'null');
321
+ }
322
+ function reduceToSingleString(output, base, braces) {
323
+ var numLinesEst = 0;
324
+ var length = output.reduce(function (prev, cur) {
325
+ numLinesEst++;
326
+ if (cur.indexOf('\n') >= 0)
327
+ numLinesEst++;
328
+ return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
329
+ }, 0);
330
+ if (length > 60) {
331
+ return braces[0] +
332
+ (base === '' ? '' : base + '\n ') +
333
+ ' ' +
334
+ output.join(',\n ') +
335
+ ' ' +
336
+ braces[1];
337
+ }
338
+ return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
339
+ }
340
340
  //# sourceMappingURL=inspect.js.map