mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Updated API reference.
This commit is contained in:
35
http/http.d.ts
vendored
35
http/http.d.ts
vendored
@@ -1,17 +1,47 @@
|
||||
|
||||
declare module "http" {
|
||||
declare module "http" {
|
||||
import image = require("image-source");
|
||||
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>
|
||||
|
||||
/**
|
||||
* 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>
|
||||
|
||||
/**
|
||||
* 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>
|
||||
|
||||
/**
|
||||
* 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>
|
||||
|
||||
/**
|
||||
* 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>
|
||||
|
||||
/**
|
||||
* 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>
|
||||
|
||||
/**
|
||||
* 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>;
|
||||
|
||||
interface HttpRequestOptions {
|
||||
@@ -31,6 +61,7 @@ declare module "http" {
|
||||
interface HttpContent {
|
||||
raw: any;
|
||||
toString: () => string;
|
||||
// TODO: Isn't parseJSON better naming? toJSON sounds to me like we will return a string object
|
||||
toJSON: () => any;
|
||||
toImage: () => image.ImageSource;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,6 @@ import request = require("http/http-request");
|
||||
declare var exports;
|
||||
require("utils/module-merge").merge(request, exports);
|
||||
|
||||
/**
|
||||
* Gets string from url.
|
||||
*/
|
||||
export function getString(arg: any): promises.Promise<string> {
|
||||
var d = promises.defer<string>();
|
||||
|
||||
@@ -19,9 +16,6 @@ export function getString(arg: any): promises.Promise<string> {
|
||||
return d.promise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets JSON from url.
|
||||
*/
|
||||
export function getJSON<T>(arg: any): promises.Promise<T> {
|
||||
var d = promises.defer<T>();
|
||||
|
||||
@@ -32,10 +26,6 @@ export function getJSON<T>(arg: any): promises.Promise<T> {
|
||||
return d.promise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets image from url.
|
||||
*/
|
||||
|
||||
export function getImage(arg: any): promises.Promise<image.ImageSource> {
|
||||
var d = promises.defer<image.ImageSource>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user