is-weakref

Is this value a JS WeakRef? This module works cross-realm/iframe, and despite ES6 @@toStringTag.

MIT 5 个版本
安装
npm install is-weakref
yarn add is-weakref
pnpm add is-weakref
bun add is-weakref
README

is-weakref Version Badge

github actions coverage dependency status dev dependency status License Downloads

[![npm badge][11]][1]

Is this value a JS WeakRef? This module works cross-realm/iframe, and despite ES6 @@toStringTag.

Example

var isWeakRef = require('is-weakref');
assert(!isWeakRef(function () {}));
assert(!isWeakRef(null));
assert(!isWeakRef(function* () { yield 42; return Infinity; });
assert(!isWeakRef(Symbol('foo')));
assert(!isWeakRef(1n));
assert(!isWeakRef(Object(1n)));

assert(!isWeakRef(new Set()));
assert(!isWeakRef(new WeakSet()));
assert(!isWeakRef(new Map()));
assert(!isWeakRef(new WeakMap()));

assert(isWeakRef(new WeakRef({})));

class MyWeakRef extends WeakRef {}
assert(isWeakRef(new MyWeakRef({})));

Tests

Simply clone the repo, npm install, and run npm test

版本列表
1.1.1 2025-02-03
1.1.0 2024-12-13
1.0.2 2021-12-10
1.0.1 2020-12-05
1.0.0 2020-08-02