Skip to content

Commit

Permalink
Added LRU, because i'm a idiot sandwitch
Browse files Browse the repository at this point in the history
This is the simplest implementation of LRU, which works faster than the npm package "lru-cache". Tests/benchmarks maybe will be added later.
  • Loading branch information
salwador committed Oct 19, 2024
1 parent 7fd88f4 commit 245905c
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 96 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Fastify-Bowser
![Build & Test](https://github.com/bsnext/fastify-bowser/actions/workflows/build_n_test.yml/badge.svg)
![Node.JS Supported](https://badgen.net/static/Node.JS/%3E=19.0.0/green)
![Fastify Supported](https://badgen.net/static/Fastify/%3E=14/green)
![Fastify Supported](https://badgen.net/static/Fastify/%3E=4.14.0/green)
![Install Size](https://badgen.net/packagephobia/install/@bsnext/fastify-bowser)
![Dependencies](https://badgen.net/bundlephobia/dependency-count/@bsnext/fastify-bowser)
![License](https://badgen.net/static/license/MIT/blue)
Expand Down Expand Up @@ -33,10 +33,11 @@ await server.register(FastifyBowser, {
cache: boolean = false;

// Cache limit. Will be automatically purged, if cache size reach limit.
cacheLimit: number = 100;
cacheLimit?: number = 100;

// Automatically cache purge interval in milliseconds.
cachePurgeTime: number = 60 * 5;
// Automatically cache purge interval in seconds.
// Disabled by default
cachePurgeTime?: number;
});

```
Expand Down
18 changes: 10 additions & 8 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
declare module "fastify" {
interface FastifyRequest {
useragent: {
ua: string;
browser: {
name: string | undefined;
version: string | undefined;
name?: string;
version?: string;
};
os: {
name: string | undefined;
version: string | undefined;
versionName: string | undefined;
name?: string;
version?: string;
versionName?: string;
};
platform: {
type: string | undefined;
type?: string;
vendor?: string;
model?: string;
};
engine: {
name: string | undefined;
name?: string;
version?: string;
};
};
}
Expand Down
142 changes: 113 additions & 29 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 30 additions & 4 deletions dist/test/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/test/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bsnext/fastify-bowser",
"version": "1.0.0",
"version": "1.2.0",
"description": "A plugin for Fastify that adds the 'request.useragent' property to get header 'user-agent' parsed data.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Loading

0 comments on commit 245905c

Please sign in to comment.