is-weakref
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
call-bind | 1.0.7 | 21.6 kB | MIT | prod |
Is-weakref is an npm package that provides a method for checking if a particular value is a JavaScript WeakRef. It boasts capabilities for cross-realm and cross-iframe compatibility, allowing for wide usage. Moreover, it handles cases despite ES6 @@toStringTag, making it a versatile tool for developers.
To use is-weakref in your JavaScript project, you first need to install it via npm using the command npm install is-weakref
. After that, you can import it into your JavaScript file using a require statement. For example:
var isWeakRef = require('is-weakref');
Then, you can use the isWeakRef
function to check if a particular object is a WeakRef or not. Here are some usage examples:
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({})));
In the provided code snippet, the isWeakRef
function is used to confirm whether various entities are WeakRef or not.
The is-weakref documentation is quite straightforward and contained within the README file on the package's GitHub repository. You can access this by visiting the git repository at git+https://github.com/inspect-js/is-weakref.git. The documentation consists of installation instructions, usage examples, and tips for running tests. It's designed to provide all the necessary information for developers to get started using the package and integrating it into their JavaScript projects.