UNPKG

1.77 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;
19class BaggageImpl {
20 constructor(entries) {
21 this._entries = entries ? new Map(entries) : new Map();
22 }
23 getEntry(key) {
24 const entry = this._entries.get(key);
25 if (!entry) {
26 return undefined;
27 }
28 return Object.assign({}, entry);
29 }
30 getAllEntries() {
31 return Array.from(this._entries.entries()).map(([k, v]) => [k, v]);
32 }
33 setEntry(key, entry) {
34 const newBaggage = new BaggageImpl(this._entries);
35 newBaggage._entries.set(key, entry);
36 return newBaggage;
37 }
38 removeEntry(key) {
39 const newBaggage = new BaggageImpl(this._entries);
40 newBaggage._entries.delete(key);
41 return newBaggage;
42 }
43 removeEntries(...keys) {
44 const newBaggage = new BaggageImpl(this._entries);
45 for (const key of keys) {
46 newBaggage._entries.delete(key);
47 }
48 return newBaggage;
49 }
50 clear() {
51 return new BaggageImpl();
52 }
53}
54exports.BaggageImpl = BaggageImpl;
55//# sourceMappingURL=baggage-impl.js.map
\No newline at end of file