Merge pull request #8698 from stpettersens/master

Type definitions and tests for electron-json-storage
This commit is contained in:
Masahiro Wakame
2016-03-26 23:07:51 +09:00
2 changed files with 44 additions and 0 deletions
@@ -0,0 +1,31 @@
/// <reference path="../github-electron/github-electron.d.ts" />
/// <reference path="electron-json-storage.d.ts" />
import electron = require('electron');
import storage = require('electron-json-storage');
storage.set("foo", { "foo": "bar" }, function(err: any) { });
storage.get("foo", function(err: any, data: Object) {
console.log(JSON.stringify(data));
});
storage.has("foo", function(err: any, hasKey: boolean) {
console.log("hasKey?: %s", hasKey);
});
storage.keys(function(err: any, keys: string[]) {
console.log(keys);
});
storage.remove("foo", function(err: any) {
console.log(err);
});
storage.clear(function(err: any) {
console.log(err);
});
storage.has("foo", function(err: any, data: Object) {
console.log(data);
});
+13
View File
@@ -0,0 +1,13 @@
// Type definitions for electron-json-storage
// Project: https://github.com/jviotti/electron-json-storage
// Definitions by: Sam Saint-Pettersen <https://github.com/stpettersens>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "electron-json-storage" {
export function get(key: string, callback: (error: any, data: Object) => void): void;
export function set(key: string, json: Object, callback: (error: any) => void): void;
export function has(key: string, callback: (error: any, hasKey: boolean) => void): void;
export function keys(callback: (error: any, keys: string[]) => void): void;
export function remove(key: string, callback: (error: any) => void): void;
export function clear(callback: (error: any) => void): void;
}