Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
chore: document the reason for symbol.for
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan committed May 12, 2021
1 parent b5784d3 commit f63dafc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ export function setBaggage(context: Context, baggage: Baggage): Context {

/** Get a key to uniquely identify a context value */
export function createContextKey(description: string) {
// The specification states that for the same input, multiple calls should
// return different keys. Due to the nature of the JS dependency management
// system, this creates problems where multiple versions of some package
// could hold different keys for the same property.
//
// Therefore, we use Symbol.for which returns the same key for the same input.
return Symbol.for(description);
}

Expand Down

0 comments on commit f63dafc

Please sign in to comment.