thisSymbolValue.js 484 B

1234567891011121314151617
  1. 'use strict';
  2. var callBound = require('call-bind/callBound');
  3. var $SymbolValueOf = callBound('Symbol.prototype.valueOf', true);
  4. // https://262.ecma-international.org/9.0/#sec-thissymbolvalue
  5. module.exports = function thisSymbolValue(value) {
  6. if (!$SymbolValueOf) {
  7. throw new SyntaxError('Symbols are not supported; thisSymbolValue requires that `value` be a Symbol or a Symbol object');
  8. }
  9. if (typeof value === 'symbol') {
  10. return value;
  11. }
  12. return $SymbolValueOf(value);
  13. };