Skip to content

Commit

Permalink
chore: document the reason for symbol.for (open-telemetry#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored May 12, 2021
1 parent 081e935 commit 37fc4f9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/src/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ import { Context } from './types';

/** 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 37fc4f9

Please sign in to comment.