File size: 391 Bytes
9ada4bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * Returns the value behind the symbol with the given name.
 */
export function getValueBySymbol<T>(
  symbolName: string,
  source: object
): T | undefined {
  const ownSymbols = Object.getOwnPropertySymbols(source)

  const symbol = ownSymbols.find((symbol) => {
    return symbol.description === symbolName
  })

  if (symbol) {
    return Reflect.get(source, symbol)
  }

  return
}