https://github.com/lamansky/weakable
[Node.js] Returns true if a value can be used as a WeakSet item or a WeakMap key.
https://github.com/lamansky/weakable
javascript nodejs weakmap weakset
Last synced: 6 months ago
JSON representation
[Node.js] Returns true if a value can be used as a WeakSet item or a WeakMap key.
- Host: GitHub
- URL: https://github.com/lamansky/weakable
- Owner: lamansky
- License: mit
- Created: 2017-11-28T11:09:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-28T11:16:08.000Z (over 8 years ago)
- Last Synced: 2025-08-04T02:48:03.576Z (7 months ago)
- Topics: javascript, nodejs, weakmap, weakset
- Language: JavaScript
- Homepage:
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# weakable
A Node.js module that returns true if a value can be used as a WeakSet item or a WeakMap key.
## Installation
```bash
npm install weakable --save
```
## Usage
```javascript
const weakable = require('weakable')
const set = new WeakSet()
const obj = {}
weakable(obj) // true
set.add(obj)
const str = 'test'
weakable(str) // false
set.add(str) // Uncaught TypeError: Invalid value used in weak set
```