Updated API reference.

This commit is contained in:
atanasovg
2014-05-22 11:46:52 +03:00
parent 5c82a6d67a
commit 87f7847155
4 changed files with 75 additions and 52 deletions

35
http/http.d.ts vendored
View File

@ -1,17 +1,47 @@
 declare module "http" {
declare module "http" {
import image = require("image-source"); import image = require("image-source");
import promises = require("promises"); import promises = require("promises");
/**
* Downloads the content from the specified URL as a string.
* @param url The URL to request from.
*/
function getString(url: string): promises.Promise<string> function getString(url: string): promises.Promise<string>
/**
* Downloads the content from the specified URL as a string.
* @param options An object that specifies various request options.
*/
function getString(options: HttpRequestOptions): promises.Promise<string> function getString(options: HttpRequestOptions): promises.Promise<string>
/**
* Downloads the content from the specified URL as a string and returns its JSON.parse representation.
* @param url The URL to request from.
*/
function getJSON<T>(url: string): promises.Promise<T> function getJSON<T>(url: string): promises.Promise<T>
/**
* Downloads the content from the specified URL as a string and returns its JSON.parse representation.
* @param options An object that specifies various request options.
*/
function getJSON<T>(options: HttpRequestOptions): promises.Promise<T> function getJSON<T>(options: HttpRequestOptions): promises.Promise<T>
/**
* Downloads the content from the specified URL and attempts to decode it as an image.
* @param url The URL to request from.
*/
function getImage(url: string): promises.Promise<image.ImageSource> function getImage(url: string): promises.Promise<image.ImageSource>
/**
* Downloads the content from the specified URL and attempts to decode it as an image.
* @param options An object that specifies various request options.
*/
function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource> function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource>
/**
* Makes a generic http request using the provided options and returns a HttpResponse Object.
* @param options An object that specifies various request options.
*/
function request(options: HttpRequestOptions): promises.Promise<HttpResponse>; function request(options: HttpRequestOptions): promises.Promise<HttpResponse>;
interface HttpRequestOptions { interface HttpRequestOptions {
@ -31,6 +61,7 @@ declare module "http" {
interface HttpContent { interface HttpContent {
raw: any; raw: any;
toString: () => string; toString: () => string;
// TODO: Isn't parseJSON better naming? toJSON sounds to me like we will return a string object
toJSON: () => any; toJSON: () => any;
toImage: () => image.ImageSource; toImage: () => image.ImageSource;
} }

View File

@ -6,9 +6,6 @@ import request = require("http/http-request");
declare var exports; declare var exports;
require("utils/module-merge").merge(request, exports); require("utils/module-merge").merge(request, exports);
/**
* Gets string from url.
*/
export function getString(arg: any): promises.Promise<string> { export function getString(arg: any): promises.Promise<string> {
var d = promises.defer<string>(); var d = promises.defer<string>();
@ -19,9 +16,6 @@ export function getString(arg: any): promises.Promise<string> {
return d.promise(); return d.promise();
} }
/**
* Gets JSON from url.
*/
export function getJSON<T>(arg: any): promises.Promise<T> { export function getJSON<T>(arg: any): promises.Promise<T> {
var d = promises.defer<T>(); var d = promises.defer<T>();
@ -32,10 +26,6 @@ export function getJSON<T>(arg: any): promises.Promise<T> {
return d.promise(); return d.promise();
} }
/**
* Gets image from url.
*/
export function getImage(arg: any): promises.Promise<image.ImageSource> { export function getImage(arg: any): promises.Promise<image.ImageSource> {
var d = promises.defer<image.ImageSource>(); var d = promises.defer<image.ImageSource>();

View File

@ -1,72 +1,56 @@
 
declare module "local-settings" { declare module "local-settings" {
/** /**
* report does such key exist * Checks whether such a key exists.
* @param key The key to check for.
*/ */
var hasKey: (key: string) => boolean; var hasKey: (key: string) => boolean;
/** /**
* gets value of the key as boolean, user can provide default value in case there is no value for the key * 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.
* @param key The key to check for.
* @param defaultValue An optional value to be returned in case there is no existing value.
*/ */
var getBoolean: (key: string, defaultValue?: boolean) => boolean; var getBoolean: (key: string, defaultValue?: boolean) => boolean;
/** /**
* gets value of the key as string, user can provide default value in case there is no value for the key * 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.
* @param key The key to check for.
* @param defaultValue An optional value to be returned in case there is no existing value.
*/ */
var getString: (key: string, defaultValue?: string) => string; var getString: (key: string, defaultValue?: string) => string;
/** /**
* gets value of the key as string array, user can provide default value in case there is no value for the key * 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.
*/ * @param key The key to check for.
var getStringArray: (key: string, defaultValue?: string[]) => string[]; * @param defaultValue An optional value to be returned in case there is no existing value.
/**
* gets value of the key as number (double), user can provide default value in case there is no value for the key
*/ */
var getNumber: (key: string, defaultValue?: number) => number; var getNumber: (key: string, defaultValue?: number) => number;
/** /**
* gets value of the key as integer, user can provide default value in case there is no value for the key * Sets a Boolean Object for a key.
*/ * @param key The key.
var getInt: (key: string, defaultValue?: number) => number; * @param value The value.
/**
* 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
*/
var getLong: (key: string, defaultValue?: number) => number;
/**
* sets value for a key as boolean
*/ */
var setBoolean: (key: string, value: boolean) => void; var setBoolean: (key: string, value: boolean) => void;
/** /**
* sets value for a key as string * Sets a String Object for a key.
* @param key The key.
* @param value The value.
*/ */
var setString: (key: string, value: string) => void; var setString: (key: string, value: string) => void;
/** /**
* sets value for a key as string array * Sets a Number Object for a key.
*/ * @param key The key.
var setStringArray: (key: string, value: string[]) => void; * @param value The value.
/**
* sets value for a key as JS number (double)
*/ */
var setNumber: (key: string, value: number) => void; var setNumber: (key: string, value: number) => void;
/** /**
* sets value for a key as integer * Removes a value (if existing) for a key.
*/ * @param key The key to check for.
var setInt: (key: string, value: number) => void;
/**
* sets value for a key as long integer
*/
var setLong: (key: string, value: number) => void;
/**
* removes a value for key
*/ */
var remove: (key: string) => void; var remove: (key: string) => void;
} }

22
timer/timer.d.ts vendored
View File

@ -1,7 +1,25 @@
/** /**
* Timer functions. * Calls a function after a specified delay.
*/ * @param callback The function to be called.
* @param milliseconds The time to wait before the function is called. Defaults to 0.
*/
export declare function setTimeout(callback: Function, milliseconds?: number): number; export declare function setTimeout(callback: Function, milliseconds?: number): number;
/**
* Clears the delay set by a call to the setTimeout function.
* @param id The identifier returned by the previously called setTimeout() method.
*/
export declare function clearTimeout(id: number): void; export declare function clearTimeout(id: number): void;
/**
* Calls a function repeatedly with a delay between each call.
* @param callback The function to be called.
* @param milliseconds The delay between each function call.
*/
export declare function setInterval(callback: Function, milliseconds?: number): number; export declare function setInterval(callback: Function, milliseconds?: number): number;
/**
* Clears repeated function which was set up by calling setInterval().
* @param id The identifier returned by the setInterval() method.
*/
export declare function clearInterval(id: number): void; export declare function clearInterval(id: number): void;