@zerodep/is-weakmap
TypeScript icon, indicating that this package has built-in type declarations

2.0.7 • Public • Published

@zerodep/is-weakmap

version language types license

CodeFactor Known Vulnerabilities

A simple, performant utility to determine if a value is a Weak Map.

Full documentation is available at the zerodep.app page.

Examples

All @zerodep packages support both ESM and CJS.

import { isWeakmap } from '@zerodep/is-weakmap';
// or
const { isWeakmap } = require('@zerodep/is-weakmap');

Positive Response

// prepare a weak map
cost obj = {}
const wm = new WeakMap();
wm.set(obj, 37);

is-weakmap(wm); // true

Negative Response

is - weakmap(['a', 'b', 'c']); // false
is - weakmap(1000n); // false
is - weakmap(true); // false
is - weakmap(new Date()); // false
is - weakmap(''); // false
is - weakmap(new Error('message')); // false
is - weakmap(3.14); // false
is - weakmap(() => 'function'); // false
is - weakmap(42); // false
is -
  weakmap(
    new Map([
      ['a', 1],
      ['b', 2],
    ])
  ); // false
is - weakmap(null); // false
is - weakmap({ an: 'object' }); // false
is - weakmap(new Promise(() => {})); // false
is - weakmap(/[regex]+/gi); // false
is - weakmap(new Set([1, 2, 3])); // false
is - weakmap('a string'); // false
is - weakmap(Symbol()); // false
is - weakmap(new Int32Array(2)); // false
is - weakmap(undefined); // false

Readme

Keywords

Package Sidebar

Install

npm i @zerodep/is-weakmap

Homepage

zerodep.app

Weekly Downloads

1

Version

2.0.7

License

MIT

Unpacked Size

4.58 kB

Total Files

7

Last publish

Collaborators

  • cdepage