🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

@trigo/atrix-acl

Package Overview
Dependencies
Maintainers
3
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trigo/atrix-acl - npm Package Compare versions

Comparing version
3.12.2
to
3.12.3
+14
-11
lib/hapi-acl-plugin/lib/route-parser.js

@@ -5,9 +5,7 @@ 'use strict';

const PARSER_CACHE = {};
const MAX_CACHE_SIZE = 100;
let cacheKeys = [];
const MAX_MATCH_CACHE_SIZE = 10000;
class CachingRouteParser {
constructor(routeParser) {
this.MAX_CACHE_SIZE = 10000;
this.MATCH_CACHE = {};

@@ -19,8 +17,11 @@ this.cacheKeys = [];

match(path) {
if (this.MATCH_CACHE[path] !== undefined) return this.MATCH_CACHE[path];
if (this.MATCH_CACHE[path] !== undefined) {
return this.MATCH_CACHE[path];
}
if (this.cacheKeys.length === this.MAX_CACHE_SIZE) {
const tenPercent = Math.max(Math.ceil(this.MAX_CACHE_SIZE * 0.5), 1);
if (this.cacheKeys.length === MAX_MATCH_CACHE_SIZE) {
const tenPercent = Math.max(Math.ceil(MAX_MATCH_CACHE_SIZE * 0.1), 1);
console.log(`atrix-acl:RouteParser:CachingRouteParser: Reached max MATCH_CACHE size: ${MAX_MATCH_CACHE_SIZE}. Free cache ${tenPercent} items...`);
for (let i = 0; i < tenPercent; i++) {
this.MATCH_CACHE[this.cacheKeys[i]] = null;
this.MATCH_CACHE[this.cacheKeys[i]] = undefined;
}

@@ -37,2 +38,5 @@

const PARSER_CACHE = {};
let cacheKeys = [];
module.exports = (route) => {

@@ -42,11 +46,10 @@ if (PARSER_CACHE[route]) return PARSER_CACHE[route];

if (cacheKeys.length === MAX_CACHE_SIZE) {
const tenPercent = Math.max(Math.ceil(MAX_CACHE_SIZE * 0.5), 1);
const tenPercent = Math.max(Math.ceil(MAX_CACHE_SIZE * 0.1), 1);
// console.log(`Reached max cache size: ${MAX_CACHE_SIZE}. Free cache ${tenPercent} items...`);
console.log(`atrix-acl:RouteParser: Reached max PARSER_CACHE size: ${MAX_CACHE_SIZE}. Free cache ${tenPercent} items...`);
for (let i = 0; i < tenPercent; i++) {
PARSER_CACHE[cacheKeys[i]] = null;
PARSER_CACHE[cacheKeys[i]] = undefined;
}
cacheKeys = cacheKeys.slice(tenPercent);
// console.log(`New cache size: ${cacheKeys.length}`);
}

@@ -53,0 +56,0 @@

@@ -8,4 +8,4 @@ 'use strict';

describe('route-parser', () => {
it.skip('uses constant max memory (SLOW!)', async () => {
describe.skip('route-parser', () => {
it('uses constant max memory (SLOW!)', async () => {
let iteration = 0;

@@ -22,4 +22,5 @@ do {

iteration++;
console.log(`Finished iteration: ${iteration}`);
} while (iteration < 10000);
});
});
{
"name": "@trigo/atrix-acl",
"version": "3.12.2",
"version": "3.12.3",
"engines": {

@@ -5,0 +5,0 @@ "node": ">=7.6.0"