Added "External Ambient Module Declarations" for most modules.

Now they are required by module name e.g require("file-system") instead of by file name.
This commit is contained in:
PanayotCankov
2014-05-21 12:23:19 +03:00
parent f3446e4099
commit 9dd3ba70c5
30 changed files with 470 additions and 467 deletions

View File

@ -9,7 +9,7 @@
*/ */
import Application = require("application/application"); import Application = require("application");
import timer = require("timer/timer"); import timer = require("timer/timer");
var runTest = function (test, testName) { var runTest = function (test, testName) {

View File

@ -4,7 +4,7 @@
// It is the main BCL module and is required for other BCL modules to work properly. // It is the main BCL module and is required for other BCL modules to work properly.
// The default bootstrap.js implementation for each platform loads and initializes this module. // The default bootstrap.js implementation for each platform loads and initializes this module.
// ``` JavaScript // ``` JavaScript
import app = require("application/application"); import app = require("application");
// ``` // ```
// The pre-required `app` module is used throughout the following code snippets. // The pre-required `app` module is used throughout the following code snippets.
// </snippet> // </snippet>

View File

@ -1,4 +1,4 @@
import app = require("application/application"); import app = require("application");
import TKUnit = require("Tests/TKUnit"); import TKUnit = require("Tests/TKUnit");
import commonTests = require("Tests/application-tests-common"); import commonTests = require("Tests/application-tests-common");

View File

@ -4,7 +4,7 @@
// Using the file system requires the FileSystem module. // Using the file system requires the FileSystem module.
// TODO: var fs = require("file-system"); => this will break the intellisense of the tests // TODO: var fs = require("file-system"); => this will break the intellisense of the tests
// ``` JavaScript // ``` JavaScript
import fs = require("file-system/file-system"); import fs = require("file-system");
// ``` // ```
// The pre-required `fs` module is used throughout the following code snippets. // The pre-required `fs` module is used throughout the following code snippets.
// </snippet> // </snippet>

View File

@ -1,5 +1,5 @@
import TKUnit = require("Tests/TKUnit"); import TKUnit = require("Tests/TKUnit");
import http = require("http/http"); import http = require("http");
require("globals"); require("globals");
// <snippet name="http"> // <snippet name="http">

View File

@ -13,8 +13,8 @@
// </snippet> // </snippet>
import imageSource = require("image-source/image-source"); import imageSource = require("image-source/image-source");
import fs = require("file-system/file-system"); import fs = require("file-system");
import app = require("application/application"); import app = require("application");
import TKUnit = require("Tests/TKUnit"); import TKUnit = require("Tests/TKUnit");
export var testFromResource = function () { export var testFromResource = function () {

View File

@ -1,47 +1,50 @@
/** 
* The main entry point event. This method is expected to return an instance of the root UI for the application. declare module "application" {
* This will be an Activity extends for Android and a RootViewController for iOS.
*/
export declare function onLaunch(): any;
/** /**
* This method will be called when the Application is suspended. * The main entry point event. This method is expected to return an instance of the root UI for the application.
*/ * This will be an Activity extends for Android and a RootViewController for iOS.
export declare function onSuspend(); */
function onLaunch(): any;
/** /**
* This method will be called when the Application is resumed after it has been suspended. * This method will be called when the Application is suspended.
*/ */
export declare function onResume(); function onSuspend();
/** /**
* This method will be called when the Application is about to exit. * This method will be called when the Application is resumed after it has been suspended.
*/ */
export declare function onExit(); function onResume();
/** /**
* This method will be called when there is low memory on the target device. * This method will be called when the Application is about to exit.
*/ */
export declare function onLowMemory(); function onExit();
/** /**
* This is the Android-specific application object instance. * This method will be called when there is low memory on the target device.
* Encapsulates methods and properties specific to the Android platform. */
* Will be undefined when TargetOS is iOS. function onLowMemory();
*/
export declare var android: AndroidApplication;
/** /**
* This is the iOS-specific application object instance. * This is the Android-specific application object instance.
* Encapsulates methods and properties specific to the iOS platform. * Encapsulates methods and properties specific to the Android platform.
* Will be undefined when TargetOS is Android. * Will be undefined when TargetOS is iOS.
*/ */
export declare var ios: iOSApplication; var android: AndroidApplication;
/** /**
* The abstraction of an Android-specific application object. * This is the iOS-specific application object instance.
*/ * Encapsulates methods and properties specific to the iOS platform.
export declare class AndroidApplication { * Will be undefined when TargetOS is Android.
*/
var ios: iOSApplication;
/**
* The abstraction of an Android-specific application object.
*/
class AndroidApplication {
/** /**
* The android.app.Application object instance provided to the init of the module. * The android.app.Application object instance provided to the init of the module.
*/ */
@ -107,12 +110,12 @@ export declare class AndroidApplication {
* Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onSaveActivityState method. * Direct handler of the android.app.Application.ActivityLifecycleCallbacks.onSaveActivityState method.
*/ */
public onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void; public onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
} }
/** /**
* The abstraction of an iOS-specific application object. * The abstraction of an iOS-specific application object.
*/ */
export declare class iOSApplication { class iOSApplication {
/** /**
* The root view controller for the application. * The root view controller for the application.
*/ */
@ -122,9 +125,10 @@ export declare class iOSApplication {
* The android.app.Application object instance provided to the init of the module. * The android.app.Application object instance provided to the init of the module.
*/ */
public nativeApp: UIKit.UIApplication; public nativeApp: UIKit.UIApplication;
} }
/** /**
* Entry point for the module. Initializes the Application singleton and hooks application lifecycle events. * Entry point for the module. Initializes the Application singleton and hooks application lifecycle events.
*/ */
export declare function init(nativeApp: any); function init(nativeApp: any);
}

View File

@ -2,7 +2,7 @@
/* /*
Current launch sequence for iOS looks like: Current launch sequence for iOS looks like:
var app = require("application/application"); var app = require("application");
app.tk.ui.Application.current.onLaunch = function() { app.tk.ui.Application.current.onLaunch = function() {
log("tk.ui.Application.current.onLaunch"); log("tk.ui.Application.current.onLaunch");

View File

@ -1,2 +1,2 @@
declare var module, require; declare var module, require;
module.exports = require("application/application"); module.exports = require("application");

View File

@ -1,4 +1,4 @@
import appModule = require("application/application"); import appModule = require("application");
var REQUEST_IMAGE_CAPTURE: number = 1; var REQUEST_IMAGE_CAPTURE: number = 1;
var REQUEST_SELECT_PICTURE: number = 2; var REQUEST_SELECT_PICTURE: number = 2;

31
camera/camera.d.ts vendored
View File

@ -1,36 +1,39 @@
 
import promises = require("promises/promises"); declare module "camera" {
import imageSource = require("image-source/image-source");
export declare enum CameraPosition { import promises = require("promises/promises");
import imageSource = require("image-source/image-source");
enum CameraPosition {
FRONT = 0, FRONT = 0,
BACK = 1, BACK = 1,
} }
export declare enum FlashMode { enum FlashMode {
AUTO = 0, // default AUTO = 0, // default
ON = 1, ON = 1,
OFF = 2 OFF = 2
} }
export interface Options { interface Options {
/** /**
* Specifies which Camera to use * Specifies which Camera to use.
*/ */
cameraPosition?: CameraPosition; cameraPosition?: CameraPosition;
/** /**
* Specifies flash mode * Specifies flash mode.
*/ */
flashMode?: FlashMode; flashMode?: FlashMode;
} }
// TODO most of hardware related parts need to handle onPause and onResume of the calling activities // TODO most of hardware related parts need to handle onPause and onResume of the calling activities
export declare class CameraManager { class CameraManager {
takePicture(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any); takePicture(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any);
// options { useSavedPhotos: true } // options { useSavedPhotos: true }
pictureFromLibrary(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any); pictureFromLibrary(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any);
} }
export declare var takePicture: (options?: Options) => promises.Promise<imageSource.ImageSource>; var takePicture: (options?: Options) => promises.Promise<imageSource.ImageSource>;
}

View File

@ -1,4 +1,4 @@
import appModule = require("application/application"); import appModule = require("application");
import textModule = require("text/text"); import textModule = require("text/text");
export class FileSystemAccess { export class FileSystemAccess {

View File

@ -1,4 +1,4 @@
import app_module = require("application/application"); import app_module = require("application");
import utilsModule = require("utils/utils_ios"); import utilsModule = require("utils/utils_ios");
import textModule = require("text/text"); import textModule = require("text/text");

View File

@ -1,6 +1,9 @@
import promises = require("promises/promises"); 
declare module "file-system" {
export declare class FileSystemEntity { import promises = require("promises/promises");
class FileSystemEntity {
/** /**
* Gets the Date object specifying the last time this entity was modified. * Gets the Date object specifying the last time this entity was modified.
*/ */
@ -32,9 +35,9 @@ export declare class FileSystemEntity {
* Renames the current entity using the specified name. * Renames the current entity using the specified name.
*/ */
public rename(newName: string): promises.Promise<any>; public rename(newName: string): promises.Promise<any>;
} }
export declare class File extends FileSystemEntity { class File extends FileSystemEntity {
/** /**
* Checks whether a File with the specified path already exists. * Checks whether a File with the specified path already exists.
*/ */
@ -64,9 +67,9 @@ export declare class File extends FileSystemEntity {
* Writes the provided string to the file, using the specified encoding (defaults to UTF-8). * Writes the provided string to the file, using the specified encoding (defaults to UTF-8).
*/ */
public writeText(content: string, encoding?: string): promises.Promise<any>; public writeText(content: string, encoding?: string): promises.Promise<any>;
} }
export declare class Folder extends FileSystemEntity { class Folder extends FileSystemEntity {
/** /**
* Determines whether this instance is a KnownFolder (accessed through the KnownFolders object). * Determines whether this instance is a KnownFolder (accessed through the KnownFolders object).
*/ */
@ -114,12 +117,12 @@ export declare class Folder extends FileSystemEntity {
If the callback returns false this will mean for the iteration to stop. If the callback returns false this will mean for the iteration to stop.
*/ */
public eachEntity(onEntity: (entity: FileSystemEntity) => boolean); public eachEntity(onEntity: (entity: FileSystemEntity) => boolean);
} }
/** /**
* Provides access to the top-level Folders instances that are accessible from the application. Use these as entry points to access the FileSystem. * Provides access to the top-level Folders instances that are accessible from the application. Use these as entry points to access the FileSystem.
*/ */
export declare module knownFolders { module knownFolders {
/** /**
* Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps. * Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
*/ */
@ -129,12 +132,12 @@ export declare module knownFolders {
* Gets the Temporary (Caches) folder available for the current application. This Folder is private for the application and not accessible from Users/External apps. * Gets the Temporary (Caches) folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
*/ */
export function temp(): Folder; export function temp(): Folder;
} }
/** /**
* Enables path-specific operations like join, extension, etc. * Enables path-specific operations like join, extension, etc.
*/ */
export declare module path { module path {
/** /**
* Normalizes a path, taking care of occurrances like ".." and "//" * Normalizes a path, taking care of occurrances like ".." and "//"
*/ */
@ -149,4 +152,5 @@ export declare module path {
* Gets the string used to separate file paths. * Gets the string used to separate file paths.
*/ */
export var separator: string; export var separator: string;
}
} }

View File

@ -1,2 +1,2 @@
declare var module, require; declare var module, require;
module.exports = require("file-system/file-system"); module.exports = require("file-system");

View File

@ -8,3 +8,4 @@ setInterval = timer.setInterval;
clearInterval = timer.clearInterval; clearInterval = timer.clearInterval;
console = new consoleModule.Console(); console = new consoleModule.Console();

View File

@ -1,6 +1,6 @@
import image = require("image-source/image-source"); import image = require("image-source/image-source");
import promises = require("promises/promises"); import promises = require("promises/promises");
import http = require("http/http"); import http = require("http");
/** /**
* Gets string from url. * Gets string from url.

View File

@ -2,7 +2,7 @@
* Android specific http request implementation. * Android specific http request implementation.
*/ */
import promises = require("promises/promises"); import promises = require("promises/promises");
import http = require("http/http"); import http = require("http");
declare var exports; declare var exports;
require("utils/module-merge").merge(require("http/http-common"), exports); require("utils/module-merge").merge(require("http/http-common"), exports);

31
http/http.d.ts vendored
View File

@ -1,34 +1,37 @@
import image = require("image-source/image-source"); 
import promises = require("promises/promises"); declare module "http" {
import image = require("image-source/image-source");
import promises = require("promises/promises");
export declare function getString(url: string): promises.Promise<string> function getString(url: string): promises.Promise<string>
export declare function getString(options: HttpRequestOptions): promises.Promise<string> function getString(options: HttpRequestOptions): promises.Promise<string>
export declare function getJSON<T>(url: string): promises.Promise<T> function getJSON<T>(url: string): promises.Promise<T>
export declare function getJSON<T>(options: HttpRequestOptions): promises.Promise<T> function getJSON<T>(options: HttpRequestOptions): promises.Promise<T>
export declare function getImage(url: string): promises.Promise<image.ImageSource> function getImage(url: string): promises.Promise<image.ImageSource>
export declare function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource> function getImage(options: HttpRequestOptions): promises.Promise<image.ImageSource>
export declare function request(options: HttpRequestOptions): promises.Promise<HttpResponse>; function request(options: HttpRequestOptions): promises.Promise<HttpResponse>;
export interface HttpRequestOptions { interface HttpRequestOptions {
url: string; url: string;
method: string; method: string;
headers?: any; headers?: any;
content?: any; content?: any;
timeout?: number; timeout?: number;
} }
export interface HttpResponse { interface HttpResponse {
statusCode: number; statusCode: number;
headers: any; headers: any;
content?: HttpContent; content?: HttpContent;
} }
export interface HttpContent { interface HttpContent {
raw: any; raw: any;
toString: () => string; toString: () => string;
toJSON: () => any; toJSON: () => any;
toImage: () => image.ImageSource; toImage: () => image.ImageSource;
}
} }

View File

@ -2,7 +2,7 @@
* iOS specific http request implementation. * iOS specific http request implementation.
*/ */
import promises = require("promises/promises"); import promises = require("promises/promises");
import http = require("http/http"); import http = require("http");
declare var exports; declare var exports;
require("utils/module-merge").merge(require("http/http-common"), exports); require("utils/module-merge").merge(require("http/http-common"), exports);

View File

@ -1,4 +1,4 @@
import appModule = require("application/application"); import appModule = require("application");
export var fromResource = function (name: string) { export var fromResource = function (name: string) {
var androidApp = appModule.android; var androidApp = appModule.android;

View File

@ -1,17 +1,19 @@
import promises = require("promises/promises"); 
declare module "image-source" {
import promises = require("promises/promises");
/** /**
* Defines the recognized image formats. * Defines the recognized image formats.
*/ */
export declare enum ImageFormat { enum ImageFormat {
PNG, PNG,
JPEG, JPEG,
} }
/** /**
* Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images. * Encapsulates the common abstraction behind a platform specific object (typically a Bitmap) that is used as a source for images.
*/ */
export declare class ImageSource { class ImageSource {
/** /**
* Gets the height of this instance. This is a read-only property. * Gets the height of this instance. This is a read-only property.
*/ */
@ -57,30 +59,31 @@ export declare class ImageSource {
* Saves this instance to the specified file, using the provided image format and quality. * Saves this instance to the specified file, using the provided image format and quality.
*/ */
saveToFile(path: string, format: ImageFormat, quality?: number): boolean; saveToFile(path: string, format: ImageFormat, quality?: number): boolean;
}
/**
* Creates a new Image instance and loads it from the specified resource name.
*/
function fromResource(name: string): ImageSource;
/**
* Creates a new Image instance and loads it from the specified file.
*/
function fromFile(path: string): ImageSource;
/**
* Creates a new Image instance and loads it from the specified resource name.
*/
function fromData(data: any): ImageSource;
/**
* Creates a new Image instance and sets the provided native source object (typically a Bitmap).
* The native source object will update either the android or ios properties, depending on the target os.
*/
function fromNativeSource(source: any): ImageSource;
/**
* Downloads the image from the provided Url and creates a new Image instance from it.
*/
function fromUrl(url: string): promises.Promise<ImageSource>;
} }
/**
* Creates a new Image instance and loads it from the specified resource name.
*/
export declare function fromResource(name: string): ImageSource;
/**
* Creates a new Image instance and loads it from the specified file.
*/
export declare function fromFile(path: string): ImageSource;
/**
* Creates a new Image instance and loads it from the specified resource name.
*/
export declare function fromData(data: any): ImageSource;
/**
* Creates a new Image instance and sets the provided native source object (typically a Bitmap).
* The native source object will update either the android or ios properties, depending on the target os.
*/
export declare function fromNativeSource(source: any): ImageSource;
/**
* Downloads the image from the provided Url and creates a new Image instance from it.
*/
export declare function fromUrl(url: string): promises.Promise<ImageSource>;

View File

@ -1,7 +1,7 @@
import app = require("application/application"); import app = require("application");
import native = require("image-source/image-source-native"); import native = require("image-source/image-source-native");
import promises = require("promises/promises"); import promises = require("promises/promises");
import http = require("http/http"); import http = require("http");
export enum ImageFormat { export enum ImageFormat {
PNG, PNG,

View File

@ -1,4 +1,4 @@
import appModule = require("application/application"); import appModule = require("application");
import Common = require("local-settings/local-settings-common"); import Common = require("local-settings/local-settings-common");
var sharedPreferences = appModule.android.context.getSharedPreferences("prefs.db", 0); var sharedPreferences = appModule.android.context.getSharedPreferences("prefs.db", 0);

View File

@ -1,73 +1,72 @@
/** 
* report does such key exist declare module "local-settings" {
*/ /**
export declare var hasKey: (key: string) => boolean; * report does such key exist
*/
var hasKey: (key: string) => boolean;
// getters /**
* gets value of the key as boolean, user can provide default value in case there is no value for the key
*/
var getBoolean: (key: string, defaultValue?: boolean) => boolean;
/** /**
* gets value of the key as boolean, user can provide default value in case there is no value for the key * gets value of the key as string, user can provide default value in case there is no value for the key
*/ */
export declare var getBoolean: (key: string, defaultValue?: boolean) => boolean; var getString: (key: string, defaultValue?: string) => string;
/** /**
* gets value of the key as string, user can provide default value in case there is no value for the key * gets value of the key as string array, user can provide default value in case there is no value for the key
*/ */
export declare var getString: (key: string, defaultValue?: string) => string; var getStringArray: (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 value of the key as number (double), user can provide default value in case there is no value for the key
*/ */
export declare var getStringArray: (key: string, defaultValue?: string[]) => string[]; var getNumber: (key: string, defaultValue?: number) => number;
/** /**
* gets value of the key as number (double), user can provide default value in case there is no value for the key * gets value of the key as integer, user can provide default value in case there is no value for the key
*/ */
export declare var getNumber: (key: string, defaultValue?: number) => number; var getInt: (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 * 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
*/ */
export declare var getInt: (key: string, defaultValue?: number) => number; var getLong: (key: string, defaultValue?: number) => number;
/** /**
* 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 * sets value for a key as boolean
*/ */
export declare var getLong: (key: string, defaultValue?: number) => number; var setBoolean: (key: string, value: boolean) => void;
// setters /**
* sets value for a key as string
*/
var setString: (key: string, value: string) => void;
/** /**
* sets value for a key as boolean * sets value for a key as string array
*/ */
export declare var setBoolean: (key: string, value: boolean) => void; var setStringArray: (key: string, value: string[]) => void;
/** /**
* sets value for a key as string * sets value for a key as JS number (double)
*/ */
export declare var setString: (key: string, value: string) => void; var setNumber: (key: string, value: number) => void;
/** /**
* sets value for a key as string array * sets value for a key as integer
*/ */
export declare var setStringArray: (key: string, value: string[]) => void; var setInt: (key: string, value: number) => void;
/** /**
* sets value for a key as JS number (double) * sets value for a key as long integer
*/ */
export declare var setNumber: (key: string, value: number) => void; var setLong: (key: string, value: number) => void;
/** /**
* sets value for a key as integer * removes a value for key
*/ */
export declare var setInt: (key: string, value: number) => void; var remove: (key: string) => void;
}
/**
* sets value for a key as long integer
*/
export declare var setLong: (key: string, value: number) => void;
/**
* removes a value for key
*/
export declare var remove: (key: string) => void;

View File

@ -1,5 +1,5 @@
import types = require("location/location-types"); import types = require("location/location-types");
import appModule = require("application/application"); import appModule = require("application");
export class LocationManager { export class LocationManager {
// in meters // in meters

View File

@ -2,7 +2,7 @@
import promises = require("promises/promises"); import promises = require("promises/promises");
import timer = require("timer/timer"); import timer = require("timer/timer");
import types = require("location/location-types"); import types = require("location/location-types");
import locationManagerModule = require("location/location-manager"); import locationManagerModule = require("location");
// merge the exports of the types module with the exports of this file // merge the exports of the types module with the exports of this file
declare var exports; declare var exports;

View File

@ -9,7 +9,6 @@
/** /**
Returns a new "Deferred" value that may be resolved or rejected. Returns a new "Deferred" value that may be resolved or rejected.
*/ */
export function defer<Value>(): Deferred<Value> { export function defer<Value>(): Deferred<Value> {
return new DeferredI<Value>(); return new DeferredI<Value>();
} }
@ -17,7 +16,6 @@ export function defer<Value>(): Deferred<Value> {
/** /**
Converts a value to a resolved promise. Converts a value to a resolved promise.
*/ */
export function resolve<Value>(v: Value): Promise<Value> { export function resolve<Value>(v: Value): Promise<Value> {
return defer<Value>().resolve(v).promise(); return defer<Value>().resolve(v).promise();
} }
@ -25,7 +23,6 @@ export function resolve<Value>(v: Value): Promise<Value> {
/** /**
Returns a rejected promise. Returns a rejected promise.
*/ */
export function reject<Value>(err: Rejection): Promise<Value> { export function reject<Value>(err: Rejection): Promise<Value> {
return defer<Value>().reject(err).promise(); return defer<Value>().reject(err).promise();
} }
@ -39,7 +36,6 @@ export function reject<Value>(err: Rejection): Promise<Value> {
All the values of all promise results are collected into the resulting promise which is resolved as soon All the values of all promise results are collected into the resulting promise which is resolved as soon
the last generated element value is resolved. the last generated element value is resolved.
*/ */
export function unfold<Seed, Element>( export function unfold<Seed, Element>(
unspool: (current: Seed) => { promise: Promise<Element>; next?: Seed }, unspool: (current: Seed) => { promise: Promise<Element>; next?: Seed },
seed: Seed) seed: Seed)
@ -94,7 +90,6 @@ function unfoldCore<Seed, Element>(
Once a promise is either Rejected or Resolved, it can not change its Once a promise is either Rejected or Resolved, it can not change its
status anymore. status anymore.
*/ */
export enum Status { export enum Status {
Unfulfilled, Unfulfilled,
Rejected, Rejected,
@ -105,7 +100,6 @@ export enum Status {
If a promise gets rejected, at least a message that indicates the error or If a promise gets rejected, at least a message that indicates the error or
reason for the rejection must be provided. reason for the rejection must be provided.
*/ */
export interface Rejection { export interface Rejection {
message: string; message: string;
} }
@ -113,7 +107,6 @@ export interface Rejection {
/** /**
Both Promise<T> and Deferred<T> share these properties. Both Promise<T> and Deferred<T> share these properties.
*/ */
export interface PromiseState<Value> { export interface PromiseState<Value> {
/// The current status of the promise. /// The current status of the promise.
status: Status; status: Status;
@ -132,7 +125,6 @@ export interface PromiseState<Value> {
When multiple handlers are registered with done(), fail(), or always(), they are called in the When multiple handlers are registered with done(), fail(), or always(), they are called in the
same order. same order.
*/ */
export interface Promise<Value> extends PromiseState<Value> { export interface Promise<Value> extends PromiseState<Value> {
/** /**
Returns a promise that represents a promise chain that consists of this Returns a promise that represents a promise chain that consists of this
@ -161,7 +153,6 @@ export interface Promise<Value> extends PromiseState<Value> {
an asynchronous process. Callers of that function should only see the Promise<Value> that an asynchronous process. Callers of that function should only see the Promise<Value> that
is returned by promise(). is returned by promise().
*/ */
export interface Deferred<Value> extends PromiseState<Value> { export interface Deferred<Value> extends PromiseState<Value> {
/// Returns the encapsulated promise of this deferred instance. /// Returns the encapsulated promise of this deferred instance.
/// The returned promise supports composition but removes the ability to resolve or reject /// The returned promise supports composition but removes the ability to resolve or reject
@ -183,7 +174,6 @@ export interface Deferred<Value> extends PromiseState<Value> {
As soon one of the arguments gets rejected, the resulting promise gets rejected. As soon one of the arguments gets rejected, the resulting promise gets rejected.
If no promises were provided, the resulting promise is immediately resolved. If no promises were provided, the resulting promise is immediately resolved.
*/ */
export function when(...promises: Promise<any>[]): Promise<any[]> { export function when(...promises: Promise<any>[]): Promise<any[]> {
var allDone = defer<any[]>(); var allDone = defer<any[]>();
if (!promises.length) { if (!promises.length) {
@ -216,7 +206,6 @@ export function when(...promises: Promise<any>[]): Promise<any[]> {
The Promise<Value> instance is a proxy to the Deferred<Value> instance. The Promise<Value> instance is a proxy to the Deferred<Value> instance.
*/ */
class PromiseI<Value> implements Promise<Value> class PromiseI<Value> implements Promise<Value>
{ {
constructor(public deferred: DeferredI<Value>) constructor(public deferred: DeferredI<Value>)
@ -249,7 +238,6 @@ class PromiseI<Value> implements Promise<Value>
/** /**
Implementation of a deferred. Implementation of a deferred.
*/ */
class DeferredI<Value> implements Deferred<Value>{ class DeferredI<Value> implements Deferred<Value>{
private _resolved: (v: Value) => void = _ => { }; private _resolved: (v: Value) => void = _ => { };
@ -379,7 +367,6 @@ class DeferredI<Value> implements Deferred<Value>{
/** /**
Promise Generators and Iterators. Promise Generators and Iterators.
*/ */
export interface Generator<E> { export interface Generator<E> {
(): Iterator<E>; (): Iterator<E>;
} }
@ -419,7 +406,6 @@ class IteratorI<E> implements Iterator<E>
/** /**
Iterator functions. Iterator functions.
*/ */
export function each<E>(gen: Generator<E>, f: (e: E) => void): Promise<{}> { export function each<E>(gen: Generator<E>, f: (e: E) => void): Promise<{}> {
var d = defer(); var d = defer();
eachCore(d, gen(), f); eachCore(d, gen(), f);
@ -443,7 +429,6 @@ function eachCore<E>(fin: Deferred<{}>, it: Iterator<E>, f: (e: E) => void): voi
/** /**
std std
*/ */
export function isUndefined(v) { export function isUndefined(v) {
return typeof v === 'undefined'; return typeof v === 'undefined';
} }

1
text/text.d.ts vendored
View File

@ -9,3 +9,4 @@ export declare module encoding {
export var UTF_16LE: any; export var UTF_16LE: any;
export var UTF_8: any; export var UTF_8: any;
} }