npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hyperlru

v2.1.2

Published

Tiny & Fast LRU Implementation as possible

Downloads

55

Readme

hyperlru

Last version Build Status Coverage Status Dependency status Dev Dependencies Status NPM Status Donate

Tiny & Fast LRU Implementation as possible.

Features

  • Fast: High performance (See benchmark).
  • Simple: The whole project is ~60 lines of code.
  • Lightweight: The package weighs less than a megabyte, with zero dependencies.

There are a lot of LRU implementations, but most of them have a poor perfomance and they are hard to understand.

hyperlru is an Abstract LRU implementation using traditional and efficienty data structures:

  • Double Linked List: It maintains the least recent list of items.
  • Hash Table It keeps the data for easily access to cache content.

For use it, you need to provide one of the created providers:

Install

$ npm install hyperlru --save

Usage

const hyperlru = require('hyperlru')
const myProvider = require('my-hyperlru-provider')

const createLRU = hyperlru(myProvider)
const cache = createLRU({max: 1000})

Benchmark

| name | size | gzip | set | get1 | update | get2 | evict | |-----------------------------------------------------|---------|---------|------|-------|--------|-------|-------| | lru-fast | 2.34 kB | 793 B | 6855 | 27105 | 21550 | 25159 | 4003 | | tiny-lru | 4 kB | 1.64 kB | 4159 | 10746 | 18909 | 15925 | 4042 | | lru_cache | 2.19 kB | 756 B | 5320 | 14489 | 10785 | 15963 | 4242 | | simple-lru-cache | 1.43 kB | 565 B | 3289 | 12134 | 8600 | 15266 | 3334 | | hyperlru-object | 433 B | 265 B | 1152 | 8800 | 6205 | 8635 | 1039 | | hashlru | 628 B | 332 B | 4438 | 5834 | 4703 | 5960 | 3474 | | hyperlru-map | 329 B | 232 B | 850 | 4555 | 4030 | 4397 | 690 | | lru | 6.07 kB | 1.86 kB | 2672 | 3302 | 3142 | 3898 | 1347 | | lru-cache | 19.1 kB | 6.23 kB | 989 | 4702 | 3034 | 4536 | 773 | | secondary-cache | 22.6 kB | 6.54 kB | 1427 | 2292 | 2740 | 4579 | 1164 | | quick-lru | 1.23 kB | 489 B | 2441 | 2075 | 2525 | 2119 | 2525 | | modern-lru | 2.27 kB | 907 B | 1019 | 2531 | 2021 | 2456 | 731 | | mkc | 10.5 kB | 3.61 kB | 729 | 1230 | 715 | 1129 | 575 |

API

hyperlru([options])

options

max

Type: number Default: 1000

Max of element to keep into the cache.

.set(key, value)

Set the value of the key and mark the key as most recently used.

It returns the value.

.get(key)

Query the value of the key and mark the key as most recently used.

It returns the value of key if found; undefined otherwise.

.peek(key)

Query the value of the key without marking the key as most recently used.

It returns the value of key if found; undefined otherwise.

.keys()

It retrieves all the keys currently in the cache.

.values()

It retrieves all the values currently in the cache.

.clear()

Clear all the elements in the cache.

.remove(key)

Remove the value from the cache.

Returns: value of key if found; undefined otherwise.

License

MIT © Kiko Beats.