Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

getSymbolDescription.js 852B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. var GetIntrinsic = require('../GetIntrinsic');
  3. var callBound = require('./callBound');
  4. var $SyntaxError = GetIntrinsic('%SyntaxError%');
  5. var symToStr = callBound('Symbol.prototype.toString', true);
  6. var getInferredName = require('./getInferredName');
  7. module.exports = function getSymbolDescription(symbol) {
  8. if (!symToStr) {
  9. throw new $SyntaxError('Symbols are not supported in this environment');
  10. }
  11. var str = symToStr(symbol); // will throw if not a symbol
  12. if (getInferredName) {
  13. var name = getInferredName(symbol);
  14. if (name === '') { return; }
  15. // eslint-disable-next-line consistent-return
  16. return name.slice(1, -1); // name.slice('['.length, -']'.length);
  17. }
  18. var desc = str.slice(7, -1); // str.slice('Symbol('.length, -')'.length);
  19. if (desc) {
  20. // eslint-disable-next-line consistent-return
  21. return desc;
  22. }
  23. };