frontend/.pnpm-store/v3/files/25/88fd1879bf90004c9f896fe9206625cce2da25663ccaa5674787686ddbc7fbea2fa28d2f8f517007562fe2841d5a5ddc41e5f4fe7540f51277d9fe028bc7cf

28 lines
909 B
Plaintext

"use strict";
var isPrototype = require("../prototype/is");
// In theory we could rely on Symbol.toStringTag directly,
// still early native implementation (e.g. in FF) predated symbols
var objectToString = Object.prototype.toString, objectTaggedString = objectToString.call(new Set());
module.exports = function (value) {
if (!value) return false;
// Sanity check (reject objects which do not expose common Set interface)
try {
if (typeof value.add !== "function") return false;
if (typeof value.has !== "function") return false;
if (typeof value.clear !== "function") return false;
} catch (error) {
return false;
}
// Ensure its native Set object (has [[SetData]] slot)
// Note: it's not 100% precise as string tag may be overriden
// and other objects could be hacked to expose it
if (objectToString.call(value) !== objectTaggedString) return false;
return !isPrototype(value);
};