mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add type definitions for flat-cache (#35472)
This commit is contained in:
parent
dbe44d6d01
commit
5f983eff84
39
types/flat-cache/flat-cache-tests.ts
Normal file
39
types/flat-cache/flat-cache-tests.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import * as flatCache from "flat-cache";
|
||||
|
||||
flatCache.load(""); // $ExpectType Cache
|
||||
flatCache.load("", ""); // $ExpectType Cache
|
||||
|
||||
flatCache.create(""); // $ExpectType Cache
|
||||
flatCache.create("", ""); // $ExpectType Cache
|
||||
|
||||
flatCache.createFromFile(""); // $ExpectType Cache
|
||||
|
||||
flatCache.clearCacheById(""); // $ExpectType boolean
|
||||
flatCache.clearCacheById("", ""); // $ExpectType boolean
|
||||
|
||||
flatCache.clearAll(); // $ExpectType boolean
|
||||
flatCache.clearAll(""); // $ExpectType boolean
|
||||
|
||||
const cache = flatCache.load(""); // $ExpectType Cache
|
||||
|
||||
cache.load(""); // $ExpectType void
|
||||
cache.load("", ""); // $ExpectType void
|
||||
|
||||
cache.loadFile(""); // $ExpectType void
|
||||
|
||||
cache.all(); // $ExpectType { [key: string]: any; }
|
||||
|
||||
cache.keys(); // $ExpectType string[]
|
||||
|
||||
cache.setKey("", ""); // $ExpectType void
|
||||
|
||||
cache.removeKey(""); // $ExpectType void
|
||||
|
||||
cache.getKey(""); // $ExpectType any
|
||||
|
||||
cache.save(); // $ExpectType void
|
||||
cache.save(true); // $ExpectType void
|
||||
|
||||
cache.removeCacheFile(); // $ExpectType boolean
|
||||
|
||||
cache.destroy(); // $ExpectType void
|
||||
27
types/flat-cache/index.d.ts
vendored
Normal file
27
types/flat-cache/index.d.ts
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Type definitions for flat-cache 2.0
|
||||
// Project: https://github.com/royriojas/flat-cache#readme
|
||||
// Definitions by: Kevin Pollet <https://github.com/kevinpollet>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export interface Cache {
|
||||
load(cacheId: string, cacheDir?: string): void;
|
||||
loadFile(pathToFile: string): void;
|
||||
all(): { [key: string]: any };
|
||||
keys(): string[];
|
||||
setKey(key: string, value: any): void;
|
||||
removeKey(key: string): void;
|
||||
getKey(key: string): any;
|
||||
save(noPrune?: boolean): void;
|
||||
removeCacheFile(): boolean;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export function load(cacheId: string, cacheDir?: string): Cache;
|
||||
|
||||
export function create(cacheId: string, cacheDir?: string): Cache;
|
||||
|
||||
export function createFromFile(filePath: string): Cache;
|
||||
|
||||
export function clearCacheById(cacheId: string, cacheDir?: string): boolean;
|
||||
|
||||
export function clearAll(cacheDir?: string): boolean;
|
||||
23
types/flat-cache/tsconfig.json
Normal file
23
types/flat-cache/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"flat-cache-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/flat-cache/tslint.json
Normal file
1
types/flat-cache/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user