CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
1'use strict';2 3var GetIntrinsic = require('get-intrinsic');4 5var callBound = require('call-bound');6 7var $SyntaxError = require('es-errors/syntax');8var getGlobalSymbolDescription = GetIntrinsic('%Symbol.keyFor%', true);9/** @type {undefined | ((thisArg: symbol | Symbol) => symbol)} */10var thisSymbolValue = callBound('%Symbol.prototype.valueOf%', true);11/** @type {undefined | ((thisArg: symbol | Symbol) => string)} */12var symToStr = callBound('Symbol.prototype.toString', true);13/** @type {(thisArg: string, start?: number, end?: number) => string} */14var $strSlice = callBound('String.prototype.slice');15 16var getInferredName = require('./getInferredName');17 18/** @type {import('.')} */19/* eslint-disable consistent-return */20module.exports = callBound('%Symbol.prototype.description%', true) || function getSymbolDescription(symbol) {21	if (!thisSymbolValue) {22		throw new $SyntaxError('Symbols are not supported in this environment');23	}24 25	// will throw if not a symbol primitive or wrapper object26	var sym = thisSymbolValue(symbol);27 28	if (getInferredName) {29		var name = getInferredName(sym);30		if (name === '') {31			return;32		}33		return name.slice(1, -1); // name.slice('['.length, -']'.length);34	}35 36	var desc;37	if (getGlobalSymbolDescription) {38		desc = getGlobalSymbolDescription(sym);39		if (typeof desc === 'string') {40			return desc;41		}42	}43 44	// eslint-disable-next-line no-extra-parens45	desc = $strSlice(/** @type {NonNullable<typeof symToStr>} */ (symToStr)(sym), 7, -1); // str.slice('Symbol('.length, -')'.length);46	if (desc) {47		return desc;48	}49};50 
basant307/AI_Governance_Project · CoolFace