CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
index.js47 linesDownload Raw Back to is-set
1'use strict';2 3var $Map = typeof Map === 'function' && Map.prototype ? Map : null;4var $Set = typeof Set === 'function' && Set.prototype ? Set : null;5 6var exported;7 8if (!$Set) {9	/** @type {import('.')} */10	// eslint-disable-next-line no-unused-vars11	exported = function isSet(x) {12		// `Set` is not present in this environment.13		return false;14	};15}16 17var $mapHas = $Map ? Map.prototype.has : null;18var $setHas = $Set ? Set.prototype.has : null;19if (!exported && !$setHas) {20	/** @type {import('.')} */21	// eslint-disable-next-line no-unused-vars22	exported = function isSet(x) {23		// `Set` does not have a `has` method24		return false;25	};26}27 28/** @type {import('.')} */29module.exports = exported || function isSet(x) {30	if (!x || typeof x !== 'object') {31		return false;32	}33	try {34		$setHas.call(x);35		if ($mapHas) {36			try {37				$mapHas.call(x);38			} catch (e) {39				return true;40			}41		}42		// @ts-expect-error TS can't figure out that $Set is always truthy here43		return x instanceof $Set; // core-js workaround, pre-v2.5.044	} catch (e) {}45	return false;46};47 
basant307/AI_Governance_Project · CoolFace