Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
A simple LRU cache supporting O(1) set, get and eviction of old keys
$ npm install lru
var LRU = require('lru').LRU;
var cache = new LRU(2),
evicted
cache.on('evict',function(data) { evicted = data });
cache.set('foo', 'bar');
cache.get('foo'); //=> bar
cache.set('foo2', 'bar2');
cache.get('foo2'); //=> bar2
cache.set('foo3', 'bar3');
cache.get('foo3'); //=> bar3, evicted = { key: 'foo', value: 'bar' }
require('lru').LRU( length )
Create a new LRU cache that stores length
elements before evicting the least recently used.
Returns: the newly created LRU cache
.set( key, value )
Set the value of the key and mark the key as most recently used.
Returns: value
.set( key, value )
Set the value of the key and mark the key as most recently used.
.get( key )
Query the value of the key and mark the key as most recently used.
Returns: value of key if found; undefined
otherwise.
.on( event, callback )
Respond to events. Currently only the evict
event is implemented. When a key is evicted, the callback is executed with an associative array containing the evicted key: {key: key, value: value}
.
A big thanks to Dusty Leary who finished the library.
MIT
FAQs
A simple O(1) LRU cache
We found that lru demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.