Lobashov_Ivan_PIBD-21_IP/Lab2/node_modules/is-weakref/index.js

22 lines
438 B
JavaScript
Raw Normal View History

2024-01-10 22:39:31 +04:00
'use strict';
var callBound = require('call-bind/callBound');
var $deref = callBound('WeakRef.prototype.deref', true);
module.exports = typeof WeakRef === 'undefined'
? function isWeakRef(value) { // eslint-disable-line no-unused-vars
return false;
}
: function isWeakRef(value) {
if (!value || typeof value !== 'object') {
return false;
}
try {
$deref(value);
return true;
} catch (e) {
return false;
}
};