Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
cache-mapset
Advanced tools
Maps and Sets with cache replacement policies, TC39 proposal-policy-map-set implementation
Maps and Sets with cache replacement policies, TC39 proposal-policy-map-set implementation. This can be used as a cache for TC39 proposal-function-memo and its implementation.
All Map-like constructors specify capacity.
When the limit is reached, the cache is adjusted according to the cache replacement policy.
import { LRUMap } from "https://deno.land/x/cache_mapset@$VERSION/mod.ts";
import { assert, assertEquals } from "https://deno.land/std/testing/asserts.ts";
declare const capacity: 2;
const map = new LRUMap<number, string>(capacity);
map.set(200, "Ok");
map.set(201, "Created");
assertEquals(map.size, 2);
map.set(202, "Accepted");
assertEquals(map.size, 2);
assert(map.has(201));
assert(map.has(202));
It provides a Map-like constructor with the following cache-replacement-policy:
SetLike
is a set-like constructor, with the same cache-replacement-policy.
LFUSet
preferentially removes item with fewer references (by has
or add
).
import { LFUSet } from "https://deno.land/x/cache_mapset@$VERSION/mod.ts";
import { assert, assertEquals } from "https://deno.land/std/testing/asserts.ts";
declare const capacity: 2;
const set = new LFUSet<number>(capacity);
set.add(200);
set.add(201);
assertEquals(set.size, 2);
assert(set.has(200));
set.add(202);
assert(set.has(200));
assert(set.has(202));
Accepts an initial value, like Map
or Set
. If overcapacity occurs, the cache
is adjusted according to the policy.
import { FIFOSet } from "https://deno.land/x/cache_mapset@$VERSION/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";
const set = new FIFOSet<number>(3, [0, 1, 2, 3, 4, 5]);
assertEquals(set.size, 3);
All constructors specify a capacity as their first argument.
If it is a negative number, an error is thrown.
import { FIFOMap } from "https://deno.land/x/cache_mapset@$VERSION/mod.ts";
import { assertThrows } from "https://deno.land/std/testing/asserts.ts";
assertThrows(() => new FIFOMap(-1));
MapLike
and SetLike
are not Iterable
.
The following members are not implemented.
Symbol.iterator
forEach
entries
keys
values
Currently, these are outside the scope of the specification. For more information, check Data iteration and order.
See deno doc for all APIs.
See CONTRIBUTING.md
MIT © 2023 Tomoki Miyauchi
FAQs
Maps and Sets with cache replacement policies, TC39 proposal-policy-map-set implementation
The npm package cache-mapset receives a total of 5 weekly downloads. As such, cache-mapset popularity was classified as not popular.
We found that cache-mapset 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.