axe 10.0.0 → 10.0.2
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/README.md +63 -27
- package/dist/axe.js +115 -367
- package/dist/axe.min.js +1 -1
- package/lib/index.js +65 -108
- package/package.json +2 -2
package/dist/axe.js
CHANGED
|
@@ -1,77 +1,62 @@
|
|
|
1
1
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Axe = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
2
2
|
function format(fmt) {
|
|
3
3
|
var re = /(%?)(%([jds]))/g,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
args = Array.prototype.slice.call(arguments, 1);
|
|
6
5
|
if (args.length) {
|
|
7
6
|
fmt = fmt.toString().replace(re, function (match, escaped, ptn, flag) {
|
|
8
7
|
var arg = args.shift();
|
|
9
|
-
|
|
10
8
|
switch (flag) {
|
|
11
9
|
case 's':
|
|
12
10
|
arg = '' + arg;
|
|
13
11
|
break;
|
|
14
|
-
|
|
15
12
|
case 'd':
|
|
16
13
|
arg = Number(arg);
|
|
17
14
|
break;
|
|
18
|
-
|
|
19
15
|
case 'j':
|
|
20
16
|
arg = JSON.stringify(arg);
|
|
21
17
|
break;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
if (!escaped) {
|
|
25
20
|
return arg;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
args.unshift(arg);
|
|
29
23
|
return match;
|
|
30
24
|
});
|
|
31
|
-
}
|
|
32
|
-
|
|
25
|
+
}
|
|
33
26
|
|
|
27
|
+
// arguments remain after formatting
|
|
34
28
|
if (args.length) {
|
|
35
29
|
fmt = fmt.toString() + ' ' + args.join(' ');
|
|
36
|
-
}
|
|
37
|
-
|
|
30
|
+
}
|
|
38
31
|
|
|
32
|
+
// update escaped %% values
|
|
39
33
|
fmt = fmt.toString().replace(/%{2,2}/g, '%');
|
|
40
34
|
return '' + fmt;
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
module.exports = format;
|
|
44
37
|
|
|
45
38
|
},{}],2:[function(require,module,exports){
|
|
46
39
|
'use strict';
|
|
47
40
|
|
|
48
41
|
const isObject = val => Object.prototype.toString.call(val) === '[object Object]';
|
|
49
|
-
|
|
50
42
|
const get = (obj, parts, length) => {
|
|
51
43
|
for (let i = 0; i < length; i++) {
|
|
52
44
|
if (obj === null) {
|
|
53
45
|
return;
|
|
54
46
|
}
|
|
55
|
-
|
|
56
47
|
const v = obj[parts[i]];
|
|
57
|
-
|
|
58
48
|
if (v === undefined) {
|
|
59
49
|
return;
|
|
60
50
|
}
|
|
61
|
-
|
|
62
51
|
obj = v;
|
|
63
52
|
}
|
|
64
|
-
|
|
65
53
|
return obj;
|
|
66
54
|
};
|
|
67
|
-
|
|
68
55
|
module.exports = function (obj, path) {
|
|
69
56
|
let sep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
|
|
70
|
-
|
|
71
57
|
if (!isObject(obj) || !path) {
|
|
72
58
|
return obj;
|
|
73
59
|
}
|
|
74
|
-
|
|
75
60
|
const parts = Array.isArray(path) ? path : String(path).split(sep);
|
|
76
61
|
const {
|
|
77
62
|
length
|
|
@@ -81,29 +66,24 @@ module.exports = function (obj, path) {
|
|
|
81
66
|
|
|
82
67
|
},{}],3:[function(require,module,exports){
|
|
83
68
|
'use strict';
|
|
84
|
-
/* eslint-disable no-continue, eqeqeq */
|
|
85
69
|
|
|
70
|
+
/* eslint-disable no-continue, eqeqeq */
|
|
86
71
|
const isObject = val => typeof val === 'object' || typeof val === 'function';
|
|
87
|
-
|
|
88
72
|
const isProto = (val, obj) => val == '__proto__' || val == 'constructor' && typeof obj.constructor === 'function';
|
|
89
|
-
|
|
90
73
|
const set = (obj, parts, length, val) => {
|
|
91
74
|
let tmp = obj;
|
|
92
75
|
let i = 0;
|
|
93
|
-
|
|
94
76
|
for (; i < length - 1; i++) {
|
|
95
77
|
const part = parts[i];
|
|
96
|
-
|
|
97
78
|
if (isProto(part, tmp)) {
|
|
98
79
|
continue;
|
|
99
80
|
}
|
|
100
|
-
|
|
101
81
|
tmp = !isObject(tmp[part]) ? tmp[part] = {} : tmp[part];
|
|
102
82
|
}
|
|
103
|
-
|
|
104
83
|
tmp[parts[i]] = val;
|
|
105
84
|
return obj;
|
|
106
85
|
};
|
|
86
|
+
|
|
107
87
|
/**
|
|
108
88
|
* Sets nested values on an object using a dot path or custom separator
|
|
109
89
|
* @param {Object} obj
|
|
@@ -112,30 +92,22 @@ const set = (obj, parts, length, val) => {
|
|
|
112
92
|
* @param {String} [sep = '.']
|
|
113
93
|
* @returns {Object}
|
|
114
94
|
*/
|
|
115
|
-
|
|
116
|
-
|
|
117
95
|
module.exports = function (obj, path, val) {
|
|
118
96
|
let sep = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
|
|
119
|
-
|
|
120
97
|
if (!isObject(obj) || !path || !path.length) {
|
|
121
98
|
return obj;
|
|
122
99
|
}
|
|
123
|
-
|
|
124
100
|
const parts = Array.isArray(path) ? path : String(path).split(sep);
|
|
125
|
-
|
|
126
101
|
if (isProto(parts[0], obj)) {
|
|
127
102
|
return obj;
|
|
128
103
|
}
|
|
129
|
-
|
|
130
104
|
const {
|
|
131
105
|
length
|
|
132
106
|
} = parts;
|
|
133
|
-
|
|
134
107
|
if (length === 1) {
|
|
135
108
|
obj[parts[0]] = val;
|
|
136
109
|
return obj;
|
|
137
110
|
}
|
|
138
|
-
|
|
139
111
|
return set(obj, parts, length, val);
|
|
140
112
|
};
|
|
141
113
|
|
|
@@ -146,23 +118,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
146
118
|
value: true
|
|
147
119
|
});
|
|
148
120
|
exports.boolean = void 0;
|
|
149
|
-
|
|
150
121
|
const boolean = function (value) {
|
|
151
122
|
switch (Object.prototype.toString.call(value)) {
|
|
152
123
|
case '[object String]':
|
|
153
124
|
return ['true', 't', 'yes', 'y', 'on', '1'].includes(value.trim().toLowerCase());
|
|
154
|
-
|
|
155
125
|
case '[object Number]':
|
|
156
126
|
return value.valueOf() === 1;
|
|
157
|
-
|
|
158
127
|
case '[object Boolean]':
|
|
159
128
|
return value.valueOf();
|
|
160
|
-
|
|
161
129
|
default:
|
|
162
130
|
return false;
|
|
163
131
|
}
|
|
164
132
|
};
|
|
165
|
-
|
|
166
133
|
exports.boolean = boolean;
|
|
167
134
|
|
|
168
135
|
},{}],5:[function(require,module,exports){
|
|
@@ -172,18 +139,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
172
139
|
value: true
|
|
173
140
|
});
|
|
174
141
|
exports.isBooleanable = exports.boolean = void 0;
|
|
175
|
-
|
|
176
142
|
const boolean_1 = require("./boolean");
|
|
177
|
-
|
|
178
143
|
Object.defineProperty(exports, "boolean", {
|
|
179
144
|
enumerable: true,
|
|
180
145
|
get: function () {
|
|
181
146
|
return boolean_1.boolean;
|
|
182
147
|
}
|
|
183
148
|
});
|
|
184
|
-
|
|
185
149
|
const isBooleanable_1 = require("./isBooleanable");
|
|
186
|
-
|
|
187
150
|
Object.defineProperty(exports, "isBooleanable", {
|
|
188
151
|
enumerable: true,
|
|
189
152
|
get: function () {
|
|
@@ -198,23 +161,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
198
161
|
value: true
|
|
199
162
|
});
|
|
200
163
|
exports.isBooleanable = void 0;
|
|
201
|
-
|
|
202
164
|
const isBooleanable = function (value) {
|
|
203
165
|
switch (Object.prototype.toString.call(value)) {
|
|
204
166
|
case '[object String]':
|
|
205
167
|
return ['true', 't', 'yes', 'y', 'on', '1', 'false', 'f', 'no', 'n', 'off', '0'].includes(value.trim().toLowerCase());
|
|
206
|
-
|
|
207
168
|
case '[object Number]':
|
|
208
169
|
return [0, 1].includes(value.valueOf());
|
|
209
|
-
|
|
210
170
|
case '[object Boolean]':
|
|
211
171
|
return true;
|
|
212
|
-
|
|
213
172
|
default:
|
|
214
173
|
return false;
|
|
215
174
|
}
|
|
216
175
|
};
|
|
217
|
-
|
|
218
176
|
exports.isBooleanable = isBooleanable;
|
|
219
177
|
|
|
220
178
|
},{}],7:[function(require,module,exports){
|
|
@@ -229,19 +187,14 @@ exports.isBooleanable = isBooleanable;
|
|
|
229
187
|
if (!global.console) {
|
|
230
188
|
global.console = {};
|
|
231
189
|
}
|
|
232
|
-
|
|
233
190
|
var con = global.console;
|
|
234
191
|
var prop, method;
|
|
235
|
-
|
|
236
192
|
var dummy = function () {};
|
|
237
|
-
|
|
238
193
|
var properties = ['memory'];
|
|
239
194
|
var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' + 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' + 'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(',');
|
|
240
|
-
|
|
241
195
|
while (prop = properties.pop()) if (!con[prop]) con[prop] = {};
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
196
|
+
while (method = methods.pop()) if (!con[method]) con[method] = dummy;
|
|
197
|
+
// Using `this` for web workers & supports Browserify / Webpack.
|
|
245
198
|
})(typeof window === 'undefined' ? this : window);
|
|
246
199
|
|
|
247
200
|
},{}],9:[function(require,module,exports){
|
|
@@ -261,112 +214,88 @@ module.exports = ['%s', '%d', '%i', '%f', '%j', '%o', '%O', '%%'];
|
|
|
261
214
|
* Copyright (c) 2014-2018, Jon Schlinkert.
|
|
262
215
|
* Released under the MIT License.
|
|
263
216
|
*/
|
|
264
|
-
const isObject = require('isobject');
|
|
265
217
|
|
|
218
|
+
const isObject = require('isobject');
|
|
266
219
|
module.exports = function (target, path, options) {
|
|
267
220
|
if (!isObject(options)) {
|
|
268
221
|
options = {
|
|
269
222
|
default: options
|
|
270
223
|
};
|
|
271
224
|
}
|
|
272
|
-
|
|
273
225
|
if (!isValidObject(target)) {
|
|
274
226
|
return typeof options.default !== 'undefined' ? options.default : target;
|
|
275
227
|
}
|
|
276
|
-
|
|
277
228
|
if (typeof path === 'number') {
|
|
278
229
|
path = String(path);
|
|
279
230
|
}
|
|
280
|
-
|
|
281
231
|
const isArray = Array.isArray(path);
|
|
282
232
|
const isString = typeof path === 'string';
|
|
283
233
|
const splitChar = options.separator || '.';
|
|
284
234
|
const joinChar = options.joinChar || (typeof splitChar === 'string' ? splitChar : '.');
|
|
285
|
-
|
|
286
235
|
if (!isString && !isArray) {
|
|
287
236
|
return target;
|
|
288
237
|
}
|
|
289
|
-
|
|
290
238
|
if (isString && path in target) {
|
|
291
239
|
return isValid(path, target, options) ? target[path] : options.default;
|
|
292
240
|
}
|
|
293
|
-
|
|
294
241
|
let segs = isArray ? path : split(path, splitChar, options);
|
|
295
242
|
let len = segs.length;
|
|
296
243
|
let idx = 0;
|
|
297
|
-
|
|
298
244
|
do {
|
|
299
245
|
let prop = segs[idx];
|
|
300
|
-
|
|
301
246
|
if (typeof prop === 'number') {
|
|
302
247
|
prop = String(prop);
|
|
303
248
|
}
|
|
304
|
-
|
|
305
249
|
while (prop && prop.slice(-1) === '\\') {
|
|
306
250
|
prop = join([prop.slice(0, -1), segs[++idx] || ''], joinChar, options);
|
|
307
251
|
}
|
|
308
|
-
|
|
309
252
|
if (prop in target) {
|
|
310
253
|
if (!isValid(prop, target, options)) {
|
|
311
254
|
return options.default;
|
|
312
255
|
}
|
|
313
|
-
|
|
314
256
|
target = target[prop];
|
|
315
257
|
} else {
|
|
316
258
|
let hasProp = false;
|
|
317
259
|
let n = idx + 1;
|
|
318
|
-
|
|
319
260
|
while (n < len) {
|
|
320
261
|
prop = join([prop, segs[n++]], joinChar, options);
|
|
321
|
-
|
|
322
262
|
if (hasProp = prop in target) {
|
|
323
263
|
if (!isValid(prop, target, options)) {
|
|
324
264
|
return options.default;
|
|
325
265
|
}
|
|
326
|
-
|
|
327
266
|
target = target[prop];
|
|
328
267
|
idx = n - 1;
|
|
329
268
|
break;
|
|
330
269
|
}
|
|
331
270
|
}
|
|
332
|
-
|
|
333
271
|
if (!hasProp) {
|
|
334
272
|
return options.default;
|
|
335
273
|
}
|
|
336
274
|
}
|
|
337
275
|
} while (++idx < len && isValidObject(target));
|
|
338
|
-
|
|
339
276
|
if (idx === len) {
|
|
340
277
|
return target;
|
|
341
278
|
}
|
|
342
|
-
|
|
343
279
|
return options.default;
|
|
344
280
|
};
|
|
345
|
-
|
|
346
281
|
function join(segs, joinChar, options) {
|
|
347
282
|
if (typeof options.join === 'function') {
|
|
348
283
|
return options.join(segs);
|
|
349
284
|
}
|
|
350
|
-
|
|
351
285
|
return segs[0] + joinChar + segs[1];
|
|
352
286
|
}
|
|
353
|
-
|
|
354
287
|
function split(path, splitChar, options) {
|
|
355
288
|
if (typeof options.split === 'function') {
|
|
356
289
|
return options.split(path);
|
|
357
290
|
}
|
|
358
|
-
|
|
359
291
|
return path.split(splitChar);
|
|
360
292
|
}
|
|
361
|
-
|
|
362
293
|
function isValid(key, target, options) {
|
|
363
294
|
if (typeof options.isValid === 'function') {
|
|
364
295
|
return options.isValid(key, target);
|
|
365
296
|
}
|
|
366
|
-
|
|
367
297
|
return true;
|
|
368
298
|
}
|
|
369
|
-
|
|
370
299
|
function isValidObject(val) {
|
|
371
300
|
return isObject(val) || Array.isArray(val) || typeof val === 'function';
|
|
372
301
|
}
|
|
@@ -378,6 +307,7 @@ function isValidObject(val) {
|
|
|
378
307
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
379
308
|
* Released under the MIT License.
|
|
380
309
|
*/
|
|
310
|
+
|
|
381
311
|
'use strict';
|
|
382
312
|
|
|
383
313
|
module.exports = function isObject(val) {
|
|
@@ -391,20 +321,17 @@ module.exports = function isObject(val) {
|
|
|
391
321
|
* Copyright (c) 2014-2018, Jon Schlinkert.
|
|
392
322
|
* Released under the MIT License.
|
|
393
323
|
*/
|
|
324
|
+
|
|
394
325
|
'use strict';
|
|
395
326
|
|
|
396
327
|
const get = require('get-value');
|
|
397
|
-
|
|
398
328
|
const has = require('has-values');
|
|
399
|
-
|
|
400
329
|
module.exports = function (obj, path, options) {
|
|
401
330
|
if (isObject(obj) && (typeof path === 'string' || Array.isArray(path))) {
|
|
402
331
|
return has(get(obj, path, options));
|
|
403
332
|
}
|
|
404
|
-
|
|
405
333
|
return false;
|
|
406
334
|
};
|
|
407
|
-
|
|
408
335
|
function isObject(val) {
|
|
409
336
|
return val != null && (typeof val === 'object' || typeof val === 'function' || Array.isArray(val));
|
|
410
337
|
}
|
|
@@ -416,10 +343,10 @@ function isObject(val) {
|
|
|
416
343
|
* Copyright (c) 2014-2018, Jon Schlinkert.
|
|
417
344
|
* Released under the MIT License.
|
|
418
345
|
*/
|
|
346
|
+
|
|
419
347
|
'use strict';
|
|
420
348
|
|
|
421
349
|
const typeOf = require('kind-of');
|
|
422
|
-
|
|
423
350
|
module.exports = function has(val) {
|
|
424
351
|
switch (typeOf(val)) {
|
|
425
352
|
case 'boolean':
|
|
@@ -428,28 +355,21 @@ module.exports = function has(val) {
|
|
|
428
355
|
case 'null':
|
|
429
356
|
case 'number':
|
|
430
357
|
return true;
|
|
431
|
-
|
|
432
358
|
case 'undefined':
|
|
433
359
|
return false;
|
|
434
|
-
|
|
435
360
|
case 'regexp':
|
|
436
361
|
return val.source !== '(?:)' && val.source !== '';
|
|
437
|
-
|
|
438
362
|
case 'buffer':
|
|
439
363
|
return val.toString() !== '';
|
|
440
|
-
|
|
441
364
|
case 'error':
|
|
442
365
|
return val.message !== '';
|
|
443
|
-
|
|
444
366
|
case 'string':
|
|
445
367
|
case 'arguments':
|
|
446
368
|
return val.length !== 0;
|
|
447
|
-
|
|
448
369
|
case 'file':
|
|
449
370
|
case 'map':
|
|
450
371
|
case 'set':
|
|
451
372
|
return val.size !== 0;
|
|
452
|
-
|
|
453
373
|
case 'array':
|
|
454
374
|
case 'object':
|
|
455
375
|
for (const key of Object.keys(val)) {
|
|
@@ -457,10 +377,9 @@ module.exports = function has(val) {
|
|
|
457
377
|
return true;
|
|
458
378
|
}
|
|
459
379
|
}
|
|
460
|
-
|
|
461
380
|
return false;
|
|
462
|
-
// everything else
|
|
463
381
|
|
|
382
|
+
// everything else
|
|
464
383
|
default:
|
|
465
384
|
{
|
|
466
385
|
return true;
|
|
@@ -475,7 +394,6 @@ module.exports = value => {
|
|
|
475
394
|
if (Object.prototype.toString.call(value) !== '[object Object]') {
|
|
476
395
|
return false;
|
|
477
396
|
}
|
|
478
|
-
|
|
479
397
|
const prototype = Object.getPrototypeOf(value);
|
|
480
398
|
return prototype === null || prototype === Object.prototype;
|
|
481
399
|
};
|
|
@@ -484,7 +402,9 @@ module.exports = value => {
|
|
|
484
402
|
/**
|
|
485
403
|
* Expose `isError`.
|
|
486
404
|
*/
|
|
405
|
+
|
|
487
406
|
module.exports = isError;
|
|
407
|
+
|
|
488
408
|
/**
|
|
489
409
|
* Test whether `value` is error object.
|
|
490
410
|
*
|
|
@@ -496,13 +416,10 @@ function isError(value) {
|
|
|
496
416
|
switch (Object.prototype.toString.call(value)) {
|
|
497
417
|
case '[object Error]':
|
|
498
418
|
return true;
|
|
499
|
-
|
|
500
419
|
case '[object Exception]':
|
|
501
420
|
return true;
|
|
502
|
-
|
|
503
421
|
case '[object DOMException]':
|
|
504
422
|
return true;
|
|
505
|
-
|
|
506
423
|
default:
|
|
507
424
|
return value instanceof Error;
|
|
508
425
|
}
|
|
@@ -510,22 +427,20 @@ function isError(value) {
|
|
|
510
427
|
|
|
511
428
|
},{}],16:[function(require,module,exports){
|
|
512
429
|
'use strict';
|
|
430
|
+
|
|
513
431
|
/*!
|
|
514
432
|
* isobject <https://github.com/jonschlinkert/isobject>
|
|
515
433
|
*
|
|
516
434
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
517
435
|
* Released under the MIT License.
|
|
518
436
|
*/
|
|
519
|
-
|
|
520
437
|
function isObject(val) {
|
|
521
438
|
return val != null && typeof val === 'object' && Array.isArray(val) === false;
|
|
522
439
|
}
|
|
523
|
-
|
|
524
440
|
module.exports = isObject;
|
|
525
441
|
|
|
526
442
|
},{}],17:[function(require,module,exports){
|
|
527
443
|
var toString = Object.prototype.toString;
|
|
528
|
-
|
|
529
444
|
module.exports = function kindOf(val) {
|
|
530
445
|
if (val === void 0) return 'undefined';
|
|
531
446
|
if (val === null) return 'null';
|
|
@@ -534,129 +449,102 @@ module.exports = function kindOf(val) {
|
|
|
534
449
|
if (type === 'string') return 'string';
|
|
535
450
|
if (type === 'number') return 'number';
|
|
536
451
|
if (type === 'symbol') return 'symbol';
|
|
537
|
-
|
|
538
452
|
if (type === 'function') {
|
|
539
453
|
return isGeneratorFn(val) ? 'generatorfunction' : 'function';
|
|
540
454
|
}
|
|
541
|
-
|
|
542
455
|
if (isArray(val)) return 'array';
|
|
543
456
|
if (isBuffer(val)) return 'buffer';
|
|
544
457
|
if (isArguments(val)) return 'arguments';
|
|
545
458
|
if (isDate(val)) return 'date';
|
|
546
459
|
if (isError(val)) return 'error';
|
|
547
460
|
if (isRegexp(val)) return 'regexp';
|
|
548
|
-
|
|
549
461
|
switch (ctorName(val)) {
|
|
550
462
|
case 'Symbol':
|
|
551
463
|
return 'symbol';
|
|
552
|
-
|
|
553
464
|
case 'Promise':
|
|
554
465
|
return 'promise';
|
|
555
|
-
// Set, Map, WeakSet, WeakMap
|
|
556
466
|
|
|
467
|
+
// Set, Map, WeakSet, WeakMap
|
|
557
468
|
case 'WeakMap':
|
|
558
469
|
return 'weakmap';
|
|
559
|
-
|
|
560
470
|
case 'WeakSet':
|
|
561
471
|
return 'weakset';
|
|
562
|
-
|
|
563
472
|
case 'Map':
|
|
564
473
|
return 'map';
|
|
565
|
-
|
|
566
474
|
case 'Set':
|
|
567
475
|
return 'set';
|
|
568
|
-
// 8-bit typed arrays
|
|
569
476
|
|
|
477
|
+
// 8-bit typed arrays
|
|
570
478
|
case 'Int8Array':
|
|
571
479
|
return 'int8array';
|
|
572
|
-
|
|
573
480
|
case 'Uint8Array':
|
|
574
481
|
return 'uint8array';
|
|
575
|
-
|
|
576
482
|
case 'Uint8ClampedArray':
|
|
577
483
|
return 'uint8clampedarray';
|
|
578
|
-
// 16-bit typed arrays
|
|
579
484
|
|
|
485
|
+
// 16-bit typed arrays
|
|
580
486
|
case 'Int16Array':
|
|
581
487
|
return 'int16array';
|
|
582
|
-
|
|
583
488
|
case 'Uint16Array':
|
|
584
489
|
return 'uint16array';
|
|
585
|
-
// 32-bit typed arrays
|
|
586
490
|
|
|
491
|
+
// 32-bit typed arrays
|
|
587
492
|
case 'Int32Array':
|
|
588
493
|
return 'int32array';
|
|
589
|
-
|
|
590
494
|
case 'Uint32Array':
|
|
591
495
|
return 'uint32array';
|
|
592
|
-
|
|
593
496
|
case 'Float32Array':
|
|
594
497
|
return 'float32array';
|
|
595
|
-
|
|
596
498
|
case 'Float64Array':
|
|
597
499
|
return 'float64array';
|
|
598
500
|
}
|
|
599
|
-
|
|
600
501
|
if (isGeneratorObj(val)) {
|
|
601
502
|
return 'generator';
|
|
602
|
-
}
|
|
603
|
-
|
|
503
|
+
}
|
|
604
504
|
|
|
505
|
+
// Non-plain objects
|
|
605
506
|
type = toString.call(val);
|
|
606
|
-
|
|
607
507
|
switch (type) {
|
|
608
508
|
case '[object Object]':
|
|
609
509
|
return 'object';
|
|
610
510
|
// iterators
|
|
611
|
-
|
|
612
511
|
case '[object Map Iterator]':
|
|
613
512
|
return 'mapiterator';
|
|
614
|
-
|
|
615
513
|
case '[object Set Iterator]':
|
|
616
514
|
return 'setiterator';
|
|
617
|
-
|
|
618
515
|
case '[object String Iterator]':
|
|
619
516
|
return 'stringiterator';
|
|
620
|
-
|
|
621
517
|
case '[object Array Iterator]':
|
|
622
518
|
return 'arrayiterator';
|
|
623
|
-
}
|
|
624
|
-
|
|
519
|
+
}
|
|
625
520
|
|
|
521
|
+
// other
|
|
626
522
|
return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
|
|
627
523
|
};
|
|
628
|
-
|
|
629
524
|
function ctorName(val) {
|
|
630
525
|
return typeof val.constructor === 'function' ? val.constructor.name : null;
|
|
631
526
|
}
|
|
632
|
-
|
|
633
527
|
function isArray(val) {
|
|
634
528
|
if (Array.isArray) return Array.isArray(val);
|
|
635
529
|
return val instanceof Array;
|
|
636
530
|
}
|
|
637
|
-
|
|
638
531
|
function isError(val) {
|
|
639
532
|
return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
|
|
640
533
|
}
|
|
641
|
-
|
|
642
534
|
function isDate(val) {
|
|
643
535
|
if (val instanceof Date) return true;
|
|
644
536
|
return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
|
|
645
537
|
}
|
|
646
|
-
|
|
647
538
|
function isRegexp(val) {
|
|
648
539
|
if (val instanceof RegExp) return true;
|
|
649
540
|
return typeof val.flags === 'string' && typeof val.ignoreCase === 'boolean' && typeof val.multiline === 'boolean' && typeof val.global === 'boolean';
|
|
650
541
|
}
|
|
651
|
-
|
|
652
542
|
function isGeneratorFn(name, val) {
|
|
653
543
|
return ctorName(name) === 'GeneratorFunction';
|
|
654
544
|
}
|
|
655
|
-
|
|
656
545
|
function isGeneratorObj(val) {
|
|
657
546
|
return typeof val.throw === 'function' && typeof val.return === 'function' && typeof val.next === 'function';
|
|
658
547
|
}
|
|
659
|
-
|
|
660
548
|
function isArguments(val) {
|
|
661
549
|
try {
|
|
662
550
|
if (typeof val.length === 'number' && typeof val.callee === 'function') {
|
|
@@ -667,20 +555,18 @@ function isArguments(val) {
|
|
|
667
555
|
return true;
|
|
668
556
|
}
|
|
669
557
|
}
|
|
670
|
-
|
|
671
558
|
return false;
|
|
672
559
|
}
|
|
560
|
+
|
|
673
561
|
/**
|
|
674
562
|
* If you need to support Safari 5-7 (8-10 yr-old browser),
|
|
675
563
|
* take a look at https://github.com/feross/is-buffer
|
|
676
564
|
*/
|
|
677
565
|
|
|
678
|
-
|
|
679
566
|
function isBuffer(val) {
|
|
680
567
|
if (val.constructor && typeof val.constructor.isBuffer === 'function') {
|
|
681
568
|
return val.constructor.isBuffer(val);
|
|
682
569
|
}
|
|
683
|
-
|
|
684
570
|
return false;
|
|
685
571
|
}
|
|
686
572
|
|
|
@@ -688,14 +574,12 @@ function isBuffer(val) {
|
|
|
688
574
|
'use strict';
|
|
689
575
|
|
|
690
576
|
const kErrors = Symbol('kErrors');
|
|
691
|
-
|
|
692
577
|
module.exports = function (errors) {
|
|
693
578
|
errors = errors.filter(defined);
|
|
694
579
|
if (errors.length === 0) return;
|
|
695
580
|
if (errors.length === 1) return errors[0];
|
|
696
581
|
return new CombinedError(errors);
|
|
697
582
|
};
|
|
698
|
-
|
|
699
583
|
class CombinedError extends Error {
|
|
700
584
|
constructor(errors) {
|
|
701
585
|
const unique = new Set(errors.map(getMessage).filter(Boolean));
|
|
@@ -707,41 +591,32 @@ class CombinedError extends Error {
|
|
|
707
591
|
getter(this, 'transient', () => errors.length > 0 && errors.every(transient));
|
|
708
592
|
getter(this, 'expected', () => errors.length > 0 && errors.every(expected));
|
|
709
593
|
}
|
|
710
|
-
|
|
711
594
|
[Symbol.iterator]() {
|
|
712
595
|
return this[kErrors][Symbol.iterator]();
|
|
713
596
|
}
|
|
714
|
-
|
|
715
597
|
}
|
|
716
|
-
|
|
717
598
|
function value(obj, prop, value) {
|
|
718
599
|
Object.defineProperty(obj, prop, {
|
|
719
600
|
value
|
|
720
601
|
});
|
|
721
602
|
}
|
|
722
|
-
|
|
723
603
|
function getter(obj, prop, get) {
|
|
724
604
|
Object.defineProperty(obj, prop, {
|
|
725
605
|
get
|
|
726
606
|
});
|
|
727
607
|
}
|
|
728
|
-
|
|
729
608
|
function defined(err) {
|
|
730
609
|
return err != null;
|
|
731
610
|
}
|
|
732
|
-
|
|
733
611
|
function getMessage(err) {
|
|
734
612
|
return err.message;
|
|
735
613
|
}
|
|
736
|
-
|
|
737
614
|
function getStack(err) {
|
|
738
615
|
return err.stack;
|
|
739
616
|
}
|
|
740
|
-
|
|
741
617
|
function transient(err) {
|
|
742
618
|
return err.transient === true;
|
|
743
619
|
}
|
|
744
|
-
|
|
745
620
|
function expected(err) {
|
|
746
621
|
return err.expected === true;
|
|
747
622
|
}
|
|
@@ -750,63 +625,51 @@ function expected(err) {
|
|
|
750
625
|
'use strict';
|
|
751
626
|
|
|
752
627
|
const isOptionObject = require('is-plain-obj');
|
|
753
|
-
|
|
754
628
|
const {
|
|
755
629
|
hasOwnProperty
|
|
756
630
|
} = Object.prototype;
|
|
757
631
|
const {
|
|
758
632
|
propertyIsEnumerable
|
|
759
633
|
} = Object;
|
|
760
|
-
|
|
761
634
|
const defineProperty = (object, name, value) => Object.defineProperty(object, name, {
|
|
762
635
|
value,
|
|
763
636
|
writable: true,
|
|
764
637
|
enumerable: true,
|
|
765
638
|
configurable: true
|
|
766
639
|
});
|
|
767
|
-
|
|
768
640
|
const globalThis = this;
|
|
769
641
|
const defaultMergeOptions = {
|
|
770
642
|
concatArrays: false,
|
|
771
643
|
ignoreUndefined: false
|
|
772
644
|
};
|
|
773
|
-
|
|
774
645
|
const getEnumerableOwnPropertyKeys = value => {
|
|
775
646
|
const keys = [];
|
|
776
|
-
|
|
777
647
|
for (const key in value) {
|
|
778
648
|
if (hasOwnProperty.call(value, key)) {
|
|
779
649
|
keys.push(key);
|
|
780
650
|
}
|
|
781
651
|
}
|
|
782
|
-
/* istanbul ignore else */
|
|
783
|
-
|
|
784
652
|
|
|
653
|
+
/* istanbul ignore else */
|
|
785
654
|
if (Object.getOwnPropertySymbols) {
|
|
786
655
|
const symbols = Object.getOwnPropertySymbols(value);
|
|
787
|
-
|
|
788
656
|
for (const symbol of symbols) {
|
|
789
657
|
if (propertyIsEnumerable.call(value, symbol)) {
|
|
790
658
|
keys.push(symbol);
|
|
791
659
|
}
|
|
792
660
|
}
|
|
793
661
|
}
|
|
794
|
-
|
|
795
662
|
return keys;
|
|
796
663
|
};
|
|
797
|
-
|
|
798
664
|
function clone(value) {
|
|
799
665
|
if (Array.isArray(value)) {
|
|
800
666
|
return cloneArray(value);
|
|
801
667
|
}
|
|
802
|
-
|
|
803
668
|
if (isOptionObject(value)) {
|
|
804
669
|
return cloneOptionObject(value);
|
|
805
670
|
}
|
|
806
|
-
|
|
807
671
|
return value;
|
|
808
672
|
}
|
|
809
|
-
|
|
810
673
|
function cloneArray(array) {
|
|
811
674
|
const result = array.slice(0, 0);
|
|
812
675
|
getEnumerableOwnPropertyKeys(array).forEach(key => {
|
|
@@ -814,7 +677,6 @@ function cloneArray(array) {
|
|
|
814
677
|
});
|
|
815
678
|
return result;
|
|
816
679
|
}
|
|
817
|
-
|
|
818
680
|
function cloneOptionObject(object) {
|
|
819
681
|
const result = Object.getPrototypeOf(object) === null ? Object.create(null) : {};
|
|
820
682
|
getEnumerableOwnPropertyKeys(object).forEach(key => {
|
|
@@ -822,6 +684,7 @@ function cloneOptionObject(object) {
|
|
|
822
684
|
});
|
|
823
685
|
return result;
|
|
824
686
|
}
|
|
687
|
+
|
|
825
688
|
/**
|
|
826
689
|
* @param {*} merged already cloned
|
|
827
690
|
* @param {*} source something to merge
|
|
@@ -829,15 +692,13 @@ function cloneOptionObject(object) {
|
|
|
829
692
|
* @param {Object} config Config Object
|
|
830
693
|
* @returns {*} cloned Object
|
|
831
694
|
*/
|
|
832
|
-
|
|
833
|
-
|
|
834
695
|
const mergeKeys = (merged, source, keys, config) => {
|
|
835
696
|
keys.forEach(key => {
|
|
836
697
|
if (typeof source[key] === 'undefined' && config.ignoreUndefined) {
|
|
837
698
|
return;
|
|
838
|
-
}
|
|
839
|
-
|
|
699
|
+
}
|
|
840
700
|
|
|
701
|
+
// Do not recurse into prototype chain of merged
|
|
841
702
|
if (key in merged && merged[key] !== Object.getPrototypeOf(merged)) {
|
|
842
703
|
defineProperty(merged, key, merge(merged[key], source[key], config));
|
|
843
704
|
} else {
|
|
@@ -846,6 +707,7 @@ const mergeKeys = (merged, source, keys, config) => {
|
|
|
846
707
|
});
|
|
847
708
|
return merged;
|
|
848
709
|
};
|
|
710
|
+
|
|
849
711
|
/**
|
|
850
712
|
* @param {*} merged already cloned
|
|
851
713
|
* @param {*} source something to merge
|
|
@@ -854,78 +716,66 @@ const mergeKeys = (merged, source, keys, config) => {
|
|
|
854
716
|
*
|
|
855
717
|
* see [Array.prototype.concat ( ...arguments )](http://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.concat)
|
|
856
718
|
*/
|
|
857
|
-
|
|
858
|
-
|
|
859
719
|
const concatArrays = (merged, source, config) => {
|
|
860
720
|
let result = merged.slice(0, 0);
|
|
861
721
|
let resultIndex = 0;
|
|
862
722
|
[merged, source].forEach(array => {
|
|
863
|
-
const indices = [];
|
|
723
|
+
const indices = [];
|
|
864
724
|
|
|
725
|
+
// `result.concat(array)` with cloning
|
|
865
726
|
for (let k = 0; k < array.length; k++) {
|
|
866
727
|
if (!hasOwnProperty.call(array, k)) {
|
|
867
728
|
continue;
|
|
868
729
|
}
|
|
869
|
-
|
|
870
730
|
indices.push(String(k));
|
|
871
|
-
|
|
872
731
|
if (array === merged) {
|
|
873
732
|
// Already cloned
|
|
874
733
|
defineProperty(result, resultIndex++, array[k]);
|
|
875
734
|
} else {
|
|
876
735
|
defineProperty(result, resultIndex++, clone(array[k]));
|
|
877
736
|
}
|
|
878
|
-
}
|
|
879
|
-
|
|
737
|
+
}
|
|
880
738
|
|
|
739
|
+
// Merge non-index keys
|
|
881
740
|
result = mergeKeys(result, array, getEnumerableOwnPropertyKeys(array).filter(key => !indices.includes(key)), config);
|
|
882
741
|
});
|
|
883
742
|
return result;
|
|
884
743
|
};
|
|
744
|
+
|
|
885
745
|
/**
|
|
886
746
|
* @param {*} merged already cloned
|
|
887
747
|
* @param {*} source something to merge
|
|
888
748
|
* @param {Object} config Config Object
|
|
889
749
|
* @returns {*} cloned Object
|
|
890
750
|
*/
|
|
891
|
-
|
|
892
|
-
|
|
893
751
|
function merge(merged, source, config) {
|
|
894
752
|
if (config.concatArrays && Array.isArray(merged) && Array.isArray(source)) {
|
|
895
753
|
return concatArrays(merged, source, config);
|
|
896
754
|
}
|
|
897
|
-
|
|
898
755
|
if (!isOptionObject(source) || !isOptionObject(merged)) {
|
|
899
756
|
return clone(source);
|
|
900
757
|
}
|
|
901
|
-
|
|
902
758
|
return mergeKeys(merged, source, getEnumerableOwnPropertyKeys(source), config);
|
|
903
759
|
}
|
|
904
|
-
|
|
905
760
|
module.exports = function () {
|
|
906
761
|
const config = merge(clone(defaultMergeOptions), this !== globalThis && this || {}, defaultMergeOptions);
|
|
907
762
|
let merged = {
|
|
908
763
|
_: {}
|
|
909
764
|
};
|
|
910
|
-
|
|
911
765
|
for (var _len = arguments.length, options = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
912
766
|
options[_key] = arguments[_key];
|
|
913
767
|
}
|
|
914
|
-
|
|
915
768
|
for (const option of options) {
|
|
916
769
|
if (option === undefined) {
|
|
917
770
|
continue;
|
|
918
771
|
}
|
|
919
|
-
|
|
920
772
|
if (!isOptionObject(option)) {
|
|
921
773
|
throw new TypeError('`' + option + '` is not an Option Object');
|
|
922
774
|
}
|
|
923
|
-
|
|
924
775
|
merged = merge(merged, {
|
|
925
776
|
_: option
|
|
926
777
|
}, config);
|
|
927
778
|
}
|
|
928
|
-
|
|
929
779
|
return merged._;
|
|
930
780
|
};
|
|
931
781
|
|
|
@@ -935,17 +785,14 @@ module.exports = function () {
|
|
|
935
785
|
const pMapSeries = async (iterable, mapper) => {
|
|
936
786
|
const result = [];
|
|
937
787
|
let index = 0;
|
|
938
|
-
|
|
939
788
|
for (const value of iterable) {
|
|
940
789
|
// eslint-disable-next-line no-await-in-loop
|
|
941
790
|
result.push(await mapper(await value, index++));
|
|
942
791
|
}
|
|
943
|
-
|
|
944
792
|
return result;
|
|
945
793
|
};
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
794
|
+
module.exports = pMapSeries;
|
|
795
|
+
// TODO: Remove this for the next major release
|
|
949
796
|
module.exports.default = pMapSeries;
|
|
950
797
|
|
|
951
798
|
},{}],21:[function(require,module,exports){
|
|
@@ -955,7 +802,6 @@ var isError = require('iserror'); // we want to support parsing other fields tha
|
|
|
955
802
|
// <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors>
|
|
956
803
|
// <https://github.com/stripe/stripe-node/blob/3c07d851cf897490d8b93dd4457dda0c4c8e667f/lib/Error.js#L33>
|
|
957
804
|
|
|
958
|
-
|
|
959
805
|
var parseErr = function parseErr(err) {
|
|
960
806
|
var fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
961
807
|
if (!isError(err)) throw new Error('`err` must be an Error');
|
|
@@ -969,73 +815,60 @@ var parseErr = function parseErr(err) {
|
|
|
969
815
|
return fields.includes(key);
|
|
970
816
|
}) : keys;
|
|
971
817
|
};
|
|
972
|
-
|
|
973
818
|
module.exports = parseErr;
|
|
974
819
|
|
|
975
820
|
},{"iserror":15}],22:[function(require,module,exports){
|
|
976
821
|
'use strict';
|
|
977
822
|
|
|
978
823
|
const get = require('@strikeentco/get');
|
|
979
|
-
|
|
980
824
|
const set = require('@strikeentco/set');
|
|
981
|
-
|
|
982
825
|
const isObject = val => Object.prototype.toString.call(val) === '[object Object]';
|
|
983
|
-
|
|
984
826
|
const pick = (obj, paths, length, sep) => {
|
|
985
827
|
const picked = {};
|
|
986
|
-
|
|
987
828
|
for (let i = 0; i < length; i++) {
|
|
988
829
|
const path = paths[i];
|
|
989
830
|
const val = get(obj, path, sep);
|
|
990
|
-
|
|
991
831
|
if (val === undefined) {
|
|
992
832
|
continue; // eslint-disable-line no-continue
|
|
993
833
|
}
|
|
994
834
|
|
|
995
835
|
set(picked, path, val, sep);
|
|
996
836
|
}
|
|
997
|
-
|
|
998
837
|
return picked;
|
|
999
838
|
};
|
|
1000
|
-
|
|
1001
839
|
module.exports = function (obj, paths) {
|
|
1002
840
|
let sep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
|
|
1003
|
-
|
|
1004
841
|
if (!isObject(obj) || !paths || !(Array.isArray(paths) || typeof paths === 'string')) {
|
|
1005
842
|
return {};
|
|
1006
843
|
}
|
|
1007
|
-
|
|
1008
844
|
const {
|
|
1009
845
|
length
|
|
1010
846
|
} = paths;
|
|
1011
|
-
|
|
1012
847
|
if (typeof paths === 'string' || length < 2) {
|
|
1013
848
|
const path = typeof paths === 'string' ? paths : paths[0];
|
|
1014
849
|
const val = get(obj, path, sep);
|
|
1015
850
|
return val !== undefined ? set({}, path, val, sep) : {};
|
|
1016
851
|
}
|
|
1017
|
-
|
|
1018
852
|
return pick(obj, paths, length, sep);
|
|
1019
853
|
};
|
|
1020
854
|
|
|
1021
855
|
},{"@strikeentco/get":2,"@strikeentco/set":3}],23:[function(require,module,exports){
|
|
1022
856
|
// shim for using process in browser
|
|
1023
|
-
var process = module.exports = {};
|
|
857
|
+
var process = module.exports = {};
|
|
858
|
+
|
|
859
|
+
// cached from whatever global is present so that test runners that stub it
|
|
1024
860
|
// don't break things. But we need to wrap it in a try catch in case it is
|
|
1025
861
|
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
|
1026
862
|
// function because try/catches deoptimize in certain engines.
|
|
1027
863
|
|
|
1028
864
|
var cachedSetTimeout;
|
|
1029
865
|
var cachedClearTimeout;
|
|
1030
|
-
|
|
1031
866
|
function defaultSetTimout() {
|
|
1032
867
|
throw new Error('setTimeout has not been defined');
|
|
1033
868
|
}
|
|
1034
|
-
|
|
1035
869
|
function defaultClearTimeout() {
|
|
1036
870
|
throw new Error('clearTimeout has not been defined');
|
|
1037
871
|
}
|
|
1038
|
-
|
|
1039
872
|
(function () {
|
|
1040
873
|
try {
|
|
1041
874
|
if (typeof setTimeout === 'function') {
|
|
@@ -1046,7 +879,6 @@ function defaultClearTimeout() {
|
|
|
1046
879
|
} catch (e) {
|
|
1047
880
|
cachedSetTimeout = defaultSetTimout;
|
|
1048
881
|
}
|
|
1049
|
-
|
|
1050
882
|
try {
|
|
1051
883
|
if (typeof clearTimeout === 'function') {
|
|
1052
884
|
cachedClearTimeout = clearTimeout;
|
|
@@ -1057,19 +889,16 @@ function defaultClearTimeout() {
|
|
|
1057
889
|
cachedClearTimeout = defaultClearTimeout;
|
|
1058
890
|
}
|
|
1059
891
|
})();
|
|
1060
|
-
|
|
1061
892
|
function runTimeout(fun) {
|
|
1062
893
|
if (cachedSetTimeout === setTimeout) {
|
|
1063
894
|
//normal enviroments in sane situations
|
|
1064
895
|
return setTimeout(fun, 0);
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
|
|
896
|
+
}
|
|
897
|
+
// if setTimeout wasn't available but was latter defined
|
|
1068
898
|
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
1069
899
|
cachedSetTimeout = setTimeout;
|
|
1070
900
|
return setTimeout(fun, 0);
|
|
1071
901
|
}
|
|
1072
|
-
|
|
1073
902
|
try {
|
|
1074
903
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
1075
904
|
return cachedSetTimeout(fun, 0);
|
|
@@ -1083,19 +912,16 @@ function runTimeout(fun) {
|
|
|
1083
912
|
}
|
|
1084
913
|
}
|
|
1085
914
|
}
|
|
1086
|
-
|
|
1087
915
|
function runClearTimeout(marker) {
|
|
1088
916
|
if (cachedClearTimeout === clearTimeout) {
|
|
1089
917
|
//normal enviroments in sane situations
|
|
1090
918
|
return clearTimeout(marker);
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
|
|
919
|
+
}
|
|
920
|
+
// if clearTimeout wasn't available but was latter defined
|
|
1094
921
|
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
1095
922
|
cachedClearTimeout = clearTimeout;
|
|
1096
923
|
return clearTimeout(marker);
|
|
1097
924
|
}
|
|
1098
|
-
|
|
1099
925
|
try {
|
|
1100
926
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
1101
927
|
return cachedClearTimeout(marker);
|
|
@@ -1110,94 +936,74 @@ function runClearTimeout(marker) {
|
|
|
1110
936
|
}
|
|
1111
937
|
}
|
|
1112
938
|
}
|
|
1113
|
-
|
|
1114
939
|
var queue = [];
|
|
1115
940
|
var draining = false;
|
|
1116
941
|
var currentQueue;
|
|
1117
942
|
var queueIndex = -1;
|
|
1118
|
-
|
|
1119
943
|
function cleanUpNextTick() {
|
|
1120
944
|
if (!draining || !currentQueue) {
|
|
1121
945
|
return;
|
|
1122
946
|
}
|
|
1123
|
-
|
|
1124
947
|
draining = false;
|
|
1125
|
-
|
|
1126
948
|
if (currentQueue.length) {
|
|
1127
949
|
queue = currentQueue.concat(queue);
|
|
1128
950
|
} else {
|
|
1129
951
|
queueIndex = -1;
|
|
1130
952
|
}
|
|
1131
|
-
|
|
1132
953
|
if (queue.length) {
|
|
1133
954
|
drainQueue();
|
|
1134
955
|
}
|
|
1135
956
|
}
|
|
1136
|
-
|
|
1137
957
|
function drainQueue() {
|
|
1138
958
|
if (draining) {
|
|
1139
959
|
return;
|
|
1140
960
|
}
|
|
1141
|
-
|
|
1142
961
|
var timeout = runTimeout(cleanUpNextTick);
|
|
1143
962
|
draining = true;
|
|
1144
963
|
var len = queue.length;
|
|
1145
|
-
|
|
1146
964
|
while (len) {
|
|
1147
965
|
currentQueue = queue;
|
|
1148
966
|
queue = [];
|
|
1149
|
-
|
|
1150
967
|
while (++queueIndex < len) {
|
|
1151
968
|
if (currentQueue) {
|
|
1152
969
|
currentQueue[queueIndex].run();
|
|
1153
970
|
}
|
|
1154
971
|
}
|
|
1155
|
-
|
|
1156
972
|
queueIndex = -1;
|
|
1157
973
|
len = queue.length;
|
|
1158
974
|
}
|
|
1159
|
-
|
|
1160
975
|
currentQueue = null;
|
|
1161
976
|
draining = false;
|
|
1162
977
|
runClearTimeout(timeout);
|
|
1163
978
|
}
|
|
1164
|
-
|
|
1165
979
|
process.nextTick = function (fun) {
|
|
1166
980
|
var args = new Array(arguments.length - 1);
|
|
1167
|
-
|
|
1168
981
|
if (arguments.length > 1) {
|
|
1169
982
|
for (var i = 1; i < arguments.length; i++) {
|
|
1170
983
|
args[i - 1] = arguments[i];
|
|
1171
984
|
}
|
|
1172
985
|
}
|
|
1173
|
-
|
|
1174
986
|
queue.push(new Item(fun, args));
|
|
1175
|
-
|
|
1176
987
|
if (queue.length === 1 && !draining) {
|
|
1177
988
|
runTimeout(drainQueue);
|
|
1178
989
|
}
|
|
1179
|
-
};
|
|
1180
|
-
|
|
990
|
+
};
|
|
1181
991
|
|
|
992
|
+
// v8 likes predictible objects
|
|
1182
993
|
function Item(fun, array) {
|
|
1183
994
|
this.fun = fun;
|
|
1184
995
|
this.array = array;
|
|
1185
996
|
}
|
|
1186
|
-
|
|
1187
997
|
Item.prototype.run = function () {
|
|
1188
998
|
this.fun.apply(null, this.array);
|
|
1189
999
|
};
|
|
1190
|
-
|
|
1191
1000
|
process.title = 'browser';
|
|
1192
1001
|
process.browser = true;
|
|
1193
1002
|
process.env = {};
|
|
1194
1003
|
process.argv = [];
|
|
1195
1004
|
process.version = ''; // empty string to avoid regexp issues
|
|
1196
|
-
|
|
1197
1005
|
process.versions = {};
|
|
1198
|
-
|
|
1199
1006
|
function noop() {}
|
|
1200
|
-
|
|
1201
1007
|
process.on = noop;
|
|
1202
1008
|
process.addListener = noop;
|
|
1203
1009
|
process.once = noop;
|
|
@@ -1207,23 +1013,18 @@ process.removeAllListeners = noop;
|
|
|
1207
1013
|
process.emit = noop;
|
|
1208
1014
|
process.prependListener = noop;
|
|
1209
1015
|
process.prependOnceListener = noop;
|
|
1210
|
-
|
|
1211
1016
|
process.listeners = function (name) {
|
|
1212
1017
|
return [];
|
|
1213
1018
|
};
|
|
1214
|
-
|
|
1215
1019
|
process.binding = function (name) {
|
|
1216
1020
|
throw new Error('process.binding is not supported');
|
|
1217
1021
|
};
|
|
1218
|
-
|
|
1219
1022
|
process.cwd = function () {
|
|
1220
1023
|
return '/';
|
|
1221
1024
|
};
|
|
1222
|
-
|
|
1223
1025
|
process.chdir = function (dir) {
|
|
1224
1026
|
throw new Error('process.chdir is not supported');
|
|
1225
1027
|
};
|
|
1226
|
-
|
|
1227
1028
|
process.umask = function () {
|
|
1228
1029
|
return 0;
|
|
1229
1030
|
};
|
|
@@ -1235,51 +1036,41 @@ process.umask = function () {
|
|
|
1235
1036
|
* Copyright (c) 2015, 2017, Jon Schlinkert.
|
|
1236
1037
|
* Released under the MIT License.
|
|
1237
1038
|
*/
|
|
1039
|
+
|
|
1238
1040
|
'use strict';
|
|
1239
1041
|
|
|
1240
1042
|
var isObject = require('isobject');
|
|
1241
|
-
|
|
1242
1043
|
var has = require('has-value');
|
|
1243
|
-
|
|
1244
1044
|
const isUnsafeKey = key => {
|
|
1245
1045
|
return key === '__proto__' || key === 'constructor' || key === 'prototype';
|
|
1246
1046
|
};
|
|
1247
|
-
|
|
1248
1047
|
const validateKey = key => {
|
|
1249
1048
|
if (isUnsafeKey(key)) {
|
|
1250
1049
|
throw new Error(`Cannot set unsafe key: "${key}"`);
|
|
1251
1050
|
}
|
|
1252
1051
|
};
|
|
1253
|
-
|
|
1254
1052
|
module.exports = function unset(obj, prop) {
|
|
1255
1053
|
if (!isObject(obj)) {
|
|
1256
1054
|
throw new TypeError('expected an object.');
|
|
1257
1055
|
}
|
|
1258
|
-
|
|
1259
1056
|
var isArray = Array.isArray(prop);
|
|
1260
|
-
|
|
1261
1057
|
if (!isArray && obj.hasOwnProperty(prop)) {
|
|
1262
1058
|
delete obj[prop];
|
|
1263
1059
|
return true;
|
|
1264
1060
|
}
|
|
1265
|
-
|
|
1266
1061
|
if (has(obj, prop)) {
|
|
1267
1062
|
var segs = isArray ? prop.slice() : prop.split('.');
|
|
1268
1063
|
var last = segs.pop();
|
|
1269
|
-
|
|
1270
1064
|
while (segs.length && segs[segs.length - 1].slice(-1) === '\\') {
|
|
1271
1065
|
last = segs.pop().slice(0, -1) + '.' + last;
|
|
1272
1066
|
}
|
|
1273
|
-
|
|
1274
1067
|
while (segs.length) {
|
|
1275
1068
|
prop = segs.shift();
|
|
1276
1069
|
validateKey(prop);
|
|
1277
1070
|
obj = obj[prop];
|
|
1278
1071
|
}
|
|
1279
|
-
|
|
1280
1072
|
return delete obj[last];
|
|
1281
1073
|
}
|
|
1282
|
-
|
|
1283
1074
|
return true;
|
|
1284
1075
|
};
|
|
1285
1076
|
|
|
@@ -1287,7 +1078,7 @@ module.exports = function unset(obj, prop) {
|
|
|
1287
1078
|
module.exports={
|
|
1288
1079
|
"name": "axe",
|
|
1289
1080
|
"description": "Axe is a logger-agnostic wrapper that normalizes logs regardless of argument style. Great for large development teams, old and new projects, and works with Pino, Bunyan, Winston, console, and more. It is lightweight, performant, highly-configurable, and automatically adds OS, CPU, and Git information to your logs. It supports hooks (useful for masking sensitive data) and dot-notation remapping, omitting, and picking of log metadata properties. Made for Forward Email, Lad, and Cabin.",
|
|
1290
|
-
"version": "10.0.
|
|
1081
|
+
"version": "10.0.2",
|
|
1291
1082
|
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com)",
|
|
1292
1083
|
"browser": {
|
|
1293
1084
|
"parse-app-info": false
|
|
@@ -1346,7 +1137,7 @@ module.exports={
|
|
|
1346
1137
|
"rimraf": "^3.0.2",
|
|
1347
1138
|
"signale": "^1.4.0",
|
|
1348
1139
|
"sinon": "^14.0.0",
|
|
1349
|
-
"tinyify": "
|
|
1140
|
+
"tinyify": "3.0.0",
|
|
1350
1141
|
"xo": "^0.50.0"
|
|
1351
1142
|
},
|
|
1352
1143
|
"engines": {
|
|
@@ -1424,64 +1215,47 @@ module.exports={
|
|
|
1424
1215
|
(function (process){(function (){
|
|
1425
1216
|
// eslint-disable-next-line import/no-unassigned-import
|
|
1426
1217
|
require('console-polyfill');
|
|
1427
|
-
|
|
1428
1218
|
const combine = require('maybe-combine-errors');
|
|
1429
|
-
|
|
1430
1219
|
const format = require('@ladjs/format-util');
|
|
1431
|
-
|
|
1432
1220
|
const formatSpecifiers = require('format-specifiers');
|
|
1433
|
-
|
|
1434
1221
|
const get = require('@strikeentco/get');
|
|
1435
|
-
|
|
1436
1222
|
const isError = require('iserror');
|
|
1437
|
-
|
|
1438
1223
|
const mergeOptions = require('merge-options');
|
|
1439
|
-
|
|
1440
1224
|
const pMapSeries = require('p-map-series');
|
|
1441
|
-
|
|
1442
1225
|
const parseAppInfo = require('parse-app-info');
|
|
1443
|
-
|
|
1444
1226
|
const parseErr = require('parse-err');
|
|
1445
|
-
|
|
1446
1227
|
const pickDeep = require('pick-deep');
|
|
1447
|
-
|
|
1448
1228
|
const set = require('@strikeentco/set');
|
|
1449
|
-
|
|
1450
1229
|
const unset = require('unset-value');
|
|
1451
|
-
|
|
1452
1230
|
const {
|
|
1453
1231
|
boolean
|
|
1454
1232
|
} = require('boolean');
|
|
1455
|
-
|
|
1456
1233
|
const pkg = require('../package.json');
|
|
1457
|
-
|
|
1458
1234
|
const omittedLoggerKeys = new Set(['config', 'log']);
|
|
1459
1235
|
const levels = ['trace', 'debug', 'info', 'warn', 'error', 'fatal'];
|
|
1460
1236
|
const aliases = {
|
|
1461
1237
|
warning: 'warn',
|
|
1462
1238
|
err: 'error'
|
|
1463
1239
|
};
|
|
1464
|
-
const levelError = `\`level\` invalid, must be: ${levels.join(', ')}`;
|
|
1240
|
+
const levelError = `\`level\` invalid, must be: ${levels.join(', ')}`;
|
|
1465
1241
|
|
|
1242
|
+
// <https://github.com/sindresorhus/is-plain-obj/blob/main/index.js>
|
|
1466
1243
|
function isPlainObject(value) {
|
|
1467
1244
|
if (typeof value !== 'object' || value === null) {
|
|
1468
1245
|
return false;
|
|
1469
1246
|
}
|
|
1470
|
-
|
|
1471
1247
|
const prototype = Object.getPrototypeOf(value);
|
|
1472
1248
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1249
|
+
}
|
|
1475
1250
|
|
|
1251
|
+
// <https://github.com/GeenenTijd/dotify/blob/master/dotify.js>
|
|
1476
1252
|
function dotifyToArray(obj) {
|
|
1477
1253
|
const res = [];
|
|
1478
|
-
|
|
1479
1254
|
function recurse(obj, current) {
|
|
1480
1255
|
for (const key of Object.keys(obj)) {
|
|
1481
1256
|
const value = obj[key];
|
|
1482
1257
|
const newKey = current ? current + '.' + key : key; // joined key with dot
|
|
1483
1258
|
// if (value && typeof value === 'object' && !(value instanceof Date) && !ObjectID.isValid(value)) {
|
|
1484
|
-
|
|
1485
1259
|
if (isPlainObject(value)) {
|
|
1486
1260
|
recurse(value, newKey); // it's a nested object, so do it again
|
|
1487
1261
|
} else {
|
|
@@ -1489,51 +1263,40 @@ function dotifyToArray(obj) {
|
|
|
1489
1263
|
}
|
|
1490
1264
|
}
|
|
1491
1265
|
}
|
|
1492
|
-
|
|
1493
1266
|
recurse(obj);
|
|
1494
1267
|
return res;
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1268
|
+
}
|
|
1497
1269
|
|
|
1270
|
+
// <https://stackoverflow.com/a/43233163>
|
|
1498
1271
|
function isEmpty(value) {
|
|
1499
1272
|
return value === undefined || value === null || typeof value === 'object' && Object.keys(value).length === 0 || typeof value === 'string' && value.trim().length === 0;
|
|
1500
1273
|
}
|
|
1501
|
-
|
|
1502
1274
|
function isNull(value) {
|
|
1503
1275
|
return value === null;
|
|
1504
1276
|
}
|
|
1505
|
-
|
|
1506
1277
|
function isUndefined(value) {
|
|
1507
1278
|
return typeof value === 'undefined';
|
|
1508
1279
|
}
|
|
1509
|
-
|
|
1510
1280
|
function isObject(value) {
|
|
1511
1281
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
1512
1282
|
}
|
|
1513
|
-
|
|
1514
1283
|
function isString(value) {
|
|
1515
1284
|
return typeof value === 'string';
|
|
1516
1285
|
}
|
|
1517
|
-
|
|
1518
1286
|
function isFunction(value) {
|
|
1519
1287
|
return typeof value === 'function';
|
|
1520
1288
|
}
|
|
1521
|
-
|
|
1522
1289
|
class Axe {
|
|
1523
1290
|
constructor() {
|
|
1524
1291
|
var _this = this;
|
|
1525
|
-
|
|
1526
1292
|
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1527
1293
|
const remappedFields = {};
|
|
1528
|
-
|
|
1529
1294
|
if (process.env.AXE_REMAPPED_META_FIELDS) {
|
|
1530
1295
|
const arr = process.env.AXE_REMAPPED_META_FIELDS.split(',').map(v => v.split(':'));
|
|
1531
|
-
|
|
1532
1296
|
for (const [prop, value] of arr) {
|
|
1533
1297
|
remappedFields[prop] = value;
|
|
1534
1298
|
}
|
|
1535
1299
|
}
|
|
1536
|
-
|
|
1537
1300
|
this.config = mergeOptions({
|
|
1538
1301
|
showStack: process.env.AXE_SHOW_STACK ? boolean(process.env.AXE_SHOW_STACK) : true,
|
|
1539
1302
|
meta: Object.assign({
|
|
@@ -1556,15 +1319,15 @@ class Axe {
|
|
|
1556
1319
|
}, typeof config.hooks === 'object' ? config.hooks : {})
|
|
1557
1320
|
}, config);
|
|
1558
1321
|
this.appInfo = this.config.appInfo ? isFunction(parseAppInfo) ? parseAppInfo() : false : false;
|
|
1559
|
-
this.log = this.log.bind(this);
|
|
1322
|
+
this.log = this.log.bind(this);
|
|
1560
1323
|
|
|
1324
|
+
// Inherit methods from parent logger
|
|
1561
1325
|
const methods = Object.keys(this.config.logger).filter(key => !omittedLoggerKeys.has(key));
|
|
1562
|
-
|
|
1563
1326
|
for (const element of methods) {
|
|
1564
1327
|
this[element] = this.config.logger[element];
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1328
|
+
}
|
|
1567
1329
|
|
|
1330
|
+
// Bind helper functions for each log level
|
|
1568
1331
|
for (const element of levels) {
|
|
1569
1332
|
// Ensure function exists in logger passed
|
|
1570
1333
|
if (typeof this.config.logger[element] !== 'function') {
|
|
@@ -1573,95 +1336,87 @@ class Axe {
|
|
|
1573
1336
|
} else {
|
|
1574
1337
|
this.config.logger[element] = this.config.logger.info || this.config.logger.log;
|
|
1575
1338
|
}
|
|
1576
|
-
}
|
|
1577
|
-
|
|
1339
|
+
}
|
|
1578
1340
|
|
|
1341
|
+
// Bind log handler which normalizes args and populates meta
|
|
1579
1342
|
this[element] = function () {
|
|
1580
1343
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1581
1344
|
args[_key] = arguments[_key];
|
|
1582
1345
|
}
|
|
1583
|
-
|
|
1584
1346
|
return _this.log(element, ...Array.prototype.slice.call(args));
|
|
1585
1347
|
};
|
|
1586
1348
|
}
|
|
1587
|
-
|
|
1588
1349
|
this.setLevel = this.setLevel.bind(this);
|
|
1589
1350
|
this.getNormalizedLevel = this.getNormalizedLevel.bind(this);
|
|
1590
|
-
this.setName = this.setName.bind(this);
|
|
1351
|
+
this.setName = this.setName.bind(this);
|
|
1591
1352
|
|
|
1592
|
-
|
|
1353
|
+
// Set the logger name
|
|
1354
|
+
if (this.config.name) this.setName(this.config.name);
|
|
1593
1355
|
|
|
1594
|
-
|
|
1356
|
+
// Set the logger level
|
|
1357
|
+
this.setLevel(this.config.level);
|
|
1595
1358
|
|
|
1359
|
+
// Aliases
|
|
1596
1360
|
this.err = this.error;
|
|
1597
|
-
this.warning = this.warn;
|
|
1361
|
+
this.warning = this.warn;
|
|
1598
1362
|
|
|
1363
|
+
// Pre and Post Hooks
|
|
1599
1364
|
this.pre = function (level, fn) {
|
|
1600
1365
|
this.config.hooks.pre.push(function (_level) {
|
|
1601
1366
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1602
1367
|
args[_key2 - 1] = arguments[_key2];
|
|
1603
1368
|
}
|
|
1604
|
-
|
|
1605
1369
|
if (level !== _level) return [...args];
|
|
1606
1370
|
return fn(...args);
|
|
1607
1371
|
});
|
|
1608
1372
|
};
|
|
1609
|
-
|
|
1610
1373
|
this.post = function (level, fn) {
|
|
1611
1374
|
this.config.hooks.post.push(function (_level) {
|
|
1612
1375
|
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
1613
1376
|
args[_key3 - 1] = arguments[_key3];
|
|
1614
1377
|
}
|
|
1615
|
-
|
|
1616
1378
|
if (level !== _level) return [...args];
|
|
1617
1379
|
return fn(...args);
|
|
1618
1380
|
});
|
|
1619
1381
|
};
|
|
1620
1382
|
}
|
|
1621
|
-
|
|
1622
1383
|
setLevel(level) {
|
|
1623
|
-
if (!isString(level) || levels.indexOf(level) === -1) throw new Error(levelError);
|
|
1624
|
-
|
|
1625
|
-
if (isString(this.config.logger.logLevel)) this.config.logger.logLevel = level;else this.config.logger.level = level;
|
|
1384
|
+
if (!isString(level) || levels.indexOf(level) === -1) throw new Error(levelError);
|
|
1385
|
+
// Support signale logger and other loggers that use `logLevel`
|
|
1386
|
+
if (isString(this.config.logger.logLevel)) this.config.logger.logLevel = level;else this.config.logger.level = level;
|
|
1387
|
+
// Adjusts `this.config.levels` array
|
|
1626
1388
|
// so that it has all proceeding (inclusive)
|
|
1627
|
-
|
|
1628
1389
|
this.config.levels = levels.slice(levels.indexOf(level));
|
|
1629
1390
|
}
|
|
1630
|
-
|
|
1631
1391
|
getNormalizedLevel(level) {
|
|
1632
1392
|
if (!isString(level)) return 'info';
|
|
1633
1393
|
if (isString(aliases[level])) return aliases[level];
|
|
1634
1394
|
if (levels.indexOf(level) === -1) return 'info';
|
|
1635
1395
|
return level;
|
|
1636
1396
|
}
|
|
1637
|
-
|
|
1638
1397
|
setName(name) {
|
|
1639
|
-
if (!isString(name)) throw new Error('`name` must be a String');
|
|
1640
|
-
|
|
1398
|
+
if (!isString(name)) throw new Error('`name` must be a String');
|
|
1399
|
+
// Support signale logger and other loggers that use `scope`
|
|
1641
1400
|
if (isString(this.config.logger.scope)) this.config.logger.scope = name;else this.config.logger.name = name;
|
|
1642
|
-
}
|
|
1643
|
-
|
|
1401
|
+
}
|
|
1644
1402
|
|
|
1403
|
+
// eslint-disable-next-line complexity
|
|
1645
1404
|
log(level, message, meta) {
|
|
1646
1405
|
const originalArgs = [];
|
|
1647
1406
|
const errors = [];
|
|
1648
1407
|
if (!isUndefined(level)) originalArgs.push(level);
|
|
1649
1408
|
if (!isUndefined(message)) originalArgs.push(message);
|
|
1650
1409
|
if (!isUndefined(meta)) originalArgs.push(meta);
|
|
1651
|
-
|
|
1652
1410
|
for (var _len4 = arguments.length, args = new Array(_len4 > 3 ? _len4 - 3 : 0), _key4 = 3; _key4 < _len4; _key4++) {
|
|
1653
1411
|
args[_key4 - 3] = arguments[_key4];
|
|
1654
1412
|
}
|
|
1655
|
-
|
|
1656
1413
|
for (const arg of Array.prototype.slice.call(args)) {
|
|
1657
1414
|
originalArgs.push(arg);
|
|
1658
1415
|
}
|
|
1659
|
-
|
|
1660
1416
|
const {
|
|
1661
1417
|
config
|
|
1662
1418
|
} = this;
|
|
1663
1419
|
let modifier = 0;
|
|
1664
|
-
|
|
1665
1420
|
if (isString(level) && isString(aliases[level])) {
|
|
1666
1421
|
level = aliases[level];
|
|
1667
1422
|
} else if (isError(level)) {
|
|
@@ -1673,24 +1428,25 @@ class Axe {
|
|
|
1673
1428
|
message = level;
|
|
1674
1429
|
level = this.getNormalizedLevel(level);
|
|
1675
1430
|
modifier = -1;
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1431
|
+
}
|
|
1678
1432
|
|
|
1679
|
-
|
|
1433
|
+
// Return early if it is not a valid logging level
|
|
1434
|
+
if (config.levels.indexOf(level) === -1) return;
|
|
1680
1435
|
|
|
1436
|
+
// Bunyan support (meta, message, ...args)
|
|
1681
1437
|
let isBunyan = false;
|
|
1682
|
-
|
|
1683
1438
|
if ((isObject(message) || Array.isArray(message)) && isString(meta)) {
|
|
1684
1439
|
isBunyan = true;
|
|
1685
1440
|
const _meta = meta;
|
|
1686
1441
|
meta = message;
|
|
1687
1442
|
message = isString(_meta) && originalArgs.length >= 3 + modifier ? format(...originalArgs.slice(2 + modifier)) : _meta;
|
|
1688
|
-
}
|
|
1443
|
+
}
|
|
1689
1444
|
|
|
1445
|
+
// If message was undefined then set it to level
|
|
1446
|
+
if (isUndefined(message)) message = level;
|
|
1690
1447
|
|
|
1691
|
-
|
|
1448
|
+
// If only `message` was passed then if it was an Object
|
|
1692
1449
|
// preserve it as an Object by setting it as meta
|
|
1693
|
-
|
|
1694
1450
|
if (originalArgs.slice(1 + modifier).length === 1 && !isString(message) && !isError(message)) {
|
|
1695
1451
|
meta = {
|
|
1696
1452
|
message
|
|
@@ -1700,11 +1456,9 @@ class Axe {
|
|
|
1700
1456
|
message = undefined;
|
|
1701
1457
|
meta = {};
|
|
1702
1458
|
const messages = [];
|
|
1703
|
-
|
|
1704
1459
|
for (const arg of originalArgs) {
|
|
1705
1460
|
if (isError(arg)) errors.push(arg);else if (isString(arg)) messages.push(arg);
|
|
1706
1461
|
}
|
|
1707
|
-
|
|
1708
1462
|
if (errors.length === 0 && messages.length > 0) message = format(...messages);else if (errors.length > 0 && level === 'log') level = 'error';
|
|
1709
1463
|
} else if (!isBunyan && originalArgs.length === 3 + modifier && isString(message) && formatSpecifiers.some(t => message.indexOf(t) !== -1)) {
|
|
1710
1464
|
// Otherwise if there are three args and if the `message` contains
|
|
@@ -1727,49 +1481,48 @@ class Axe {
|
|
|
1727
1481
|
message = format(message);
|
|
1728
1482
|
}
|
|
1729
1483
|
} else if (isError(meta)) {
|
|
1730
|
-
errors.push(meta);
|
|
1731
|
-
|
|
1484
|
+
errors.push(meta);
|
|
1485
|
+
// handle additional args
|
|
1732
1486
|
for (const arg of originalArgs.slice(2 + modifier)) {
|
|
1733
1487
|
// should skip this better with slice and modifier adjustment
|
|
1734
1488
|
if (meta === arg) continue;
|
|
1735
1489
|
if (isError(arg)) errors.push(arg);
|
|
1736
1490
|
}
|
|
1737
|
-
|
|
1738
1491
|
meta = {};
|
|
1739
1492
|
}
|
|
1740
|
-
|
|
1741
1493
|
if (!isUndefined(meta) && !isObject(meta)) meta = {
|
|
1742
1494
|
original_meta: meta
|
|
1743
1495
|
};else if (!isObject(meta)) meta = {};
|
|
1744
|
-
|
|
1745
1496
|
if (isError(message)) {
|
|
1746
1497
|
errors.unshift(message);
|
|
1747
1498
|
message = undefined;
|
|
1748
|
-
}
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
//
|
|
1749
1502
|
// rewrite `meta.err` to `meta.original_err` for consistency
|
|
1750
1503
|
// (in case someone has an object with `.err` property on it with an error)
|
|
1751
1504
|
//
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
1505
|
if (isObject(meta.err)) {
|
|
1755
1506
|
if (isError(meta.err)) errors.push(meta.err);
|
|
1756
1507
|
meta.original_err = isError(meta.err) ? parseErr(meta.err) : meta.err;
|
|
1757
1508
|
}
|
|
1758
|
-
|
|
1759
1509
|
let err;
|
|
1760
|
-
|
|
1761
1510
|
if (errors.length > 0) {
|
|
1762
1511
|
err = combine(errors);
|
|
1763
1512
|
meta.err = parseErr(err);
|
|
1764
1513
|
if (!isString(message)) message = err.message;
|
|
1765
|
-
}
|
|
1514
|
+
}
|
|
1766
1515
|
|
|
1516
|
+
// Set `args` prop with original arguments passed
|
|
1517
|
+
meta.args = originalArgs;
|
|
1767
1518
|
|
|
1768
|
-
|
|
1519
|
+
// Set default level on meta
|
|
1520
|
+
meta.level = level;
|
|
1769
1521
|
|
|
1770
|
-
|
|
1522
|
+
// Add `app` object to metadata
|
|
1523
|
+
if (this.appInfo) meta.app = this.appInfo;
|
|
1771
1524
|
|
|
1772
|
-
|
|
1525
|
+
//
|
|
1773
1526
|
// determine log method to use
|
|
1774
1527
|
//
|
|
1775
1528
|
// if we didn't pass a level as a method
|
|
@@ -1778,8 +1531,9 @@ class Axe {
|
|
|
1778
1531
|
//
|
|
1779
1532
|
// and fatal should use error (e.g. in browser)
|
|
1780
1533
|
//
|
|
1534
|
+
const method = modifier === -1 ? 'log' : level;
|
|
1781
1535
|
|
|
1782
|
-
|
|
1536
|
+
//
|
|
1783
1537
|
// NOTE: using lodash _.omit and _.pick would have been _very slow_
|
|
1784
1538
|
//
|
|
1785
1539
|
// const omittedAndPickedFields = {
|
|
@@ -1795,8 +1549,8 @@ class Axe {
|
|
|
1795
1549
|
if (!isEmpty(this.config.meta.remappedFields)) {
|
|
1796
1550
|
for (const key of Object.keys(this.config.meta.remappedFields)) {
|
|
1797
1551
|
set(meta, this.config.meta.remappedFields[key], get(meta, key));
|
|
1798
|
-
unset(meta, key);
|
|
1799
|
-
|
|
1552
|
+
unset(meta, key);
|
|
1553
|
+
// cleanup empty objects after remapping
|
|
1800
1554
|
if (this.config.meta.cleanupRemapping) {
|
|
1801
1555
|
const index = key.lastIndexOf('.');
|
|
1802
1556
|
if (index === -1) continue;
|
|
@@ -1805,9 +1559,9 @@ class Axe {
|
|
|
1805
1559
|
}
|
|
1806
1560
|
}
|
|
1807
1561
|
}
|
|
1808
|
-
|
|
1809
1562
|
if (!isEmpty(this.config.meta.omittedFields) || !isEmpty(this.config.meta.pickedFields)) {
|
|
1810
|
-
const dotified = dotifyToArray(meta);
|
|
1563
|
+
const dotified = dotifyToArray(meta);
|
|
1564
|
+
// dotified = [
|
|
1811
1565
|
// 'err.name',
|
|
1812
1566
|
// 'err.message',
|
|
1813
1567
|
// 'err.stack',
|
|
@@ -1823,13 +1577,11 @@ class Axe {
|
|
|
1823
1577
|
for (const prop of this.config.meta.omittedFields) {
|
|
1824
1578
|
// <https://stackoverflow.com/a/9882349>
|
|
1825
1579
|
let i = dotified.length;
|
|
1826
|
-
|
|
1827
1580
|
while (i--) {
|
|
1828
1581
|
if (dotified[i] === prop || dotified[i].indexOf(`${prop}.`) === 0) dotified.splice(i, 1);
|
|
1829
1582
|
}
|
|
1830
1583
|
}
|
|
1831
1584
|
}
|
|
1832
|
-
|
|
1833
1585
|
if (!isEmpty(this.config.meta.pickedFields)) {
|
|
1834
1586
|
for (const prop of this.config.meta.pickedFields) {
|
|
1835
1587
|
// response.headers.boop
|
|
@@ -1841,30 +1593,28 @@ class Axe {
|
|
|
1841
1593
|
// so we need to split by the first period and omit any keys from dotified starting with it
|
|
1842
1594
|
const index = prop.indexOf('.');
|
|
1843
1595
|
const key = prop.slice(0, index + 1);
|
|
1844
|
-
|
|
1845
1596
|
if (index !== -1) {
|
|
1846
1597
|
let i = dotified.length;
|
|
1847
|
-
|
|
1848
1598
|
while (i--) {
|
|
1849
1599
|
if (dotified[i].indexOf(key) === 0) dotified.splice(i, 1);
|
|
1850
1600
|
}
|
|
1851
|
-
}
|
|
1852
|
-
|
|
1601
|
+
}
|
|
1853
1602
|
|
|
1603
|
+
// finally add it if it did not already exist
|
|
1854
1604
|
if (dotified.indexOf(prop) === -1) dotified.push(prop);
|
|
1855
1605
|
}
|
|
1856
|
-
}
|
|
1857
|
-
|
|
1606
|
+
}
|
|
1858
1607
|
|
|
1608
|
+
// now we call pick-deep using the final array
|
|
1859
1609
|
meta = pickDeep(meta, dotified);
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1610
|
+
}
|
|
1862
1611
|
|
|
1612
|
+
// pre-hooks
|
|
1863
1613
|
for (const hook of this.config.hooks.pre) {
|
|
1864
1614
|
[err, message, meta] = hook(method, err, message, meta);
|
|
1865
|
-
}
|
|
1866
|
-
|
|
1615
|
+
}
|
|
1867
1616
|
|
|
1617
|
+
// only invoke logger methods if it was not silent
|
|
1868
1618
|
if (!config.silent) {
|
|
1869
1619
|
// Show stack trace if necessary (along with any metadata)
|
|
1870
1620
|
if (isError(err) && config.showStack) {
|
|
@@ -1878,16 +1628,14 @@ class Axe {
|
|
|
1878
1628
|
} else {
|
|
1879
1629
|
this.config.logger[method](message, meta);
|
|
1880
1630
|
}
|
|
1881
|
-
}
|
|
1882
|
-
|
|
1631
|
+
}
|
|
1883
1632
|
|
|
1633
|
+
// post-hooks
|
|
1884
1634
|
pMapSeries(this.config.hooks.post, hook => hook(method, err, message, meta)).then().catch(err => {
|
|
1885
1635
|
this.config.logger.error(err);
|
|
1886
1636
|
});
|
|
1887
1637
|
}
|
|
1888
|
-
|
|
1889
1638
|
}
|
|
1890
|
-
|
|
1891
1639
|
module.exports = Axe;
|
|
1892
1640
|
|
|
1893
1641
|
}).call(this)}).call(this,require('_process'))
|