Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg: add type lints. #2

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
]
}
}