mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-04-30 13:02:15 +00:00
17 lines
316 B
JavaScript
17 lines
316 B
JavaScript
'use strict'
|
|
|
|
const LRU = require('hashlru')
|
|
|
|
/**
|
|
* Creates and returns a Least Recently Used Cache
|
|
*
|
|
* @param {number} maxSize
|
|
* @returns {any}
|
|
*/
|
|
module.exports = (maxSize) => {
|
|
// @ts-ignore LRU expression is not callable
|
|
const patched = LRU(maxSize)
|
|
patched.delete = patched.remove
|
|
return patched
|
|
}
|