mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Add types for good-storage (#37888)
* Add types form good-storage * prettier formatter good-storage code * fix good-storage code
This commit is contained in:
19
types/good-storage/good-storage-tests.ts
Normal file
19
types/good-storage/good-storage-tests.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import storage = require('good-storage');
|
||||
|
||||
// localStorage
|
||||
storage.set('name', 'value');
|
||||
storage.get('name', 'defaultValue');
|
||||
storage.has('name');
|
||||
storage.remove('name');
|
||||
storage.clear();
|
||||
storage.getAll();
|
||||
storage.forEach(() => {});
|
||||
|
||||
// sessionStorage
|
||||
storage.session.set('name', 'value');
|
||||
storage.session.get('name', 'defaultValue');
|
||||
storage.session.has('name');
|
||||
storage.session.remove('name');
|
||||
storage.session.clear();
|
||||
storage.session.getAll();
|
||||
storage.session.forEach(() => {});
|
||||
26
types/good-storage/index.d.ts
vendored
Normal file
26
types/good-storage/index.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Type definitions for good-storage 1.1
|
||||
// Project: https://github.com/ustbhuangyi/storage
|
||||
// Definitions by: Wang KaiLing <https://github.com/wkl007>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Storage {
|
||||
session: Storage;
|
||||
|
||||
set(key: string, val?: any): any;
|
||||
|
||||
get(key: string, def?: any): any;
|
||||
|
||||
has(key: string): boolean;
|
||||
|
||||
remove(key: string): void;
|
||||
|
||||
clear(): void;
|
||||
|
||||
getAll(): any;
|
||||
|
||||
forEach(callback: () => void): void;
|
||||
}
|
||||
|
||||
declare const storage: Storage;
|
||||
|
||||
export = storage;
|
||||
23
types/good-storage/tsconfig.json
Normal file
23
types/good-storage/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",
|
||||
"good-storage-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/good-storage/tslint.json
Normal file
1
types/good-storage/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user