lru-queue

WebJar for lru-queue

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

lru-queue
Последняя версия

Последняя версия

0.1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

lru-queue
WebJar for lru-queue
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/medikoo/lru-queue

Скачать lru-queue

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/lru-queue/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>lru-queue</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/lru-queue/
implementation 'org.webjars.npm:lru-queue:0.1.0'
// https://jarcasting.com/artifacts/org.webjars.npm/lru-queue/
implementation ("org.webjars.npm:lru-queue:0.1.0")
'org.webjars.npm:lru-queue:jar:0.1.0'
<dependency org="org.webjars.npm" name="lru-queue" rev="0.1.0">
  <artifact name="lru-queue" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='lru-queue', version='0.1.0')
)
libraryDependencies += "org.webjars.npm" % "lru-queue" % "0.1.0"
[org.webjars.npm/lru-queue "0.1.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.webjars.npm : es5-ext jar [0.10.2,0.11)

Модули Проекта

Данный проект не имеет модулей.

Build status Windows status Transpilation status npm version

lru-queue

Size limited queue based on LRU algorithm

Originally derived from memoizee package.

It's low-level utility meant to be used internally within cache algorithms. It backs up max functionality in memoizee project.

Installation

$ npm install lru-queue

To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: Browserify, Webmake or Webpack

Usage

Create queue, and provide a limit

var lruQueue = require("lru-queue");
var queue = lruQueue(3); // limit size to 3

Each queue exposes three methods:

queue.hit(id)

Registers hit for given id (must be plain string).

queue.hit("raz"); // size: 1

If hit doesn't remove any old item from list it returns undefined, otherwise removed id is returned.

queue.hit("dwa"); // undefined, size: 2
queue.hit("trzy"); // undefined, size: 3 (at max)
queue.hit("raz"); // undefined, size: 3 (at max)
queue.hit("dwa"); // undefined, size: 3 (at max)
queue.hit("cztery"); // 'trzy', size: 3 (at max)

queue.delete(id);

id's can be cleared from queue externally

queue.delete("raz"); // size: 2
queue.delete("cztery"); // size: 1

queue.clear();

Resets the queue

queue.clear(); // size: 0

Tests

$ npm test

Версии библиотеки

Версия
0.1.0