11'use strict' ;
2- var fs = require ( 'fs' ) ;
32var path = require ( 'path' ) ;
43
54var file = require ( './file' ) ;
@@ -12,22 +11,22 @@ cache.init = function() {
1211
1312cache . get = function ( k ) {
1413 const fullpath = file . cacheFile ( k ) ;
15- if ( ! fs . existsSync ( fullpath ) ) return null ;
14+ if ( ! file . exist ( fullpath ) ) return null ;
1615
17- return JSON . parse ( fs . readFileSync ( fullpath ) ) ;
16+ return JSON . parse ( file . data ( fullpath ) ) ;
1817} ;
1918
2019cache . set = function ( k , v ) {
2120 const fullpath = file . cacheFile ( k ) ;
22- fs . writeFileSync ( fullpath , JSON . stringify ( v ) ) ;
21+ file . write ( fullpath , JSON . stringify ( v ) ) ;
2322 return true ;
2423} ;
2524
2625cache . del = function ( k ) {
2726 const fullpath = file . cacheFile ( k ) ;
28- if ( ! fs . existsSync ( fullpath ) ) return false ;
27+ if ( ! file . exist ( fullpath ) ) return false ;
2928
30- fs . unlinkSync ( fullpath ) ;
29+ file . rm ( fullpath ) ;
3130 return true ;
3231} ;
3332
@@ -36,7 +35,7 @@ cache.list = function() {
3635 . filter ( x => path . extname ( x ) === '.json' )
3736 . map ( function ( filename ) {
3837 const k = path . basename ( filename , '.json' ) ;
39- const stat = fs . statSync ( file . cacheFile ( k ) ) ;
38+ const stat = file . stat ( file . cacheFile ( k ) ) ;
4039 return {
4140 name : k ,
4241 size : stat . size ,
0 commit comments