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

Commit 26ae4c4

Browse files
authored
chore: document the reason for symbol.for (#64)
1 parent 6dda822 commit 26ae4c4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/context/context.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ import { Context } from './types';
1818

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

0 commit comments

Comments
 (0)