Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Use ES6 Maps with a bunch of convenience methods. Help improve the ES6 spec!
var map = new Map([['foo', 'bar']]);
map.set(0, 42);
// Filter map by a function
map.filter(function(key, value, map) {
return typeof key == 'string';
});
=> new Map([[0, 42]])
// Merge Maps
map.merge(new Map([['baz', 'thing']]));
=> new Map([[0, 42], ['baz', 'thing']])
// map.get with a default
map.fetch('NON_EXISTANT', 'default');
=> 'default'
// Invert map (makes keys->values and vice versa)
map.invert();
=> new Map([[42, 0], ['thing', 'baz']])
// Destructive filter (inline map delete)
map.reject(function(key, value, map) {
return index < 3;
});
map.has('thing');
=> false
// Remove all items
map.clear();
// Check if Map has no items
map.isEmpty();
=> true
In browsers, include smap-shim.js in your page:
<script type="text/javascript" src="https://raw.github.com/eriwen/smap.js/master/smap-shim.min.js"></script>
You can install this via:
npm install smap
component install eriwen/smap.js
bower install smap
If you also use the es5-shim, you can use this in:
Boris Smus makes an excellent suggestion for moving the web forward: forward polyfills. I hope this project can be the basis for a future proposal to TC39. Please gratuitously discuss Map and WeakMap workings in issues, and add methods/tests with pull requests.
This is for everyone, not just JavaScript gurus. Standards bodies want feedback from developers like you.
FAQs
A forward polyfill with ES6 Map utilities
The npm package smap receives a total of 2 weekly downloads. As such, smap popularity was classified as not popular.
We found that smap demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.