File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 "editor.tabSize" : 2 ,
66 "editor.insertSpaces" : true ,
77 "editor.codeActionsOnSave" : {
8- "source.fixAll" : true
8+ "source.fixAll" : " explicit "
99 },
1010 "eslint.alwaysShowStatus" : true ,
1111 "files.autoSave" : " onFocusChange" ,
Original file line number Diff line number Diff line change 1+ dist
Original file line number Diff line number Diff line change 11{
2- "name" : " cache" ,
3- "version" : " 1. 0.0" ,
2+ "name" : " @surjit/ cache" ,
3+ "version" : " 0.0.2 " ,
44 "description" : " A simple cache library" ,
55 "author" : " Surjit Kumar Sahoo" ,
66 "license" : " MIT" ,
7- "main" : " src/index.js" ,
7+ "main" : " dist/index.js" ,
8+ "types" : " dist/index.d.ts" ,
89 "type" : " module" ,
10+ "files" : [
11+ " dist"
12+ ],
913 "scripts" : {
10- "test" : " cross-env NODE_OPTIONS=--experimental-vm-modules jest"
14+ "test" : " cross-env NODE_OPTIONS=--experimental-vm-modules jest" ,
15+ "build:types" : " rimraf dist && tsc --declaration --outDir dist"
1116 },
1217 "engines" : {
1318 "node" : " >=14.5.0"
1419 },
1520 "devDependencies" : {
1621 "@types/jest" : " ^29.2.4" ,
1722 "cross-env" : " ^7.0.3" ,
18- "jest" : " ^29.3.1"
23+ "jest" : " ^29.3.1" ,
24+ "rimraf" : " ^5.0.7" ,
25+ "typescript" : " ^5.4.5"
1926 }
2027}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export class Cache {
2020 #logger = console ;
2121
2222 /**
23- * @param {object= } config - Optional Config options
23+ * @param {object } [ config] - Optional Config options
2424 * @param {object } config.logger - A logger instance which must have .log method in it
2525 * @param {boolean } config.debug - Enable debug mode
2626 */
@@ -93,6 +93,10 @@ export class Cache {
9393 return value ;
9494 }
9595
96+ /**
97+ *
98+ * @param {string } key
99+ */
96100 #del( key ) {
97101 this . #size -= 1 ;
98102 delete this . #cache[ key ] ;
@@ -135,6 +139,11 @@ export class Cache {
135139 }
136140 }
137141
142+ /**
143+ * Get Cached data
144+ * @param {string } key
145+ * @returns {any }
146+ */
138147 get ( key ) {
139148 const data = this . #cache[ key ] ;
140149 if ( data ) {
@@ -152,6 +161,9 @@ export class Cache {
152161 return null ;
153162 }
154163
164+ /**
165+ * Count the cache size
166+ */
155167 get size ( ) {
156168 return this . #size;
157169 }
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "noEmit" : false ,
4+ "moduleResolution" : " Node" ,
5+ "target" : " ESNext" ,
6+ "allowJs" : true ,
7+ "checkJs" : true ,
8+ "esModuleInterop" : true
9+ },
10+ "include" : [" ./src/**/*" ],
11+ "exclude" : [" ./src/**/*.test.js" ]
12+ }
You can’t perform that action at this time.
0 commit comments