Skip to content

Commit

Permalink
docs: improve documentation (#35)
Browse files Browse the repository at this point in the history
* docs: improve documentation

* docs: improve documentation

* docs: improve documentation
  • Loading branch information
wellwelwel committed Aug 28, 2024
1 parent 61afeb4 commit de35d95
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ deno add npm:lru.min
```js
import { createLRU } from 'lru.min';

const max = 2;
const onEviction = (key, value) => {
console.log(`Key "${key}" with value "${value}" has been evicted.`);
};

const LRU = createLRU({
max: 2,
onEviction: (key, value) => {
console.log(`Key "${key}" with value "${value}" has been evicted.`);
},
max,
onEviction,
});

LRU.set('A', 'My Value');
Expand All @@ -62,11 +65,23 @@ LRU.delete('B');

// => Key "B" with value "Other Value" has been evicted.

LRU.clear();
LRU.peek('C');

LRU.clear(); // LRU.evict(max)

// => Key "C" with value "Another Value" has been evicted.

LRU.set('D', "You're amazing 💛");

LRU.size; // 1
LRU.max; // 2
LRU.available; // 1

LRU.resize(10);

LRU.size; // 1
LRU.max; // 10
LRU.available; // 9
```

> For _up-to-date_ documentation, always follow the [**README.md**](https://github.com/wellwelwel/lru.min?tab=readme-ov-file#readme) in the **GitHub** repository.
Expand Down Expand Up @@ -286,7 +301,9 @@ For more comprehensive features such as **TTL** support, consider using and supp

#### What comes from [**lru-cache**](https://github.com/isaacs/node-lru-cache)?

- _Not the same, but majority based on:_
Architecture's essence:

> _It's not the same code, but majority based on [this](https://github.com/isaacs/node-lru-cache/blob/8f51d75351cbb4ac819952eb8e9f95eda00ef800/src/index.ts#L1385-L1394)._
```ts
let free: number[] = [];
Expand All @@ -302,7 +319,7 @@ const prev: number[] = new Array(max).fill(0);

#### What comes from [**quick-lru**](https://github.com/sindresorhus/quick-lru)?

Name of methods and options _(including its final functionality idea)_:
Name of methods and options _(including their final functionality ideas)_:

- `resize`
- `peek`
Expand Down

0 comments on commit de35d95

Please sign in to comment.