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

chore: document the reason for symbol.for #64

Merged
merged 2 commits into from
May 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions 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