Nikolay Vitkov | d76576c | 2024-12-02 14:10:15 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | var callBound = require('call-bind/callBound'); |
| 4 | |
| 5 | /** @type {undefined | ((value: ThisParameterType<typeof FinalizationRegistry.prototype.register>, ...args: Parameters<typeof FinalizationRegistry.prototype.register>) => ReturnType<typeof FinalizationRegistry.prototype.register>)} */ |
| 6 | var $register = callBound('FinalizationRegistry.prototype.register', true); |
| 7 | |
| 8 | /** @type {import('.')} */ |
| 9 | module.exports = $register |
| 10 | ? function isFinalizationRegistry(value) { |
| 11 | if (!value || typeof value !== 'object') { |
| 12 | return false; |
| 13 | } |
| 14 | try { |
| 15 | // @ts-expect-error TS can't figure out that it's always truthy here |
| 16 | $register(value, {}, null); |
| 17 | return true; |
| 18 | } catch (e) { |
| 19 | return false; |
| 20 | } |
| 21 | } |
| 22 | // @ts-ignore unused var |
| 23 | : function isFinalizationRegistry(value) { // eslint-disable-line no-unused-vars |
| 24 | return false; |
| 25 | }; |