newrelic 8.5.2 → 8.6.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/NEWS.md +12 -0
- package/api.js +121 -135
- package/lib/agent.js +11 -2
- package/lib/context-manager/create-context-manager.js +32 -0
- package/lib/context-manager/diagnostics/legacy-diagnostic-context-manager.js +36 -0
- package/lib/context-manager/legacy-context-manager.js +66 -0
- package/lib/instrumentation/promise.js +28 -41
- package/lib/shim/message-shim.js +45 -90
- package/lib/shim/shim.js +139 -324
- package/lib/shim/transaction-shim.js +9 -39
- package/lib/shimmer.js +110 -10
- package/lib/transaction/tracer/index.js +24 -22
- package/package.json +2 -1
package/lib/shim/shim.js
CHANGED
|
@@ -20,10 +20,8 @@ const fnApply = Function.prototype.apply
|
|
|
20
20
|
/**
|
|
21
21
|
* Constructs a shim associated with the given agent instance.
|
|
22
22
|
*
|
|
23
|
-
* @
|
|
24
|
-
* @classdesc
|
|
25
|
-
* A helper class for wrapping modules with segments.
|
|
26
|
-
*
|
|
23
|
+
* @class
|
|
24
|
+
* @classdesc A helper class for wrapping modules with segments.
|
|
27
25
|
* @param {Agent} agent - The agent this shim will use.
|
|
28
26
|
* @param {string} moduleName - The name of the module being instrumented.
|
|
29
27
|
* @param {string} resolvedName - The full path to the loaded module.
|
|
@@ -35,6 +33,7 @@ function Shim(agent, moduleName, resolvedName) {
|
|
|
35
33
|
|
|
36
34
|
this._logger = logger.child({ module: moduleName })
|
|
37
35
|
this._agent = agent
|
|
36
|
+
this._contextManager = agent._contextManager
|
|
38
37
|
this._toExport = null
|
|
39
38
|
this._debug = false
|
|
40
39
|
this.defineProperty(this, 'moduleName', moduleName)
|
|
@@ -68,6 +67,7 @@ defineProperties(Shim.prototype, {
|
|
|
68
67
|
*
|
|
69
68
|
* @readonly
|
|
70
69
|
* @member {Agent} Shim.prototype.agent
|
|
70
|
+
* @returns {Agent} The instance of the agent.
|
|
71
71
|
*/
|
|
72
72
|
agent: function getAgent() {
|
|
73
73
|
return this._agent
|
|
@@ -78,6 +78,7 @@ defineProperties(Shim.prototype, {
|
|
|
78
78
|
*
|
|
79
79
|
* @readonly
|
|
80
80
|
* @member {Tracer} Shim.prototype.tracer
|
|
81
|
+
* @returns {Tracer} The instance of the tracer
|
|
81
82
|
*/
|
|
82
83
|
tracer: function getTracer() {
|
|
83
84
|
return this._agent.tracer
|
|
@@ -88,6 +89,7 @@ defineProperties(Shim.prototype, {
|
|
|
88
89
|
*
|
|
89
90
|
* @readonly
|
|
90
91
|
* @member {Logger} Shim.prototype.logger
|
|
92
|
+
* @returns {Logger} The logger.
|
|
91
93
|
*/
|
|
92
94
|
logger: function getLogger() {
|
|
93
95
|
return this._logger
|
|
@@ -148,37 +150,28 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
148
150
|
|
|
149
151
|
/**
|
|
150
152
|
* @callback WrapFunction
|
|
151
|
-
*
|
|
152
153
|
* @summary
|
|
153
154
|
* A function which performs the actual wrapping logic.
|
|
154
|
-
*
|
|
155
155
|
* @description
|
|
156
156
|
* If the return value of this function is not `original` then the return value
|
|
157
157
|
* will be marked as a wrapper.
|
|
158
|
-
*
|
|
159
158
|
* @param {Shim} shim
|
|
160
159
|
* The shim this function was passed to.
|
|
161
|
-
*
|
|
162
|
-
* @param {Object|Function} original
|
|
160
|
+
* @param {object|Function} original
|
|
163
161
|
* The item which needs wrapping. Most of the time this will be a function.
|
|
164
|
-
*
|
|
165
162
|
* @param {string} name
|
|
166
163
|
* The name of `original` if it can be determined, otherwise `'<anonymous>'`.
|
|
167
|
-
*
|
|
168
|
-
* @return {*} The wrapper for the original, or the original value itself.
|
|
164
|
+
* @returns {*} The wrapper for the original, or the original value itself.
|
|
169
165
|
*/
|
|
170
166
|
|
|
171
167
|
/**
|
|
172
168
|
* @private
|
|
173
169
|
* @callback ArrayWrapFunction
|
|
174
|
-
*
|
|
175
170
|
* @description
|
|
176
171
|
* A wrap function used on elements of an array. In addition to the parameters
|
|
177
172
|
* of `WrapFunction`, these also receive an `index` and `total` as described
|
|
178
173
|
* below.
|
|
179
|
-
*
|
|
180
174
|
* @see WrapFunction
|
|
181
|
-
*
|
|
182
175
|
* @param {number} index - The index of the current element in the array.
|
|
183
176
|
* @param {number} total - The total number of items in the array.
|
|
184
177
|
*/
|
|
@@ -186,81 +179,59 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
186
179
|
/**
|
|
187
180
|
* @private
|
|
188
181
|
* @callback ArgumentsFunction
|
|
189
|
-
*
|
|
190
182
|
* @param {Shim} shim
|
|
191
183
|
* The shim this function was passed to.
|
|
192
|
-
*
|
|
193
184
|
* @param {Function} func
|
|
194
185
|
* The function these arguments were passed to.
|
|
195
|
-
*
|
|
196
186
|
* @param {*} context
|
|
197
187
|
* The context the function is executing under (i.e. `this`).
|
|
198
|
-
*
|
|
199
188
|
* @param {Array.<*>} args
|
|
200
189
|
* The arguments being passed into the function.
|
|
201
190
|
*/
|
|
202
191
|
|
|
203
192
|
/**
|
|
204
193
|
* @callback SegmentFunction
|
|
205
|
-
*
|
|
206
194
|
* @summary
|
|
207
195
|
* A function which is called to compose a segment.
|
|
208
|
-
*
|
|
209
196
|
* @param {Shim} shim
|
|
210
197
|
* The shim this function was passed to.
|
|
211
|
-
*
|
|
212
198
|
* @param {Function} func
|
|
213
199
|
* The function the segment is created for.
|
|
214
|
-
*
|
|
215
200
|
* @param {string} name
|
|
216
201
|
* The name of the function.
|
|
217
|
-
*
|
|
218
202
|
* @param {Array.<*>} args
|
|
219
203
|
* The arguments being passed into the function.
|
|
220
|
-
*
|
|
221
|
-
* @return {string|SegmentSpec} The desired properties for the new segment.
|
|
204
|
+
* @returns {string|SegmentSpec} The desired properties for the new segment.
|
|
222
205
|
*/
|
|
223
206
|
|
|
224
207
|
/**
|
|
225
208
|
* @callback RecorderFunction
|
|
226
|
-
*
|
|
227
209
|
* @summary
|
|
228
210
|
* A function which is called to compose a segment for recording.
|
|
229
|
-
*
|
|
230
211
|
* @param {Shim} shim
|
|
231
212
|
* The shim this function was passed to.
|
|
232
|
-
*
|
|
233
213
|
* @param {Function} func
|
|
234
214
|
* The function being recorded.
|
|
235
|
-
*
|
|
236
215
|
* @param {string} name
|
|
237
216
|
* The name of the function.
|
|
238
|
-
*
|
|
239
217
|
* @param {Array.<*>} args
|
|
240
218
|
* The arguments being passed into the function.
|
|
241
|
-
*
|
|
242
|
-
* @return {string|RecorderSpec} The desired properties for the new segment.
|
|
219
|
+
* @returns {string|RecorderSpec} The desired properties for the new segment.
|
|
243
220
|
*/
|
|
244
221
|
|
|
245
222
|
/**
|
|
246
223
|
* @callback CallbackBindFunction
|
|
247
|
-
*
|
|
248
224
|
* @summary
|
|
249
225
|
* Performs segment binding on a callback function. Useful when identifying a
|
|
250
226
|
* callback is more complex than a simple argument offset.
|
|
251
|
-
*
|
|
252
227
|
* @param {Shim} shim
|
|
253
228
|
* The shim this function was passed to.
|
|
254
|
-
*
|
|
255
229
|
* @param {Function} func
|
|
256
230
|
* The function being recorded.
|
|
257
|
-
*
|
|
258
231
|
* @param {string} name
|
|
259
232
|
* The name of the function.
|
|
260
|
-
*
|
|
261
233
|
* @param {TraceSegment} segment
|
|
262
234
|
* The segment that the callback should be bound to.
|
|
263
|
-
*
|
|
264
235
|
* @param {Array.<*>} args
|
|
265
236
|
* The arguments being passed into the function.
|
|
266
237
|
*/
|
|
@@ -268,47 +239,37 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
268
239
|
/**
|
|
269
240
|
* @private
|
|
270
241
|
* @callback MetricFunction
|
|
271
|
-
*
|
|
272
242
|
* @summary
|
|
273
243
|
* Measures all the necessary metrics for the given segment. This functionality
|
|
274
244
|
* is meant to be used by Shim subclasses, instrumentations should never create
|
|
275
245
|
* their own recorders.
|
|
276
|
-
*
|
|
277
246
|
* @param {TraceSegment} segment - The segment to record.
|
|
278
247
|
* @param {string} [scope] - The scope of the recording.
|
|
279
248
|
*/
|
|
280
249
|
|
|
281
250
|
/**
|
|
282
251
|
* @callback ConstructorHookFunction
|
|
283
|
-
*
|
|
284
252
|
* @summary
|
|
285
253
|
* Pre/post constructor execution hook for wrapping classes. Used by
|
|
286
254
|
* {@link ClassWrapSpec}.
|
|
287
|
-
*
|
|
288
255
|
* @param {Shim} shim
|
|
289
256
|
* The shim performing the wrapping/binding.
|
|
290
|
-
*
|
|
291
257
|
* @param {Function} Base
|
|
292
258
|
* The class that was wrapped.
|
|
293
|
-
*
|
|
294
259
|
* @param {string} name
|
|
295
260
|
* The name of the `Base` class.
|
|
296
|
-
*
|
|
297
261
|
* @param {Array.<*>} args
|
|
298
262
|
* The arguments to the class constructor.
|
|
299
|
-
*
|
|
300
263
|
* @see ClassWrapSpec
|
|
301
264
|
*/
|
|
302
265
|
|
|
303
266
|
/**
|
|
304
267
|
* @private
|
|
305
268
|
* @interface Spec
|
|
306
|
-
*
|
|
307
269
|
* @description
|
|
308
270
|
* The syntax for declarative instrumentation. It can be used interlaced with
|
|
309
271
|
* custom, hand-written instrumentation for one-off or hard to simplify
|
|
310
272
|
* instrumentation logic.
|
|
311
|
-
*
|
|
312
273
|
* @property {Spec|WrapFunction} $return
|
|
313
274
|
* Changes the context to the return value of the current context. This means
|
|
314
275
|
* the sub spec will not be executed up front, but instead upon every execution
|
|
@@ -318,7 +279,6 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
318
279
|
* var ret = func.apply(this, args);
|
|
319
280
|
* return shim.wrap(ret, spec.$return)
|
|
320
281
|
* ```
|
|
321
|
-
*
|
|
322
282
|
* @property {Spec|WrapFunction} $proto
|
|
323
283
|
* Changes the context to the prototype of the current context. The prototype
|
|
324
284
|
* is found using `Object.getPrototypeOf`.
|
|
@@ -326,7 +286,6 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
326
286
|
* ```js
|
|
327
287
|
* shim.wrap(Object.getPrototypeOf(context), spec.$proto)
|
|
328
288
|
* ```
|
|
329
|
-
*
|
|
330
289
|
* @property {bool} $once
|
|
331
290
|
* Ensures that the parent spec will only be executed one time if the value is
|
|
332
291
|
* `true`. Good for preventing double wrapping of prototype methods.
|
|
@@ -337,7 +296,6 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
337
296
|
* }
|
|
338
297
|
* spec.__NR_onceExecuted = true
|
|
339
298
|
* ```
|
|
340
|
-
*
|
|
341
299
|
* @property {ArgumentsFunction} $arguments
|
|
342
300
|
* Executes the function with all of the arguments passed in. The arguments can
|
|
343
301
|
* be modified in place. This will execute before `$eachArgument`.
|
|
@@ -345,7 +303,6 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
345
303
|
* ```js
|
|
346
304
|
* spec.$arguments(args)
|
|
347
305
|
* ```
|
|
348
|
-
*
|
|
349
306
|
* @property {Spec|ArrayWrapFunction} $eachArgument
|
|
350
307
|
* Executes `shim.wrap` on each argument passed to the current context. The
|
|
351
308
|
* returned arguments will then be used to actually execute the function.
|
|
@@ -361,7 +318,6 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
361
318
|
* }
|
|
362
319
|
* func.apply(this, args)
|
|
363
320
|
* ```
|
|
364
|
-
*
|
|
365
321
|
* @property {Array.<{$properties: Array.<string>, $spec: Spec}>} $wrappings
|
|
366
322
|
* Executes `shim.wrap` with the current context as the `nodule` for each
|
|
367
323
|
* element in the array. The `$properties` sub-key must list one or more
|
|
@@ -373,7 +329,6 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
373
329
|
* shim.wrap(context, $wrap.$properties, $wrap.$spec)
|
|
374
330
|
* })
|
|
375
331
|
* ```
|
|
376
|
-
*
|
|
377
332
|
* @property {bool|string|SegmentFunction} $segment
|
|
378
333
|
* Controls segment creation. If a falsey value (i.e. `undefined`, `false`,
|
|
379
334
|
* `null`, etc) then no segment will be created. If the value is `true`, then
|
|
@@ -395,8 +350,7 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
395
350
|
* segment = shim.createSegment(seg.name, seg.recorder, seg.parent)
|
|
396
351
|
* }
|
|
397
352
|
* ```
|
|
398
|
-
*
|
|
399
|
-
* @property {Object.<string, *>} $cache
|
|
353
|
+
* @property {object.<string, *>} $cache
|
|
400
354
|
* Adds the value as an extra parameter to all specs in the same context as the
|
|
401
355
|
* cache. If the current context is a function, the cache will be recreated on
|
|
402
356
|
* each invocation of the function. This value can be useful for passing a
|
|
@@ -408,7 +362,6 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
408
362
|
* args.push({})
|
|
409
363
|
* }
|
|
410
364
|
* ```
|
|
411
|
-
*
|
|
412
365
|
* @property {number} $callback
|
|
413
366
|
* Indicates that one of the parameters is a callback which should be wrapped.
|
|
414
367
|
*
|
|
@@ -421,7 +374,6 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
421
374
|
* args[idx] = shim.bindSegment(args[idx], segment)
|
|
422
375
|
* }
|
|
423
376
|
* ```
|
|
424
|
-
*
|
|
425
377
|
* @property {Spec|WrapFunction} property
|
|
426
378
|
* Any field which does not start with a `$` is assumed to name a property on
|
|
427
379
|
* the current context which should be wrapped. This is simply shorthand for a
|
|
@@ -430,56 +382,45 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
430
382
|
|
|
431
383
|
/**
|
|
432
384
|
* @interface SegmentSpec
|
|
433
|
-
*
|
|
434
385
|
* @description
|
|
435
386
|
* The return value from a {@link SegmentFunction}, used to set the parameters
|
|
436
387
|
* of segment creation.
|
|
437
|
-
*
|
|
438
388
|
* @property {string} name
|
|
439
389
|
* The name for the segment to-be.
|
|
440
|
-
*
|
|
441
390
|
* @property {MetricFunction} [recorder]
|
|
442
391
|
* A metric recorder for the segment. This is purely for internal use by shim
|
|
443
392
|
* classes. Instrumentations should never implement their own metric functions.
|
|
444
|
-
*
|
|
445
393
|
* @property {TraceSegment} [parent]
|
|
446
394
|
* The parent segment. Defaults to the currently active segment.
|
|
447
|
-
*
|
|
448
395
|
* @see RecorderSpec
|
|
449
396
|
* @see SegmentFunction
|
|
450
397
|
*/
|
|
451
398
|
|
|
452
399
|
/**
|
|
453
400
|
* @interface RecorderSpec
|
|
454
|
-
* @
|
|
455
|
-
*
|
|
401
|
+
* @augments SegmentSpec
|
|
456
402
|
* @description
|
|
457
403
|
* The return value from a {@link RecorderFunction}, used to set the parameters
|
|
458
404
|
* of segment creation and lifetime. Extends the {@link SegmentSpec}.
|
|
459
|
-
*
|
|
460
405
|
* @property {bool|string} [stream]
|
|
461
406
|
* Indicates if the return value from the wrapped function is a stream. If the
|
|
462
407
|
* value is truthy then the recording will extend to the `end` event of the
|
|
463
408
|
* stream. If the value is a string it is assumed to be the name of an event to
|
|
464
409
|
* measure. A segment will be created to record emissions of the event.
|
|
465
|
-
*
|
|
466
410
|
* @property {bool} [promise]
|
|
467
411
|
* Indicates if the return value from the wrapped function is a Promise. If the
|
|
468
412
|
* value is truthy then the recording will extend to the completion of the
|
|
469
413
|
* Promise.
|
|
470
|
-
*
|
|
471
414
|
* @property {number|CallbackBindFunction} [callback]
|
|
472
415
|
* If this is a number, it identifies which argument is the callback and the
|
|
473
416
|
* segment will also be bound to the callback. Otherwise, the passed function
|
|
474
417
|
* should perform the segment binding itself.
|
|
475
|
-
*
|
|
476
418
|
* @property {number|CallbackBindFunction} [rowCallback]
|
|
477
419
|
* Like `callback`, this identifies a callback function in the arguments. The
|
|
478
420
|
* difference is that the default behavior for row callbacks is to only create
|
|
479
421
|
* one segment for all calls to the callback. This is mostly useful for
|
|
480
422
|
* functions which will be called repeatedly, such as once for each item in a
|
|
481
423
|
* result set.
|
|
482
|
-
*
|
|
483
424
|
* @property {bool} [internal=false]
|
|
484
425
|
* Marks this as the boundary point into the instrumented library. If `true`
|
|
485
426
|
* and the current segment is _also_ marked as `internal` by the same shim,
|
|
@@ -489,36 +430,29 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
489
430
|
* methods which simply call other public methods and you only want to record
|
|
490
431
|
* the method directly called by the user while still instrumenting all
|
|
491
432
|
* endpoints.
|
|
492
|
-
*
|
|
493
|
-
* @property {function} [after=null]
|
|
433
|
+
* @property {Function} [after=null]
|
|
494
434
|
* A function to call after the synchronous execution of the recorded method.
|
|
495
435
|
* If the function synchronously threw an error, that error will be handed to
|
|
496
436
|
* this function.
|
|
497
|
-
*
|
|
498
437
|
* @property {bool} [callbackRequired]
|
|
499
438
|
* When `true`, a recorded method must be called with a callback for a segment
|
|
500
439
|
* to be created. Does not apply if a custom callback method has been assigned
|
|
501
440
|
* via {@link callback}.
|
|
502
|
-
*
|
|
503
441
|
* @see SegmentSpec
|
|
504
442
|
* @see RecorderFunction
|
|
505
443
|
*/
|
|
506
444
|
|
|
507
445
|
/**
|
|
508
446
|
* @interface ClassWrapSpec
|
|
509
|
-
*
|
|
510
447
|
* @description
|
|
511
448
|
* Specifies the style of wrapping and construction hooks for wrapping classes.
|
|
512
|
-
*
|
|
513
449
|
* @property {bool} [es6=false]
|
|
514
450
|
* @property {ConstructorHookFunction} [pre=null]
|
|
515
451
|
* A function called with the constructor's arguments before the base class'
|
|
516
452
|
* constructor is executed. The `this` value will be `null`.
|
|
517
|
-
*
|
|
518
453
|
* @property {ConstructorHookFunction} [post=null]
|
|
519
454
|
* A function called with the constructor's arguments after the base class'
|
|
520
455
|
* constructor is executed. The `this` value will be the just-constructed object.
|
|
521
|
-
*
|
|
522
456
|
*/
|
|
523
457
|
|
|
524
458
|
// -------------------------------------------------------------------------- //
|
|
@@ -526,6 +460,8 @@ Shim.prototype.__NR_unwrap = unwrapAll
|
|
|
526
460
|
/**
|
|
527
461
|
* Entry point for executing a spec.
|
|
528
462
|
*
|
|
463
|
+
* @param nodule
|
|
464
|
+
* @param spec
|
|
529
465
|
* @memberof Shim.prototype
|
|
530
466
|
*/
|
|
531
467
|
function execute(nodule, spec) {
|
|
@@ -553,23 +489,17 @@ function execute(nodule, spec) {
|
|
|
553
489
|
* method.
|
|
554
490
|
*
|
|
555
491
|
* @memberof Shim.prototype
|
|
556
|
-
*
|
|
557
|
-
* @param {Object|Function} nodule
|
|
492
|
+
* @param {object | Function} nodule
|
|
558
493
|
* The source for the properties to wrap, or a single function to wrap.
|
|
559
|
-
*
|
|
560
494
|
* @param {string|Array.<string>} [properties]
|
|
561
495
|
* One or more properties to wrap. If omitted, the `nodule` parameter is
|
|
562
496
|
* assumed to be the function to wrap.
|
|
563
|
-
*
|
|
564
497
|
* @param {Spec|WrapFunction} spec
|
|
565
498
|
* The spec for wrapping these items.
|
|
566
|
-
*
|
|
567
499
|
* @param {Array.<*>} [args=[]]
|
|
568
500
|
* Optional extra arguments to be sent to the spec when executing it.
|
|
569
|
-
*
|
|
570
|
-
* @return {Object|Function} The first parameter to this function, after
|
|
501
|
+
* @returns {object | Function} The first parameter to this function, after
|
|
571
502
|
* wrapping it or its properties.
|
|
572
|
-
*
|
|
573
503
|
* @see WrapFunction
|
|
574
504
|
*/
|
|
575
505
|
function wrap(nodule, properties, spec, args) {
|
|
@@ -644,23 +574,17 @@ function wrap(nodule, properties, spec, args) {
|
|
|
644
574
|
* constructors instead.
|
|
645
575
|
*
|
|
646
576
|
* @memberof Shim.prototype
|
|
647
|
-
*
|
|
648
|
-
* @param {Object|Function} nodule
|
|
577
|
+
* @param {object | Function} nodule
|
|
649
578
|
* The source for the properties to wrap, or a single function to wrap.
|
|
650
|
-
*
|
|
651
579
|
* @param {string|Array.<string>} [properties]
|
|
652
580
|
* One or more properties to wrap. If omitted, the `nodule` parameter is
|
|
653
581
|
* assumed to be the function to wrap.
|
|
654
|
-
*
|
|
655
582
|
* @param {Spec|WrapReturnFunction} spec
|
|
656
583
|
* The spec for wrapping the returned value from the properties.
|
|
657
|
-
*
|
|
658
584
|
* @param {Array.<*>} [args=[]]
|
|
659
585
|
* Optional extra arguments to be sent to the spec when executing it.
|
|
660
|
-
*
|
|
661
|
-
* @return {Object|Function} The first parameter to this function, after
|
|
586
|
+
* @returns {object | Function} The first parameter to this function, after
|
|
662
587
|
* wrapping it or its properties.
|
|
663
|
-
*
|
|
664
588
|
* @see Shim#wrap
|
|
665
589
|
* @see WrapReturnFunction
|
|
666
590
|
*/
|
|
@@ -766,23 +690,17 @@ function wrapReturn(nodule, properties, spec, args) {
|
|
|
766
690
|
* - `wrapClass(func, spec [, args])`
|
|
767
691
|
*
|
|
768
692
|
* @memberof Shim.prototype
|
|
769
|
-
*
|
|
770
|
-
* @param {Object|Function} nodule
|
|
693
|
+
* @param {object | Function} nodule
|
|
771
694
|
* The source for the properties to wrap, or a single function to wrap.
|
|
772
|
-
*
|
|
773
695
|
* @param {string|Array.<string>} [properties]
|
|
774
696
|
* One or more properties to wrap. If omitted, the `nodule` parameter is
|
|
775
697
|
* assumed to be the constructor to wrap.
|
|
776
|
-
*
|
|
777
698
|
* @param {ClassWrapSpec|ConstructorHookFunction} spec
|
|
778
699
|
* The spec for wrapping the returned value from the properties or a post hook.
|
|
779
|
-
*
|
|
780
700
|
* @param {Array.<*>} [args=[]]
|
|
781
701
|
* Optional extra arguments to be sent to the spec when executing it.
|
|
782
|
-
*
|
|
783
|
-
* @return {Object|Function} The first parameter to this function, after
|
|
702
|
+
* @returns {object | Function} The first parameter to this function, after
|
|
784
703
|
* wrapping it or its properties.
|
|
785
|
-
*
|
|
786
704
|
* @see Shim#wrap
|
|
787
705
|
*/
|
|
788
706
|
function wrapClass(nodule, properties, spec, args) {
|
|
@@ -824,15 +742,12 @@ function wrapClass(nodule, properties, spec, args) {
|
|
|
824
742
|
* - `wrapExport(nodule, spec)`
|
|
825
743
|
*
|
|
826
744
|
* @memberof Shim.prototype
|
|
827
|
-
*
|
|
828
745
|
* @param {*} nodule
|
|
829
746
|
* The original export to replace with our new one.
|
|
830
|
-
*
|
|
831
747
|
* @param {WrapFunction} spec
|
|
832
748
|
* A wrapper function. The return value from this spec is what will replace
|
|
833
749
|
* the export.
|
|
834
|
-
*
|
|
835
|
-
* @return {*} The return value from `spec`.
|
|
750
|
+
* @returns {*} The return value from `spec`.
|
|
836
751
|
*/
|
|
837
752
|
function wrapExport(nodule, spec) {
|
|
838
753
|
return (this._toExport = this.wrap(nodule, null, spec))
|
|
@@ -843,12 +758,9 @@ function wrapExport(nodule, spec) {
|
|
|
843
758
|
*
|
|
844
759
|
* @private
|
|
845
760
|
* @memberof Shim.prototype
|
|
846
|
-
*
|
|
847
761
|
* @param {*} defaultExport - The original export in case it was never wrapped.
|
|
848
|
-
*
|
|
849
|
-
* @return {*} The result from calling {@link Shim#wrapExport} or `defaultExport`
|
|
762
|
+
* @returns {*} The result from calling {@link Shim#wrapExport} or `defaultExport`
|
|
850
763
|
* if it was never used.
|
|
851
|
-
*
|
|
852
764
|
* @see Shim.wrapExport
|
|
853
765
|
*/
|
|
854
766
|
function getExport(defaultExport) {
|
|
@@ -862,16 +774,12 @@ function getExport(defaultExport) {
|
|
|
862
774
|
* - `isWrapped(func)`
|
|
863
775
|
*
|
|
864
776
|
* @memberof Shim.prototype
|
|
865
|
-
*
|
|
866
|
-
* @param {Object|Function} nodule
|
|
777
|
+
* @param {object | Function} nodule
|
|
867
778
|
* The source for the property or a single function to check.
|
|
868
|
-
*
|
|
869
779
|
* @param {string} [property]
|
|
870
780
|
* The property to check. If omitted, the `nodule` parameter is assumed to be
|
|
871
781
|
* the function to check.
|
|
872
|
-
*
|
|
873
|
-
* @return {bool} True if the item exists and has been wrapped.
|
|
874
|
-
*
|
|
782
|
+
* @returns {bool} True if the item exists and has been wrapped.
|
|
875
783
|
* @see Shim#wrap
|
|
876
784
|
* @see Shim#bindSegment
|
|
877
785
|
*/
|
|
@@ -891,20 +799,15 @@ function isWrapped(nodule, property) {
|
|
|
891
799
|
* This is shorthand for calling {@link Shim#wrap} and manually creating a segment.
|
|
892
800
|
*
|
|
893
801
|
* @memberof Shim.prototype
|
|
894
|
-
*
|
|
895
|
-
* @param {Object|Function} nodule
|
|
802
|
+
* @param {object | Function} nodule
|
|
896
803
|
* The source for the properties to record, or a single function to record.
|
|
897
|
-
*
|
|
898
804
|
* @param {string|Array.<string>} [properties]
|
|
899
805
|
* One or more properties to record. If omitted, the `nodule` parameter is
|
|
900
806
|
* assumed to be the function to record.
|
|
901
|
-
*
|
|
902
807
|
* @param {RecorderFunction} recordNamer
|
|
903
808
|
* A function which returns a record descriptor that gives the name and type of
|
|
904
809
|
* record we'll make.
|
|
905
|
-
*
|
|
906
|
-
* @return {Object|Function} The first parameter, possibly wrapped.
|
|
907
|
-
*
|
|
810
|
+
* @returns {object | Function} The first parameter, possibly wrapped.
|
|
908
811
|
* @see RecorderFunction
|
|
909
812
|
* @see RecorderSpec
|
|
910
813
|
* @see Shim#wrap
|
|
@@ -965,6 +868,11 @@ function record(nodule, properties, recordNamer) {
|
|
|
965
868
|
return _doRecord.call(this, segment, args, segDesc, shouldCreateSegment)
|
|
966
869
|
}
|
|
967
870
|
|
|
871
|
+
/**
|
|
872
|
+
* @param shim
|
|
873
|
+
* @param args
|
|
874
|
+
* @param specCallback
|
|
875
|
+
*/
|
|
968
876
|
function _hasValidCallbackArg(shim, args, specCallback) {
|
|
969
877
|
if (shim.isNumber(specCallback)) {
|
|
970
878
|
const cbIdx = normalizeIndex(args.length, specCallback)
|
|
@@ -979,6 +887,12 @@ function record(nodule, properties, recordNamer) {
|
|
|
979
887
|
return true
|
|
980
888
|
}
|
|
981
889
|
|
|
890
|
+
/**
|
|
891
|
+
* @param segment
|
|
892
|
+
* @param args
|
|
893
|
+
* @param segDesc
|
|
894
|
+
* @param shouldCreateSegment
|
|
895
|
+
*/
|
|
982
896
|
function _doRecord(segment, args, segDesc, shouldCreateSegment) {
|
|
983
897
|
// Now bind any callbacks specified in the segment descriptor.
|
|
984
898
|
_bindAllCallbacks.call(this, shim, fn, name, args, {
|
|
@@ -1007,6 +921,12 @@ function record(nodule, properties, recordNamer) {
|
|
|
1007
921
|
return ret
|
|
1008
922
|
}
|
|
1009
923
|
|
|
924
|
+
/**
|
|
925
|
+
* @param segment
|
|
926
|
+
* @param ctx
|
|
927
|
+
* @param args
|
|
928
|
+
* @param segDesc
|
|
929
|
+
*/
|
|
1010
930
|
function _applyRecorderSegment(segment, ctx, args, segDesc) {
|
|
1011
931
|
let error = null
|
|
1012
932
|
let promised = false
|
|
@@ -1051,15 +971,12 @@ function record(nodule, properties, recordNamer) {
|
|
|
1051
971
|
* back on the nodule. Otherwise, the unwrapped function is just returned.
|
|
1052
972
|
*
|
|
1053
973
|
* @memberof Shim.prototype
|
|
1054
|
-
*
|
|
1055
|
-
* @param {Object|Function} nodule
|
|
974
|
+
* @param {object | Function} nodule
|
|
1056
975
|
* The source for the properties to unwrap, or a single function to unwrap.
|
|
1057
|
-
*
|
|
1058
976
|
* @param {string|Array.<string>} [properties]
|
|
1059
977
|
* One or more properties to unwrap. If omitted, the `nodule` parameter is
|
|
1060
978
|
* assumed to be the function to unwrap.
|
|
1061
|
-
*
|
|
1062
|
-
* @return {Object|Function} The first parameter after unwrapping.
|
|
979
|
+
* @returns {object | Function} The first parameter after unwrapping.
|
|
1063
980
|
*/
|
|
1064
981
|
function unwrap(nodule, properties) {
|
|
1065
982
|
// Don't try to unwrap potentially `null` or `undefined` things.
|
|
@@ -1093,15 +1010,12 @@ function unwrap(nodule, properties) {
|
|
|
1093
1010
|
* back on the nodule. Otherwise, the unwrapped function is just returned.
|
|
1094
1011
|
*
|
|
1095
1012
|
* @memberof Shim.prototype
|
|
1096
|
-
*
|
|
1097
|
-
* @param {Object|Function} nodule
|
|
1013
|
+
* @param {object | Function} nodule
|
|
1098
1014
|
* The source for the properties to unwrap, or a single function to unwrap.
|
|
1099
|
-
*
|
|
1100
1015
|
* @param {string|Array.<string>} [properties]
|
|
1101
1016
|
* One or more properties to unwrap. If omitted, the `nodule` parameter is
|
|
1102
1017
|
* assumed to be the function to unwrap.
|
|
1103
|
-
*
|
|
1104
|
-
* @return {Object|Function} The first parameter after unwrapping.
|
|
1018
|
+
* @returns {object | Function} The first parameter after unwrapping.
|
|
1105
1019
|
*/
|
|
1106
1020
|
function unwrapOnce(nodule, properties) {
|
|
1107
1021
|
// Don't try to unwrap potentially `null` or `undefined` things.
|
|
@@ -1132,14 +1046,11 @@ function unwrapOnce(nodule, properties) {
|
|
|
1132
1046
|
* - `getOriginal(func)`
|
|
1133
1047
|
*
|
|
1134
1048
|
* @memberof Shim.prototype
|
|
1135
|
-
*
|
|
1136
|
-
* @param {Object|Function} nodule
|
|
1049
|
+
* @param {object | Function} nodule
|
|
1137
1050
|
* The source of the property to get the original of, or a function to unwrap.
|
|
1138
|
-
*
|
|
1139
1051
|
* @param {string} [property]
|
|
1140
1052
|
* A property on `nodule` to get the original value of.
|
|
1141
|
-
*
|
|
1142
|
-
* @return {Object|Function} The original value for the given item.
|
|
1053
|
+
* @returns {object | Function} The original value for the given item.
|
|
1143
1054
|
*/
|
|
1144
1055
|
function getOriginal(nodule, property) {
|
|
1145
1056
|
if (!nodule) {
|
|
@@ -1163,22 +1074,17 @@ function getOriginal(nodule, property) {
|
|
|
1163
1074
|
* back on the nodule. Otherwise, the wrapped function is just returned.
|
|
1164
1075
|
*
|
|
1165
1076
|
* @memberof Shim.prototype
|
|
1166
|
-
*
|
|
1167
|
-
* @param {Object|Function} nodule
|
|
1077
|
+
* @param {object | Function} nodule
|
|
1168
1078
|
* The source for the property or a single function to bind to a segment.
|
|
1169
|
-
*
|
|
1170
1079
|
* @param {string} [property]
|
|
1171
1080
|
* The property to bind. If omitted, the `nodule` parameter is assumed
|
|
1172
1081
|
* to be the function to bind the segment to.
|
|
1173
|
-
*
|
|
1174
1082
|
* @param {?TraceSegment} [segment=null]
|
|
1175
1083
|
* The segment to bind the execution of the function to. If omitted or `null`
|
|
1176
1084
|
* the currently active segment will be bound instead.
|
|
1177
|
-
*
|
|
1178
1085
|
* @param {bool} [full=false]
|
|
1179
1086
|
* Indicates if the full lifetime of the segment is bound to this function.
|
|
1180
|
-
*
|
|
1181
|
-
* @return {Object|Function} The first parameter after wrapping.
|
|
1087
|
+
* @returns {object | Function} The first parameter after wrapping.
|
|
1182
1088
|
*/
|
|
1183
1089
|
function bindSegment(nodule, property, segment, full) {
|
|
1184
1090
|
// Don't bind to null arguments.
|
|
@@ -1229,17 +1135,13 @@ function bindSegment(nodule, property, segment, full) {
|
|
|
1229
1135
|
* - `bindCallbackSegment(obj, property [, segment])`
|
|
1230
1136
|
*
|
|
1231
1137
|
* @memberof Shim.prototype
|
|
1232
|
-
*
|
|
1233
|
-
* @param {Array|Object} args
|
|
1138
|
+
* @param {Array | object} args
|
|
1234
1139
|
* The arguments array to pull the cb from.
|
|
1235
|
-
*
|
|
1236
1140
|
* @param {number|string} cbIdx
|
|
1237
1141
|
* The index of the callback.
|
|
1238
|
-
*
|
|
1239
1142
|
* @param {TraceSegment} [parentSegment]
|
|
1240
1143
|
* The segment to use as the callback segment's parent. Defaults to the
|
|
1241
1144
|
* currently active segment.
|
|
1242
|
-
*
|
|
1243
1145
|
* @see Shim#bindSegment
|
|
1244
1146
|
*/
|
|
1245
1147
|
function bindCallbackSegment(args, cbIdx, parentSegment) {
|
|
@@ -1299,10 +1201,8 @@ function bindCallbackSegment(args, cbIdx, parentSegment) {
|
|
|
1299
1201
|
* - `getSegment([obj])`
|
|
1300
1202
|
*
|
|
1301
1203
|
* @memberof Shim.prototype
|
|
1302
|
-
*
|
|
1303
1204
|
* @param {*} [obj] - The object to retrieve a segment from.
|
|
1304
|
-
*
|
|
1305
|
-
* @return {?TraceSegment} The trace segment associated with the given object or
|
|
1205
|
+
* @returns {?TraceSegment} The trace segment associated with the given object or
|
|
1306
1206
|
* the current segment if no object is provided or no segment is associated
|
|
1307
1207
|
* with the object.
|
|
1308
1208
|
*/
|
|
@@ -1310,7 +1210,8 @@ function getSegment(obj) {
|
|
|
1310
1210
|
if (obj && obj.__NR_segment) {
|
|
1311
1211
|
return obj.__NR_segment
|
|
1312
1212
|
}
|
|
1313
|
-
|
|
1213
|
+
|
|
1214
|
+
return this._contextManager.getContext()
|
|
1314
1215
|
}
|
|
1315
1216
|
|
|
1316
1217
|
/**
|
|
@@ -1323,10 +1224,8 @@ function getSegment(obj) {
|
|
|
1323
1224
|
* ended yet).
|
|
1324
1225
|
*
|
|
1325
1226
|
* @memberof Shim.prototype
|
|
1326
|
-
*
|
|
1327
1227
|
* @param {*} [obj] - The object to retrieve a segment from.
|
|
1328
|
-
*
|
|
1329
|
-
* @return {?TraceSegment} The trace segment associated with the given object or
|
|
1228
|
+
* @returns {?TraceSegment} The trace segment associated with the given object or
|
|
1330
1229
|
* the currently active segment if no object is provided or no segment is
|
|
1331
1230
|
* associated with the object.
|
|
1332
1231
|
*/
|
|
@@ -1346,12 +1245,12 @@ function getActiveSegment(obj) {
|
|
|
1346
1245
|
* - `setActiveSegment(segment)`
|
|
1347
1246
|
*
|
|
1348
1247
|
* @memberof Shim.prototype
|
|
1349
|
-
*
|
|
1350
1248
|
* @param {TraceSegment} segment - The segment to set as the active segment.
|
|
1351
|
-
*
|
|
1249
|
+
* @returns {TraceSegment} - The segment set as active on the context.
|
|
1352
1250
|
*/
|
|
1353
1251
|
function setActiveSegment(segment) {
|
|
1354
|
-
|
|
1252
|
+
this._contextManager.setContext(segment)
|
|
1253
|
+
return segment
|
|
1355
1254
|
}
|
|
1356
1255
|
|
|
1357
1256
|
/**
|
|
@@ -1362,14 +1261,14 @@ function setActiveSegment(segment) {
|
|
|
1362
1261
|
* If no segment is provided, the currently active segment is used.
|
|
1363
1262
|
*
|
|
1364
1263
|
* @memberof Shim.prototype
|
|
1365
|
-
*
|
|
1366
1264
|
* @param {!*} obj - The object to retrieve a segment from.
|
|
1367
1265
|
* @param {TraceSegment} [segment] - The segment to link the object to.
|
|
1368
1266
|
*/
|
|
1369
1267
|
function storeSegment(obj, segment) {
|
|
1370
|
-
this.setInternalProperty(obj, '__NR_segment', segment || this.
|
|
1268
|
+
this.setInternalProperty(obj, '__NR_segment', segment || this.getSegment())
|
|
1371
1269
|
}
|
|
1372
1270
|
|
|
1271
|
+
/* eslint-disable max-params */
|
|
1373
1272
|
/**
|
|
1374
1273
|
* Sets the given segment as the active one for the duration of the function's
|
|
1375
1274
|
* execution.
|
|
@@ -1377,30 +1276,15 @@ function storeSegment(obj, segment) {
|
|
|
1377
1276
|
* - `applySegment(func, segment, full, context, args[, inContextCB])`
|
|
1378
1277
|
*
|
|
1379
1278
|
* @memberof Shim.prototype
|
|
1380
|
-
*
|
|
1381
|
-
* @param {
|
|
1382
|
-
*
|
|
1383
|
-
*
|
|
1384
|
-
* @param {
|
|
1385
|
-
*
|
|
1386
|
-
*
|
|
1387
|
-
* @param {bool} full
|
|
1388
|
-
* Indicates if the full lifetime of the segment is bound to this function.
|
|
1389
|
-
*
|
|
1390
|
-
* @param {*} context
|
|
1391
|
-
* The `this` argument for the function.
|
|
1392
|
-
*
|
|
1393
|
-
* @param {Array.<*>} args
|
|
1394
|
-
* The arguments to be passed into the function.
|
|
1395
|
-
*
|
|
1396
|
-
* @param {Function} [inContextCB]
|
|
1397
|
-
* The function used to do more instrumentation work. This function is
|
|
1279
|
+
* @param {Function} func The function to execute in the context of the given segment.
|
|
1280
|
+
* @param {TraceSegment} segment The segment to make active for the duration of the function.
|
|
1281
|
+
* @param {bool} full Indicates if the full lifetime of the segment is bound to this function.
|
|
1282
|
+
* @param {*} context The `this` argument for the function.
|
|
1283
|
+
* @param {Array.<*>} args The arguments to be passed into the function.
|
|
1284
|
+
* @param {Function} [inContextCB] The function used to do more instrumentation work. This function is
|
|
1398
1285
|
* guaranteed to be executed with the segment associated with.
|
|
1399
|
-
*
|
|
1400
|
-
*
|
|
1401
|
-
* @return {*} Whatever value `func` returned.
|
|
1286
|
+
* @returns {*} Whatever value `func` returned.
|
|
1402
1287
|
*/
|
|
1403
|
-
/* eslint-disable max-params */
|
|
1404
1288
|
function applySegment(func, segment, full, context, args, inContextCB) {
|
|
1405
1289
|
// Exist fast for bad arguments.
|
|
1406
1290
|
if (!this.isFunction(func)) {
|
|
@@ -1411,35 +1295,35 @@ function applySegment(func, segment, full, context, args, inContextCB) {
|
|
|
1411
1295
|
this.logger.trace('No segment to apply to function.')
|
|
1412
1296
|
return fnApply.call(func, context, args)
|
|
1413
1297
|
}
|
|
1298
|
+
|
|
1414
1299
|
this.logger.trace('Applying segment %s', segment.name)
|
|
1415
1300
|
|
|
1416
|
-
|
|
1417
|
-
const
|
|
1418
|
-
const prevSegment = tracer.segment
|
|
1419
|
-
tracer.segment = segment
|
|
1420
|
-
if (full) {
|
|
1421
|
-
segment.start()
|
|
1422
|
-
}
|
|
1301
|
+
const contextManager = this._contextManager
|
|
1302
|
+
const prevSegment = contextManager.getContext()
|
|
1423
1303
|
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1304
|
+
return contextManager.runInContext(segment, () => {
|
|
1305
|
+
if (full) {
|
|
1306
|
+
segment.start()
|
|
1307
|
+
}
|
|
1427
1308
|
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
return fnApply.call(func, context, args)
|
|
1431
|
-
} catch (error) {
|
|
1432
|
-
if (prevSegment === null && process.domain != null) {
|
|
1433
|
-
process.domain.__NR_segment = tracer.segment
|
|
1309
|
+
if (typeof inContextCB === 'function') {
|
|
1310
|
+
inContextCB()
|
|
1434
1311
|
}
|
|
1435
1312
|
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1313
|
+
try {
|
|
1314
|
+
return fnApply.call(func, context, args)
|
|
1315
|
+
} catch (error) {
|
|
1316
|
+
if (prevSegment === null && process.domain != null) {
|
|
1317
|
+
process.domain.__NR_segment = contextManager.getContext()
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
throw error // Re-throwing application error, this is not an agent error.
|
|
1321
|
+
} finally {
|
|
1322
|
+
if (full) {
|
|
1323
|
+
segment.touch()
|
|
1324
|
+
}
|
|
1440
1325
|
}
|
|
1441
|
-
|
|
1442
|
-
}
|
|
1326
|
+
})
|
|
1443
1327
|
}
|
|
1444
1328
|
/* eslint-enable max-params */
|
|
1445
1329
|
|
|
@@ -1450,19 +1334,15 @@ function applySegment(func, segment, full, context, args, inContextCB) {
|
|
|
1450
1334
|
* - `createSegment(name [, recorder] [, parent])`
|
|
1451
1335
|
*
|
|
1452
1336
|
* @memberof Shim.prototype
|
|
1453
|
-
*
|
|
1454
1337
|
* @param {string} name
|
|
1455
1338
|
* The name to give the new segment.
|
|
1456
|
-
*
|
|
1457
1339
|
* @param {?Function} [recorder=null]
|
|
1458
1340
|
* Optional. A function which will record the segment as a metric. Default is
|
|
1459
1341
|
* to not record the segment.
|
|
1460
|
-
*
|
|
1461
1342
|
* @param {TraceSegment} [parent]
|
|
1462
1343
|
* Optional. The segment to use as the parent. Default is to use the currently
|
|
1463
1344
|
* active segment.
|
|
1464
|
-
*
|
|
1465
|
-
* @return {?TraceSegment} A new trace segment if a transaction is active, else
|
|
1345
|
+
* @returns {?TraceSegment} A new trace segment if a transaction is active, else
|
|
1466
1346
|
* `null` is returned.
|
|
1467
1347
|
*/
|
|
1468
1348
|
function createSegment(name, recorder, parent) {
|
|
@@ -1488,6 +1368,10 @@ function createSegment(name, recorder, parent) {
|
|
|
1488
1368
|
return _rawCreateSegment(this, opts)
|
|
1489
1369
|
}
|
|
1490
1370
|
|
|
1371
|
+
/**
|
|
1372
|
+
* @param shim
|
|
1373
|
+
* @param opts
|
|
1374
|
+
*/
|
|
1491
1375
|
function _rawCreateSegment(shim, opts) {
|
|
1492
1376
|
// Grab parent segment when none in opts so we can check opaqueness
|
|
1493
1377
|
opts.parent = opts.parent || shim.getActiveSegment()
|
|
@@ -1521,10 +1405,8 @@ function _rawCreateSegment(shim, opts) {
|
|
|
1521
1405
|
* Determine the name of an object.
|
|
1522
1406
|
*
|
|
1523
1407
|
* @memberof Shim.prototype
|
|
1524
|
-
*
|
|
1525
1408
|
* @param {*} obj - The object to get a name for.
|
|
1526
|
-
*
|
|
1527
|
-
* @return {string} The name of the object if it has one, else `<anonymous>`.
|
|
1409
|
+
* @returns {string} The name of the object if it has one, else `<anonymous>`.
|
|
1528
1410
|
*/
|
|
1529
1411
|
function getName(obj) {
|
|
1530
1412
|
return String(!obj || obj === true ? obj : obj.name || '<anonymous>')
|
|
@@ -1534,10 +1416,8 @@ function getName(obj) {
|
|
|
1534
1416
|
* Determines if the given object is an Object.
|
|
1535
1417
|
*
|
|
1536
1418
|
* @memberof Shim.prototype
|
|
1537
|
-
*
|
|
1538
1419
|
* @param {*} obj - The object to check.
|
|
1539
|
-
*
|
|
1540
|
-
* @return {bool} True if the object is an Object, else false.
|
|
1420
|
+
* @returns {bool} True if the object is an Object, else false.
|
|
1541
1421
|
*/
|
|
1542
1422
|
function isObject(obj) {
|
|
1543
1423
|
return obj instanceof Object
|
|
@@ -1547,10 +1427,8 @@ function isObject(obj) {
|
|
|
1547
1427
|
* Determines if the given object exists and is a function.
|
|
1548
1428
|
*
|
|
1549
1429
|
* @memberof Shim.prototype
|
|
1550
|
-
*
|
|
1551
1430
|
* @param {*} obj - The object to check.
|
|
1552
|
-
*
|
|
1553
|
-
* @return {bool} True if the object is a function, else false.
|
|
1431
|
+
* @returns {bool} True if the object is a function, else false.
|
|
1554
1432
|
*/
|
|
1555
1433
|
function isFunction(obj) {
|
|
1556
1434
|
return typeof obj === 'function'
|
|
@@ -1560,10 +1438,8 @@ function isFunction(obj) {
|
|
|
1560
1438
|
* Determines if the given object exists and is a string.
|
|
1561
1439
|
*
|
|
1562
1440
|
* @memberof Shim.prototype
|
|
1563
|
-
*
|
|
1564
1441
|
* @param {*} obj - The object to check.
|
|
1565
|
-
*
|
|
1566
|
-
* @return {bool} True if the object is a string, else false.
|
|
1442
|
+
* @returns {bool} True if the object is a string, else false.
|
|
1567
1443
|
*/
|
|
1568
1444
|
function isString(obj) {
|
|
1569
1445
|
return typeof obj === 'string'
|
|
@@ -1573,10 +1449,8 @@ function isString(obj) {
|
|
|
1573
1449
|
* Determines if the given object is a number literal.
|
|
1574
1450
|
*
|
|
1575
1451
|
* @memberof Shim.prototype
|
|
1576
|
-
*
|
|
1577
1452
|
* @param {*} obj - The object to check.
|
|
1578
|
-
*
|
|
1579
|
-
* @return {bool} True if the object is a number literal, else false.
|
|
1453
|
+
* @returns {bool} True if the object is a number literal, else false.
|
|
1580
1454
|
*/
|
|
1581
1455
|
function isNumber(obj) {
|
|
1582
1456
|
return typeof obj === 'number'
|
|
@@ -1586,10 +1460,8 @@ function isNumber(obj) {
|
|
|
1586
1460
|
* Determines if the given object is a boolean literal.
|
|
1587
1461
|
*
|
|
1588
1462
|
* @memberof Shim.prototype
|
|
1589
|
-
*
|
|
1590
1463
|
* @param {*} obj - The object to check.
|
|
1591
|
-
*
|
|
1592
|
-
* @return {bool} True if the object is a boolean literal, else false.
|
|
1464
|
+
* @returns {bool} True if the object is a boolean literal, else false.
|
|
1593
1465
|
*/
|
|
1594
1466
|
function isBoolean(obj) {
|
|
1595
1467
|
return typeof obj === 'boolean'
|
|
@@ -1599,10 +1471,8 @@ function isBoolean(obj) {
|
|
|
1599
1471
|
* Determines if the given object exists and is an array.
|
|
1600
1472
|
*
|
|
1601
1473
|
* @memberof Shim.prototype
|
|
1602
|
-
*
|
|
1603
1474
|
* @param {*} obj - The object to check.
|
|
1604
|
-
*
|
|
1605
|
-
* @return {bool} True if the object is an array, else false.
|
|
1475
|
+
* @returns {bool} True if the object is an array, else false.
|
|
1606
1476
|
*/
|
|
1607
1477
|
function isArray(obj) {
|
|
1608
1478
|
return obj instanceof Array
|
|
@@ -1612,10 +1482,8 @@ function isArray(obj) {
|
|
|
1612
1482
|
* Determines if the given object is a promise instance.
|
|
1613
1483
|
*
|
|
1614
1484
|
* @memberof Shim.prototype
|
|
1615
|
-
*
|
|
1616
1485
|
* @param {*} obj - The object to check.
|
|
1617
|
-
*
|
|
1618
|
-
* @return {bool} True if the object is a promise, else false.
|
|
1486
|
+
* @returns {bool} True if the object is a promise, else false.
|
|
1619
1487
|
*/
|
|
1620
1488
|
function isPromise(obj) {
|
|
1621
1489
|
return obj && typeof obj.then === 'function'
|
|
@@ -1625,10 +1493,8 @@ function isPromise(obj) {
|
|
|
1625
1493
|
* Determines if the given value is null.
|
|
1626
1494
|
*
|
|
1627
1495
|
* @memberof Shim.prototype
|
|
1628
|
-
*
|
|
1629
1496
|
* @param {*} val - The value to check.
|
|
1630
|
-
*
|
|
1631
|
-
* @return {bool} True if the value is null, else false.
|
|
1497
|
+
* @returns {bool} True if the value is null, else false.
|
|
1632
1498
|
*/
|
|
1633
1499
|
function isNull(val) {
|
|
1634
1500
|
return val === null
|
|
@@ -1638,10 +1504,8 @@ function isNull(val) {
|
|
|
1638
1504
|
* Converts an array-like object into an array.
|
|
1639
1505
|
*
|
|
1640
1506
|
* @memberof Shim.prototype
|
|
1641
|
-
*
|
|
1642
1507
|
* @param {*} obj - The array-like object (i.e. `arguments`).
|
|
1643
|
-
*
|
|
1644
|
-
* @return {Array.<*>} An instance of `Array` containing the elements of the
|
|
1508
|
+
* @returns {Array.<*>} An instance of `Array` containing the elements of the
|
|
1645
1509
|
* array-like.
|
|
1646
1510
|
*/
|
|
1647
1511
|
function toArray(obj) {
|
|
@@ -1660,9 +1524,7 @@ function toArray(obj) {
|
|
|
1660
1524
|
* `arguments` object into an actual `Array` as it will not cause deopts.
|
|
1661
1525
|
*
|
|
1662
1526
|
* @memberof Shim.prototype
|
|
1663
|
-
*
|
|
1664
|
-
* @return {Array} An array containing the elements of `arguments`.
|
|
1665
|
-
*
|
|
1527
|
+
* @returns {Array} An array containing the elements of `arguments`.
|
|
1666
1528
|
* @see Shim#toArray
|
|
1667
1529
|
* @see https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
|
|
1668
1530
|
*/
|
|
@@ -1682,11 +1544,9 @@ function argsToArray() {
|
|
|
1682
1544
|
* array length before checking it.
|
|
1683
1545
|
*
|
|
1684
1546
|
* @memberof Shim.prototype
|
|
1685
|
-
*
|
|
1686
1547
|
* @param {number} arrayLength - The length of the array this index is for.
|
|
1687
1548
|
* @param {number} idx - The index to normalize.
|
|
1688
|
-
*
|
|
1689
|
-
* @return {?number} The adjusted index value if it is valid, else `null`.
|
|
1549
|
+
* @returns {?number} The adjusted index value if it is valid, else `null`.
|
|
1690
1550
|
*/
|
|
1691
1551
|
function normalizeIndex(arrayLength, idx) {
|
|
1692
1552
|
if (idx < 0) {
|
|
@@ -1699,10 +1559,8 @@ function normalizeIndex(arrayLength, idx) {
|
|
|
1699
1559
|
* Wraps a function such that it will only be executed once.
|
|
1700
1560
|
*
|
|
1701
1561
|
* @memberof Shim.prototype
|
|
1702
|
-
*
|
|
1703
|
-
* @
|
|
1704
|
-
*
|
|
1705
|
-
* @return {function} A function which will execute `fn` at most once.
|
|
1562
|
+
* @param {Function} fn - The function to wrap in an execution guard.
|
|
1563
|
+
* @returns {Function} A function which will execute `fn` at most once.
|
|
1706
1564
|
*/
|
|
1707
1565
|
function once(fn) {
|
|
1708
1566
|
let called = false
|
|
@@ -1719,12 +1577,10 @@ function once(fn) {
|
|
|
1719
1577
|
* be made writable and non-enumerable.
|
|
1720
1578
|
*
|
|
1721
1579
|
* @memberof Shim.prototype
|
|
1722
|
-
*
|
|
1723
1580
|
* @param {!object} obj - The object to add the property to.
|
|
1724
1581
|
* @param {!string} name - The name for this property.
|
|
1725
1582
|
* @param {*} val - The value to set the property as.
|
|
1726
|
-
*
|
|
1727
|
-
* @return {object} The `obj` value.
|
|
1583
|
+
* @returns {object} The `obj` value.
|
|
1728
1584
|
*/
|
|
1729
1585
|
function setInternalProperty(obj, name, val) {
|
|
1730
1586
|
if (!obj || !name) {
|
|
@@ -1744,6 +1600,11 @@ function setInternalProperty(obj, name, val) {
|
|
|
1744
1600
|
return obj
|
|
1745
1601
|
}
|
|
1746
1602
|
|
|
1603
|
+
/**
|
|
1604
|
+
* @param obj
|
|
1605
|
+
* @param name
|
|
1606
|
+
* @param val
|
|
1607
|
+
*/
|
|
1747
1608
|
function _slowSetInternalProperty(obj, name, val) {
|
|
1748
1609
|
if (!hasOwnProperty(obj, name)) {
|
|
1749
1610
|
Object.defineProperty(obj, name, {
|
|
@@ -1760,14 +1621,11 @@ function _slowSetInternalProperty(obj, name, val) {
|
|
|
1760
1621
|
* Defines a read-only property on the given object.
|
|
1761
1622
|
*
|
|
1762
1623
|
* @memberof Shim.prototype
|
|
1763
|
-
*
|
|
1764
1624
|
* @param {object} obj
|
|
1765
1625
|
* The object to add the property to.
|
|
1766
|
-
*
|
|
1767
1626
|
* @param {string} name
|
|
1768
1627
|
* The name of the property to add.
|
|
1769
|
-
*
|
|
1770
|
-
* @param {*|function} value
|
|
1628
|
+
* @param {* | Function} value
|
|
1771
1629
|
* The value to set. If a function is given, it is used as a getter, otherwise
|
|
1772
1630
|
* the value is directly set as an unwritable property.
|
|
1773
1631
|
*/
|
|
@@ -1790,10 +1648,8 @@ function defineProperty(obj, name, value) {
|
|
|
1790
1648
|
* Adds several properties to the given object.
|
|
1791
1649
|
*
|
|
1792
1650
|
* @memberof Shim.prototype
|
|
1793
|
-
*
|
|
1794
1651
|
* @param {object} obj - The object to add the properties to.
|
|
1795
1652
|
* @param {object} props - A mapping of properties to values to add.
|
|
1796
|
-
*
|
|
1797
1653
|
* @see Shim#defineProperty
|
|
1798
1654
|
*/
|
|
1799
1655
|
function defineProperties(obj, props) {
|
|
@@ -1809,11 +1665,9 @@ function defineProperties(obj, props) {
|
|
|
1809
1665
|
* not already have that property.
|
|
1810
1666
|
*
|
|
1811
1667
|
* @memberof Shim.prototype
|
|
1812
|
-
*
|
|
1813
1668
|
* @param {object?} obj - The object to copy the defaults onto.
|
|
1814
1669
|
* @param {object} defaults - A mapping of keys to default values.
|
|
1815
|
-
*
|
|
1816
|
-
* @return {object} The `obj` with the default values copied onto it. If `obj`
|
|
1670
|
+
* @returns {object} The `obj` with the default values copied onto it. If `obj`
|
|
1817
1671
|
* was falsey, then a new object with the defaults copied onto it is returned
|
|
1818
1672
|
* instead.
|
|
1819
1673
|
*/
|
|
@@ -1837,13 +1691,10 @@ function setDefaults(obj, defaults) {
|
|
|
1837
1691
|
* Proxies all set/get actions for each given property on `dest` onto `source`.
|
|
1838
1692
|
*
|
|
1839
1693
|
* @memberof Shim.prototype
|
|
1840
|
-
*
|
|
1841
1694
|
* @param {*} source
|
|
1842
1695
|
* The object on which all the set/get actions will actually occur.
|
|
1843
|
-
*
|
|
1844
1696
|
* @param {string|Array.<string>} properties
|
|
1845
1697
|
* All of the properties to proxy.
|
|
1846
|
-
*
|
|
1847
1698
|
* @param {*} dest
|
|
1848
1699
|
* The object which is proxying the source's properties.
|
|
1849
1700
|
*/
|
|
@@ -1868,10 +1719,8 @@ function proxy(source, properties, dest) {
|
|
|
1868
1719
|
* Loads a node module from the instrumented library's own root directory.
|
|
1869
1720
|
*
|
|
1870
1721
|
* @memberof Shim.prototype
|
|
1871
|
-
*
|
|
1872
1722
|
* @param {string} filePath - A relative path inside the module's directory.
|
|
1873
|
-
*
|
|
1874
|
-
* @return {*?} The result of loading the given module. If the module fails to
|
|
1723
|
+
* @returns {*?} The result of loading the given module. If the module fails to
|
|
1875
1724
|
* load, `null` is returned instead.
|
|
1876
1725
|
*/
|
|
1877
1726
|
function shimRequire(filePath) {
|
|
@@ -1893,11 +1742,9 @@ function shimRequire(filePath) {
|
|
|
1893
1742
|
* resolved or rejected.
|
|
1894
1743
|
*
|
|
1895
1744
|
* @memberof Shim.prototype
|
|
1896
|
-
*
|
|
1897
1745
|
* @param {Promise} prom - Some kind of promise. Must have a `then` method.
|
|
1898
1746
|
* @param {Function} cb - A function to call when the promise resolves.
|
|
1899
|
-
*
|
|
1900
|
-
* @return {Promise} A new promise to replace the original one.
|
|
1747
|
+
* @returns {Promise} A new promise to replace the original one.
|
|
1901
1748
|
*/
|
|
1902
1749
|
function interceptPromise(prom, cb) {
|
|
1903
1750
|
if (this.isFunction(prom.finally)) {
|
|
@@ -1920,14 +1767,11 @@ function interceptPromise(prom, cb) {
|
|
|
1920
1767
|
* Updates segment timing and resets opaque state.
|
|
1921
1768
|
*
|
|
1922
1769
|
* @memberof Shim.prototype
|
|
1923
|
-
*
|
|
1924
1770
|
* @param {!Promise} promise
|
|
1925
1771
|
* The Promise to bind.
|
|
1926
|
-
*
|
|
1927
1772
|
* @param {!TraceSegment} segment
|
|
1928
1773
|
* The segment to bind to the Promise.
|
|
1929
|
-
*
|
|
1930
|
-
* @return {Promise} The promise to continue with.
|
|
1774
|
+
* @returns {Promise} The promise to continue with.
|
|
1931
1775
|
*/
|
|
1932
1776
|
function bindPromise(promise, segment) {
|
|
1933
1777
|
return this.interceptPromise(promise, function thenTouch() {
|
|
@@ -1941,7 +1785,6 @@ function bindPromise(promise, segment) {
|
|
|
1941
1785
|
* configuration.
|
|
1942
1786
|
*
|
|
1943
1787
|
* @memberof Shim.prototype
|
|
1944
|
-
*
|
|
1945
1788
|
* @param {TraceSegment} segment - The segment to copy the parameters onto.
|
|
1946
1789
|
* @param {object} parameters - The parameters to copy.
|
|
1947
1790
|
*/
|
|
@@ -1991,13 +1834,14 @@ function unwrapAll() {
|
|
|
1991
1834
|
* Coerces the given spec into a function which {@link Shim#wrap} can use.
|
|
1992
1835
|
*
|
|
1993
1836
|
* @private
|
|
1994
|
-
*
|
|
1995
1837
|
* @param {Spec|WrapFunction} spec - The spec to coerce into a function.
|
|
1996
|
-
*
|
|
1997
|
-
* @return {WrapFunction} The spec itself if spec is a function, otherwise a
|
|
1838
|
+
* @returns {WrapFunction} The spec itself if spec is a function, otherwise a
|
|
1998
1839
|
* function which will execute the spec when called.
|
|
1999
1840
|
*/
|
|
2000
1841
|
/* eslint-disable no-unused-vars */
|
|
1842
|
+
/**
|
|
1843
|
+
* @param spec
|
|
1844
|
+
*/
|
|
2001
1845
|
function _specToFunction(spec) {
|
|
2002
1846
|
throw new Error('Declarative specs are not implemented yet.')
|
|
2003
1847
|
}
|
|
@@ -2009,23 +1853,17 @@ function _specToFunction(spec) {
|
|
|
2009
1853
|
* - `_wrap(shim, original, name, spec [, args])`
|
|
2010
1854
|
*
|
|
2011
1855
|
* @private
|
|
2012
|
-
*
|
|
2013
1856
|
* @param {Shim} shim
|
|
2014
1857
|
* The shim that is executing the wrapping.
|
|
2015
|
-
*
|
|
2016
1858
|
* @param {*} original
|
|
2017
1859
|
* The object being wrapped.
|
|
2018
|
-
*
|
|
2019
1860
|
* @param {string} name
|
|
2020
1861
|
* A logical name for the item to be wrapped.
|
|
2021
|
-
*
|
|
2022
1862
|
* @param {WrapFunction} spec
|
|
2023
1863
|
* The spec for wrapping these items.
|
|
2024
|
-
*
|
|
2025
1864
|
* @param {Array.<*>} [args=[]]
|
|
2026
1865
|
* Optional extra arguments to be sent to the spec when executing it.
|
|
2027
|
-
*
|
|
2028
|
-
* @return {Function} The return value from `spec` or the original value if it
|
|
1866
|
+
* @returns {Function} The return value from `spec` or the original value if it
|
|
2029
1867
|
* did not return anything.
|
|
2030
1868
|
*/
|
|
2031
1869
|
function _wrap(shim, original, name, spec, args) {
|
|
@@ -2062,20 +1900,15 @@ function _wrap(shim, original, name, spec, args) {
|
|
|
2062
1900
|
* Creates the `bindSegment` wrapper function in its own, clean closure.
|
|
2063
1901
|
*
|
|
2064
1902
|
* @private
|
|
2065
|
-
*
|
|
2066
1903
|
* @param {Shim} shim
|
|
2067
1904
|
* The shim used for the binding.
|
|
2068
|
-
*
|
|
2069
|
-
* @param {function} fn
|
|
1905
|
+
* @param {Function} fn
|
|
2070
1906
|
* The function to be bound to the segment.
|
|
2071
|
-
*
|
|
2072
1907
|
* @param {TraceSegment} segment
|
|
2073
1908
|
* The segment the function is bound to.
|
|
2074
|
-
*
|
|
2075
1909
|
* @param {boolean} full
|
|
2076
1910
|
* Indicates if the segment's full lifetime is bound to the function.
|
|
2077
|
-
*
|
|
2078
|
-
* @return {function} A function which wraps `fn` and makes the given segment
|
|
1911
|
+
* @returns {Function} A function which wraps `fn` and makes the given segment
|
|
2079
1912
|
* active for the duration of its execution.
|
|
2080
1913
|
*/
|
|
2081
1914
|
function _makeBindWrapper(shim, fn, segment, full) {
|
|
@@ -2093,29 +1926,21 @@ function _makeBindWrapper(shim, fn, segment, full) {
|
|
|
2093
1926
|
*
|
|
2094
1927
|
* @this *
|
|
2095
1928
|
* @private
|
|
2096
|
-
*
|
|
2097
1929
|
* @param {Shim} shim
|
|
2098
1930
|
* The shim performing this binding.
|
|
2099
|
-
*
|
|
2100
1931
|
* @param {Function} fn
|
|
2101
1932
|
* The function the spec describes.
|
|
2102
|
-
*
|
|
2103
1933
|
* @param {string} name
|
|
2104
1934
|
* The name of the function the spec describes.
|
|
2105
|
-
*
|
|
2106
1935
|
* @param {Array} args
|
|
2107
1936
|
* The arguments to be passed into `fn`.
|
|
2108
|
-
*
|
|
2109
1937
|
* @param {object} spec
|
|
2110
1938
|
* The specification for bind the callbacks.
|
|
2111
|
-
*
|
|
2112
1939
|
* @param {SegmentSpec} spec.spec
|
|
2113
1940
|
* The segment specification for the function we're pulling callbacks out of.
|
|
2114
|
-
*
|
|
2115
1941
|
* @param {TraceSegment} spec.segment
|
|
2116
1942
|
* The segment measuring the function which will be the parent of any callback
|
|
2117
1943
|
* segments that may be created.
|
|
2118
|
-
*
|
|
2119
1944
|
* @param {bool} spec.shouldCreateSegment
|
|
2120
1945
|
* Flag indicating if we should create segments for the callbacks. We almost
|
|
2121
1946
|
* always do, but in the special case of nested internal methods we do not.
|
|
@@ -2135,6 +1960,11 @@ function _bindAllCallbacks(shim, fn, name, args, spec) {
|
|
|
2135
1960
|
)
|
|
2136
1961
|
}
|
|
2137
1962
|
|
|
1963
|
+
/**
|
|
1964
|
+
* @param context
|
|
1965
|
+
* @param callback
|
|
1966
|
+
* @param binder
|
|
1967
|
+
*/
|
|
2138
1968
|
function _bindCallback(context, callback, binder) {
|
|
2139
1969
|
if (shim.isFunction(callback)) {
|
|
2140
1970
|
callback.call(context, shim, fn, name, spec.segment, args)
|
|
@@ -2156,25 +1986,19 @@ function _bindAllCallbacks(shim, fn, name, args, spec) {
|
|
|
2156
1986
|
* Binds the given segment to the lifetime of the stream.
|
|
2157
1987
|
*
|
|
2158
1988
|
* @private
|
|
2159
|
-
*
|
|
2160
1989
|
* @param {Shim} shim
|
|
2161
1990
|
* The shim performing the wrapping/binding.
|
|
2162
|
-
*
|
|
2163
1991
|
* @param {EventEmitter} stream
|
|
2164
1992
|
* The stream to bind.
|
|
2165
|
-
*
|
|
2166
1993
|
* @param {?TraceSegment} segment
|
|
2167
1994
|
* The segment to bind to the stream.
|
|
2168
|
-
*
|
|
2169
|
-
* @param {Object} [spec]
|
|
1995
|
+
* @param {object} [spec]
|
|
2170
1996
|
* Specification for how to bind the stream. The `end` and `error` events will
|
|
2171
1997
|
* always be bound, so if no functionality is desired beyond that, then this
|
|
2172
1998
|
* parameter may be omitted.
|
|
2173
|
-
*
|
|
2174
1999
|
* @param {string} [spec.event]
|
|
2175
2000
|
* The name of an event to record. If provided, a new segment will be created
|
|
2176
2001
|
* for this event and will measure each time the event is emitted.
|
|
2177
|
-
*
|
|
2178
2002
|
* @param {bool} spec.shouldCreateSegment
|
|
2179
2003
|
* Indicates if any child segments should be created. This should always be
|
|
2180
2004
|
* true unless this segment and its parent are both internal segments.
|
|
@@ -2250,23 +2074,17 @@ function _bindStream(shim, stream, segment, spec) {
|
|
|
2250
2074
|
* - `_es6WrapClass(shim, Base, fnName, spec, args)`
|
|
2251
2075
|
*
|
|
2252
2076
|
* @private
|
|
2253
|
-
*
|
|
2254
2077
|
* @param {Shim} shim
|
|
2255
2078
|
* The shim performing the wrapping/binding.
|
|
2256
|
-
*
|
|
2257
2079
|
* @param {class} Base
|
|
2258
2080
|
* The es6 class to be wrapped.
|
|
2259
|
-
*
|
|
2260
2081
|
* @param {string} fnName
|
|
2261
2082
|
* The name of the base class.
|
|
2262
|
-
*
|
|
2263
2083
|
* @param {ClassWrapSpec} spec
|
|
2264
2084
|
* The spec with pre- and post-execution hooks to call.
|
|
2265
|
-
*
|
|
2266
2085
|
* @param {Array.<*>} args
|
|
2267
2086
|
* Extra arguments to pass through to the pre- and post-execution hooks.
|
|
2268
|
-
*
|
|
2269
|
-
* @return {class} A class that extends Base with execution hooks.
|
|
2087
|
+
* @returns {class} A class that extends Base with execution hooks.
|
|
2270
2088
|
*/
|
|
2271
2089
|
function _es6WrapClass(shim, Base, fnName, spec, args) {
|
|
2272
2090
|
return class WrappedClass extends Base {
|
|
@@ -2293,25 +2111,22 @@ function _es6WrapClass(shim, Base, fnName, spec, args) {
|
|
|
2293
2111
|
* - `_es5WrapClass(shim, Base, fnName, spec, args)`
|
|
2294
2112
|
*
|
|
2295
2113
|
* @private
|
|
2296
|
-
*
|
|
2297
2114
|
* @param {Shim} shim
|
|
2298
2115
|
* The shim performing the wrapping/binding.
|
|
2299
|
-
*
|
|
2300
2116
|
* @param {Function} Base
|
|
2301
2117
|
* The class to be wrapped.
|
|
2302
|
-
*
|
|
2303
2118
|
* @param {string} fnName
|
|
2304
2119
|
* The name of the base class.
|
|
2305
|
-
*
|
|
2306
2120
|
* @param {ClassWrapSpec} spec
|
|
2307
2121
|
* The spec with pre- and post-execution hooks to call.
|
|
2308
|
-
*
|
|
2309
2122
|
* @param {Array.<*>} args
|
|
2310
2123
|
* Extra arguments to pass through to the pre- and post-execution hooks.
|
|
2311
|
-
*
|
|
2312
|
-
* @return {Function} A class that extends Base with execution hooks.
|
|
2124
|
+
* @returns {Function} A class that extends Base with execution hooks.
|
|
2313
2125
|
*/
|
|
2314
2126
|
function _es5WrapClass(shim, Base, fnName, spec, args) {
|
|
2127
|
+
/**
|
|
2128
|
+
*
|
|
2129
|
+
*/
|
|
2315
2130
|
function WrappedClass() {
|
|
2316
2131
|
const cnstrctArgs = argsToArray.apply(shim, arguments)
|
|
2317
2132
|
if (!(this instanceof WrappedClass)) {
|