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 🙏

© 2026 – Pkg Stats / Ryan Hefner

super-lru-cache

v1.0.0

Published

A super fast LRU Cache implementation using Doubly Linked List and Hash Map. O(1) time complexity.

Downloads

78

Readme

⚡ Super Fast LRU Cache

A high-performance, lightweight implementation of the Least Recently Used (LRU) Cache algorithm in JavaScript.

NPM Version

Built using a combination of Doubly Linked List and Hash Map, ensuring that both read and write operations happen in O(1) (Constant Time). Perfect for caching API responses, managing browser history, or optimizing heavy computations.


🚀 Features

  • ⚡ Blazing Fast: get and put operations perform in O(1) time complexity.
  • 📦 Ultra Lightweight: Zero external dependencies.
  • 🧠 Efficient Memory Management: Automatically removes the least recently used items when capacity is reached.
  • ✅ Easy to Use: Simple and intuitive API.

📦 Installation

You can install this package via npm:

npm install super-lru-cache


🛠 Usage
Here is a quick example of how to use the cache:

const LRUCache = require('super-lru-cache');

// 1. Initialize the cache with a capacity of 3 items
const cache = new LRUCache(3);

// 2. Add items to the cache
cache.put("user_1", "Rohit");
cache.put("user_2", "Virat");
cache.put("user_3", "Dhoni");

console.log(cache.get("user_1")); 
// Output: "Rohit"
// (user_1 is now the "Most Recently Used" item)

// 3. Add a new item (Cache is full!)
// This will trigger the eviction of 'user_2' (Virat) because 'user_1' was just accessed
// and 'user_2' became the least recently used.
cache.put("user_4", "Hardik");

// 4. Try to access the evicted item
console.log(cache.get("user_2")); 
// Output: -1 (Item was removed)

// 5. Check the current state
// Cache contains: [Hardik, user_1, user_3]

Bilkul, yeh lijiye saari files ek jagah. Aapko bas 2 files update karni hain aur phir publish command chalana hai.

File 1: package.json
(Is file mein poora purana code hata kar ye paste karein. Maine version 1.0.1 kar diya hai aur keywords add kar diye hain).

JSON

{
  "name": "super-lru-cache",
  "version": "1.0.1",
  "description": "A high-performance, O(1) time complexity LRU Cache implementation using Doubly Linked List and Hash Map.",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "lru",
    "cache",
    "lru-cache",
    "linked-list",
    "data-structure",
    "fast",
    "optimization",
    "performance",
    "javascript"
  ],
  "author": "Rohit Kumar",
  "license": "MIT"
}
File 2: README.md
(Is file mein purana content hata kar ye paste karein).

Markdown

# ⚡ Super Fast LRU Cache

> A high-performance, lightweight implementation of the Least Recently Used (LRU) Cache algorithm in JavaScript.

[![NPM Version](https://img.shields.io/npm/v/super-lru-cache.svg)](https://www.npmjs.com/package/super-lru-cache)

Built using a combination of **Doubly Linked List** and **Hash Map**, ensuring that both read and write operations happen in **O(1)** (Constant Time). Perfect for caching API responses, managing browser history, or optimizing heavy computations.

---

## 🚀 Features

- **⚡ Blazing Fast:** `get` and `put` operations perform in **O(1)** time complexity.
- **📦 Ultra Lightweight:** Zero external dependencies.
- **🧠 Efficient Memory Management:** Automatically removes the least recently used items when capacity is reached.
- **✅ Easy to Use:** Simple and intuitive API.

---

## 📦 Installation

You can install this package via npm:

```bash
npm install super-lru-cache
🛠 Usage
Here is a quick example of how to use the cache:

JavaScript

const LRUCache = require('super-lru-cache');

// 1. Initialize the cache with a capacity of 3 items
const cache = new LRUCache(3);

// 2. Add items to the cache
cache.put("user_1", "Rohit");
cache.put("user_2", "Virat");
cache.put("user_3", "Dhoni");

console.log(cache.get("user_1")); 
// Output: "Rohit"
// (user_1 is now the "Most Recently Used" item)

// 3. Add a new item (Cache is full!)
// This will trigger the eviction of 'user_2' (Virat) because 'user_1' was just accessed
// and 'user_2' became the least recently used.
cache.put("user_4", "Hardik");

// 4. Try to access the evicted item
console.log(cache.get("user_2")); 
// Output: -1 (Item was removed)

// 5. Check the current state
// Cache contains: [Hardik, user_1, user_3]
📚 API Reference
new LRUCache(capacity)
Creates a new cache instance.

capacity (number): The maximum number of items the cache can hold.

.put(key, value)
Adds a key-value pair to the cache. If the key already exists, its value is updated and it becomes the most recently used item. If the cache is full, the least recently used item is removed.

.get(key)
Retrieves the value associated with the key.

Returns the value if the key exists.

Returns -1 if the key does not exist.

Side Effect: Moves the accessed item to the "Most Recently Used" position.

🤝 Contributing
Contributions, issues, and feature requests are welcome!

📝 Author
Rohit Kumar

📄 License
This project is MIT licensed.