Skip to content

Commit

Permalink
Merge PR #2 from 'nodech/ts-lint'
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Aug 31, 2023
2 parents d158e62 + 470bed1 commit 5cf90dd
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 16 deletions.
21 changes: 7 additions & 14 deletions lib/lru.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const assert = require('bsert');
*/

class LRU {
/** @type {Map} */
map;

/**
* Create an LRU cache.
* @constructor
Expand All @@ -27,6 +30,7 @@ class LRU {
assert(!getSize || typeof getSize === 'function', 'Bad size callback.');
assert(!CustomMap || typeof CustomMap === 'function');

// @ts-ignore
this.map = CustomMap ? new CustomMap() : new Map();
this.size = 0;
this.items = 0;
Expand Down Expand Up @@ -202,20 +206,10 @@ class LRU {
return true;
}

/**
* Prepend an item to the linked list (sets new head).
* @private
* @param {LRUItem}
*/

_prependList(item) {
this._insertList(null, item);
}

/**
* Append an item to the linked list (sets new tail).
* @private
* @param {LRUItem}
* @param {LRUItem} item
*/

_appendList(item) {
Expand Down Expand Up @@ -259,7 +253,7 @@ class LRU {
/**
* Remove item from the linked list.
* @private
* @param {LRUItem}
* @param {LRUItem} item
*/

_removeList(item) {
Expand Down Expand Up @@ -420,8 +414,7 @@ class LRUItem {
/**
* Create an LRU item.
* @constructor
* @private
* @param {String} key
* @param {String|Number} key
* @param {Object} value
*/

Expand Down
9 changes: 8 additions & 1 deletion package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
"main": "./lib/blru.js",
"scripts": {
"lint": "eslint lib/ test/",
"lint-types": "tsc -p .",
"test": "bmocha --reporter spec test/*-test.js"
},
"dependencies": {
"bsert": "~0.0.12"
},
"devDependencies": {
"bmocha": "^2.1.8"
"bmocha": "^2.1.8",
"bts-type-deps": "^0.0.3"
},
"engines": {
"node": ">=8.0.0"
Expand Down
31 changes: 31 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"include": [
"lib/**/*.js"
],
"compilerOptions": {
"rootDir": ".",
"target": "ES2020",
"lib": [
"ES2020"
],

"noEmit": true,

"allowJs": true,
"checkJs": true,
"maxNodeModuleJsDepth": 10,

"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,

"stripInternal": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": false,

"typeRoots": [
"node_modules/bts-type-deps/types"
]
}
}

0 comments on commit 5cf90dd

Please sign in to comment.