Files
30-seconds-of-code/node_modules/opentracing/lib/reference.js
2019-08-20 15:52:05 +02:00

43 lines
1.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var span_1 = require("./span");
/**
* Reference pairs a reference type constant (e.g., REFERENCE_CHILD_OF or
* REFERENCE_FOLLOWS_FROM) with the SpanContext it points to.
*
* See the exported childOf() and followsFrom() functions at the package level.
*/
var Reference = /** @class */ (function () {
/**
* Initialize a new Reference instance.
*
* @param {string} type - the Reference type constant (e.g.,
* REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM).
* @param {SpanContext} referencedContext - the SpanContext being referred
* to. As a convenience, a Span instance may be passed in instead
* (in which case its .context() is used here).
*/
function Reference(type, referencedContext) {
this._type = type;
this._referencedContext = (referencedContext instanceof span_1.default ?
referencedContext.context() :
referencedContext);
}
/**
* @return {string} The Reference type (e.g., REFERENCE_CHILD_OF or
* REFERENCE_FOLLOWS_FROM).
*/
Reference.prototype.type = function () {
return this._type;
};
/**
* @return {SpanContext} The SpanContext being referred to (e.g., the
* parent in a REFERENCE_CHILD_OF Reference).
*/
Reference.prototype.referencedContext = function () {
return this._referencedContext;
};
return Reference;
}());
exports.default = Reference;
//# sourceMappingURL=reference.js.map