-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18253 from vinodkumarsharma276/patch-1
Upgrade file-system-cache to 2.0.0 and remove custom types
- Loading branch information
Showing
4 changed files
with
29 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,8 @@ | ||
// @ts-ignore - this package has no typings, so we wrap it and add typings that way, because we expose it | ||
import Cache from 'file-system-cache'; | ||
|
||
export interface Options { | ||
basePath?: string; | ||
ns?: string | string[]; | ||
extension?: string; | ||
} | ||
|
||
export class FileSystemCache { | ||
constructor(options: Options) { | ||
this.internal = Cache(options) as any as FileSystemCache; | ||
} | ||
|
||
private internal: FileSystemCache; | ||
|
||
path(key: string): string { | ||
return this.internal.path(key); | ||
} | ||
|
||
fileExists(key: string): Promise<boolean> { | ||
return this.internal.fileExists(key); | ||
} | ||
|
||
ensureBasePath(): Promise<void> { | ||
return this.internal.ensureBasePath(); | ||
} | ||
|
||
get(key: string, defaultValue?: any): Promise<any | typeof defaultValue> { | ||
return this.internal.get(key, defaultValue); | ||
} | ||
|
||
getSync(key: string, defaultValue?: any): any | typeof defaultValue { | ||
return this.internal.getSync(key, defaultValue); | ||
} | ||
|
||
set(key: string, value: any): Promise<{ path: string }> { | ||
return this.internal.set(key, value); | ||
} | ||
|
||
setSync(key: string, value: any): this { | ||
this.internal.setSync(key, value); | ||
return this; | ||
} | ||
|
||
remove(key: string): Promise<void> { | ||
return this.internal.remove(key); | ||
} | ||
|
||
clear(): Promise<void> { | ||
return this.internal.clear(); | ||
} | ||
|
||
save(): Promise<{ paths: string[] }> { | ||
return this.internal.save(); | ||
} | ||
|
||
load(): Promise<{ files: Array<{ path: string; value: any }> }> { | ||
return this.internal.load(); | ||
} | ||
} | ||
export type Options = Parameters<typeof Cache>['0']; | ||
export type FileSystemCache = ReturnType<typeof Cache>; | ||
|
||
export function createFileSystemCache(options: Options): FileSystemCache { | ||
return new FileSystemCache(options); | ||
return Cache(options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters