UNPKG

2.3 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright The OpenTelemetry Authors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.BaggageImpl = void 0;
19var BaggageImpl = /** @class */ (function () {
20 function BaggageImpl(entries) {
21 this._entries = entries ? new Map(entries) : new Map();
22 }
23 BaggageImpl.prototype.getEntry = function (key) {
24 var entry = this._entries.get(key);
25 if (!entry) {
26 return undefined;
27 }
28 return Object.assign({}, entry);
29 };
30 BaggageImpl.prototype.getAllEntries = function () {
31 return Array.from(this._entries.entries()).map(function (_a) {
32 var k = _a[0], v = _a[1];
33 return [k, v];
34 });
35 };
36 BaggageImpl.prototype.setEntry = function (key, entry) {
37 var newBaggage = new BaggageImpl(this._entries);
38 newBaggage._entries.set(key, entry);
39 return newBaggage;
40 };
41 BaggageImpl.prototype.removeEntry = function (key) {
42 var newBaggage = new BaggageImpl(this._entries);
43 newBaggage._entries.delete(key);
44 return newBaggage;
45 };
46 BaggageImpl.prototype.removeEntries = function () {
47 var keys = [];
48 for (var _i = 0; _i < arguments.length; _i++) {
49 keys[_i] = arguments[_i];
50 }
51 var newBaggage = new BaggageImpl(this._entries);
52 for (var _a = 0, keys_1 = keys; _a < keys_1.length; _a++) {
53 var key = keys_1[_a];
54 newBaggage._entries.delete(key);
55 }
56 return newBaggage;
57 };
58 BaggageImpl.prototype.clear = function () {
59 return new BaggageImpl();
60 };
61 return BaggageImpl;
62}());
63exports.BaggageImpl = BaggageImpl;
64//# sourceMappingURL=baggage-impl.js.map
\No newline at end of file