
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
weakmap.prototype.getorinsert
Advanced tools
ES Proposal spec-compliant shim for WeakMap.prototype.getOrInsert
An ESnext spec-compliant WeakMap.prototype.getOrInsert shim/polyfill/replacement that works as far down as ES3.
This package implements the es-shim API v3 interface. It works in an ES3-supported environment and complies with the proposed spec.
npm install --save weakmap.prototype.getorinsert
var getOrInsert = require('weakmap.prototype.getorinsert');
var assert = require('assert');
var map = new WeakMap();
var key = {};
var value = {};
assert.equal(map.has(key), false);
assert.equal(getOrInsert(map, key, value), value);
assert.equal(map.has(key), true);
var getPolyfill = require('weakmap.prototype.getorinsert/polyfill');
var shim = require('weakmap.prototype.getorinsert/shim');
var assert = require('assert');
/* when WeakMap.prototype.getOrInsert is not present */
delete WeakMap.prototype.getOrInsert;
var shimmed = shim();
assert.equal(shimmed, getPolyfill());
var map = new WeakMap();
var key = {};
var value = {};
assert.equal(map.has(key), false);
assert.equal(map.getOrInsert(key, value), value);
assert.equal(map.has(key), true);
var shim = require('weakmap.prototype.getorinsert/shim');
var assert = require('assert');
/* when WeakMap.prototype.getOrInsert is present */
var shimmed = shim();
assert.equal(shimmed, WeakMap.prototype.getOrInsert);
var map = new WeakMap();
var key = {};
var value = {};
assert.equal(map.has(key), false);
assert.equal(map.getOrInsert(key, value), value);
assert.equal(map.has(key), true);
Simply clone the repo, npm install, and run npm test
FAQs
ES Proposal spec-compliant shim for WeakMap.prototype.getOrInsert
The npm package weakmap.prototype.getorinsert receives a total of 1 weekly downloads. As such, weakmap.prototype.getorinsert popularity was classified as not popular.
We found that weakmap.prototype.getorinsert demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.