index.js 469 B

123456789101112131415161718192021
  1. 'use strict';
  2. var callBound = require('call-bind/callBound');
  3. var $register = callBound('FinalizationRegistry.prototype.register', true);
  4. module.exports = $register
  5. ? function isFinalizationRegistry(value) {
  6. if (!value || typeof value !== 'object') {
  7. return false;
  8. }
  9. try {
  10. $register(value, {});
  11. return true;
  12. } catch (e) {
  13. return false;
  14. }
  15. }
  16. : function isFinalizationRegistry(value) { // eslint-disable-line no-unused-vars
  17. return false;
  18. };