Skip to content

Commit 87f7847

Browse files
committed
Updated API reference.
1 parent 5c82a6d commit 87f7847

File tree

4 files changed

+75
-52
lines changed

4 files changed

+75
-52
lines changed

http/http.d.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,47 @@
1-

2-
declare module "http" {
1+
declare module "http" {
32
import image = require("image-source");
43
import promises = require("promises");
54

5+
/**
6+
* Downloads the content from the specified URL as a string.
7+
* @param url The URL to request from.
8+
*/
69
function getString(url: string): promises.Promise<string>
10+
11+
/**
12+
* Downloads the content from the specified URL as a string.
13+
* @param options An object that specifies various request options.
14+
*/
715
function getString(options: HttpRequestOptions): promises.Promise<string>
816

17+
/**
18+
* Downloads the content from the specified URL as a string and returns its JSON.parse representation.
19+
* @param url The URL to request from.
20+
*/
921
function getJSON<T>(url: string): promises.Promise<T>
22+
23+
/**
24+
* Downloads the content from the specified URL as a string and returns its JSON.parse representation.
25+
* @param options An object that specifies various request options.
26+
*/
1027
function getJSON<T>(options: HttpRequestOptions): promises.Promise<T>
1128

29+
/**
30+
* Downloads the content from the specified URL and attempts to decode it as an image.
31+
* @param url The URL to request from.
32+
*/
1233
function getImage(url: string): promises.Promise<image.ImageSource>
34+
35+
/**
36+
* Downloads the content from the specified URL and attempts to decode it as an image.
37+
* @param options An object that specifies various request options.
38+
*/
1339
function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource>
1440

41+
/**
42+
* Makes a generic http request using the provided options and returns a HttpResponse Object.
43+
* @param options An object that specifies various request options.
44+
*/
1545
function request(options: HttpRequestOptions): promises.Promise<HttpResponse>;
1646

1747
interface HttpRequestOptions {
@@ -31,6 +61,7 @@ declare module "http" {
3161
interface HttpContent {
3262
raw: any;
3363
toString: () => string;
64+
// TODO: Isn't parseJSON better naming? toJSON sounds to me like we will return a string object
3465
toJSON: () => any;
3566
toImage: () => image.ImageSource;
3667
}

http/http.impl.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import request = require("http/http-request");
66
declare var exports;
77
require("utils/module-merge").merge(request, exports);
88

9-
/**
10-
* Gets string from url.
11-
*/
129
export function getString(arg: any): promises.Promise<string> {
1310
var d = promises.defer<string>();
1411

@@ -19,9 +16,6 @@ export function getString(arg: any): promises.Promise<string> {
1916
return d.promise();
2017
}
2118

22-
/**
23-
* Gets JSON from url.
24-
*/
2519
export function getJSON<T>(arg: any): promises.Promise<T> {
2620
var d = promises.defer<T>();
2721

@@ -32,10 +26,6 @@ export function getJSON<T>(arg: any): promises.Promise<T> {
3226
return d.promise();
3327
}
3428

35-
/**
36-
* Gets image from url.
37-
*/
38-
3929
export function getImage(arg: any): promises.Promise<image.ImageSource> {
4030
var d = promises.defer<image.ImageSource>();
4131

local-settings/local-settings.d.ts

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,56 @@
11

22
declare module "local-settings" {
33
/**
4-
* report does such key exist
4+
* Checks whether such a key exists.
5+
* @param key The key to check for.
56
*/
67
var hasKey: (key: string) => boolean;
78

89
/**
9-
* gets value of the key as boolean, user can provide default value in case there is no value for the key
10+
* Gets a value (if existing) for a key as a Boolean Object. A default value can be provided in case there is no existing value.
11+
* @param key The key to check for.
12+
* @param defaultValue An optional value to be returned in case there is no existing value.
1013
*/
1114
var getBoolean: (key: string, defaultValue?: boolean) => boolean;
1215

1316
/**
14-
* gets value of the key as string, user can provide default value in case there is no value for the key
17+
* Gets a value (if existing) for a key as a String Object. A default value can be provided in case there is no existing value.
18+
* @param key The key to check for.
19+
* @param defaultValue An optional value to be returned in case there is no existing value.
1520
*/
1621
var getString: (key: string, defaultValue?: string) => string;
1722

1823
/**
19-
* gets value of the key as string array, user can provide default value in case there is no value for the key
20-
*/
21-
var getStringArray: (key: string, defaultValue?: string[]) => string[];
22-
23-
/**
24-
* gets value of the key as number (double), user can provide default value in case there is no value for the key
24+
* Gets a value (if existing) for a key as a Number Object. A default value can be provided in case there is no existing value.
25+
* @param key The key to check for.
26+
* @param defaultValue An optional value to be returned in case there is no existing value.
2527
*/
2628
var getNumber: (key: string, defaultValue?: number) => number;
2729

2830
/**
29-
* gets value of the key as integer, user can provide default value in case there is no value for the key
30-
*/
31-
var getInt: (key: string, defaultValue?: number) => number;
32-
33-
/**
34-
* gets value of the key as long integer (not fully supported by JS), user can provide default value in case there is no value for the key
35-
*/
36-
var getLong: (key: string, defaultValue?: number) => number;
37-
38-
/**
39-
* sets value for a key as boolean
31+
* Sets a Boolean Object for a key.
32+
* @param key The key.
33+
* @param value The value.
4034
*/
4135
var setBoolean: (key: string, value: boolean) => void;
4236

4337
/**
44-
* sets value for a key as string
38+
* Sets a String Object for a key.
39+
* @param key The key.
40+
* @param value The value.
4541
*/
4642
var setString: (key: string, value: string) => void;
4743

4844
/**
49-
* sets value for a key as string array
50-
*/
51-
var setStringArray: (key: string, value: string[]) => void;
52-
53-
/**
54-
* sets value for a key as JS number (double)
45+
* Sets a Number Object for a key.
46+
* @param key The key.
47+
* @param value The value.
5548
*/
5649
var setNumber: (key: string, value: number) => void;
5750

5851
/**
59-
* sets value for a key as integer
60-
*/
61-
var setInt: (key: string, value: number) => void;
62-
63-
/**
64-
* sets value for a key as long integer
65-
*/
66-
var setLong: (key: string, value: number) => void;
67-
68-
/**
69-
* removes a value for key
52+
* Removes a value (if existing) for a key.
53+
* @param key The key to check for.
7054
*/
7155
var remove: (key: string) => void;
7256
}

timer/timer.d.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
11
/**
2-
* Timer functions.
3-
*/
2+
* Calls a function after a specified delay.
3+
* @param callback The function to be called.
4+
* @param milliseconds The time to wait before the function is called. Defaults to 0.
5+
*/
46
export declare function setTimeout(callback: Function, milliseconds?: number): number;
7+
8+
/**
9+
* Clears the delay set by a call to the setTimeout function.
10+
* @param id The identifier returned by the previously called setTimeout() method.
11+
*/
512
export declare function clearTimeout(id: number): void;
13+
14+
/**
15+
* Calls a function repeatedly with a delay between each call.
16+
* @param callback The function to be called.
17+
* @param milliseconds The delay between each function call.
18+
*/
619
export declare function setInterval(callback: Function, milliseconds?: number): number;
20+
21+
/**
22+
* Clears repeated function which was set up by calling setInterval().
23+
* @param id The identifier returned by the setInterval() method.
24+
*/
725
export declare function clearInterval(id: number): void;

0 commit comments

Comments
 (0)