|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var GetIntrinsic = require('get-intrinsic');
|
|---|
| 4 | var callBound = require('call-bound');
|
|---|
| 5 |
|
|---|
| 6 | var $WeakSet = GetIntrinsic('%WeakSet%', true);
|
|---|
| 7 |
|
|---|
| 8 | /** @type {undefined | (<V>(thisArg: Set<V>, value: V) => boolean)} */
|
|---|
| 9 | var $setHas = callBound('WeakSet.prototype.has', true);
|
|---|
| 10 |
|
|---|
| 11 | if ($setHas) {
|
|---|
| 12 | /** @type {undefined | (<K extends object, V>(thisArg: WeakMap<K, V>, key: K) => boolean)} */
|
|---|
| 13 | var $mapHas = callBound('WeakMap.prototype.has', true);
|
|---|
| 14 |
|
|---|
| 15 | /** @type {import('.')} */
|
|---|
| 16 | module.exports = function isWeakSet(x) {
|
|---|
| 17 | if (!x || typeof x !== 'object') {
|
|---|
| 18 | return false;
|
|---|
| 19 | }
|
|---|
| 20 | try {
|
|---|
| 21 | // @ts-expect-error TS can't figure out that $setHas is always truthy here
|
|---|
| 22 | $setHas(x, $setHas);
|
|---|
| 23 | if ($mapHas) {
|
|---|
| 24 | try {
|
|---|
| 25 | // @ts-expect-error this indeed might not be a weak collection
|
|---|
| 26 | $mapHas(x, $mapHas);
|
|---|
| 27 | } catch (e) {
|
|---|
| 28 | return true;
|
|---|
| 29 | }
|
|---|
| 30 | }
|
|---|
| 31 | // @ts-expect-error TS can't figure out that $WeakSet is always truthy here
|
|---|
| 32 | return x instanceof $WeakSet; // core-js workaround, pre-v3
|
|---|
| 33 | } catch (e) {}
|
|---|
| 34 | return false;
|
|---|
| 35 | };
|
|---|
| 36 | } else {
|
|---|
| 37 | /** @type {import('.')} */
|
|---|
| 38 | // @ts-expect-error
|
|---|
| 39 | module.exports = function isWeakSet(x) { // eslint-disable-line no-unused-vars
|
|---|
| 40 | // `WeakSet` does not exist, or does not have a `has` method
|
|---|
| 41 | return false;
|
|---|
| 42 | };
|
|---|
| 43 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.