1 | # is-finalizationregistry <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
|
---|
2 |
|
---|
3 | [![github actions][actions-image]][actions-url]
|
---|
4 | [![coverage][codecov-image]][codecov-url]
|
---|
5 | [![dependency status][deps-svg]][deps-url]
|
---|
6 | [![dev dependency status][dev-deps-svg]][dev-deps-url]
|
---|
7 | [![License][license-image]][license-url]
|
---|
8 | [![Downloads][downloads-image]][downloads-url]
|
---|
9 |
|
---|
10 | [![npm badge][npm-badge-png]][package-url]
|
---|
11 |
|
---|
12 | Is this value a JS FinalizationRegistry? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
|
---|
13 |
|
---|
14 | ## Example
|
---|
15 |
|
---|
16 | ```js
|
---|
17 | var isFinalizationRegistry = require('is-finalizationregistry');
|
---|
18 | assert(!isFinalizationRegistry(function () {}));
|
---|
19 | assert(!isFinalizationRegistry(null));
|
---|
20 | assert(!isFinalizationRegistry(function* () { yield 42; return Infinity; });
|
---|
21 | assert(!isFinalizationRegistry(Symbol('foo')));
|
---|
22 | assert(!isFinalizationRegistry(1n));
|
---|
23 | assert(!isFinalizationRegistry(Object(1n)));
|
---|
24 |
|
---|
25 | assert(!isFinalizationRegistry(new Set()));
|
---|
26 | assert(!isFinalizationRegistry(new WeakSet()));
|
---|
27 | assert(!isFinalizationRegistry(new Map()));
|
---|
28 | assert(!isFinalizationRegistry(new WeakMap()));
|
---|
29 | assert(!isFinalizationRegistry(new WeakRef({})));
|
---|
30 |
|
---|
31 | assert(isFinalizationRegistry(new FinalizationRegistry(function () {})));
|
---|
32 |
|
---|
33 | class MyFinalizationRegistry extends FinalizationRegistry {}
|
---|
34 | assert(isFinalizationRegistry(new MyFinalizationRegistry(function () {})));
|
---|
35 | ```
|
---|
36 |
|
---|
37 | ## Tests
|
---|
38 | Simply clone the repo, `npm install`, and run `npm test`
|
---|
39 |
|
---|
40 | [package-url]: https://npmjs.org/package/is-finalizationregistry
|
---|
41 | [npm-version-svg]: https://versionbadg.es/inspect-js/is-finalizationregistry.svg
|
---|
42 | [deps-svg]: https://david-dm.org/inspect-js/is-finalizationregistry.svg
|
---|
43 | [deps-url]: https://david-dm.org/inspect-js/is-finalizationregistry
|
---|
44 | [dev-deps-svg]: https://david-dm.org/inspect-js/is-finalizationregistry/dev-status.svg
|
---|
45 | [dev-deps-url]: https://david-dm.org/inspect-js/is-finalizationregistry#info=devDependencies
|
---|
46 | [npm-badge-png]: https://nodei.co/npm/is-finalizationregistry.png?downloads=true&stars=true
|
---|
47 | [license-image]: https://img.shields.io/npm/l/is-finalizationregistry.svg
|
---|
48 | [license-url]: LICENSE
|
---|
49 | [downloads-image]: https://img.shields.io/npm/dm/is-finalizationregistry.svg
|
---|
50 | [downloads-url]: https://npm-stat.com/charts.html?package=is-finalizationregistry
|
---|
51 | [codecov-image]: https://codecov.io/gh/inspect-js/is-finalizationregistry/branch/main/graphs/badge.svg
|
---|
52 | [codecov-url]: https://app.codecov.io/gh/inspect-js/is-finalizationregistry/
|
---|
53 | [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/is-finalizationregistry
|
---|
54 | [actions-url]: https://github.com/inspect-js/is-finalizationregistry/actions
|
---|