mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-10 11:40:16 +08:00
Merge branch 'master' of github.com:Sebazzz/DefinitelyTyped into generic-linqjs
This commit is contained in:
@@ -33,3 +33,5 @@ _infrastructure/tests/build
|
||||
!rx.js
|
||||
|
||||
node_modules
|
||||
|
||||
.sublimets
|
||||
|
||||
@@ -2,5 +2,7 @@ language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
|
||||
sudo: false
|
||||
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
+665
-395
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
/// <reference path="headroom.d.ts" />
|
||||
|
||||
new Headroom(document.getElementById('siteHead'));
|
||||
|
||||
new Headroom(document.getElementsByClassName('siteHead')[0]);
|
||||
|
||||
new Headroom(document.getElementsByClassName('siteHead')[0], {
|
||||
tolerance: 34
|
||||
});
|
||||
|
||||
new Headroom(document.getElementsByClassName('siteHead')[0], {
|
||||
offset: 500
|
||||
});
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// Type definitions for headroom.js v0.7.0
|
||||
// Project: http://wicky.nillia.ms/headroom.js/
|
||||
// Definitions by: Jakub Olek <https://github.com/hakubo/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface HeadroomOptions {
|
||||
offset?: number;
|
||||
tolerance?: any;
|
||||
classes?: {
|
||||
initial?: string;
|
||||
pinned?: string;
|
||||
unpinned?: string;
|
||||
top?: string;
|
||||
notTop?: string;
|
||||
};
|
||||
scroller?: Element;
|
||||
onPin?: () => void;
|
||||
onUnPin?: () => void;
|
||||
onTop?: () => void;
|
||||
onNotTop?: () => void;
|
||||
|
||||
}
|
||||
|
||||
declare class Headroom {
|
||||
constructor(element: Node, options?: HeadroomOptions);
|
||||
constructor(element: Element, options?: HeadroomOptions);
|
||||
init: () => void;
|
||||
}
|
||||
@@ -1 +1,23 @@
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
function readJSON(target) {
|
||||
return JSON.parse(fs.readFileSync(target, 'utf8'));
|
||||
}
|
||||
|
||||
function getSemFloat(str) {
|
||||
var m = /^[^\d]*(\d+)\.(\d+)/.exec(str);
|
||||
return parseFloat(m[1] + '.' + m[2]);
|
||||
}
|
||||
|
||||
var repo = readJSON(path.resolve(__dirname, '..', 'package.json'));
|
||||
|
||||
var testerPath = path.resolve(__dirname, '..', 'node_modules', 'definition-tester', 'package.json');
|
||||
|
||||
// ultra lame semver major/minor check
|
||||
if (!fs.existsSync(testerPath) || getSemFloat(repo.dependencies['definition-tester']) > getSemFloat(readJSON(testerPath).version)) {
|
||||
console.log('DefinitelyTyped tester needs an update!\n\n please run \'npm install\'\n');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
require('definition-tester');
|
||||
|
||||
+14169
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsc.js')
|
||||
File diff suppressed because one or more lines are too long
+14169
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
require('./tsc.js')
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,33 @@
|
||||
/// <reference path="adm-zip.d.ts" />
|
||||
import AdmZip = require("adm-zip");
|
||||
|
||||
|
||||
// reading archives
|
||||
var zip = new AdmZip("./my_file.zip");
|
||||
var zipEntries = zip.getEntries(); // an array of ZipEntry records
|
||||
|
||||
zipEntries.forEach(function (zipEntry) {
|
||||
console.log(zipEntry.toString()); // outputs zip entries information
|
||||
if (zipEntry.entryName == "my_file.txt") {
|
||||
console.log(zipEntry.getData().toString('utf8'));
|
||||
}
|
||||
});
|
||||
// outputs the content of some_folder/my_file.txt
|
||||
console.log(zip.readAsText("some_folder/my_file.txt"));
|
||||
// extracts the specified file to the specified location
|
||||
zip.extractEntryTo(/*entry name*/"some_folder/my_file.txt", /*target path*/"/home/me/tempfolder", /*overwrite*/true)
|
||||
// extracts everything
|
||||
zip.extractAllTo(/*target path*/"/home/me/zipcontent/", /*overwrite*/true);
|
||||
|
||||
|
||||
// creating archives
|
||||
var zip = new AdmZip();
|
||||
|
||||
// add file directly
|
||||
zip.addFile("test.txt", new Buffer("inner content of the file"), "entry comment goes here");
|
||||
// add local file
|
||||
zip.addLocalFile("/home/me/some_picture.png");
|
||||
// get everything as a buffer
|
||||
var willSendthis = zip.toBuffer();
|
||||
// or write everything to disk
|
||||
zip.writeZip(/*target file name*/"/home/me/files.zip");
|
||||
Vendored
+300
@@ -0,0 +1,300 @@
|
||||
// Type definitions for adm-zip v0.4.4
|
||||
// Project: https://github.com/cthackers/adm-zip
|
||||
// Definitions by: John Vilk <https://github.com/jvilk>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module AdmZip {
|
||||
class ZipFile {
|
||||
/**
|
||||
* Create a new, empty archive.
|
||||
*/
|
||||
constructor();
|
||||
/**
|
||||
* Read an existing archive.
|
||||
*/
|
||||
constructor(fileName: string);
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as a
|
||||
* Buffer object.
|
||||
* @param entry String with the full path of the entry
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFile(entry: string): Buffer;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as a
|
||||
* Buffer object.
|
||||
* @param entry ZipEntry object
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFile(entry: IZipEntry): Buffer;
|
||||
/**
|
||||
* Asynchronous readFile
|
||||
* @param entry String with the full path of the entry
|
||||
* @param callback Called with a Buffer or Null in case of error
|
||||
*/
|
||||
readFileAsync(entry: string, callback: (data: Buffer, err: string) => any): void;
|
||||
/**
|
||||
* Asynchronous readFile
|
||||
* @param entry ZipEntry object
|
||||
* @param callback Called with a Buffer or Null in case of error
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFileAsync(entry: IZipEntry, callback: (data: Buffer, err: string) => any): void;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as
|
||||
* plain text in the given encoding
|
||||
* @param entry String with the full path of the entry
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @return String
|
||||
*/
|
||||
readAsText(fileName: string, encoding?: string): string;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as
|
||||
* plain text in the given encoding
|
||||
* @param entry ZipEntry object
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
* @return String
|
||||
*/
|
||||
readAsText(fileName: IZipEntry, encoding?: string): string;
|
||||
/**
|
||||
* Asynchronous readAsText
|
||||
* @param entry String with the full path of the entry
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
*/
|
||||
readAsTextAsync(fileName: string, callback: (data: string) => any, encoding?: string): void;
|
||||
/**
|
||||
* Asynchronous readAsText
|
||||
* @param entry ZipEntry object
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
*/
|
||||
readAsTextAsync(fileName: IZipEntry, callback: (data: string) => any, encoding?: string): void;
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all its nested directories
|
||||
* and files if the given entry is a directory
|
||||
* @param entry String with the full path of the entry
|
||||
*/
|
||||
deleteFile(entry: string): void;
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all its nested directories
|
||||
* and files if the given entry is a directory
|
||||
* @param entry A ZipEntry object.
|
||||
*/
|
||||
deleteFile(entry: IZipEntry): void;
|
||||
/**
|
||||
* Adds a comment to the zip. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* @param comment Content of the comment.
|
||||
*/
|
||||
addZipComment(comment: string): void;
|
||||
/**
|
||||
* Returns the zip comment
|
||||
* @return The zip comment.
|
||||
*/
|
||||
getZipComment(): string;
|
||||
/**
|
||||
* Adds a comment to a specified zipEntry. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* The comment cannot exceed 65535 characters in length.
|
||||
* @param entry String with the full path of the entry
|
||||
* @param comment The comment to add to the entry.
|
||||
*/
|
||||
addZipEntryComment(entry: string, comment: string): void;
|
||||
/**
|
||||
* Adds a comment to a specified zipEntry. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* The comment cannot exceed 65535 characters in length.
|
||||
* @param entry ZipEntry object.
|
||||
* @param comment The comment to add to the entry.
|
||||
*/
|
||||
addZipEntryComment(entry: IZipEntry, comment: string): void;
|
||||
/**
|
||||
* Returns the comment of the specified entry.
|
||||
* @param entry String with the full path of the entry.
|
||||
* @return String The comment of the specified entry.
|
||||
*/
|
||||
getZipEntryComment(entry: string): string;
|
||||
/**
|
||||
* Returns the comment of the specified entry
|
||||
* @param entry ZipEntry object.
|
||||
* @return String The comment of the specified entry.
|
||||
*/
|
||||
getZipEntryComment(entry: IZipEntry): string;
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip
|
||||
* must be rewritten after updating the content
|
||||
* @param entry String with the full path of the entry.
|
||||
* @param content The entry's new contents.
|
||||
*/
|
||||
updateFile(entry: string, content: Buffer): void;
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip
|
||||
* must be rewritten after updating the content
|
||||
* @param entry ZipEntry object.
|
||||
* @param content The entry's new contents.
|
||||
*/
|
||||
updateFile(entry: IZipEntry, content: Buffer): void;
|
||||
/**
|
||||
* Adds a file from the disk to the archive.
|
||||
* @param localPath Path to a file on disk.
|
||||
* @param zipPath Path to a directory in the archive. Defaults to the empty
|
||||
* string.
|
||||
*/
|
||||
addLocalFile(localPath: string, zipPath?: string): void;
|
||||
/**
|
||||
* Adds a local directory and all its nested files and directories to the
|
||||
* archive.
|
||||
* @param localPath Path to a folder on disk.
|
||||
* @param zipPath Path to a folder in the archive. Defaults to an empty
|
||||
* string.
|
||||
*/
|
||||
addLocalFolder(localPath: string, zipPath?: string): void;
|
||||
/**
|
||||
* Allows you to create a entry (file or directory) in the zip file.
|
||||
* If you want to create a directory the entryName must end in / and a null
|
||||
* buffer should be provided.
|
||||
* @param entryName Entry path
|
||||
* @param content Content to add to the entry; must be a 0-length buffer
|
||||
* for a directory.
|
||||
* @param comment Comment to add to the entry.
|
||||
* @param attr Attribute to add to the entry.
|
||||
*/
|
||||
addFile(entryName: string, data: Buffer, comment?: string, attr?: number): void;
|
||||
/**
|
||||
* Returns an array of ZipEntry objects representing the files and folders
|
||||
* inside the archive
|
||||
*/
|
||||
getEntries(): IZipEntry[];
|
||||
/**
|
||||
* Returns a ZipEntry object representing the file or folder specified by
|
||||
* ``name``.
|
||||
* @param name Name of the file or folder to retrieve.
|
||||
* @return ZipEntry The entry corresponding to the name.
|
||||
*/
|
||||
getEntry(name: string): IZipEntry;
|
||||
/**
|
||||
* Extracts the given entry to the given targetPath.
|
||||
* If the entry is a directory inside the archive, the entire directory and
|
||||
* its subdirectories will be extracted.
|
||||
* @param entry String with the full path of the entry
|
||||
* @param targetPath Target folder where to write the file
|
||||
* @param maintainEntryPath If maintainEntryPath is true and the entry is
|
||||
* inside a folder, the entry folder will be created in targetPath as
|
||||
* well. Default is TRUE
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
extractEntryTo(entryPath: string, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
|
||||
/**
|
||||
* Extracts the given entry to the given targetPath.
|
||||
* If the entry is a directory inside the archive, the entire directory and
|
||||
* its subdirectories will be extracted.
|
||||
* @param entry ZipEntry object
|
||||
* @param targetPath Target folder where to write the file
|
||||
* @param maintainEntryPath If maintainEntryPath is true and the entry is
|
||||
* inside a folder, the entry folder will be created in targetPath as
|
||||
* well. Default is TRUE
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
* @return Boolean
|
||||
*/
|
||||
extractEntryTo(entryPath: IZipEntry, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
|
||||
/**
|
||||
* Extracts the entire archive to the given location
|
||||
* @param targetPath Target location
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is true. Default is FALSE
|
||||
*/
|
||||
extractAllTo(targetPath: string, overwrite?: boolean): void;
|
||||
/**
|
||||
* Writes the newly created zip file to disk at the specified location or
|
||||
* if a zip was opened and no ``targetFileName`` is provided, it will
|
||||
* overwrite the opened zip
|
||||
* @param targetFileName
|
||||
*/
|
||||
writeZip(targetPath?: string): void;
|
||||
/**
|
||||
* Returns the content of the entire zip file as a Buffer object
|
||||
* @return Buffer
|
||||
*/
|
||||
toBuffer(): Buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* The ZipEntry is more than a structure representing the entry inside the
|
||||
* zip file. Beside the normal attributes and headers a entry can have, the
|
||||
* class contains a reference to the part of the file where the compressed
|
||||
* data resides and decompresses it when requested. It also compresses the
|
||||
* data and creates the headers required to write in the zip file.
|
||||
*/
|
||||
interface IZipEntry {
|
||||
/**
|
||||
* Represents the full name and path of the file
|
||||
*/
|
||||
entryName: string;
|
||||
rawEntryName: Buffer;
|
||||
/**
|
||||
* Extra data associated with this entry.
|
||||
*/
|
||||
extra: Buffer;
|
||||
/**
|
||||
* Entry comment.
|
||||
*/
|
||||
comment: string;
|
||||
name: string;
|
||||
/**
|
||||
* Read-Only property that indicates the type of the entry.
|
||||
*/
|
||||
isDirectory: boolean;
|
||||
/**
|
||||
* Get the header associated with this ZipEntry.
|
||||
*/
|
||||
header: Buffer;
|
||||
/**
|
||||
* Retrieve the compressed data for this entry. Note that this may trigger
|
||||
* compression if any properties were modified.
|
||||
*/
|
||||
getCompressedData(): Buffer;
|
||||
/**
|
||||
* Asynchronously retrieve the compressed data for this entry. Note that
|
||||
* this may trigger compression if any properties were modified.
|
||||
*/
|
||||
getCompressedDataAsync(callback: (data: Buffer) => void): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: string): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: Buffer): void;
|
||||
/**
|
||||
* Get the decompressed data associated with this entry.
|
||||
*/
|
||||
getData(): Buffer;
|
||||
/**
|
||||
* Asynchronously get the decompressed data associated with this entry.
|
||||
*/
|
||||
getDataAsync(callback: (data: Buffer) => void): void;
|
||||
/**
|
||||
* Returns the CEN Entry Header to be written to the output zip file, plus
|
||||
* the extra data and the entry comment.
|
||||
*/
|
||||
packHeader(): Buffer;
|
||||
/**
|
||||
* Returns a nicely formatted string with the most important properties of
|
||||
* the ZipEntry.
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "adm-zip" {
|
||||
import zipFile = AdmZip.ZipFile;
|
||||
export = zipFile;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/// <reference path="angular-file-upload.d.ts" />
|
||||
|
||||
module controllers {
|
||||
|
||||
"use strict";
|
||||
|
||||
var controllerId = "upload";
|
||||
|
||||
class Upload {
|
||||
|
||||
static $inject = ["$upload"];
|
||||
constructor(
|
||||
private $upload: ng.angularFileUpload.IUploadService
|
||||
) {
|
||||
}
|
||||
|
||||
onFileSelect($files: File[]) {
|
||||
//$files: an array of files selected, each file has name, size, and type.
|
||||
var uploads: ng.IPromise<any>[] = [];
|
||||
for (var i = 0; i < $files.length; i++) {
|
||||
var file = $files[i];
|
||||
uploads.push(this.$upload.upload<any>({
|
||||
url: "/api/upload",
|
||||
method: "POST",
|
||||
data: {
|
||||
extraData: {
|
||||
fileName: file.name, test: "anything"
|
||||
}
|
||||
},
|
||||
file: file
|
||||
})
|
||||
.progress((evt: any) => {
|
||||
console.log('progress');
|
||||
})
|
||||
.then(success => {
|
||||
// file is uploaded successfully
|
||||
console.log(success.data);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
angular.module("app").controller(controllerId, Upload);
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for Angular File Upload 1.6.7
|
||||
// Project: https://github.com/danialfarid/angular-file-upload
|
||||
// Definitions by: John Reilly <https://github.com/johnnyreilly>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ng.angularFileUpload {
|
||||
|
||||
interface IUploadService {
|
||||
|
||||
http<T>(config: IFileUploadConfig): IUploadPromise<T>;
|
||||
upload<T>(config: IFileUploadConfig): IUploadPromise<T>;
|
||||
}
|
||||
|
||||
interface IUploadPromise<T> extends IHttpPromise<T> {
|
||||
|
||||
progress(callback: IHttpPromiseCallback<T>): IUploadPromise<T>;
|
||||
}
|
||||
|
||||
interface IFileUploadConfig extends ng.IRequestConfig {
|
||||
|
||||
file: File;
|
||||
fileName?: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path="./angular-http-auth.d.ts" />
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
angular.module('login', ['http-auth-interceptor'])
|
||||
|
||||
.controller('LoginController', ($scope:any, $http:any, authService:ng.httpAuth.IAuthService) => {
|
||||
$scope.submit = () => {
|
||||
$http.post('auth/login').success(() => {
|
||||
authService.loginConfirmed();
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for angular-http-auth 1.2.1
|
||||
// Project: https://github.com/witoldsz/angular-http-auth
|
||||
// Definitions by: vvakame <https://github.com/vvakame>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ng.httpAuth {
|
||||
interface IAuthService {
|
||||
loginConfirmed(data?:any, configUpdater?:Function):void;
|
||||
loginCancelled(data?:any, reason?:any):void;
|
||||
}
|
||||
|
||||
interface IHttpBuffer {
|
||||
append(config:ng.IRequestConfig, deferred:{resolve(data:any):void; reject(data:any):void;}):void;
|
||||
rejectAll(reason?:any):void;
|
||||
retryAll(updater?:Function):void;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/// <reference path="angular-notify.d.ts" />
|
||||
|
||||
var myapp = angular.module("myapp", ["cgNotify"]);
|
||||
|
||||
myapp.controller("MyController", ["$scope", "cgNotify",
|
||||
function ($scope:ng.IScope, notify:ng.cgNotify.INotifyService) { // <-- Inject notify
|
||||
|
||||
var notifyObj = notify("Your notification message"); // <-- Call notify with your message
|
||||
notifyObj.close();
|
||||
|
||||
notify.config({
|
||||
startTop: 10,
|
||||
verticalSpacing: 15,
|
||||
duration: 10000,
|
||||
templateUrl: "angular-notify.html",
|
||||
position: "center",
|
||||
container: document.body
|
||||
});
|
||||
|
||||
notify( {
|
||||
message: "My message",
|
||||
templateUrl: "my_template.html",
|
||||
position: "center",
|
||||
container: document.body,
|
||||
classes: "", // <-- CSS class names
|
||||
$scope: $scope
|
||||
}); // <-- Call notify with your message + option
|
||||
|
||||
notify.closeAll();
|
||||
}
|
||||
]);
|
||||
Vendored
+116
@@ -0,0 +1,116 @@
|
||||
// Type definitions for angular-notify 2.0.2
|
||||
// Project: https://github.com/cgross/angular-notify
|
||||
// Definitions by: Suwato <https://github.com/Suwato/DefinitelyTyped>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ng.cgNotify {
|
||||
|
||||
interface INotifyService {
|
||||
|
||||
/**
|
||||
* The notify function can either be passed a string or an object.
|
||||
* This function will return an object with a close() method and a message property.
|
||||
* @param message
|
||||
*/
|
||||
(message:string):INotify;
|
||||
|
||||
/**
|
||||
* When passing an object, the object parameters can be:
|
||||
* @param option
|
||||
*/
|
||||
(option:{
|
||||
/**
|
||||
* Required. The message to show.
|
||||
*/
|
||||
message : string;
|
||||
|
||||
/**
|
||||
* Optional. A custom template for the UI of the message.
|
||||
*/
|
||||
templateUrl? : string;
|
||||
|
||||
/**
|
||||
* Optional. A list of custom CSS classes to apply to the message element.
|
||||
*/
|
||||
classes? : string;
|
||||
|
||||
/**
|
||||
* Optional. A string containing any valid Angular HTML which will be shown instead of the regular message text.
|
||||
* The string must contain one root element like all valid Angular HTML templates (so wrap everything in a <span>).
|
||||
*/
|
||||
messageTemplate? : string;
|
||||
|
||||
/**
|
||||
* Optional. A valid Angular scope object. The scope of the template will be created by calling $new() on this scope.
|
||||
*/
|
||||
$scope? : ng.IScope;
|
||||
|
||||
/**
|
||||
* Optional. Currently center and right are the only acceptable values.
|
||||
*/
|
||||
position? : string;
|
||||
|
||||
/**
|
||||
* Optional. Element that contains each notification. Defaults to document.body.
|
||||
*/
|
||||
container? : any;
|
||||
}):INotify;
|
||||
|
||||
|
||||
/**
|
||||
* Call config to set the default configuration options for angular-notify.
|
||||
* The following options may be specified in the given object:
|
||||
* @param option
|
||||
*/
|
||||
config(option:{
|
||||
/**
|
||||
* The default duration (in milliseconds) of each message. A duration of 0 will prevent messages from closing automatically.
|
||||
*/
|
||||
duration? : number;
|
||||
|
||||
/**
|
||||
* The Y pixel value where messages will be shown.
|
||||
*/
|
||||
startTop? : number;
|
||||
|
||||
/**
|
||||
* The number of pixels that should be reserved between messages vertically.
|
||||
*/
|
||||
verticalSpacing? : number;
|
||||
|
||||
/**
|
||||
* The default message template.
|
||||
*/
|
||||
templateUrl? : string;
|
||||
|
||||
/**
|
||||
* The default position of each message. Currently only center and right are the supported values.
|
||||
*/
|
||||
position? : string;
|
||||
|
||||
/**
|
||||
* The default element that contains each notification. Defaults to document.body.
|
||||
*/
|
||||
container? : any;
|
||||
}):void;
|
||||
|
||||
/**
|
||||
* Closes all currently open notifications.
|
||||
*/
|
||||
closeAll():void;
|
||||
}
|
||||
|
||||
interface INotify{
|
||||
/**
|
||||
* The message to show.
|
||||
*/
|
||||
message:string;
|
||||
|
||||
/**
|
||||
* Close this open notifications.
|
||||
*/
|
||||
close():void;
|
||||
}
|
||||
}
|
||||
+7
-4
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular Translate (pascalprecht.translate module)
|
||||
// Type definitions for Angular Translate v2.4.0 (pascalprecht.translate module)
|
||||
// Project: https://github.com/PascalPrecht/angular-translate
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -42,7 +42,7 @@ declare module ng.translate {
|
||||
instant(translationId: string, interpolateParams?: any, interpolationId?: string): string;
|
||||
instant(translationId: string[], interpolateParams?: any, interpolationId?: string): { [key: string]: string };
|
||||
isPostCompilingEnabled(): boolean;
|
||||
preferredLanguage(): string;
|
||||
preferredLanguage(langKey?: string): string;
|
||||
proposedLanguage(): string;
|
||||
refresh(langKey?: string): ng.IPromise<void>;
|
||||
storage(): IStorage;
|
||||
@@ -50,6 +50,8 @@ declare module ng.translate {
|
||||
use(): string;
|
||||
use(key: string): ng.IPromise<string>;
|
||||
useFallbackLanguage(langKey?: string): void;
|
||||
versionInfo(): string;
|
||||
loaderCache(): any;
|
||||
}
|
||||
|
||||
interface ITranslateProvider extends ng.IServiceProvider {
|
||||
@@ -61,14 +63,14 @@ declare module ng.translate {
|
||||
useMessageFormatInterpolation(): ITranslateProvider;
|
||||
useInterpolation(factory: string): ITranslateProvider;
|
||||
useSanitizeValueStrategy(value: string): ITranslateProvider;
|
||||
preferredLanguage(): string;
|
||||
preferredLanguage(): ITranslateProvider;
|
||||
preferredLanguage(language: string): ITranslateProvider;
|
||||
translationNotFoundIndicator(indicator: string): ITranslateProvider;
|
||||
translationNotFoundIndicatorLeft(): string;
|
||||
translationNotFoundIndicatorLeft(indicator: string): ITranslateProvider;
|
||||
translationNotFoundIndicatorRight(): string;
|
||||
translationNotFoundIndicatorRight(indicator: string): ITranslateProvider;
|
||||
fallbackLanguage(): string;
|
||||
fallbackLanguage(): ITranslateProvider;
|
||||
fallbackLanguage(language: string): ITranslateProvider;
|
||||
fallbackLanguage(languages: string[]): ITranslateProvider;
|
||||
use(): string;
|
||||
@@ -89,5 +91,6 @@ declare module ng.translate {
|
||||
determinePreferredLanguage(fn?: () => void): ITranslateProvider;
|
||||
registerAvailableLanguageKeys(): string[];
|
||||
registerAvailableLanguageKeys(languageKeys: string[], aliases?: ILanguageKeyAlias): ITranslateProvider;
|
||||
useLoaderCache(cache?: any): ITranslateProvider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,53 +3,166 @@
|
||||
var myapp = angular.module("myapp", ["firebase"]);
|
||||
|
||||
interface AngularFireScope extends ng.IScope {
|
||||
items: AngularFire;
|
||||
remoteItems: RemoteItems;
|
||||
}
|
||||
|
||||
interface RemoteItems {
|
||||
bar: string;
|
||||
data: any;
|
||||
}
|
||||
|
||||
var url = "https://myapp.firebaseio.com";
|
||||
|
||||
myapp.controller("MyController", ["$scope", "$firebase",
|
||||
function($scope: AngularFireScope, $firebase: AngularFireService) {
|
||||
$scope.items = $firebase(new Firebase(url));
|
||||
$scope.items.$add({ foo: "bar" });
|
||||
$scope.items.$remove("foo");
|
||||
$scope.items.$remove();
|
||||
$scope.items.$save();
|
||||
var child = $scope.items.$child("foo");
|
||||
child.$remove();
|
||||
$scope.items.$set({ bar: "baz" });
|
||||
var keys = $scope.items.$getIndex();
|
||||
keys.forEach(function(key, i) {
|
||||
console.log(i, (<any>$scope.items)[key]);
|
||||
});
|
||||
$scope.items.$on("loaded", function() {
|
||||
console.log("Initial data received!");
|
||||
});
|
||||
$scope.items.$on("change", function() {
|
||||
console.log("A remote change was applied locally!");
|
||||
});
|
||||
$scope.items.$off('loaded');
|
||||
function stopSync() {
|
||||
$scope.items.$off();
|
||||
myapp.controller("MyController", ["$scope", "$firebase", '$FirebaseObject', '$FirebaseArray',
|
||||
function ($scope: AngularFireScope, $firebase: AngularFireService, $FirebaseObject: AngularFireObjectService, $FirebaseArray: AngularFireArrayService) {
|
||||
var ref = new Firebase(url);
|
||||
var sync = $firebase(ref);
|
||||
|
||||
// AngularFire
|
||||
{
|
||||
sync.$asArray();
|
||||
sync.$asObject();
|
||||
sync.$ref();
|
||||
sync.$remove();
|
||||
sync.$push({ foo: "foo data" });
|
||||
sync.$set("foo", 1);
|
||||
sync.$set({ foo: 2 });
|
||||
sync.$update({ foo: 3 });
|
||||
sync.$update("foo", { bar: 1 });
|
||||
|
||||
// Increment the message count by 1
|
||||
sync.$transaction('count', function (currentCount) {
|
||||
if (!currentCount) return 1; // Initial value for counter.
|
||||
if (currentCount < 0) return; // Return undefined to abort transaction.
|
||||
return currentCount + 1; // Increment the count by 1.
|
||||
}).then(function (snapshot) {
|
||||
if (!snapshot) {
|
||||
// Handle aborted transaction.
|
||||
} else {
|
||||
// Do something.
|
||||
console.log(snapshot.val());
|
||||
}
|
||||
}, function (err) {
|
||||
// Handle the error condition.
|
||||
console.log(err.stack);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// AngularFireObject
|
||||
{
|
||||
var obj = sync.$asObject();
|
||||
|
||||
// $id
|
||||
if (obj.$id !== ref.name()) throw "error";
|
||||
|
||||
// $loaded()
|
||||
obj.$loaded().then((data) => {
|
||||
if (data !== obj) throw "error";
|
||||
// $priority
|
||||
obj.$priority;
|
||||
|
||||
// $value, $save()
|
||||
obj.$value = "foobar";
|
||||
obj.$save();
|
||||
});
|
||||
|
||||
// $inst()
|
||||
if (obj.$inst() !== sync) throw "error";
|
||||
|
||||
// $bindTo()
|
||||
obj.$bindTo($scope, "data").then(function () {
|
||||
console.log($scope.data);
|
||||
$scope.data.foo = "baz"; // will be saved to Firebase
|
||||
sync.$set({ foo: "baz" }); // this would update Firebase and $scope.data
|
||||
});
|
||||
|
||||
// $watch()
|
||||
var unwatch = obj.$watch(function () {
|
||||
console.log("data changed!");
|
||||
});
|
||||
unwatch();
|
||||
|
||||
// $destroy()
|
||||
obj.$destroy();
|
||||
|
||||
// $extendFactory()
|
||||
var NewFactory = $FirebaseObject.$extendFactory({
|
||||
getMyFavoriteColor: function () {
|
||||
return this.favoriteColor + ", no green!"; // obscure Monty Python reference
|
||||
}
|
||||
});
|
||||
var customObj = $firebase(ref, { objectFactory: NewFactory }).$asObject();
|
||||
}
|
||||
|
||||
// AngularFireArray
|
||||
{
|
||||
var list = sync.$asArray();
|
||||
|
||||
// $inst()
|
||||
if (list.$inst() !== sync) throw "error";
|
||||
|
||||
// $add()
|
||||
list.$add({ foo: "foo value" });
|
||||
|
||||
// $keyAt()
|
||||
var key = list.$keyAt(0);
|
||||
|
||||
// $indexFor()
|
||||
var index = list.$indexFor(key);
|
||||
|
||||
// $getRecord()
|
||||
var item = list.$getRecord(key);
|
||||
|
||||
// $save()
|
||||
item["bar"] = "bar value";
|
||||
list.$save(item);
|
||||
|
||||
// $remove()
|
||||
list.$remove(item);
|
||||
|
||||
// $loaded()
|
||||
list.$loaded().then(data => {
|
||||
if (data !== list) throw "error";
|
||||
});
|
||||
|
||||
// $watch()
|
||||
var unwatch = list.$watch((event, key, prevChild) => {
|
||||
switch (event) {
|
||||
case "child_added":
|
||||
console.log(key + " added");
|
||||
break;
|
||||
case "child_changed":
|
||||
console.log(key + " changed");
|
||||
break;
|
||||
case "child_moved":
|
||||
console.log(key + " moved");
|
||||
break;
|
||||
case "child_removed":
|
||||
console.log(key + " removed");
|
||||
break;
|
||||
default:
|
||||
throw "error";
|
||||
}
|
||||
});
|
||||
unwatch();
|
||||
|
||||
// $destroy()
|
||||
list.$destroy();
|
||||
|
||||
// $extendFactory()
|
||||
var ArrayWithSum = $FirebaseArray.$extendFactory({
|
||||
sum: function () {
|
||||
var total = 0;
|
||||
angular.forEach(this.$list, function (rec) {
|
||||
total += rec.x;
|
||||
});
|
||||
return total;
|
||||
}
|
||||
});
|
||||
var list = $firebase(ref, { arrayFactory: ArrayWithSum }).$asArray();
|
||||
list.$loaded().then(function () {
|
||||
console.log("List has " + (<any>list).sum() + " items");
|
||||
});
|
||||
}
|
||||
$scope.items.$bind($scope, "remoteItems");
|
||||
$scope.remoteItems.bar = "foo";
|
||||
$scope.items.$bind($scope, "remote").then(function(unbind) {
|
||||
unbind();
|
||||
$scope.remoteItems.bar = "foo";
|
||||
});
|
||||
}
|
||||
]);
|
||||
|
||||
var foo: AngularFireObject = {
|
||||
$priority: 0
|
||||
};
|
||||
|
||||
interface AngularFireAuthScope extends ng.IScope {
|
||||
loginObj: AngularFireAuth;
|
||||
}
|
||||
|
||||
Vendored
+55
-14
@@ -1,4 +1,4 @@
|
||||
// Type definitions for AngularFire 0.6.0
|
||||
// Type definitions for AngularFire 0.8.2
|
||||
// Project: http://angularfire.com
|
||||
// Definitions by: Dénes Harmath <http://github.com/thSoft>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -7,24 +7,65 @@
|
||||
/// <reference path="../firebase/firebase.d.ts"/>
|
||||
|
||||
interface AngularFireService {
|
||||
(firebase: Firebase): AngularFire;
|
||||
(firebase: Firebase, config?: any): AngularFire;
|
||||
}
|
||||
|
||||
interface AngularFire {
|
||||
$add(value: any): void;
|
||||
$remove(key?: string): void;
|
||||
$save(key?: string): void;
|
||||
$child(key: string): AngularFire;
|
||||
$set(value: any): void;
|
||||
$getIndex(): string[];
|
||||
$on(eventType: string, callback: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void;
|
||||
$off(eventType?: string, callback?: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void;
|
||||
$bind($scope: ng.IScope, modelName: string): ng.IPromise<any>;
|
||||
$asArray(): AngularFireArray;
|
||||
$asObject(): AngularFireObject;
|
||||
$ref(): Firebase;
|
||||
$push(data: any): ng.IPromise<Firebase>;
|
||||
$set(key: string, data: any): ng.IPromise<Firebase>;
|
||||
$set(data: any): ng.IPromise<Firebase>;
|
||||
$remove(key?: string): ng.IPromise<Firebase>;
|
||||
$update(key: string, data: Object): ng.IPromise<Firebase>;
|
||||
$update(data: any): ng.IPromise<Firebase>;
|
||||
$transaction(updateFn: (currentData: any) => any, applyLocally?: boolean): ng.IPromise<IFirebaseDataSnapshot>;
|
||||
$transaction(key:string, updateFn: (currentData: any) => any, applyLocally?: boolean): ng.IPromise<IFirebaseDataSnapshot>;
|
||||
}
|
||||
|
||||
interface AngularFireObject {
|
||||
$priority: number;
|
||||
interface AngularFireObject extends AngularFireSimpleObject {
|
||||
$id: string;
|
||||
$priority: number;
|
||||
$value: any;
|
||||
$save(): ng.IPromise<Firebase>;
|
||||
$loaded(resolve?: (x: AngularFireObject) => ng.IHttpPromise<{}>, reject?: (err: any) => any): ng.IPromise<AngularFireObject>;
|
||||
$loaded(resolve?: (x: AngularFireObject) => ng.IPromise<{}>, reject?: (err: any) => any): ng.IPromise<AngularFireObject>;
|
||||
$loaded(resolve?: (x: AngularFireObject) => void, reject?: (err: any) => any): ng.IPromise<AngularFireObject>;
|
||||
$inst(): AngularFire;
|
||||
$bindTo(scope: ng.IScope, varName: string): ng.IPromise<any>;
|
||||
$watch(callback: Function, context?: any): Function;
|
||||
$destroy(): void;
|
||||
}
|
||||
interface AngularFireObjectService {
|
||||
$extendFactory(ChildClass: Object, methods?: Object): Object;
|
||||
}
|
||||
|
||||
interface AngularFireArray extends Array<AngularFireSimpleObject> {
|
||||
$add(newData: any): ng.IPromise<Firebase>;
|
||||
$save(recordOrIndex: any): ng.IPromise<Firebase>;
|
||||
$remove(recordOrIndex: any): ng.IPromise<Firebase>;
|
||||
$getRecord(key: string): AngularFireSimpleObject;
|
||||
$keyAt(recordOrIndex: any): string;
|
||||
$indexFor(key: string): number;
|
||||
$loaded(resolve?: (x: AngularFireArray) => ng.IHttpPromise<{}>, reject?: (err: any) => any): ng.IPromise<AngularFireArray>;
|
||||
$loaded(resolve?: (x: AngularFireArray) => ng.IPromise<{}>, reject?: (err: any) => any): ng.IPromise<AngularFireArray>;
|
||||
$loaded(resolve?: (x: AngularFireArray) => void, reject?: (err: any) => any): ng.IPromise<AngularFireArray>;
|
||||
$inst(): AngularFire;
|
||||
$watch(cb: (event: string, key: string, prevChild: string) => void, context?: any): Function;
|
||||
$destroy(): void;
|
||||
}
|
||||
interface AngularFireArrayService {
|
||||
$extendFactory(ChildClass: Object, methods?: Object): Object;
|
||||
}
|
||||
|
||||
interface AngularFireSimpleObject {
|
||||
$id: string;
|
||||
$priority: number;
|
||||
$value: any;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
||||
interface AngularFireAuthService {
|
||||
(firebase: Firebase): AngularFireAuth;
|
||||
@@ -34,7 +75,7 @@ interface AngularFireAuth {
|
||||
$getCurrentUser(): ng.IPromise<any>;
|
||||
$login(provider: string, options?: Object): ng.IPromise<any>;
|
||||
$logout(): void;
|
||||
$createUser(email: string, password: string, noLogin?: boolean): ng.IPromise<any>;
|
||||
$createUser(email: string, password: string): ng.IPromise<any>;
|
||||
$changePassword(email: string, oldPassword: string, newPassword: string): ng.IPromise<any>;
|
||||
$removeUser(email: string, password: string): ng.IPromise<any>;
|
||||
$sendPasswordResetEmail(email: string): ng.IPromise<any>;
|
||||
|
||||
Vendored
+98
-3
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Angular JS 1.2+ (ngAnimate module)
|
||||
// Type definitions for Angular JS 1.3 (ngAnimate module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="angular.d.ts" />
|
||||
@@ -13,9 +13,104 @@ declare module ng.animate {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AnimateService
|
||||
// see http://docs.angularjs.org/api/ngAnimate.$animate
|
||||
// see http://docs.angularjs.org/api/ngAnimate/service/$animate
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAnimateService extends ng.IAnimateService {
|
||||
/**
|
||||
* Globally enables / disables animations.
|
||||
*
|
||||
* @param value If provided then set the animation on or off.
|
||||
* @param element If provided then the element will be used to represent the enable/disable operation.
|
||||
* @returns current animation state
|
||||
*/
|
||||
enabled(value?: boolean, element?: JQuery): boolean;
|
||||
|
||||
/**
|
||||
* Appends the element to the parentElement element that resides in the document and then runs the enter animation.
|
||||
*
|
||||
* @param element the element that will be the focus of the enter animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the enter animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery): ng.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Runs the leave animation operation and, upon completion, removes the element from the DOM.
|
||||
*
|
||||
* @param element the element that will be the focus of the leave animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
leave(element: JQuery): ng.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Fires the move DOM operation. Just before the animation starts, the animate service will either append
|
||||
* it into the parentElement container or add the element directly after the afterElement element if present.
|
||||
* Then the move animation will be run.
|
||||
*
|
||||
* @param element the element that will be the focus of the move animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the move animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): ng.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then attaches the className
|
||||
* value to the element as a CSS class.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be added to the element and then animated
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
addClass(element: JQuery, className: string): ng.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then removes the CSS class
|
||||
* provided by the className value from the element.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be animated and then removed from the element
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
removeClass(element: JQuery, className: string): ng.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
|
||||
* will be fired (if provided).
|
||||
*
|
||||
* @param element the element which will have its CSS classes changed removed from it
|
||||
* @param add the CSS classes which will be added to the element
|
||||
* @param remove the CSS class which will be removed from the element CSS classes have been set on the element
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
setClass(element: JQuery, add: string, remove: string): ng.IPromise<void>;
|
||||
|
||||
/**
|
||||
* Cancels the provided animation.
|
||||
*/
|
||||
cancel(animationPromise: ng.IPromise<void>): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularProvider
|
||||
// see http://docs.angularjs.org/api/ngAnimate/provider/$animateProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAnimateProvider {
|
||||
/**
|
||||
* Registers a new injectable animation factory function.
|
||||
*
|
||||
* @param name The name of the animation.
|
||||
* @param factory The factory function that will be executed to return the animation object.
|
||||
*/
|
||||
register(name: string, factory: () => ng.IAnimateCallbackObject): void;
|
||||
|
||||
/**
|
||||
* Gets and/or sets the CSS class expression that is checked when performing an animation.
|
||||
*
|
||||
* @param expression The className expression which will be checked against all animations.
|
||||
* @returns The current CSS className expression value. If null then there is no expression value.
|
||||
*/
|
||||
classNameFilter(expression?: RegExp): RegExp;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular JS 1.2 (ngCookies module)
|
||||
// Type definitions for Angular JS 1.3 (ngCookies module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -15,7 +15,9 @@ declare module ng.cookies {
|
||||
// CookieService
|
||||
// see http://docs.angularjs.org/api/ngCookies.$cookies
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ICookiesService {}
|
||||
interface ICookiesService {
|
||||
[index: string]: any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CookieStoreService
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module)
|
||||
// Type definitions for Angular JS 1.3 (ngMock, ngMockE2E module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
Vendored
+20
-10
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular JS 1.2 (ngResource module)
|
||||
// Type definitions for Angular JS 1.3 (ngResource module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels>
|
||||
// Definitions: https://github.com/daptiv/DefinitelyTyped
|
||||
@@ -11,6 +11,16 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare module ng.resource {
|
||||
|
||||
/**
|
||||
* Currently supported options for the $resource factory options argument.
|
||||
*/
|
||||
interface IResourceOptions {
|
||||
/**
|
||||
* If true then the trailing slashes from any calculated URL will be stripped (defaults to true)
|
||||
*/
|
||||
stripTrailingSlashes?: boolean;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ResourceService
|
||||
// see http://docs.angularjs.org/api/ngResource.$resource
|
||||
@@ -20,17 +30,17 @@ declare module ng.resource {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IResourceService {
|
||||
(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actionDescriptors?: any): IResourceClass<IResource<any>>;
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): IResourceClass<IResource<any>>;
|
||||
<T, U>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actionDescriptors?: any): U;
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): U;
|
||||
<T>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actionDescriptors?: any): IResourceClass<T>;
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): IResourceClass<T>;
|
||||
}
|
||||
|
||||
// Just a reference to facilitate describing new actions
|
||||
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular JS 1.2 (ngRoute module)
|
||||
// Type definitions for Angular JS 1.3 (ngRoute module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Jonathan Park <https://github.com/park9140>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -75,7 +75,7 @@ declare module ng.route {
|
||||
* - key - {string}: a name of a dependency to be injected into the controller.
|
||||
* - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead.
|
||||
*/
|
||||
resolve?: any;
|
||||
resolve?: {[key: string]: any};
|
||||
/**
|
||||
* {(string|function())=}
|
||||
* Value to update $location path with and trigger route redirection.
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular JS 1.2 (ngSanitize module)
|
||||
// Type definitions for Angular JS 1.3 (ngSanitize module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular Scenario Testing
|
||||
// Type definitions for Angular Scenario Testing 1.3 (ngScenario module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: RomanoLindano <https://github.com/RomanoLindano>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
@@ -83,7 +83,7 @@ angular.module('http-auth-interceptor', [])
|
||||
}
|
||||
|
||||
}];
|
||||
$httpProvider.responseInterceptors.push(interceptor);
|
||||
$httpProvider.interceptors.push(interceptor);
|
||||
}]);
|
||||
|
||||
|
||||
@@ -250,6 +250,12 @@ httpFoo.then((x) => {
|
||||
x.toFixed();
|
||||
});
|
||||
|
||||
httpFoo.success((data, status, headers, config) => {
|
||||
var h = headers("test");
|
||||
h.charAt(0);
|
||||
var hs = headers();
|
||||
hs["content-type"].charAt(1);
|
||||
});
|
||||
|
||||
function test_angular_forEach() {
|
||||
var values: { [key: string]: string } = { name: 'misko', gender: 'male' };
|
||||
@@ -320,6 +326,47 @@ class SampleDirective2 implements ng.IDirective {
|
||||
|
||||
angular.module('SameplDirective', []).directive('sampleDirective', SampleDirective.instance).directive('sameplDirective2', SampleDirective2.instance);
|
||||
|
||||
angular.module('AnotherSampleDirective', []).directive('myDirective', ['$interpolate', '$q', ($interpolate: ng.IInterpolateService, $q: ng.IQService) => {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: (scope: ng.IScope, el: ng.IAugmentedJQuery, attr: ng.IAttributes) => {
|
||||
$interpolate(attr['test'])(scope);
|
||||
$interpolate('', true)(scope);
|
||||
$interpolate('', true, 'html')(scope);
|
||||
$interpolate('', true, 'html', true)(scope);
|
||||
var defer = $q.defer();
|
||||
defer.reject();
|
||||
defer.resolve();
|
||||
defer.promise.then(function(d) {
|
||||
return d;
|
||||
}).then(function(): any {
|
||||
return null;
|
||||
}, function(): any {
|
||||
return null;
|
||||
})
|
||||
.catch((): any => {
|
||||
return null;
|
||||
})
|
||||
.finally((): any => {
|
||||
return null;
|
||||
});
|
||||
var promise = new $q((resolve) => {
|
||||
resolve();
|
||||
});
|
||||
|
||||
promise = new $q((resolve, reject) => {
|
||||
reject();
|
||||
resolve(true);
|
||||
});
|
||||
|
||||
promise = new $q<boolean>((resolver, reject) => {
|
||||
resolver(true);
|
||||
reject(false);
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
// test from https://docs.angularjs.org/guide/directive
|
||||
angular.module('docsSimpleDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
|
||||
Vendored
+163
-34
@@ -13,6 +13,11 @@ interface Function {
|
||||
$inject?: string[];
|
||||
}
|
||||
|
||||
// Support AMD require
|
||||
declare module 'angular' {
|
||||
export = angular;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ng module (angular.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -32,6 +37,10 @@ declare module ng {
|
||||
$get: any;
|
||||
}
|
||||
|
||||
interface IAngularBootstrapConfig {
|
||||
strictDi?: boolean;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularStatic
|
||||
// see http://docs.angularjs.org/api
|
||||
@@ -46,8 +55,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: string, modules?: string): auto.IInjectorService;
|
||||
bootstrap(element: string, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -55,8 +66,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: string, modules?: Function): auto.IInjectorService;
|
||||
bootstrap(element: string, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -64,8 +77,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: string, modules?: string[]): auto.IInjectorService;
|
||||
bootstrap(element: string, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -73,8 +88,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: JQuery, modules?: string): auto.IInjectorService;
|
||||
bootstrap(element: JQuery, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -82,8 +99,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: JQuery, modules?: Function): auto.IInjectorService;
|
||||
bootstrap(element: JQuery, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -91,8 +110,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: JQuery, modules?: string[]): auto.IInjectorService;
|
||||
bootstrap(element: JQuery, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -100,8 +121,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Element, modules?: string): auto.IInjectorService;
|
||||
bootstrap(element: Element, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -109,8 +132,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Element, modules?: Function): auto.IInjectorService;
|
||||
bootstrap(element: Element, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -118,8 +143,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Element, modules?: string[]): auto.IInjectorService;
|
||||
bootstrap(element: Element, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -127,8 +154,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Document, modules?: string): auto.IInjectorService;
|
||||
bootstrap(element: Document, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -136,8 +165,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Document, modules?: Function): auto.IInjectorService;
|
||||
bootstrap(element: Document, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
/**
|
||||
* Use this function to manually start up angular application.
|
||||
*
|
||||
@@ -145,8 +176,10 @@ declare module ng {
|
||||
* @param modules An array of modules to load into the application.
|
||||
* Each item in the array should be the name of a predefined module or a (DI annotated)
|
||||
* function that will be invoked by the injector as a run block.
|
||||
* @param config an object for defining configuration options for the application. The following keys are supported:
|
||||
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
|
||||
*/
|
||||
bootstrap(element: Document, modules?: string[]): auto.IInjectorService;
|
||||
bootstrap(element: Document, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
|
||||
|
||||
/**
|
||||
* Creates a deep copy of source, which should be an object or an array.
|
||||
@@ -230,6 +263,7 @@ declare module ng {
|
||||
configFn?: Function): IModule;
|
||||
|
||||
noop(...args: any[]): void;
|
||||
reloadWithDebugInfo(): void;
|
||||
toJson(obj: any, pretty?: boolean): string;
|
||||
uppercase(str: string): string;
|
||||
version: {
|
||||
@@ -237,7 +271,7 @@ declare module ng {
|
||||
major: number;
|
||||
minor: number;
|
||||
dot: number;
|
||||
codename: string;
|
||||
codeName: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -412,6 +446,7 @@ declare module ng {
|
||||
$commitViewValue(): void;
|
||||
$rollbackViewValue(): void;
|
||||
$setSubmitted(): void;
|
||||
$setUntouched(): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -423,12 +458,13 @@ declare module ng {
|
||||
$setValidity(validationErrorKey: string, isValid: boolean): void;
|
||||
// Documentation states viewValue and modelValue to be a string but other
|
||||
// types do work and it's common to use them.
|
||||
$setViewValue(value: any): void;
|
||||
$setViewValue(value: any, trigger?: string): void;
|
||||
$setPristine(): void;
|
||||
$validate(): void;
|
||||
$setTouched(): void;
|
||||
$setUntouched(): void;
|
||||
$rollbackViewValue(): void;
|
||||
$commitViewValue(revalidate?: boolean): void;
|
||||
$commitViewValue(): void;
|
||||
$isEmpty(value: any): boolean;
|
||||
|
||||
$viewValue: any;
|
||||
@@ -447,6 +483,7 @@ declare module ng {
|
||||
$validators: IModelValidators;
|
||||
$asyncValidators: IAsyncModelValidators;
|
||||
|
||||
$pending: any;
|
||||
$pristine: boolean;
|
||||
$dirty: boolean;
|
||||
$valid: boolean;
|
||||
@@ -478,23 +515,31 @@ declare module ng {
|
||||
* see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope
|
||||
*/
|
||||
interface IRootScopeService {
|
||||
[index: string]: any;
|
||||
|
||||
$apply(): any;
|
||||
$apply(exp: string): any;
|
||||
$apply(exp: (scope: IScope) => any): any;
|
||||
|
||||
$applyAsync(): any;
|
||||
$applyAsync(exp: string): any;
|
||||
$applyAsync(exp: (scope: IScope) => any): any;
|
||||
|
||||
$broadcast(name: string, ...args: any[]): IAngularEvent;
|
||||
$destroy(): void;
|
||||
$digest(): void;
|
||||
$emit(name: string, ...args: any[]): IAngularEvent;
|
||||
|
||||
$eval(expression?: string, args?: Object): any;
|
||||
$eval(expression?: (scope: IScope) => any, args?: Object): any;
|
||||
$eval(): any;
|
||||
$eval(expression: string, locals?: Object): any;
|
||||
$eval(expression: (scope: IScope) => any, locals?: Object): any;
|
||||
|
||||
$evalAsync(expression?: string): void;
|
||||
$evalAsync(expression?: (scope: IScope) => any): void;
|
||||
$evalAsync(): void;
|
||||
$evalAsync(expression: string): void;
|
||||
$evalAsync(expression: (scope: IScope) => any): void;
|
||||
|
||||
// Defaults to false by the implementation checking strategy
|
||||
$new(isolate?: boolean): IScope;
|
||||
$new(isolate?: boolean, parent?: IScope): IScope;
|
||||
|
||||
/**
|
||||
* Listens on events of a given type. See $emit for discussion of event life cycle.
|
||||
@@ -518,10 +563,7 @@ declare module ng {
|
||||
$watchGroup(watchExpressions: { (scope: IScope): any }[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
|
||||
|
||||
$parent: IScope;
|
||||
|
||||
$root: IRootScopeService;
|
||||
this: IRootScopeService;
|
||||
|
||||
$id: number;
|
||||
|
||||
// Hidden members
|
||||
@@ -529,9 +571,7 @@ declare module ng {
|
||||
$$phase: any;
|
||||
}
|
||||
|
||||
interface IScope extends IRootScopeService {
|
||||
[index: string]: any;
|
||||
}
|
||||
interface IScope extends IRootScopeService { }
|
||||
|
||||
interface IAngularEvent {
|
||||
/**
|
||||
@@ -594,6 +634,35 @@ declare module ng {
|
||||
cancel(promise: IPromise<any>): boolean;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularProvider
|
||||
// see http://docs.angularjs.org/api/ng/provider/$animateProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAnimateProvider {
|
||||
/**
|
||||
* Registers a new injectable animation factory function.
|
||||
*
|
||||
* @param name The name of the animation.
|
||||
* @param factory The factory function that will be executed to return the animation object.
|
||||
*/
|
||||
register(name: string, factory: () => IAnimateCallbackObject): void;
|
||||
|
||||
/**
|
||||
* Gets and/or sets the CSS class expression that is checked when performing an animation.
|
||||
*
|
||||
* @param expression The className expression which will be checked against all animations.
|
||||
* @returns The current CSS className expression value. If null then there is no expression value.
|
||||
*/
|
||||
classNameFilter(expression?: RegExp): RegExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* The animation object which contains callback functions for each event that is expected to be animated.
|
||||
*/
|
||||
interface IAnimateCallbackObject {
|
||||
eventFn(element: Node, doneFn: () => void): Function;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// FilterService
|
||||
// see http://docs.angularjs.org/api/ng.$filter
|
||||
@@ -670,8 +739,8 @@ declare module ng {
|
||||
}
|
||||
|
||||
interface ILogProvider {
|
||||
debugEnabled(enabled: boolean): ILogProvider;
|
||||
debugEnabled(): boolean;
|
||||
debugEnabled(enabled: boolean): ILogProvider;
|
||||
}
|
||||
|
||||
// We define this as separete interface so we can reopen it later for
|
||||
@@ -779,6 +848,8 @@ declare module ng {
|
||||
*/
|
||||
search(search: string, paramValue: boolean): ILocationService;
|
||||
|
||||
state(): any;
|
||||
state(state: any): ILocationService;
|
||||
url(): string;
|
||||
url(url: string): ILocationService;
|
||||
}
|
||||
@@ -814,12 +885,20 @@ declare module ng {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRootElementService extends JQuery {}
|
||||
|
||||
interface IQResolveReject<T> {
|
||||
(): void;
|
||||
(value: T): void;
|
||||
}
|
||||
/**
|
||||
* $q - service in module ng
|
||||
* A promise/deferred implementation inspired by Kris Kowal's Q.
|
||||
* See http://docs.angularjs.org/api/ng/service/$q
|
||||
*/
|
||||
interface IQService {
|
||||
new (resolver: (resolve: IQResolveReject<any>) => any): IPromise<any>;
|
||||
new (resolver: (resolve: IQResolveReject<any>, reject: IQResolveReject<any>) => any): IPromise<any>;
|
||||
new <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
|
||||
|
||||
/**
|
||||
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
|
||||
*
|
||||
@@ -922,6 +1001,7 @@ declare module ng {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAnchorScrollService {
|
||||
(): void;
|
||||
yOffset: any;
|
||||
}
|
||||
|
||||
interface IAnchorScrollProvider extends IServiceProvider {
|
||||
@@ -981,6 +1061,8 @@ declare module ng {
|
||||
|
||||
imgSrcSanitizationWhitelist(): RegExp;
|
||||
imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider;
|
||||
|
||||
debugInfoEnabled(enabled?: boolean): any;
|
||||
}
|
||||
|
||||
interface ICloneAttachFunction {
|
||||
@@ -1015,6 +1097,7 @@ declare module ng {
|
||||
interface IControllerProvider extends IServiceProvider {
|
||||
register(name: string, controllerConstructor: Function): void;
|
||||
register(name: string, dependencyAnnotatedConstructor: any[]): void;
|
||||
allowGlobals(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1170,8 +1253,13 @@ declare module ng {
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface IHttpHeadersGetter {
|
||||
(): { [name: string]: string; };
|
||||
(headerName: string): string;
|
||||
}
|
||||
|
||||
interface IHttpPromiseCallback<T> {
|
||||
(data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): void;
|
||||
(data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void;
|
||||
}
|
||||
|
||||
interface IHttpPromiseCallbackArg<T> {
|
||||
@@ -1189,10 +1277,22 @@ declare module ng {
|
||||
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg<any>) => any): IPromise<TResult>;
|
||||
}
|
||||
|
||||
interface IHttpProviderDefaults {
|
||||
xsrfCookieName?: string;
|
||||
xsrfHeaderName?: string;
|
||||
headers?: {
|
||||
common?: any;
|
||||
post?: any;
|
||||
put?: any;
|
||||
patch?: any;
|
||||
}
|
||||
}
|
||||
|
||||
interface IHttpProvider extends IServiceProvider {
|
||||
defaults: IRequestConfig;
|
||||
defaults: IHttpProviderDefaults;
|
||||
interceptors: any[];
|
||||
responseInterceptors: any[];
|
||||
useApplyAsync(): boolean;
|
||||
useApplyAsync(value: boolean): IHttpProvider;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@@ -1211,7 +1311,7 @@ declare module ng {
|
||||
// see http://docs.angularjs.org/api/ng.$interpolateProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IInterpolateService {
|
||||
(text: string, mustHaveExpression?: boolean): IInterpolationFunction;
|
||||
(text: string, mustHaveExpression?: boolean, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction;
|
||||
endSymbol(): string;
|
||||
startSymbol(): string;
|
||||
}
|
||||
@@ -1286,6 +1386,34 @@ declare module ng {
|
||||
resourceUrlWhitelist(whitelist: any[]): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* $templateRequest service
|
||||
* see http://docs.angularjs.org/api/ng/service/$templateRequest
|
||||
*/
|
||||
interface ITemplateRequestService {
|
||||
/**
|
||||
* Downloads a template using $http and, upon success, stores the
|
||||
* contents inside of $templateCache.
|
||||
*
|
||||
* If the HTTP request fails or the response data of the HTTP request is
|
||||
* empty then a $compile error will be thrown (unless
|
||||
* {ignoreRequestError} is set to true).
|
||||
*
|
||||
* @param tpl The template URL.
|
||||
* @param ignoreRequestError Whether or not to ignore the exception
|
||||
* when the request fails or the template is
|
||||
* empty.
|
||||
*
|
||||
* @return A promise whose value is the template content.
|
||||
*/
|
||||
(tpl: string, ignoreRequestError?: boolean): IPromise<string>;
|
||||
/**
|
||||
* total amount of pending template requests being downloaded.
|
||||
* @type {number}
|
||||
*/
|
||||
totalPendingRequests: number;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Directive
|
||||
// see http://docs.angularjs.org/api/ng.$compileProvider#directive
|
||||
@@ -1303,7 +1431,7 @@ declare module ng {
|
||||
instanceAttributes: IAttributes,
|
||||
controller: any,
|
||||
transclude: ITranscludeFunction
|
||||
): void;
|
||||
): void;
|
||||
}
|
||||
|
||||
interface IDirectivePrePost {
|
||||
@@ -1316,13 +1444,14 @@ declare module ng {
|
||||
templateElement: IAugmentedJQuery,
|
||||
templateAttributes: IAttributes,
|
||||
transclude: ITranscludeFunction
|
||||
): IDirectivePrePost;
|
||||
): IDirectivePrePost;
|
||||
}
|
||||
|
||||
interface IDirective {
|
||||
compile?: IDirectiveCompileFn;
|
||||
controller?: any;
|
||||
controllerAs?: string;
|
||||
bindToController?: boolean;
|
||||
link?: IDirectiveLinkFn;
|
||||
name?: string;
|
||||
priority?: number;
|
||||
@@ -1360,7 +1489,7 @@ declare module ng {
|
||||
find(selector: string): IAugmentedJQuery;
|
||||
find(element: any): IAugmentedJQuery;
|
||||
find(obj: JQuery): IAugmentedJQuery;
|
||||
|
||||
controller(): any;
|
||||
controller(name: string): any;
|
||||
injector(): any;
|
||||
scope(): IScope;
|
||||
|
||||
Vendored
+7
@@ -410,6 +410,13 @@ declare module ng {
|
||||
cancel(promise: IPromise<any>): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* The animation object which contains callback functions for each event that is expected to be animated.
|
||||
*/
|
||||
interface IAnimateCallbackObject {
|
||||
eventFn(element: Node, doneFn: () => void): Function;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// FilterService
|
||||
// see http://docs.angularjs.org/api/ng.$filter
|
||||
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
// Type definitions for Angular JS 1.2 (ngAnimate module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="angular-1.2.d.ts" />
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngAnimate module (angular-animate.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare module ng.animate {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AnimateService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngAnimate/service/$animate
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAnimateService extends ng.IAnimateService {
|
||||
/**
|
||||
* Globally enables / disables animations.
|
||||
*
|
||||
* @param value If provided then set the animation on or off.
|
||||
* @param element If provided then the element will be used to represent the enable/disable operation.
|
||||
* @returns current animation state
|
||||
*/
|
||||
enabled(value?: boolean, element?: JQuery): boolean;
|
||||
|
||||
/**
|
||||
* Appends the element to the parentElement element that resides in the document and then runs the enter animation.
|
||||
*
|
||||
* @param element the element that will be the focus of the enter animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the enter animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
|
||||
* @param doneCallback the callback function that will be called once the animation is complete
|
||||
*/
|
||||
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, doneCallback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Runs the leave animation operation and, upon completion, removes the element from the DOM.
|
||||
*
|
||||
* @param element the element that will be the focus of the leave animation
|
||||
* @param doneCallback the callback function that will be called once the animation is complete
|
||||
*/
|
||||
leave(element: JQuery, doneCallback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Fires the move DOM operation. Just before the animation starts, the animate service will either append
|
||||
* it into the parentElement container or add the element directly after the afterElement element if present.
|
||||
* Then the move animation will be run.
|
||||
*
|
||||
* @param element the element that will be the focus of the move animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the move animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
|
||||
* @param doneCallback the callback function that will be called once the animation is complete
|
||||
*/
|
||||
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery, doneCallback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then attaches the className
|
||||
* value to the element as a CSS class.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be added to the element and then animated
|
||||
* @param doneCallback the callback function that will be called once the animation is complete
|
||||
*/
|
||||
addClass(element: JQuery, className: string, doneCallback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then removes the CSS class
|
||||
* provided by the className value from the element.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be animated and then removed from the element
|
||||
* @param doneCallback the callback function that will be called once the animation is complete
|
||||
*/
|
||||
removeClass(element: JQuery, className: string, doneCallback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
|
||||
* will be fired (if provided).
|
||||
*
|
||||
* @param element the element which will have its CSS classes changed removed from it
|
||||
* @param add the CSS classes which will be added to the element
|
||||
* @param remove the CSS class which will be removed from the element CSS classes have been set on the element
|
||||
* @param doneCallback done the callback function (if provided) that will be fired after the CSS classes have been set on the element
|
||||
*/
|
||||
setClass(element: JQuery, add: string, remove: string, doneCallback?: () => void): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularProvider
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngAnimate/provider/$animateProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAnimateProvider {
|
||||
/**
|
||||
* Registers a new injectable animation factory function.
|
||||
*
|
||||
* @param name The name of the animation.
|
||||
* @param factory The factory function that will be executed to return the animation object.
|
||||
*/
|
||||
register(name: string, factory: () => ng.IAnimateCallbackObject): void;
|
||||
|
||||
/**
|
||||
* Gets and/or sets the CSS class expression that is checked when performing an animation.
|
||||
*
|
||||
* @param expression The className expression which will be checked against all animations.
|
||||
* @returns The current CSS className expression value. If null then there is no expression value.
|
||||
*/
|
||||
classNameFilter(expression?: RegExp): RegExp;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// Type definitions for Angular JS 1.2 (ngCookies module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
/// <reference path="angular-1.2.d.ts" />
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngCookies module (angular-cookies.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare module ng.cookies {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CookieService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookies
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ICookiesService {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CookieStoreService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookieStore
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ICookieStoreService {
|
||||
/**
|
||||
* Returns the value of given cookie key
|
||||
* @param key Id to use for lookup
|
||||
*/
|
||||
get(key: string): any;
|
||||
/**
|
||||
* Sets a value for given cookie key
|
||||
* @param key Id for the value
|
||||
* @param value Value to be stored
|
||||
*/
|
||||
put(key: string, value: any): void;
|
||||
/**
|
||||
* Remove given cookie
|
||||
* @param key Id of the key-value pair to delete
|
||||
*/
|
||||
remove(key: string): void;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
/// <reference path="angular-mocks-1.2.d.ts" />
|
||||
|
||||
///////////////////////////////////////
|
||||
// IAngularStatic
|
||||
///////////////////////////////////////
|
||||
var angular: ng.IAngularStatic;
|
||||
var mock: ng.IMockStatic;
|
||||
|
||||
mock = angular.mock;
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IMockStatic
|
||||
///////////////////////////////////////
|
||||
var date: Date;
|
||||
|
||||
mock.dump({ key: 'value' });
|
||||
|
||||
mock.inject(
|
||||
function () { return 1; },
|
||||
function () { return 2; }
|
||||
);
|
||||
|
||||
mock.inject(
|
||||
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }]);
|
||||
|
||||
// This overload is not documented on the website, but flows from
|
||||
// how the injector works.
|
||||
mock.inject(
|
||||
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }],
|
||||
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 2; }]);
|
||||
|
||||
mock.module('module1', 'module2');
|
||||
mock.module(
|
||||
function () { return 1; },
|
||||
function () { return 2; }
|
||||
);
|
||||
mock.module({ module1: function () { return 1; } });
|
||||
|
||||
date = mock.TzDate(-7, '2013-1-1T15:00:00Z');
|
||||
date = mock.TzDate(-8, 12345678);
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IExceptionHandlerProvider
|
||||
///////////////////////////////////////
|
||||
var exceptionHandlerProvider: ng.IExceptionHandlerProvider;
|
||||
|
||||
exceptionHandlerProvider.mode('log');
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// ITimeoutService
|
||||
///////////////////////////////////////
|
||||
var timeoutService: ng.ITimeoutService;
|
||||
|
||||
timeoutService.flush();
|
||||
timeoutService.flush(1234);
|
||||
timeoutService.flushNext();
|
||||
timeoutService.flushNext(1234);
|
||||
timeoutService.verifyNoPendingTasks();
|
||||
|
||||
////////////////////////////////////////
|
||||
// IIntervalService
|
||||
////////////////////////////////////////
|
||||
var intervalService: ng.IIntervalService;
|
||||
var intervalServiceTimeActuallyAdvanced: number;
|
||||
|
||||
intervalServiceTimeActuallyAdvanced = intervalService.flush();
|
||||
intervalServiceTimeActuallyAdvanced = intervalService.flush(1234);
|
||||
|
||||
///////////////////////////////////////
|
||||
// ILogService, ILogCall
|
||||
///////////////////////////////////////
|
||||
var logService: ng.ILogService;
|
||||
var logCall: ng.ILogCall;
|
||||
var logs: string[];
|
||||
|
||||
logService.assertEmpty();
|
||||
logService.reset();
|
||||
|
||||
logCall = logService.debug;
|
||||
logCall = logService.error;
|
||||
logCall = logService.info;
|
||||
logCall = logService.log;
|
||||
logCall = logService.warn;
|
||||
|
||||
logs = logCall.logs;
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IHttpBackendService
|
||||
///////////////////////////////////////
|
||||
var httpBackendService: ng.IHttpBackendService;
|
||||
var requestHandler: ng.mock.IRequestHandler;
|
||||
|
||||
httpBackendService.flush();
|
||||
httpBackendService.flush(1234);
|
||||
httpBackendService.resetExpectations();
|
||||
httpBackendService.verifyNoOutstandingExpectation();
|
||||
httpBackendService.verifyNoOutstandingRequest();
|
||||
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local');
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/);
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
|
||||
requestHandler = httpBackendService.expectDELETE('http://test.local');
|
||||
requestHandler = httpBackendService.expectDELETE('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectDELETE(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectGET('http://test.local');
|
||||
requestHandler = httpBackendService.expectGET('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectGET(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectHEAD('http://test.local');
|
||||
requestHandler = httpBackendService.expectHEAD('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectHEAD(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectJSONP('http://test.local');
|
||||
requestHandler = httpBackendService.expectJSONP(/test.local/);
|
||||
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local');
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/);
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local');
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/);
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local');
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/);
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local');
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/);
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, 'response data');
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, /response data/);
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
|
||||
requestHandler = httpBackendService.whenDELETE('http://test.local');
|
||||
requestHandler = httpBackendService.whenDELETE('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenDELETE(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenGET('http://test.local');
|
||||
requestHandler = httpBackendService.whenGET('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenGET(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenHEAD('http://test.local');
|
||||
requestHandler = httpBackendService.whenHEAD('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenHEAD(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenJSONP('http://test.local');
|
||||
requestHandler = httpBackendService.whenJSONP(/test.local/);
|
||||
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local');
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/);
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local');
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/);
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local');
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/);
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IRequestHandler
|
||||
///////////////////////////////////////
|
||||
requestHandler.passThrough();
|
||||
requestHandler.respond(function () { });
|
||||
requestHandler.respond({ key: 'value' });
|
||||
requestHandler.respond({ key: 'value' }, { header: 'value' });
|
||||
requestHandler.respond(404);
|
||||
requestHandler.respond(404, { key: 'value' });
|
||||
requestHandler.respond(404, { key: 'value' }, { header: 'value' });
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="angular-1.2.d.ts" />
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// functions attached to global object (window)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare var module: (...modules: any[]) => any;
|
||||
declare var inject: (...fns: Function[]) => any;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngMock module (angular-mocks.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare module ng {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularStatic
|
||||
// We reopen it to add the MockStatic definition
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAngularStatic {
|
||||
mock: IMockStatic;
|
||||
}
|
||||
|
||||
interface IMockStatic {
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.dump
|
||||
dump(obj: any): string;
|
||||
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.inject
|
||||
inject(...fns: Function[]): any;
|
||||
inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works
|
||||
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.module
|
||||
module(...modules: any[]): any;
|
||||
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/type/angular.mock.TzDate
|
||||
TzDate(offset: number, timestamp: number): Date;
|
||||
TzDate(offset: number, timestamp: string): Date;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ExceptionHandlerService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$exceptionHandler
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/provider/$exceptionHandlerProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IExceptionHandlerProvider extends IServiceProvider {
|
||||
mode(mode: string): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// TimeoutService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$timeout
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ITimeoutService {
|
||||
flush(delay?: number): void;
|
||||
flushNext(expectedDelay?: number): void;
|
||||
verifyNoPendingTasks(): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IntervalService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$interval
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IIntervalService {
|
||||
flush(millis?: number): number;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// LogService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$log
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ILogService {
|
||||
assertEmpty(): void;
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
interface ILogCall {
|
||||
logs: string[];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// HttpBackendService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$httpBackend
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IHttpBackendService {
|
||||
flush(count?: number): void;
|
||||
resetExpectations(): void;
|
||||
verifyNoOutstandingExpectation(): void;
|
||||
verifyNoOutstandingRequest(): void;
|
||||
|
||||
expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
|
||||
expectDELETE(url: string, headers?: Object): mock.IRequestHandler;
|
||||
expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectGET(url: string, headers?: Object): mock.IRequestHandler;
|
||||
expectGET(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectHEAD(url: string, headers?: Object): mock.IRequestHandler;
|
||||
expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectJSONP(url: string): mock.IRequestHandler;
|
||||
expectJSONP(url: RegExp): mock.IRequestHandler;
|
||||
|
||||
expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
|
||||
expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
|
||||
expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
|
||||
when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
|
||||
whenDELETE(url: string, headers?: Object): mock.IRequestHandler;
|
||||
whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
|
||||
whenGET(url: string, headers?: Object): mock.IRequestHandler;
|
||||
whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
whenGET(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
|
||||
whenHEAD(url: string, headers?: Object): mock.IRequestHandler;
|
||||
whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
|
||||
whenJSONP(url: string): mock.IRequestHandler;
|
||||
whenJSONP(url: RegExp): mock.IRequestHandler;
|
||||
|
||||
whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
|
||||
whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
|
||||
whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
}
|
||||
|
||||
export module mock {
|
||||
|
||||
// returned interface by the the mocked HttpBackendService expect/when methods
|
||||
interface IRequestHandler {
|
||||
respond(func: Function): void;
|
||||
respond(status: number, data?: any, headers?: any): void;
|
||||
respond(data: any, headers?: any): void;
|
||||
|
||||
// Available wehn ngMockE2E is loaded
|
||||
passThrough(): void;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/// <reference path="angular-resource-1.2.d.ts" />
|
||||
|
||||
interface IMyResource extends ng.resource.IResource<IMyResource> { };
|
||||
interface IMyResourceClass extends ng.resource.IResourceClass<IMyResource> { };
|
||||
|
||||
///////////////////////////////////////
|
||||
// IActionDescriptor
|
||||
///////////////////////////////////////
|
||||
var actionDescriptor: ng.resource.IActionDescriptor;
|
||||
|
||||
actionDescriptor.headers = { header: 'value' };
|
||||
actionDescriptor.isArray = true;
|
||||
actionDescriptor.method = 'method action';
|
||||
actionDescriptor.params = { key: 'value' };
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResourceClass
|
||||
///////////////////////////////////////
|
||||
var resourceClass: IMyResourceClass;
|
||||
var resource: IMyResource;
|
||||
var resourceArray: ng.resource.IResourceArray<IMyResource>;
|
||||
|
||||
resource = resourceClass.delete();
|
||||
resource = resourceClass.delete({ key: 'value' });
|
||||
resource = resourceClass.delete({ key: 'value' }, function () { });
|
||||
resource = resourceClass.delete(function () { });
|
||||
resource = resourceClass.delete(function () { }, function () { });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
resource.$promise.then(function(data: IMyResource) {});
|
||||
|
||||
resource = resourceClass.get();
|
||||
resource = resourceClass.get({ key: 'value' });
|
||||
resource = resourceClass.get({ key: 'value' }, function () { });
|
||||
resource = resourceClass.get(function () { });
|
||||
resource = resourceClass.get(function () { }, function () { });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
|
||||
resourceArray = resourceClass.query();
|
||||
resourceArray = resourceClass.query({ key: 'value' });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, function () { });
|
||||
resourceArray = resourceClass.query(function () { });
|
||||
resourceArray = resourceClass.query(function () { }, function () { });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
resourceArray.push(resource);
|
||||
resourceArray.$promise.then(function(data: ng.resource.IResourceArray<IMyResource>) {});
|
||||
|
||||
resource = resourceClass.remove();
|
||||
resource = resourceClass.remove({ key: 'value' });
|
||||
resource = resourceClass.remove({ key: 'value' }, function () { });
|
||||
resource = resourceClass.remove(function () { });
|
||||
resource = resourceClass.remove(function () { }, function () { });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
|
||||
resource = resourceClass.save();
|
||||
resource = resourceClass.save({ key: 'value' });
|
||||
resource = resourceClass.save({ key: 'value' }, function () { });
|
||||
resource = resourceClass.save(function () { });
|
||||
resource = resourceClass.save(function () { }, function () { });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResource
|
||||
///////////////////////////////////////
|
||||
|
||||
var promise : ng.IPromise<IMyResource>;
|
||||
var arrayPromise : ng.IPromise<IMyResource[]>;
|
||||
|
||||
promise = resource.$delete();
|
||||
promise = resource.$delete({ key: 'value' });
|
||||
promise = resource.$delete({ key: 'value' }, function () { });
|
||||
promise = resource.$delete(function () { });
|
||||
promise = resource.$delete(function () { }, function () { });
|
||||
promise = resource.$delete({ key: 'value' }, function () { }, function () { });
|
||||
promise.then(function(data: IMyResource) {});
|
||||
|
||||
promise = resource.$get();
|
||||
promise = resource.$get({ key: 'value' });
|
||||
promise = resource.$get({ key: 'value' }, function () { });
|
||||
promise = resource.$get(function () { });
|
||||
promise = resource.$get(function () { }, function () { });
|
||||
promise = resource.$get({ key: 'value' }, function () { }, function () { });
|
||||
|
||||
arrayPromise = resourceArray[0].$query();
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' });
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { });
|
||||
arrayPromise = resourceArray[0].$query(function () { });
|
||||
arrayPromise = resourceArray[0].$query(function () { }, function () { });
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }, function () { });
|
||||
arrayPromise.then(function(data: ng.resource.IResourceArray<IMyResource>) {});
|
||||
|
||||
promise = resource.$remove();
|
||||
promise = resource.$remove({ key: 'value' });
|
||||
promise = resource.$remove({ key: 'value' }, function () { });
|
||||
promise = resource.$remove(function () { });
|
||||
promise = resource.$remove(function () { }, function () { });
|
||||
promise = resource.$remove({ key: 'value' }, function () { }, function () { });
|
||||
|
||||
promise = resource.$save();
|
||||
promise = resource.$save({ key: 'value' });
|
||||
promise = resource.$save({ key: 'value' }, function () { });
|
||||
promise = resource.$save(function () { });
|
||||
promise = resource.$save(function () { }, function () { });
|
||||
promise = resource.$save({ key: 'value' }, function () { }, function () { });
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResourceService
|
||||
///////////////////////////////////////
|
||||
var resourceService: ng.resource.IResourceService;
|
||||
resourceClass = resourceService<IMyResource, IMyResourceClass>('test');
|
||||
resourceClass = resourceService<IMyResource>('test');
|
||||
resourceClass = resourceService('test');
|
||||
|
||||
///////////////////////////////////////
|
||||
// IModule
|
||||
///////////////////////////////////////
|
||||
var mod: ng.IModule;
|
||||
var resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction<IMyResource>;
|
||||
var resourceService: ng.resource.IResourceService;
|
||||
|
||||
resourceClass = resourceServiceFactoryFunction<IMyResourceClass>(resourceService);
|
||||
|
||||
resourceServiceFactoryFunction = function (resourceService: ng.resource.IResourceService) { return <any>resourceClass; };
|
||||
mod = mod.factory('factory name', resourceServiceFactoryFunction);
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResource
|
||||
///////////////////////////////////////
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
// Type definitions for Angular JS 1.2 (ngResource module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels>
|
||||
// Definitions: https://github.com/daptiv/DefinitelyTyped
|
||||
|
||||
/// <reference path="angular-1.2.d.ts" />
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngResource module (angular-resource.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare module ng.resource {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ResourceService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngResource/service/$resource
|
||||
// Most of the following definitions were achieved by analyzing the
|
||||
// actual implementation, since the documentation doesn't seem to cover
|
||||
// that deeply.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IResourceService {
|
||||
(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actionDescriptors?: any): IResourceClass<IResource<any>>;
|
||||
<T, U>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actionDescriptors?: any): U;
|
||||
<T>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actionDescriptors?: any): IResourceClass<T>;
|
||||
}
|
||||
|
||||
// Just a reference to facilitate describing new actions
|
||||
interface IActionDescriptor {
|
||||
method: string;
|
||||
isArray?: boolean;
|
||||
params?: any;
|
||||
headers?: any;
|
||||
}
|
||||
|
||||
// Baseclass for everyresource with default actions.
|
||||
// If you define your new actions for the resource, you will need
|
||||
// to extend this interface and typecast the ResourceClass to it.
|
||||
//
|
||||
// In case of passing the first argument as anything but a function,
|
||||
// it's gonna be considered data if the action method is POST, PUT or
|
||||
// PATCH (in other words, methods with body). Otherwise, it's going
|
||||
// to be considered as parameters to the request.
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465
|
||||
//
|
||||
// Only those methods with an HTTP body do have 'data' as first parameter:
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463
|
||||
// More specifically, those methods are POST, PUT and PATCH:
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432
|
||||
//
|
||||
// Also, static calls always return the IResource (or IResourceArray) retrieved
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549
|
||||
interface IResourceClass<T> {
|
||||
new(dataOrParams? : any) : T;
|
||||
get(): T;
|
||||
get(params: Object): T;
|
||||
get(success: Function, error?: Function): T;
|
||||
get(params: Object, success: Function, error?: Function): T;
|
||||
get(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
|
||||
query(): IResourceArray<T>;
|
||||
query(params: Object): IResourceArray<T>;
|
||||
query(success: Function, error?: Function): IResourceArray<T>;
|
||||
query(params: Object, success: Function, error?: Function): IResourceArray<T>;
|
||||
query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray<T>;
|
||||
|
||||
save(): T;
|
||||
save(data: Object): T;
|
||||
save(success: Function, error?: Function): T;
|
||||
save(data: Object, success: Function, error?: Function): T;
|
||||
save(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
|
||||
remove(): T;
|
||||
remove(params: Object): T;
|
||||
remove(success: Function, error?: Function): T;
|
||||
remove(params: Object, success: Function, error?: Function): T;
|
||||
remove(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
|
||||
delete(): T;
|
||||
delete(params: Object): T;
|
||||
delete(success: Function, error?: Function): T;
|
||||
delete(params: Object, success: Function, error?: Function): T;
|
||||
delete(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
}
|
||||
|
||||
// Instance calls always return the the promise of the request which retrieved the object
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546
|
||||
interface IResource<T> {
|
||||
$get(): ng.IPromise<T>;
|
||||
$get(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
|
||||
$get(success: Function, error?: Function): ng.IPromise<T>;
|
||||
|
||||
$query(): ng.IPromise<IResourceArray<T>>;
|
||||
$query(params?: Object, success?: Function, error?: Function): ng.IPromise<IResourceArray<T>>;
|
||||
$query(success: Function, error?: Function): ng.IPromise<IResourceArray<T>>;
|
||||
|
||||
$save(): ng.IPromise<T>;
|
||||
$save(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
|
||||
$save(success: Function, error?: Function): ng.IPromise<T>;
|
||||
|
||||
$remove(): ng.IPromise<T>;
|
||||
$remove(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
|
||||
$remove(success: Function, error?: Function): ng.IPromise<T>;
|
||||
|
||||
$delete(): ng.IPromise<T>;
|
||||
$delete(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
|
||||
$delete(success: Function, error?: Function): ng.IPromise<T>;
|
||||
|
||||
/** the promise of the original server interaction that created this instance. **/
|
||||
$promise : ng.IPromise<T>;
|
||||
$resolved : boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Really just a regular Array object with $promise and $resolve attached to it
|
||||
*/
|
||||
interface IResourceArray<T> extends Array<T> {
|
||||
/** the promise of the original server interaction that created this collection. **/
|
||||
$promise : ng.IPromise<IResourceArray<T>>;
|
||||
$resolved : boolean;
|
||||
}
|
||||
|
||||
/** when creating a resource factory via IModule.factory */
|
||||
interface IResourceServiceFactoryFunction<T> {
|
||||
($resource: ng.resource.IResourceService): IResourceClass<T>;
|
||||
<U extends IResourceClass<T>>($resource: ng.resource.IResourceService): U;
|
||||
}
|
||||
}
|
||||
|
||||
/** extensions to base ng based on using angular-resource */
|
||||
declare module ng {
|
||||
|
||||
interface IModule {
|
||||
/** creating a resource service factory */
|
||||
factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction<any>): IModule;
|
||||
}
|
||||
}
|
||||
|
||||
interface Array<T>
|
||||
{
|
||||
/** the promise of the original server interaction that created this collection. **/
|
||||
$promise : ng.IPromise<Array<T>>;
|
||||
$resolved : boolean;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path="angular-route-1.2.d.ts" />
|
||||
|
||||
/**
|
||||
* @license HTTP Auth Interceptor Module for AngularJS
|
||||
* (c) 2013 Jonathan Park @ Daptiv Solutions Inc
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
declare var $routeProvider: ng.route.IRouteProvider;
|
||||
$routeProvider
|
||||
.when('/projects/:projectId/dashboard',{
|
||||
controller: '',
|
||||
templateUrl: '',
|
||||
caseInsensitiveMatch: true,
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.otherwise({redirectTo: '/'});
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
// Type definitions for Angular JS 1.2 (ngRoute module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Jonathan Park <https://github.com/park9140>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="angular-1.2.d.ts" />
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngRoute module (angular-route.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare module ng.route {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RouteParamsService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$routeParams
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRouteParamsService {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RouteService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$route
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/provider/$routeProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRouteService {
|
||||
/**
|
||||
* Causes $route service to reload the current route even if $location hasn't changed.
|
||||
* As a result of that, ngView creates new scope, reinstantiates the controller.
|
||||
*/
|
||||
reload(): void;
|
||||
|
||||
/**
|
||||
* Object with all route configuration Objects as its properties.
|
||||
*/
|
||||
routes: any;
|
||||
|
||||
// May not always be available. For instance, current will not be available
|
||||
// to a controller that was not initialized as a result of a route maching.
|
||||
current?: ICurrentRoute;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* see https://code.angularjs.org/1.2.26/docs/api/ngRoute/provider/$routeProvider#when for API documentation
|
||||
*/
|
||||
interface IRoute {
|
||||
/**
|
||||
* {(string|function()=}
|
||||
* Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string.
|
||||
*/
|
||||
controller?: any;
|
||||
/**
|
||||
* A controller alias name. If present the controller will be published to scope under the controllerAs name.
|
||||
*/
|
||||
controllerAs?: string;
|
||||
/**
|
||||
* Undocumented?
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* {string=|function()=}
|
||||
* Html template as a string or a function that returns an html template as a string which should be used by ngView or ngInclude directives. This property takes precedence over templateUrl.
|
||||
*
|
||||
* If template is a function, it will be called with the following parameters:
|
||||
*
|
||||
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
|
||||
*/
|
||||
template?: string;
|
||||
/**
|
||||
* {string=|function()=}
|
||||
* Path or function that returns a path to an html template that should be used by ngView.
|
||||
*
|
||||
* If templateUrl is a function, it will be called with the following parameters:
|
||||
*
|
||||
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
|
||||
*/
|
||||
templateUrl?: any;
|
||||
/**
|
||||
* {Object.<string, function>=} - An optional map of dependencies which should be injected into the controller. If any of these dependencies are promises, the router will wait for them all to be resolved or one to be rejected before the controller is instantiated. If all the promises are resolved successfully, the values of the resolved promises are injected and $routeChangeSuccess event is fired. If any of the promises are rejected the $routeChangeError event is fired. The map object is:
|
||||
*
|
||||
* - key - {string}: a name of a dependency to be injected into the controller.
|
||||
* - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead.
|
||||
*/
|
||||
resolve?: {[key: string]: any};
|
||||
/**
|
||||
* {(string|function())=}
|
||||
* Value to update $location path with and trigger route redirection.
|
||||
*
|
||||
* If redirectTo is a function, it will be called with the following parameters:
|
||||
*
|
||||
* - {Object.<string>} - route parameters extracted from the current $location.path() by applying the current route templateUrl.
|
||||
* - {string} - current $location.path()
|
||||
* - {Object} - current $location.search()
|
||||
* - The custom redirectTo function is expected to return a string which will be used to update $location.path() and $location.search().
|
||||
*/
|
||||
redirectTo?: any;
|
||||
/**
|
||||
* Reload route when only $location.search() or $location.hash() changes.
|
||||
*
|
||||
* This option defaults to true. If the option is set to false and url in the browser changes, then $routeUpdate event is broadcasted on the root scope.
|
||||
*/
|
||||
reloadOnSearch?: boolean;
|
||||
/**
|
||||
* Match routes without being case sensitive
|
||||
*
|
||||
* This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive
|
||||
*/
|
||||
caseInsensitiveMatch?: boolean;
|
||||
}
|
||||
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$route#current
|
||||
interface ICurrentRoute extends IRoute {
|
||||
locals: {
|
||||
$scope: IScope;
|
||||
$template: string;
|
||||
};
|
||||
|
||||
params: any;
|
||||
}
|
||||
|
||||
interface IRouteProvider extends IServiceProvider {
|
||||
/**
|
||||
* Sets route definition that will be used on route change when no other route definition is matched.
|
||||
*
|
||||
* @params Mapping information to be assigned to $route.current.
|
||||
*/
|
||||
otherwise(params: IRoute): IRouteProvider;
|
||||
/**
|
||||
* Adds a new route definition to the $route service.
|
||||
*
|
||||
* @param path Route path (matched against $location.path). If $location.path contains redundant trailing slash or is missing one, the route will still match and the $location.path will be updated to add or drop the trailing slash to exactly match the route definition.
|
||||
*
|
||||
* - path can contain named groups starting with a colon: e.g. :name. All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches.
|
||||
* - path can contain named groups starting with a colon and ending with a star: e.g.:name*. All characters are eagerly stored in $routeParams under the given name when the route matches.
|
||||
* - path can contain optional named groups with a question mark: e.g.:name?.
|
||||
*
|
||||
* For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode/code/with/slashes/edit and extract: color: brown and largecode: code/with/slashes.
|
||||
*
|
||||
* @param route Mapping information to be assigned to $route.current on route match.
|
||||
*/
|
||||
when(path: string, route: IRoute): IRouteProvider;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path="angular-sanitize-1.2.d.ts" />
|
||||
|
||||
var shouldBeString: string;
|
||||
|
||||
declare var $sanitizeService: ng.sanitize.ISanitizeService;
|
||||
shouldBeString = $sanitizeService(shouldBeString);
|
||||
|
||||
declare var $linky: ng.sanitize.filter.ILinky;
|
||||
shouldBeString = $linky(shouldBeString);
|
||||
shouldBeString = $linky(shouldBeString, shouldBeString);
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for Angular JS 1.2 (ngSanitize module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
/// <reference path="angular-1.2.d.ts" />
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngSanitize module (angular-sanitize.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare module ng.sanitize {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// SanitizeService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/service/$sanitize
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ISanitizeService {
|
||||
(html: string): string;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Filters included with the ngSanitize
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/filter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
export module filter {
|
||||
|
||||
// Finds links in text input and turns them into html links.
|
||||
// Supports http/https/ftp/mailto and plain email address links.
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/filter/linky
|
||||
interface ILinky {
|
||||
(text: string, target?: string): string;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular Scenario Testing
|
||||
// Type definitions for Angular Scenario Testing 1.0 (ngScenario module)
|
||||
// Project: [http://angularjs.org]
|
||||
// Definitions by: [RomanoLindano]
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
// Type definitions for Angular Scenario Testing 1.2 (ngScenario module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: RomanoLindano <https://github.com/RomanoLindano>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../../jquery/jquery.d.ts" />
|
||||
|
||||
declare module ng {
|
||||
export interface IAngularStatic {
|
||||
scenario: any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module angularScenario {
|
||||
|
||||
export interface RunFunction {
|
||||
(functionToRun: any): any;
|
||||
}
|
||||
export interface RunFunctionWithDescription {
|
||||
(description: string, functionToRun: any): any;
|
||||
}
|
||||
|
||||
export interface PauseFunction {
|
||||
(): any;
|
||||
}
|
||||
|
||||
export interface SleepFunction {
|
||||
(seconds: number): any;
|
||||
}
|
||||
|
||||
export interface Future {
|
||||
}
|
||||
|
||||
export interface testWindow {
|
||||
href(): Future;
|
||||
path(): Future;
|
||||
search(): Future;
|
||||
hash(): Future;
|
||||
}
|
||||
|
||||
export interface testLocation {
|
||||
url(): Future;
|
||||
path(): Future;
|
||||
search(): Future;
|
||||
hash(): Future;
|
||||
}
|
||||
|
||||
export interface Browser {
|
||||
navigateTo(url: string): void;
|
||||
navigateTo(urlDescription: string, urlFunction: () => string): void;
|
||||
reload(): void;
|
||||
window(): testWindow;
|
||||
location(): testLocation;
|
||||
}
|
||||
|
||||
export interface Matchers {
|
||||
toEqual(value: any): void;
|
||||
toBe(value: any): void;
|
||||
toBeDefined(): void;
|
||||
toBeTruthy(): void;
|
||||
toBeFalsy(): void;
|
||||
toMatch(regularExpression: any): void;
|
||||
toBeNull(): void;
|
||||
toContain(value: any): void;
|
||||
toBeLessThan(value: any): void;
|
||||
toBeGreaterThan(value: any): void;
|
||||
}
|
||||
|
||||
export interface CustomMatchers extends Matchers {
|
||||
}
|
||||
|
||||
export interface Expect extends CustomMatchers {
|
||||
not(): angularScenario.CustomMatchers;
|
||||
}
|
||||
|
||||
export interface UsingFunction {
|
||||
(selector: string, selectorDescription?: string): void;
|
||||
}
|
||||
|
||||
export interface BindingFunction {
|
||||
(bracketBindingExpression: string): Future;
|
||||
}
|
||||
|
||||
export interface Input {
|
||||
enter(value: any): any;
|
||||
check(): any;
|
||||
select(radioButtonValue: any): any;
|
||||
val(): Future;
|
||||
}
|
||||
|
||||
export interface Repeater {
|
||||
count(): Future;
|
||||
row(index: number): Future;
|
||||
column(ngBindingExpression: string): Future;
|
||||
}
|
||||
|
||||
export interface Select {
|
||||
option(value: any): any;
|
||||
option(...listOfValues: any[]): any;
|
||||
}
|
||||
|
||||
export interface Element {
|
||||
count(): Future;
|
||||
click(): any;
|
||||
dblclick(): any;
|
||||
mouseover(): any;
|
||||
mousedown(): any;
|
||||
mouseup(): any;
|
||||
query(callback: (selectedDOMElements: JQuery, callbackWhenDone: (objNull: any, futureValue: any) => any) => any): any;
|
||||
val(): Future;
|
||||
text(): Future;
|
||||
html(): Future;
|
||||
height(): Future;
|
||||
innerHeight(): Future;
|
||||
outerHeight(): Future;
|
||||
width(): Future;
|
||||
innerWidth(): Future;
|
||||
outerWidth(): Future;
|
||||
position(): Future;
|
||||
scrollLeft(): Future;
|
||||
scrollTop(): Future;
|
||||
offset(): Future;
|
||||
|
||||
val(value: any): void;
|
||||
text(value: any): void;
|
||||
html(value: any): void;
|
||||
height(value: any): void;
|
||||
innerHeight(value: any): void;
|
||||
outerHeight(value: any): void;
|
||||
width(value: any): void;
|
||||
innerWidth(value: any): void;
|
||||
outerWidth(value: any): void;
|
||||
position(value: any): void;
|
||||
scrollLeft(value: any): void;
|
||||
scrollTop(value: any): void;
|
||||
offset(value: any): void;
|
||||
|
||||
attr(key: any): Future;
|
||||
prop(key: any): Future;
|
||||
css(key: any): Future;
|
||||
|
||||
attr(key: any, value: any): void;
|
||||
prop(key: any, value: any): void;
|
||||
css(key: any, value: any): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare var describe: angularScenario.RunFunctionWithDescription;
|
||||
declare var ddescribe: angularScenario.RunFunctionWithDescription;
|
||||
declare var xdescribe: angularScenario.RunFunctionWithDescription;
|
||||
declare var beforeEach: angularScenario.RunFunction;
|
||||
declare var afterEach: angularScenario.RunFunction;
|
||||
declare var it: angularScenario.RunFunctionWithDescription;
|
||||
declare var iit: angularScenario.RunFunctionWithDescription;
|
||||
declare var xit: angularScenario.RunFunctionWithDescription;
|
||||
declare var pause: angularScenario.PauseFunction;
|
||||
declare var sleep: angularScenario.SleepFunction;
|
||||
declare function browser(): angularScenario.Browser;
|
||||
declare function expect(expectation: angularScenario.Future): angularScenario.Expect;
|
||||
declare var using: angularScenario.UsingFunction;
|
||||
declare var binding: angularScenario.BindingFunction;
|
||||
declare function input(ngModelBinding: string): angularScenario.Input;
|
||||
declare function repeater(selector: string, repeaterDescription?: string): angularScenario.Repeater;
|
||||
declare function select(ngModelBinding: string): angularScenario.Select;
|
||||
declare function element(selector: string, elementDescription?: string): angularScenario.Element;
|
||||
declare var angular: ng.IAngularStatic;
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
/// <reference path="../any-db/any-db.d.ts" />
|
||||
/// <reference path="any-db-transaction.d.ts" />
|
||||
|
||||
"use strict";
|
||||
|
||||
import anyDB = require("any-db");
|
||||
import begin = require("any-db-transaction");
|
||||
|
||||
var conn: anyDB.Connection = anyDB.createConnection("mysql://user:password@localhost/testdb");
|
||||
|
||||
|
||||
var transaction = begin(conn);
|
||||
var transaction2 = begin(transaction);
|
||||
|
||||
begin(conn, { autoRollback: true });
|
||||
begin(conn, (error: Error, result: begin.Transaction): void => {
|
||||
});
|
||||
|
||||
transaction.query("SELECT * FROM MyTable");
|
||||
|
||||
transaction.commit();
|
||||
transaction.commit((error: Error): void => {
|
||||
});
|
||||
|
||||
transaction.rollback();
|
||||
transaction.rollback((error: Error): void => {
|
||||
});
|
||||
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
// Type definitions for any-db-transaction 2.2.1
|
||||
// Project: https://github.com/grncdr/node-any-db-transaction
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../any-db/any-db.d.ts" />
|
||||
|
||||
declare module "any-db-transaction" {
|
||||
import anyDB = require("any-db");
|
||||
|
||||
module begin {
|
||||
/**
|
||||
* Transaction objects are are simple wrappers around a Connection that also implement the Queryable API,
|
||||
* but guarantee that all queries take place within a single database transaction or not at all. Note that
|
||||
* begin also understands how to acquire (and release) a connection from a ConnectionPool as well, so you
|
||||
* can simply pass a pool to it: var tx = begin(pool)
|
||||
*
|
||||
* By default, any queries that error during a transaction will cause an automatic rollback. If a query has
|
||||
* no callback, the transaction will also handle (and re-emit) 'error' events for the Query instance.
|
||||
* This enables handling errors for an entire transaction in a single place.
|
||||
*
|
||||
* Transactions may also be nested by passing a Transaction to begin and these nested transactions can
|
||||
* safely error and rollback without rolling back their parent transaction
|
||||
*
|
||||
* Transaction events:
|
||||
* 'query', query - emitted immediately after .query is called on a connection via tx.query. The argument is a query object.
|
||||
* 'commit:start' - Emitted when .commit() is called.
|
||||
* 'commit:complete' - Emitted after the transaction has committed.
|
||||
* 'rollback:start' - Emitted when .rollback() is called.
|
||||
* 'rollback:complete' - Emitted after the transaction has rolled back.
|
||||
* 'close' - Emitted after rollback or commit completes.
|
||||
* 'error', err - Emitted under three conditions:
|
||||
* There was an error acquiring a connection.
|
||||
* Any query performed in this transaction emits an error that would otherwise go unhandled.
|
||||
* Any of query, begin, commit, or rollback are called after the connection has already been committed or rolled back.
|
||||
* Note that the 'error' event may be emitted multiple times! depending on the callback you are registering, you way want to wrap it using [once][].
|
||||
*/
|
||||
interface Transaction extends anyDB.Queryable {
|
||||
|
||||
/**
|
||||
* Issue a COMMIT (or RELEASE ... in the case of nested transactions) statement to the database.
|
||||
* If a continuation is provided it will be called (possibly with an error) after the COMMIT
|
||||
* statement completes. The transaction object itself will be unusable after calling commit().
|
||||
*/
|
||||
commit(callback?: (error: Error) => void): void;
|
||||
|
||||
/**
|
||||
* The same as Transaction.commit but issues a ROLLBACK. Again, the transaction will be unusable after calling this method.
|
||||
*/
|
||||
rollback(callback?: (error: Error) => void): void;
|
||||
}
|
||||
|
||||
interface TransactionOptions {
|
||||
/**
|
||||
* Adapter name e.g. 'mysql'
|
||||
*/
|
||||
adapter?: anyDB.Adapter;
|
||||
/**
|
||||
* SQL statement for beginning a transaction, default 'BEGIN'
|
||||
*/
|
||||
begin?: string;
|
||||
/**
|
||||
* SQL statement for committing a transaction, default 'COMMIT'
|
||||
*/
|
||||
commit?: string;
|
||||
/**
|
||||
* SQL statement for rolling back a transaction, default 'ROLLBACK'
|
||||
*/
|
||||
rollback?: string;
|
||||
/**
|
||||
* Callback for transaction
|
||||
*/
|
||||
callback?: (error: Error, transaction: Transaction) => void;
|
||||
/**
|
||||
* Rollback automatically on error, default true
|
||||
*/
|
||||
autoRollback?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a transaction
|
||||
*/
|
||||
function begin(q: anyDB.Queryable, options?: begin.TransactionOptions, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
|
||||
function begin(q: anyDB.Queryable, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
|
||||
function begin(q: anyDB.Queryable, beginStatement?: string, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
|
||||
function begin(q: anyDB.Queryable, options?: begin.TransactionOptions, beginStatement?: string, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
|
||||
|
||||
export = begin;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
/// <reference path="any-db.d.ts" />
|
||||
|
||||
"use strict";
|
||||
|
||||
import anyDB = require("any-db");
|
||||
|
||||
var conn: anyDB.Connection = anyDB.createConnection("mysql://user:password@localhost/testdb");
|
||||
var sql: string = "SELECT * FROM questions";
|
||||
|
||||
conn.query(sql, [1, "boo"]);
|
||||
|
||||
conn.query(sql).on("data", (row: Object[]): void => {
|
||||
// nothing
|
||||
});
|
||||
|
||||
conn.query(sql, [1, "s"], (error: Error, result: anyDB.ResultSet): void => {
|
||||
result.rows.length;
|
||||
result.fields.length;
|
||||
});
|
||||
|
||||
conn.end();
|
||||
|
||||
|
||||
var poolConfig: anyDB.PoolConfig = {
|
||||
min: 1,
|
||||
max: 200
|
||||
};
|
||||
|
||||
var pool: anyDB.ConnectionPool = anyDB.createPool("mysql://user:password@localhost/testdb", poolConfig);
|
||||
|
||||
pool.query(sql).on("data", (row: Object[]): void => {
|
||||
// nothing
|
||||
});
|
||||
|
||||
pool.close((error: Error): void => {
|
||||
});
|
||||
|
||||
Vendored
+303
@@ -0,0 +1,303 @@
|
||||
// Type definitions for any-db 2.1.0
|
||||
// Project: https://github.com/grncdr/node-any-db
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "any-db" {
|
||||
import events = require("events");
|
||||
import stream = require("stream");
|
||||
|
||||
export interface ConnectOpts {
|
||||
adapter: string;
|
||||
}
|
||||
|
||||
export interface Adapter {
|
||||
name: string;
|
||||
/**
|
||||
* Create a new connection object. In common usage, config will be created by parse-db-url and passed to the adapter by any-db.
|
||||
* If a continuation is given, it must be called, either with an error or the established connection.
|
||||
*/
|
||||
createConnection(opts: ConnectOpts, callback?: (error: Error, result: Connection) => void): Connection;
|
||||
|
||||
/**
|
||||
* Create a Query that may eventually be executed later on by a Connection. While this function is rarely needed by user code,
|
||||
* it makes it possible for ConnectionPool.query and Transaction.query to fulfill the Queryable.query contract
|
||||
* by synchronously returning a Query stream
|
||||
*/
|
||||
createQuery(text: string, params?: any[], callback?: (error: Error, result: ResultSet) => void): Query;
|
||||
createQuery(query: Query): Query;
|
||||
}
|
||||
/**
|
||||
* Other properties are driver specific
|
||||
*/
|
||||
export interface Field {
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* ResultSet objects are just plain data that collect results of a query when a continuation
|
||||
* is provided to Queryable.query. The lastInsertId is optional, and currently supported by
|
||||
* sqlite3 and mysql but not postgres, because it is not supported by Postgres itself.
|
||||
*/
|
||||
export interface ResultSet {
|
||||
/**
|
||||
* Affected rows. Note e.g. for INSERT queries the rows property is not filled even
|
||||
* though rowCount is non-zero.
|
||||
*/
|
||||
rowCount: number;
|
||||
/**
|
||||
* Result rows
|
||||
*/
|
||||
rows: Object[];
|
||||
/**
|
||||
* Result field descriptions
|
||||
*/
|
||||
fields: Field[];
|
||||
|
||||
/**
|
||||
* Not supported by all drivers.
|
||||
*/
|
||||
fieldCount?: number;
|
||||
/**
|
||||
* Not supported by all drivers.
|
||||
*/
|
||||
lastInsertId?: any;
|
||||
/**
|
||||
* Not supported by all drivers.
|
||||
*/
|
||||
affectedRows?: number;
|
||||
/**
|
||||
* Not supported by all drivers.
|
||||
*/
|
||||
changedRows?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query objects are returned by the Queryable.query method, available on connections,
|
||||
* pools, and transactions. Queries are instances of Readable, and as such can be piped
|
||||
* through transforms and support backpressure for more efficient memory-usage on very
|
||||
* large results sets. (Note: at this time the sqlite3 driver does not support backpressure)
|
||||
*
|
||||
* Internally, Query instances are created by a database Adapter and may have more methods,
|
||||
* properties, and events than are described here. Consult the documentation for your
|
||||
* specific adapter to find out about any extensions.
|
||||
*
|
||||
* Events:
|
||||
*
|
||||
* Error event
|
||||
* The 'error' event is emitted at most once per query. Note that this event will be
|
||||
* emitted for errors even if a callback was provided, the callback will
|
||||
* simply be subscribed to the 'error' event.
|
||||
* One argument is passed to event listeners:
|
||||
* error - the error object.
|
||||
*
|
||||
* Fields event
|
||||
* A 'fields' event is emmitted before any 'data' events.
|
||||
* One argument is passed to event listeners:
|
||||
* fields - an array of [Field][ResultSet] objects.
|
||||
*
|
||||
* The following events are part of the stream.Readable interface which is implemented by Query:
|
||||
*
|
||||
* Data event
|
||||
* A 'data' event is emitted for each row in the query result set.
|
||||
* One argument is passed to event listeners:
|
||||
* row contains the contents of a single row in the query result
|
||||
*
|
||||
* Close event
|
||||
* A 'close' event is emitted when the query completes.
|
||||
* No arguments are passed to event listeners.
|
||||
*
|
||||
* End event
|
||||
* An 'end' event is emitted after all query results have been consumed.
|
||||
* No arguments are passed to event listeners.
|
||||
*/
|
||||
export interface Query extends stream.Readable {
|
||||
/**
|
||||
* The SQL query as a string. If you are using MySQL this will contain
|
||||
* interpolated values after the query has been enqueued by a connection.
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The array of parameter values.
|
||||
*/
|
||||
values: any[];
|
||||
|
||||
/**
|
||||
* The callback (if any) that was provided to Queryable.query. Note that
|
||||
* Query objects must not use a closed over reference to their callback,
|
||||
* as other any-db libraries may rely on modifying the callback property
|
||||
* of a Query they did not create.
|
||||
*/
|
||||
callback: (error: Error, results: ResultSet) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Events:
|
||||
* The 'query' event is emitted immediately before a query is executed. One argument is passed to event handlers:
|
||||
* - query: a Query object
|
||||
*/
|
||||
export interface Queryable extends events.EventEmitter {
|
||||
/**
|
||||
* The Adapter instance that will be used by this Queryable for creating Query instances and/or connections.
|
||||
*/
|
||||
adapter: Adapter;
|
||||
|
||||
/**
|
||||
* Execute a SQL statement using bound parameters (if they are provided) and return a Query object
|
||||
* that is a Readable stream of the resulting rows. If a Continuation<ResultSet> is provided the rows
|
||||
* returned by the database will be aggregated into a [ResultSet][] which will be passed to the
|
||||
* continuation after the query has completed.
|
||||
* The second form is not needed for normal use, but must be implemented by adapters to work correctly
|
||||
* with ConnectionPool and Transaction. See Adapter.createQuery for more details.
|
||||
*/
|
||||
query(text: string, params?: any[], callback?: (error: Error, results: ResultSet) => void): Query
|
||||
|
||||
/**
|
||||
* The second form is not needed for normal use, but must be implemented by adapters to work correctly
|
||||
* with ConnectionPool and Transaction. See Adapter.createQuery for more details.
|
||||
*/
|
||||
// query(query: Query): Query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connection objects are obtained using createConnection from Any-DB or ConnectionPool.acquire,
|
||||
* both of which delegate to the createConnection implementation of the specified adapter.
|
||||
* While all Connection objects implement the Queryable interface, the implementations in
|
||||
* each adapter may add additional methods or emit additional events. If you need to access a
|
||||
* feature of your database that is not described here (such as Postgres' server-side prepared
|
||||
* statements), consult the documentation for your adapter.
|
||||
*
|
||||
* Events:
|
||||
* Error event
|
||||
* The 'error' event is emitted when there is a connection-level error.
|
||||
* No arguments are passed to event listeners.
|
||||
*
|
||||
* Open event
|
||||
* The 'open' event is emitted when the connection has been established and is ready to query.
|
||||
* No arguments are passed to event listeners.
|
||||
*
|
||||
* Close event
|
||||
* The 'close' event is emitted when the connection has been closed.
|
||||
* No arguments are passed to event listeners.
|
||||
*/
|
||||
export interface Connection extends Queryable {
|
||||
/**
|
||||
* Close the database connection. If a continuation is provided it
|
||||
* will be called after the connection has closed.
|
||||
*/
|
||||
end(callback?: (error: Error) => void): void;
|
||||
}
|
||||
|
||||
export interface ConnectionStatic {
|
||||
new(): Connection;
|
||||
|
||||
name: string;
|
||||
createConnection(): void;
|
||||
createPool(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* ConnectionPool events
|
||||
* 'acquire' - emitted whenever pool.acquire is called
|
||||
* 'release' - emitted whenever pool.release is called
|
||||
* 'query', query - emitted immediately after .query is called on a
|
||||
* connection via pool.query. The argument is a Query object.
|
||||
* 'close' - emitted when the connection pool has closed all of it
|
||||
* connections after a call to close().
|
||||
*/
|
||||
export interface ConnectionPool extends Queryable {
|
||||
/**
|
||||
* Implements Queryable.query by automatically acquiring a connection
|
||||
* and releasing it when the query completes.
|
||||
*/
|
||||
query(text: string, params?: any[], callback?: (error: Error, results: ResultSet) => void): Query;
|
||||
|
||||
/**
|
||||
* Remove a connection from the pool. If you use this method you must
|
||||
* return the connection back to the pool using ConnectionPool.release
|
||||
*/
|
||||
acquire(callback: (error: Error, result: Connection) => void): void;
|
||||
|
||||
/**
|
||||
* Return a connection to the pool. This should only be called with connections
|
||||
* you've manually acquired. You must not continue to use the connection after releasing it.
|
||||
*/
|
||||
release(connection: Connection): void;
|
||||
|
||||
/**
|
||||
* Stop giving out new connections, and close all existing database connections as they
|
||||
* are returned to the pool.
|
||||
*/
|
||||
close(callback?: (error: Error) => void): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A PoolConfig is generally a plain object with any of the following properties (they are all optional):
|
||||
*/
|
||||
export interface PoolConfig {
|
||||
/**
|
||||
* min (default 0) The minimum number of connections to keep open in the pool.
|
||||
*/
|
||||
min?: number;
|
||||
/**
|
||||
* max (default 10) The maximum number of connections to keep open in the pool.
|
||||
* When this limit is reached further requests for connections will queue waiting
|
||||
* for an existing connection to be released back into the pool.
|
||||
*/
|
||||
max?: number;
|
||||
/**
|
||||
* (default 30000) The maximum amount of time a connection can sit idle in the pool before being reaped
|
||||
*/
|
||||
idleTimeout?: number;
|
||||
/**
|
||||
* (default 1000) How frequently the pool should check for connections that are old enough to be reaped.
|
||||
*/
|
||||
reapInterval?: number;
|
||||
/**
|
||||
* (default true) When this is true, the pool will reap connections that
|
||||
* have been idle for more than idleTimeout milliseconds.
|
||||
*/
|
||||
refreshIdle?: boolean;
|
||||
/**
|
||||
* Called immediately after a connection is first established. Use this to do one-time setup of new connections.
|
||||
* The supplied Connection will not be added to the pool until you pass it to the done continuation.
|
||||
*/
|
||||
onConnect?: (connection: Connection, ready: (error: Error, result: Connection) => void) => void;
|
||||
/**
|
||||
* Called each time a connection is returned to the pool. Use this to restore a connection to
|
||||
* it's original state (e.g. rollback transactions, set the database session vars). If reset
|
||||
* fails to call the done continuation the connection will be lost in limbo.
|
||||
*/
|
||||
reset?: (connection: Connection, done: (error: Error) => void) => void;
|
||||
/**
|
||||
* (default function (err) { return true }) - Called when an error is encountered
|
||||
* by pool.query or emitted by an idle connection. If shouldDestroyConnection(error)
|
||||
* is truthy the connection will be destroyed, otherwise it will be reset.
|
||||
*/
|
||||
shouldDestroyConnection?: (error: Error) => boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a database connection.
|
||||
* @param url String of the form adapter://user:password@host/database
|
||||
* @param callback
|
||||
* @returns Connection object.
|
||||
*/
|
||||
export function createConnection(url: string, callback?: (error: Error, connection: Connection) => void): Connection;
|
||||
|
||||
/**
|
||||
* Create a database connection.
|
||||
* @param opts Object with adapter name and any properties that the given adapter requires
|
||||
* @param callback
|
||||
* @returns Connection object.
|
||||
*/
|
||||
export function createConnection(opts: ConnectOpts, callback?: (error: Error, connection: Connection) => void): Connection;
|
||||
|
||||
|
||||
export function createPool(url: string, config: PoolConfig): ConnectionPool;
|
||||
export function createPool(opts: ConnectOpts, config: PoolConfig): ConnectionPool;
|
||||
|
||||
}
|
||||
Vendored
+1
@@ -57,6 +57,7 @@ declare module assert {
|
||||
// export = assert;
|
||||
// }
|
||||
|
||||
// move to power-assert.d.ts. do not use this definition file.
|
||||
declare module "power-assert" {
|
||||
export = assert;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for assertion-error 1.0 0
|
||||
// Type definitions for assertion-error 1.0.0
|
||||
// Project: https://github.com/chaijs/assertion-error
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
Vendored
+19
-1
@@ -31,6 +31,23 @@ interface AsyncQueue<T> {
|
||||
kill(): void;
|
||||
}
|
||||
|
||||
interface AsyncPriorityQueue<T> {
|
||||
length(): number;
|
||||
concurrency: number;
|
||||
started: boolean;
|
||||
paused: boolean;
|
||||
push(task: T, priority: number, callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
push(task: T[], priority: number, callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
saturated: () => any;
|
||||
empty: () => any;
|
||||
drain: () => any;
|
||||
running(): number;
|
||||
idle(): boolean;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
kill(): void;
|
||||
}
|
||||
|
||||
interface Async {
|
||||
|
||||
// Collections
|
||||
@@ -56,7 +73,7 @@ interface Async {
|
||||
some<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
any<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
every<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any): any;
|
||||
all<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any): any;
|
||||
all<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any): any;
|
||||
concat<T, R>(arr: T[], iterator: AsyncIterator<T, R[]>, callback: AsyncMultipleResultsCallback<R>): any;
|
||||
concatSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R[]>, callback: AsyncMultipleResultsCallback<R>): any;
|
||||
|
||||
@@ -72,6 +89,7 @@ interface Async {
|
||||
waterfall<T>(tasks: T[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
waterfall<T>(tasks: T, callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
queue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncQueue<T>;
|
||||
priorityQueue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncPriorityQueue<T>;
|
||||
// auto(tasks: any[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
auto(tasks: any, callback?: AsyncMultipleResultsCallback<any>): void;
|
||||
iterator(tasks: Function[]): Function;
|
||||
|
||||
Vendored
+4
@@ -48,6 +48,10 @@ declare module "aws-sdk" {
|
||||
public client: s3.Client;
|
||||
}
|
||||
|
||||
export class DynamoDB {
|
||||
constructor(options?: any);
|
||||
}
|
||||
|
||||
export module Sqs {
|
||||
|
||||
export interface Client {
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/// <reference path="bcrypt.d.ts" />
|
||||
|
||||
import bcrypt = require("bcrypt");
|
||||
|
||||
var num: number;
|
||||
var str: string;
|
||||
var bool: boolean;
|
||||
|
||||
str = bcrypt.genSaltSync();
|
||||
str = bcrypt.genSaltSync(num);
|
||||
|
||||
bcrypt.genSalt(function (err: Error, salt: string): void {
|
||||
str = salt;
|
||||
});
|
||||
bcrypt.genSalt(num, function (err: Error, salt: string): void {
|
||||
str = salt;
|
||||
});
|
||||
|
||||
str = bcrypt.hashSync(str, str);
|
||||
str = bcrypt.hashSync(str, num);
|
||||
|
||||
bcrypt.hash(str, str, function (err: Error, encrypted: string):void {
|
||||
str = encrypted;
|
||||
})
|
||||
bcrypt.hash(str, num, function (err: Error, encrypted: string): void {
|
||||
str = encrypted;
|
||||
});
|
||||
|
||||
bool = bcrypt.compareSync(str, str);
|
||||
bcrypt.compare(str, str, function (err: Error, same: boolean): void {
|
||||
bool = same;
|
||||
});
|
||||
|
||||
num = bcrypt.getRounds(str);
|
||||
Vendored
+65
@@ -0,0 +1,65 @@
|
||||
// Type definitions for bcrypt
|
||||
// Project: https://www.npmjs.org/package/bcrypt
|
||||
// Definitions by: Peter Harris <https://github.com/codeanimal>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "bcrypt" {
|
||||
/**
|
||||
* @param rounds The cost of processing the data. Default 10.
|
||||
*/
|
||||
export function genSaltSync(rounds?: number): string;
|
||||
|
||||
/**
|
||||
* @param rounds The cost of processing the data. Default 10.
|
||||
* @param callback A callback to be fire once the sald has been generated. Uses eio making it asynchronous.
|
||||
*/
|
||||
export function genSalt(rounds: number, callback: (err: Error, salt: string) => void): void;
|
||||
/**
|
||||
* @param callback A callback to be fire once the sald has been generated. Uses eio making it asynchronous.
|
||||
*/
|
||||
export function genSalt(callback: (err: Error, salt: string) => void): void;
|
||||
|
||||
/**
|
||||
* @param data The data to be encrypted.
|
||||
* @param salt The salt to be used in encryption.
|
||||
*/
|
||||
export function hashSync(data: any, salt: string): string;
|
||||
/**
|
||||
* @param data The data to be encrypted.
|
||||
* @param rounds A salt will be generated using the rounds specified.
|
||||
*/
|
||||
export function hashSync(data: any, rounds: number): string;
|
||||
|
||||
/**
|
||||
* @param data The data to be encrypted.
|
||||
* @param salt The salt to be used in encryption.
|
||||
* @param callback A callback to be fired once the data has been encrypted. Uses eio making it asynchronous.
|
||||
*/
|
||||
export function hash(data: any, salt: string, callback: (err: Error, encrypted: string) => void): void;
|
||||
/**
|
||||
* @param data The data to be encrypted.
|
||||
* @param rounds A salt will be generated using the rounds specified.
|
||||
* @param callback A callback to be fired once the data has been encrypted. Uses eio making it asynchronous.
|
||||
*/
|
||||
export function hash(data: any, rounds: number, callback: (err: Error, encrypted: string) => void): void;
|
||||
|
||||
/**
|
||||
* @param data The data to be encrypted.
|
||||
* @param encrypted The data to be compared against.
|
||||
*/
|
||||
export function compareSync(data: any, encrypted: string): boolean;
|
||||
|
||||
/**
|
||||
* @param data The data to be encrypted.
|
||||
* @param encrypted The data to be compared against.
|
||||
* @param callback A callback to be fire once the data has been compared. Uses eio making it asynchronous.
|
||||
*/
|
||||
export function compare(data: any, encrypted: string, callback: (err: Error, same: boolean) => void): void;
|
||||
|
||||
/**
|
||||
* Return the number of rounds used to encrypt a given hash
|
||||
*
|
||||
* @param encrypted Hash from which the number of rounds used should be extracted.
|
||||
*/
|
||||
export function getRounds(encrypted: string): number;
|
||||
}
|
||||
@@ -49,7 +49,7 @@ bi = BigInt.trim(bi, num);
|
||||
BigInt.addInt_(bi, num);
|
||||
BigInt.add_(bi, bi);
|
||||
BigInt.copy_(bi, bi);
|
||||
num = BigInt.copyInt_(bi, num);
|
||||
BigInt.copyInt_(bi, num);
|
||||
BigInt.GCD_(bi, bi);
|
||||
b = BigInt.inverseMod_(bi, bi);
|
||||
BigInt.mod_(bi, bi);
|
||||
|
||||
Vendored
+388
-114
@@ -1,8 +1,11 @@
|
||||
// Type definitions for BigInt v5.5.1
|
||||
// Type definitions for BigInt v5.5.3
|
||||
// Project: https://github.com/Evgenus/BigInt
|
||||
// Definitions by: Eugene Chernyshov <https://github.com/Evgenus>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// Development repository: https://github.com/Evgenus/bigint-typescript-definitions
|
||||
// For answers, fixes and cutting edge version please see development repository.
|
||||
|
||||
declare module BigInt {
|
||||
export interface BigInt extends Array<number> {
|
||||
}
|
||||
@@ -11,361 +14,632 @@ declare module BigInt {
|
||||
(): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a random number generator.
|
||||
*
|
||||
* @param {IRandom} random function that returns random number.
|
||||
*/
|
||||
export function setRandom(random: IRandom): void;
|
||||
|
||||
/**
|
||||
* bigInt add(x,y)
|
||||
* return (x+y) for bigInts x and y.
|
||||
*
|
||||
* @param {BigInt} x The BigInt augend.
|
||||
* @param {BigInt} y The BigInt addend.
|
||||
*
|
||||
* @return {BigInt} A sum as BigInt.
|
||||
*/
|
||||
export function add(x: BigInt, y: BigInt): BigInt;
|
||||
|
||||
/**
|
||||
* bigInt addInt(x,n)
|
||||
* return (x+n) where x is a bigInt and n is an integer.
|
||||
*
|
||||
* @param {BigInt} x The BigInt augend.
|
||||
* @param {number} n The number addend.
|
||||
*
|
||||
* @return {BigInt} A sum as BigInt.
|
||||
*/
|
||||
export function addInt(x: BigInt, n: number): BigInt;
|
||||
|
||||
interface bigInt2str_T<T> {
|
||||
/**
|
||||
* string bigInt2str(x,base)
|
||||
* return a string form of bigInt x in a given base, with 2 <= base <= 95
|
||||
*/
|
||||
(x: BigInt, base: T): string;
|
||||
}
|
||||
|
||||
interface bigInt2strSignature extends bigInt2str_T<string>, bigInt2str_T<number>{
|
||||
}
|
||||
|
||||
export var bigInt2str: bigInt2strSignature;
|
||||
/**
|
||||
* return a string form of bigInt x in a given base, with 2 <= base <= 95.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to stringify.
|
||||
* @param {number} base The base as radix number.
|
||||
*
|
||||
* @return {string} A string representation of given BigInt.
|
||||
*/
|
||||
export function bigInt2str(x: BigInt, base: number): string;
|
||||
|
||||
/**
|
||||
* int bitSize(x)
|
||||
* return how many bits long the bigInt x is, not counting leading zeros
|
||||
* return a string form of bigInt x in a given base, with 2 <= base <= 95.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to stringify.
|
||||
* @param {string} base The base as vocabulary of characters.
|
||||
*
|
||||
* @return {string} A string representation of given BigInt.
|
||||
*/
|
||||
export function bigInt2str(x: BigInt, base: string): string;
|
||||
|
||||
/**
|
||||
* return how many bits long the bigInt x is, not counting leading zeros.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to process.
|
||||
*
|
||||
* @return {number} A size in BigInt as number.
|
||||
*/
|
||||
export function bitSize(x: BigInt): number;
|
||||
|
||||
/**
|
||||
* bigInt dup(x)
|
||||
* return a copy of bigInt x
|
||||
* return a copy of bigInt x.
|
||||
*
|
||||
* @param {BigInt} x Source BigInt to be copied.
|
||||
*
|
||||
* @return {BigInt} A copy of this object.
|
||||
*/
|
||||
export function dup(x: BigInt): BigInt;
|
||||
|
||||
/**
|
||||
* boolean equals(x,y)
|
||||
* is the bigInt x equal to the bigint y?
|
||||
*
|
||||
* @param {BigInt} x BigInt to be compared.
|
||||
* @param {BigInt} y BigInt to be compared.
|
||||
*
|
||||
* @return {boolean} true if the objects are considered equal, false if they are not.
|
||||
*/
|
||||
export function equals(x: BigInt, y: BigInt): boolean;
|
||||
|
||||
/**
|
||||
* boolean equalsInt(x,y)
|
||||
* is bigint x equal to integer y?
|
||||
*
|
||||
* @param {BigInt} x BigInt to be compared.
|
||||
* @param {BigInt} y BigInt to be compared.
|
||||
*
|
||||
* @return {boolean} true if the objects are considered equal, false if not.
|
||||
*/
|
||||
export function equalsInt(x: BigInt, y: number): boolean;
|
||||
|
||||
/**
|
||||
* bigInt expand(x,n)
|
||||
* return a copy of x with at least n elements, adding leading zeros if needed
|
||||
* return a copy of x with at least n elements, adding leading zeros if needed.
|
||||
*
|
||||
* @param {BigInt} value The source object to copy.
|
||||
* @param {number} n The minimal number of elements.
|
||||
*
|
||||
* @return {BigInt} A copy of given BigInt.
|
||||
*/
|
||||
export function expand(value: BigInt, n: number): BigInt;
|
||||
|
||||
/**
|
||||
* Array findPrimes(n)
|
||||
* return array of all primes less than integer n
|
||||
* return array of all primes less than integer n.
|
||||
*
|
||||
* @param {number} n Upper limit of search.
|
||||
*
|
||||
* @return {Array} The found primes as Array.
|
||||
*/
|
||||
export function findPrimes(n: number): number[];
|
||||
|
||||
/**
|
||||
* bigInt GCD(x,y)
|
||||
* return greatest common divisor of bigInts x and y (each with same number of elements).
|
||||
*
|
||||
* @param {BigInt} x The BigInt to process.
|
||||
* @param {BigInt} y The BigInt to process.
|
||||
*
|
||||
* @return {BigInt} A greatest common divisor as BigInt.
|
||||
*/
|
||||
export function GCD(x: BigInt, y: BigInt): BigInt;
|
||||
|
||||
/**
|
||||
* boolean greater(x,y)
|
||||
* is x>y? (x and y are nonnegative bigInts)
|
||||
*
|
||||
* @param {BigInt} x BigInt to be compared.
|
||||
* @param {BigInt} y BigInt to be compared.
|
||||
*
|
||||
* @return {boolean} true if x is greater, false if it's not.
|
||||
*/
|
||||
export function greater(x: BigInt, y: BigInt): boolean;
|
||||
|
||||
/**
|
||||
* boolean greaterShift(x,y,shift)
|
||||
* is (x <<(shift*bpe)) > y?
|
||||
*
|
||||
* @param {BigInt} x BigInt to be compared.
|
||||
* @param {BigInt} y BigInt to be compared.
|
||||
* @param {number} shift The shift amount in bits.
|
||||
*
|
||||
* @return {boolean} true if x is greater, false if it's not.
|
||||
*/
|
||||
export function greaterShift(x: BigInt, y: BigInt, shift: number): boolean;
|
||||
|
||||
/**
|
||||
* bigInt int2bigInt(t,n,m)
|
||||
* return a bigInt equal to integer t, with at least n bits and m array elements
|
||||
* return a bigInt equal to integer t, with at least n bits and m array elements.
|
||||
*
|
||||
* @param {number} t The number to process.
|
||||
* @param {number=} n (Optional) the number to process.
|
||||
* @param {number=} m (Optional) the number to process.
|
||||
*
|
||||
* @return {BigInt} A BigInt equivalent of given number.
|
||||
*/
|
||||
export function int2bigInt(t: number, n?: number, m?: number): BigInt;
|
||||
|
||||
/**
|
||||
* bigInt inverseMod(x,n)
|
||||
* return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null
|
||||
* return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null.
|
||||
*
|
||||
* @param {BigInt} x The BigInt base.
|
||||
* @param {BigInt} n The BigInt divisor.
|
||||
*
|
||||
* @return {BigInt} A BigInt remainder.
|
||||
*/
|
||||
export function inverseMod(x: BigInt, n: BigInt): BigInt;
|
||||
|
||||
/**
|
||||
* int inverseModInt(x,n)
|
||||
* return x**(-1) mod n, for integers x and n. Return 0 if there is no inverse
|
||||
* return x**(-1) mod n, for integers x and n.
|
||||
* Return 0 if there is no inverse.
|
||||
*
|
||||
* @param {number} x The BigInt base.
|
||||
* @param {number} n The BigInt divisor.
|
||||
*
|
||||
* @return {BigInt} A BigInt remainder.
|
||||
*/
|
||||
export function inverseModInt(x: number, n: number): BigInt;
|
||||
|
||||
/**
|
||||
* boolean isZero(x)
|
||||
* is the bigInt x equal to zero?
|
||||
*
|
||||
* @param {BigInt} x BigInt to be compared.
|
||||
*
|
||||
* @return {boolean} true if zero, false if not.
|
||||
*/
|
||||
export function isZero(x: BigInt): boolean;
|
||||
|
||||
/**
|
||||
* boolean millerRabin(x,b)
|
||||
* does one round of Miller-Rabin base integer b say that bigInt x is possibly prime? (b is bigInt, 1<b<x)
|
||||
* does one round of Miller-Rabin base integer b say that bigInt x is possibly prime?
|
||||
*
|
||||
* @param {BigInt} x The BigInt to process.
|
||||
* @param {BigInt} b The BigInt to process. (b is bigInt, 1<b<x)
|
||||
*
|
||||
* @return {boolean} true if it is prime, false if it is not.
|
||||
*/
|
||||
export function millerRabin(x: BigInt, b: BigInt): boolean;
|
||||
|
||||
/**
|
||||
* boolean millerRabinInt(x,b)
|
||||
* does one round of Miller-Rabin base integer b say that bigInt x is possibly prime? (b is int, 1<b<x)
|
||||
* does one round of Miller-Rabin base integer b say that bigInt x is possibly prime?
|
||||
*
|
||||
* @param {number} x The number to process.
|
||||
* @param {number} b The number to process. (b is int, 1<b<x)
|
||||
*
|
||||
* @return {boolean} true if it is prime, false if it is not.
|
||||
*/
|
||||
export function millerRabinInt(x: number, b: number): boolean;
|
||||
|
||||
/**
|
||||
* bigInt mod(x,n)
|
||||
* return a new bigInt equal to (x mod n) for bigInts x and n.
|
||||
*
|
||||
* @param {BigInt} x The dividend.
|
||||
* @param {BigInt} n The divisor.
|
||||
*
|
||||
* @return {BigInt} A remainder as BigInt.
|
||||
*/
|
||||
export function mod(x: BigInt, n: BigInt): BigInt;
|
||||
|
||||
/**
|
||||
* int modInt(x,n)
|
||||
* return x mod n for bigInt x and integer n.
|
||||
*
|
||||
* @param {BigInt} x The dividend.
|
||||
* @param {number} n The divisor.
|
||||
*
|
||||
* @return {number} A remainder as number.
|
||||
*/
|
||||
export function modInt(x: BigInt, n: number): number;
|
||||
|
||||
/**
|
||||
* bigInt mult(x,y)
|
||||
* return x*y for bigInts x and y. This is faster when y<x.
|
||||
*
|
||||
* @param {BigInt} x The multiplicand.
|
||||
* @param {BigInt} y The multiplier.
|
||||
*
|
||||
* @return {BigInt} A product as BigInt.
|
||||
*/
|
||||
export function mult(x: BigInt, y: BigInt): BigInt;
|
||||
|
||||
/**
|
||||
* bigInt multMod(x,y,n)
|
||||
* return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x.
|
||||
* return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x.
|
||||
*
|
||||
* @param {BigInt} x The multiplicand.
|
||||
* @param {BigInt} y The multiplier.
|
||||
* @param {BigInt} n The divisor.
|
||||
*
|
||||
* @return {BigInt} A remainder as BigInt.
|
||||
*/
|
||||
export function multMod(x: BigInt, y: BigInt, n: BigInt): BigInt;
|
||||
|
||||
/**
|
||||
* boolean negative(x)
|
||||
* is bigInt x negative?
|
||||
*
|
||||
* @param {BigInt} x BigInt to be compared.
|
||||
*
|
||||
* @return {boolean} true if x is negative, false if x is positive.
|
||||
*/
|
||||
export function negative(x: BigInt): boolean;
|
||||
|
||||
/**
|
||||
* bigInt powMod(x,y,n)
|
||||
* return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n.
|
||||
* return (x**y mod n) where x,y,n are bigInts and ** is exponentiation.
|
||||
* 0**0=1. Faster for odd n.
|
||||
*
|
||||
* @param {BigInt} x The BigInt base.
|
||||
* @param {BigInt} y The BigInt exponent.
|
||||
* @param {BigInt} n The BigInt divisor.
|
||||
*
|
||||
* @return {BigInt} A remainder as BigInt.
|
||||
*/
|
||||
export function powMod(x: BigInt, y: BigInt, n: BigInt): BigInt;
|
||||
|
||||
/**
|
||||
* bigInt randBigInt(n,s)
|
||||
* return an n-bit random BigInt (n>=1). If s=1, then the most significant of those n bits is set to 1.
|
||||
* return an n-bit random BigInt (n>=1).
|
||||
* If s=1, then the most significant of those n bits is set to 1.
|
||||
*
|
||||
* @param {number} n The number of bits (n>=1).
|
||||
* @param {number} s The sign bit.
|
||||
*
|
||||
* @return {BigInt} A new random BigInt.
|
||||
*/
|
||||
export function randBigInt(n: number, s: number): BigInt;
|
||||
|
||||
/**
|
||||
* bigInt randTruePrime(k)
|
||||
* return a new, random, k-bit, true prime bigInt using Maurer's algorithm.
|
||||
*
|
||||
* @param {number} k The number of bits.
|
||||
*
|
||||
* @return {BigInt} A new random BigInt.
|
||||
*/
|
||||
export function randTruePrime(k: number): BigInt;
|
||||
|
||||
/**
|
||||
* bigInt randProbPrime(k)
|
||||
* return a new, random, k-bit, probable prime bigInt (probability it's composite less than 2^-80).
|
||||
* return a new, random, k-bit, probable prime bigInt.
|
||||
* Probability it's composite less than 2^- 80.
|
||||
*
|
||||
* @param {number} k The number of bits.
|
||||
*
|
||||
* @return {BigInt} A new probably random BigInt.
|
||||
*/
|
||||
export function randProbPrime(k: number): BigInt;
|
||||
|
||||
interface str2bigInt_T<T> {
|
||||
/**
|
||||
* bigInt str2bigInt(s,b,n,m)
|
||||
* return a bigInt for number represented in string s in base b with at least n bits and m array elements
|
||||
*/
|
||||
(s: string, b: T, n?: number, m?: number): BigInt;
|
||||
}
|
||||
|
||||
interface str2bigIntSignature extends str2bigInt_T<number>, str2bigInt_T<string> {
|
||||
}
|
||||
|
||||
export var str2bigInt: str2bigIntSignature;
|
||||
/**
|
||||
* return a bigInt for number represented in string s in base b with at least n bits and m array
|
||||
* elements.
|
||||
*
|
||||
* @param {string} s The string representation of number.
|
||||
* @param {number} b The base as radix number.
|
||||
* @param {number=} n (Optional) minimal bit length as number.
|
||||
* @param {number=} m (Optional) the number of array elements as number.
|
||||
*
|
||||
* @return {BigInt} A parsed BigInt.
|
||||
*/
|
||||
export function str2bigInt(s: string, b: number, n?: number, m?: number): BigInt;
|
||||
|
||||
/**
|
||||
* bigInt sub(x,y)
|
||||
* return (x-y) for bigInts x and y. Negative answers will be 2s complement
|
||||
* return a bigInt for number represented in string s in base b with at least n bits and m array
|
||||
* elements.
|
||||
*
|
||||
* @param {string} s The string representation of number.
|
||||
* @param {string} b The base as string vocabulary of characters.
|
||||
* @param {number=} n (Optional) minimal bit length as number.
|
||||
* @param {number=} m (Optional) the number of array elements as number.
|
||||
*
|
||||
* @return {BigInt} A parsed BigInt.
|
||||
*/
|
||||
export function str2bigInt(s: string, b: string, n?: number, m?: number): BigInt;
|
||||
|
||||
/**
|
||||
* return (x-y) for bigInts x and y.
|
||||
* Negative answers will be 2s complement.
|
||||
*
|
||||
* @param {BigInt} x The minuend as BigInt.
|
||||
* @param {BigInt} y The subtrahend as BigInt.
|
||||
*
|
||||
* @return {BigInt} A difference BigInt.
|
||||
*/
|
||||
export function sub(x: BigInt, y: BigInt): BigInt;
|
||||
|
||||
/**
|
||||
* bigInt trim(x,k)
|
||||
* return a copy of x with exactly k leading zero elements
|
||||
* return a copy of x with exactly k leading zero elements.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to be copied.
|
||||
* @param {number} k The number of zeroes.
|
||||
*
|
||||
* @return {BigInt} A copy BigInt.
|
||||
*/
|
||||
export function trim(x: BigInt, k: number): BigInt;
|
||||
|
||||
/**
|
||||
* void addInt_(x,n)
|
||||
* do x=x+n where x is a bigInt and n is an integer
|
||||
* do x=x+n where x is a bigInt and n is an integer.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt accumulator.
|
||||
* @param {number} n The number addend.
|
||||
*/
|
||||
export function addInt_(x: BigInt, n: number): void;
|
||||
|
||||
/**
|
||||
* void add_(x,y)
|
||||
* do x=x+y for bigInts x and y
|
||||
* do x=x+y for bigInts x and y.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt accumulator.
|
||||
* @param {BigInt} y The BigInt addend.
|
||||
*/
|
||||
export function add_(x: BigInt, y: BigInt): void;
|
||||
|
||||
/**
|
||||
* void copy_(x,y)
|
||||
* do x=y on bigInts x and y
|
||||
* do x=y on bigInts x and y.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt destination.
|
||||
* @param {BigInt} y The BigInt source.
|
||||
*/
|
||||
export function copy_(x: BigInt, y: BigInt): void;
|
||||
|
||||
/**
|
||||
* void copyInt_(x,n)
|
||||
* do x=n on bigInt x and integer n
|
||||
* do x=n on bigInt x and integer n.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt destination.
|
||||
* @param {number} n The number source.
|
||||
*/
|
||||
export function copyInt_(x: BigInt, n: number): number;
|
||||
export function copyInt_(x: BigInt, n: number): void;
|
||||
|
||||
/**
|
||||
* void GCD_(x,y)
|
||||
* set x to the greatest common divisor of bigInts x and y, (y is destroyed). (This never overflows its array).
|
||||
* set x to the greatest common divisor of bigInts x and y, (y is destroyed).
|
||||
* This never overflows its array.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt first dividend.
|
||||
* @param {BigInt} y The BigInt second dividend.
|
||||
*/
|
||||
export function GCD_(x: BigInt, y: BigInt): void;
|
||||
|
||||
/**
|
||||
* boolean inverseMod_(x,n)
|
||||
* do x=x**(-1) mod n, for bigInts x and n. Returns 1 (0) if inverse does (doesn't) exist
|
||||
* do x=x**(-1) mod n, for bigInts x and n. Returns 1 (0) if inverse does (doesn't) exist.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt base and the remainder result.
|
||||
* @param {BigInt} n The BigInt divisor.
|
||||
*
|
||||
* @return {boolean} true if inverse does exist, false if doesn't.
|
||||
*/
|
||||
export function inverseMod_(x: BigInt, n: BigInt): boolean;
|
||||
|
||||
/**
|
||||
* void mod_(x,n)
|
||||
* do x=x mod n for bigInts x and n. (This never overflows its array).
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt dividend and the remainder result.
|
||||
* @param {BigInt} n The BigInt divisor.
|
||||
*/
|
||||
export function mod_(x: BigInt, n: BigInt): void;
|
||||
|
||||
/**
|
||||
* void mult_(x,y)
|
||||
* do x=x*y for bigInts x and y.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt multiplicand and the product result.
|
||||
* @param {BigInt} y The BigInt multiplier.
|
||||
*/
|
||||
export function mult_(x: BigInt, y: BigInt): void;
|
||||
|
||||
/**
|
||||
* void multMod_(x,y,n)
|
||||
* do x=x*y mod n for bigInts x,y,n.
|
||||
* do x=x*y mod n for bigInts x,y,n.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt multiplicand and the remainder result.
|
||||
* @param {BigInt} y The BigInt multiplier.
|
||||
* @param {BigInt} n The BigInt divisor.
|
||||
*/
|
||||
export function multMod_(x: BigInt, y: BigInt, n: BigInt): void;
|
||||
|
||||
/**
|
||||
* void powMod_(x,y,n)
|
||||
* do x=x**y mod n, where x,y,n are bigInts (n is odd) and ** is exponentiation. 0**0=1.
|
||||
* do x=x**y mod n, where x,y,n are bigInts (n is odd) and ** is exponentiation.
|
||||
* 0**0=1.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt base and the remainder result.
|
||||
* @param {BigInt} y The BigInt exponent.
|
||||
* @param {BigInt} n The BigInt divisor.
|
||||
*/
|
||||
export function powMod_(x: BigInt, y: BigInt, n: BigInt): void;
|
||||
|
||||
/**
|
||||
* void randBigInt_(b,n,s)
|
||||
* do b = an n-bit random BigInt. if s=1, then nth bit (most significant bit) is set to 1. n>=1.
|
||||
* do b = an n-bit random BigInt.
|
||||
* if s=1, then nth bit (most significant bit) is set to 1. n>=1.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} b The BigInt destination.
|
||||
* @param {number} n The number of bits.
|
||||
* @param {number} s The sign bit number.
|
||||
*/
|
||||
export function randBigInt_(b: BigInt, n: number, s: number): void;
|
||||
|
||||
/**
|
||||
* void randTruePrime_(ans,k)
|
||||
* do ans = a random k-bit true random prime (not just probable prime) with 1 in the msb.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} ans The destination.
|
||||
* @param {number} k The number of bits.
|
||||
*/
|
||||
export function randTruePrime_(ans: BigInt, k: number): void;
|
||||
|
||||
/**
|
||||
* void sub_(x,y)
|
||||
* do x=x-y for bigInts x and y. Negative answers will be 2s complement.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt minuend and the result difference.
|
||||
* @param {BigInt} y The BigInt subtrahend .
|
||||
*/
|
||||
export function sub_(x: BigInt, y: BigInt): void;
|
||||
|
||||
/**
|
||||
* void addShift_(x,y,ys)
|
||||
* do x=x+(y<<(ys*bpe))
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt accumulator.
|
||||
* @param {BigInt} y The BigInt addend to be shifted.
|
||||
* @param {number} ys The number of shift amount.
|
||||
*/
|
||||
export function addShift_(x: BigInt, y: BigInt, ys: number): void;
|
||||
|
||||
/**
|
||||
* void carry_(x)
|
||||
* do carries and borrows so each element of the bigInt x fits in bpe bits.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to process.
|
||||
*/
|
||||
export function carry_(x: BigInt): void;
|
||||
|
||||
/**
|
||||
* void divide_(x,y,q,r)
|
||||
* divide x by y giving quotient q and remainder r
|
||||
* divide x by y giving quotient q and remainder r.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt dividend.
|
||||
* @param {BigInt} y The BigInt divisor.
|
||||
* @param {BigInt} q The BigInt quotient.
|
||||
* @param {BigInt} r The BigInt remainder.
|
||||
*/
|
||||
export function divide_(x: BigInt, y: BigInt, q: BigInt, r: BigInt): void;
|
||||
|
||||
/**
|
||||
* int divInt_(x,n)
|
||||
* do x=floor(x/n) for bigInt x and integer n, and return the remainder. (This never overflows its array).
|
||||
* do x=floor(x/n) for bigInt x and integer n, and return the remainder.
|
||||
* This never overflows its array.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt dividend and the quotient result.
|
||||
* @param {number} n The number divisor.
|
||||
*
|
||||
* @return {number} A number remainder.
|
||||
*/
|
||||
export function divInt_(x: BigInt, n: number): number;
|
||||
|
||||
/**
|
||||
* void eGCD_(x,y,d,a,b)
|
||||
* sets a,b,d to positive bigInts such that d = GCD_(x,y) = a*x-b*y
|
||||
* sets a,b,d to positive bigInts such that d = GCD_(x,y) = a*x-b*y.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to process.
|
||||
* @param {BigInt} y The BigInt to process.
|
||||
* @param {BigInt} d The BigInt to process.
|
||||
* @param {BigInt} a The BigInt to process.
|
||||
* @param {BigInt} b The BigInt to process.
|
||||
*/
|
||||
export function eGCD_(x: BigInt, y: BigInt, d: BigInt, a: BigInt, b: BigInt): void;
|
||||
|
||||
/**
|
||||
* void halve_(x)
|
||||
* do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement. (This never overflows its array).
|
||||
* do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement.
|
||||
* This never overflows its array.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to process.
|
||||
*/
|
||||
export function halve_(x: BigInt): void;
|
||||
|
||||
/**
|
||||
* void leftShift_(x,n)
|
||||
* left shift bigInt x by n bits. n<bpe.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to process.
|
||||
* @param {number} n The number of bits.
|
||||
*/
|
||||
export function leftShift_(x: BigInt, n: number): void;
|
||||
|
||||
/**
|
||||
* void linComb_(x,y,a,b)
|
||||
* do x=a*x+b*y for bigInts x and y and integers a and b
|
||||
* do x=a*x+b*y for bigInts x and y and integers a and b.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt first multiplicand.
|
||||
* @param {BigInt} y The BigInt second multiplicand.
|
||||
* @param {number} a The number first multiplier.
|
||||
* @param {number} b The number second multiplier.
|
||||
*/
|
||||
export function linComb_(x: BigInt, y: BigInt, a: number, b: number): void;
|
||||
|
||||
/**
|
||||
* void linCombShift_(x,y,b,ys)
|
||||
* do x=x+b*(y<<(ys*bpe)) for bigInts x and y, and integers b and ys
|
||||
/**
|
||||
* do x=x+b*(y<<(ys*bpe)) for bigInts x and y, and integers b and ys.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to process.
|
||||
* @param {BigInt} y The BigInt to process.
|
||||
* @param {number} b The number to process.
|
||||
* @param {number} ys The number shift.
|
||||
*/
|
||||
export function linCombShift_(x: BigInt, y: BigInt, b: number, ys: number): void;
|
||||
|
||||
/**
|
||||
* void mont_(x,y,n,np)
|
||||
* Montgomery multiplication (see comments where the function is defined)
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to process.
|
||||
* @param {BigInt} y The BigInt to process.
|
||||
* @param {BigInt} n The BigInt to process.
|
||||
* @param {number} np The np.
|
||||
*/
|
||||
export function mont_(x: BigInt, y: BigInt, n: BigInt, np: number): void;
|
||||
|
||||
/**
|
||||
* void multInt_(x,n)
|
||||
* do x=x*n where x is a bigInt and n is an integer.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt multiplicand and the result product.
|
||||
* @param {number} n The number multiplier.
|
||||
*/
|
||||
export function multInt_(x: BigInt, n: number): void;
|
||||
|
||||
/**
|
||||
* void rightShift_(x,n)
|
||||
* right shift bigInt x by n bits. 0 <= n < bpe. (This never overflows its array).
|
||||
* right shift bigInt x by n bits. 0 <= n < bpe.
|
||||
* This never overflows its array.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt to process.
|
||||
* @param {number} n The number to process.
|
||||
*/
|
||||
export function rightShift_(x: BigInt, n: number): void;
|
||||
|
||||
/**
|
||||
* void squareMod_(x,n)
|
||||
* do x=x*x mod n for bigInts x,n
|
||||
* do x=x*x mod n for bigInts x,n.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt base and the result remainder.
|
||||
* @param {BigInt} n The BigInt divisor.
|
||||
*/
|
||||
export function squareMod_(x: BigInt, n: BigInt): void;
|
||||
|
||||
/**
|
||||
* void subShift_(x,y,ys)
|
||||
* do x=x-(y<<(ys*bpe)). Negative answers will be 2s complement.
|
||||
*
|
||||
* @private Intend to be internal function.
|
||||
*
|
||||
* @param {BigInt} x The BigInt minuend and the result difference.
|
||||
* @param {BigInt} y The BigInt shifted subtrahend .
|
||||
* @param {number} ys The number shift amount.
|
||||
*/
|
||||
export function subShift_(x: BigInt, y: BigInt, ys: number): void;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,882 @@
|
||||
/// <reference path="bluebird-1.0.d.ts" />
|
||||
|
||||
// Tests by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
|
||||
// Note: replicate changes to all overloads in both definition and test file
|
||||
// Note: keep both static and instance members inline (so similar)
|
||||
|
||||
// Note: try to maintain the ordering and separators, and keep to the pattern
|
||||
|
||||
var obj: Object;
|
||||
var bool: boolean;
|
||||
var num: number;
|
||||
var str: string;
|
||||
var err: Error;
|
||||
var x: any;
|
||||
var f: Function;
|
||||
var func: Function;
|
||||
var arr: any[];
|
||||
var exp: RegExp;
|
||||
var anyArr: any[];
|
||||
var strArr: string[];
|
||||
var numArr: number[];
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
var value: any;
|
||||
var reason: any;
|
||||
var insanity: any;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
interface Foo {
|
||||
foo(): string;
|
||||
}
|
||||
interface Bar {
|
||||
bar(): string;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
interface StrFooMap {
|
||||
[key:string]:Foo;
|
||||
}
|
||||
|
||||
interface StrBarMap {
|
||||
[key:string]:Bar;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
interface StrFooArrMap {
|
||||
[key:string]:Foo[];
|
||||
}
|
||||
|
||||
interface StrBarArrMap {
|
||||
[key:string]:Bar[];
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var foo: Foo;
|
||||
var bar: Bar;
|
||||
|
||||
var fooArr: Foo[];
|
||||
var barArr: Bar[];
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numProm: Promise<number>;
|
||||
var strProm: Promise<string>;
|
||||
var anyProm: Promise<any>;
|
||||
var boolProm: Promise<boolean>;
|
||||
var objProm: Promise<Object>;
|
||||
var voidProm: Promise<void>;
|
||||
|
||||
var fooProm: Promise<Foo>;
|
||||
var barProm: Promise<Bar>;
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numThen: Promise.Thenable<number>;
|
||||
var strThen: Promise.Thenable<string>;
|
||||
var anyThen: Promise.Thenable<any>;
|
||||
var boolThen: Promise.Thenable<boolean>;
|
||||
var objThen: Promise.Thenable<Object>;
|
||||
var voidThen: Promise.Thenable<void>;
|
||||
|
||||
var fooThen: Promise.Thenable<Foo>;
|
||||
var barThen: Promise.Thenable<Bar>;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numArrProm: Promise<number[]>;
|
||||
var strArrProm: Promise<string[]>;
|
||||
var anyArrProm: Promise<any[]>;
|
||||
|
||||
var fooArrProm: Promise<Foo[]>;
|
||||
var barArrProm: Promise<Bar[]>;
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numArrThen: Promise.Thenable<number[]>;
|
||||
var strArrThen: Promise.Thenable<string[]>;
|
||||
var anyArrThen: Promise.Thenable<any[]>;
|
||||
|
||||
var fooArrThen: Promise.Thenable<Foo[]>;
|
||||
var barArrThen: Promise.Thenable<Bar[]>;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numPromArr: Promise<number>[];
|
||||
var strPromArr: Promise<string>[];
|
||||
var anyPromArr: Promise<any>[];
|
||||
|
||||
var fooPromArr: Promise<Foo>[];
|
||||
var barPromArr: Promise<Bar>[];
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
var numThenArr: Promise.Thenable<number>[];
|
||||
var strThenArr: Promise.Thenable<string>[];
|
||||
var anyThenArr: Promise.Thenable<any>[];
|
||||
|
||||
var fooThenArr: Promise.Thenable<Foo>[];
|
||||
var barThenArr: Promise.Thenable<Bar>[];
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// booya!
|
||||
var fooThenArrThen: Promise.Thenable<Promise.Thenable<Foo>[]>;
|
||||
var barThenArrThen: Promise.Thenable<Promise.Thenable<Bar>[]>;
|
||||
|
||||
var fooResolver: Promise.Resolver<Foo>;
|
||||
var barResolver: Promise.Resolver<Bar>;
|
||||
|
||||
var fooInspection: Promise.Inspection<Foo>;
|
||||
var barInspection: Promise.Inspection<Bar>;
|
||||
|
||||
var fooInspectionArrProm: Promise<Promise.Inspection<Foo>[]>;
|
||||
var barInspectionArrProm: Promise<Promise.Inspection<Bar>[]>;
|
||||
|
||||
var BlueBird: typeof Promise;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooThen = fooProm;
|
||||
barThen = barProm;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = new Promise((resolve: (value: Foo) => void, reject: (reason: any) => void) => {
|
||||
if (bool) {
|
||||
resolve(foo);
|
||||
}
|
||||
else {
|
||||
reject(new Error(str));
|
||||
}
|
||||
});
|
||||
fooProm = new Promise((resolve: (value: Foo) => void) => {
|
||||
if (bool) {
|
||||
resolve(foo);
|
||||
}
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// needs a hint when used untyped?
|
||||
fooProm = new Promise<Foo>((resolve, reject) => {
|
||||
if (bool) {
|
||||
resolve(fooThen);
|
||||
}
|
||||
else {
|
||||
reject(new Error(str));
|
||||
}
|
||||
});
|
||||
fooProm = new Promise<Foo>((resolve) => {
|
||||
resolve(fooThen);
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooResolver.resolve(foo);
|
||||
|
||||
fooResolver.reject(err);
|
||||
|
||||
fooResolver.progress(bar);
|
||||
|
||||
fooResolver.callback = (err: any, value: Foo) => {
|
||||
|
||||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
bool = fooInspection.isFulfilled();
|
||||
|
||||
bool = fooInspection.isRejected();
|
||||
|
||||
bool = fooInspection.isPending();
|
||||
|
||||
foo = fooInspection.value();
|
||||
|
||||
x = fooInspection.error();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.then((value: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.catch((reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.caught((reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
barProm = fooProm.catch((reason: any) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.caught((reason: any) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.catch(Error, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.caught(Error, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.error((reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
return foo;
|
||||
});
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
});
|
||||
fooProm = fooProm.finally(() => {
|
||||
// return is ignored
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
return foo;
|
||||
});
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
});
|
||||
fooProm = fooProm.lastly(() => {
|
||||
// return is ignored
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.bind(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.progressed((note: any) => {
|
||||
return foo;
|
||||
});
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.delay(num);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.timeout(num);
|
||||
fooProm = fooProm.timeout(num, str);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm.nodeify();
|
||||
fooProm = fooProm.nodeify((err: any) => {
|
||||
|
||||
});
|
||||
fooProm = fooProm.nodeify((err: any, foo?: Foo) => {
|
||||
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooProm.fork((value: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.cancel<Bar>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.cancellable();
|
||||
fooProm = fooProm.uncancellable();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
bool = fooProm.isCancellable();
|
||||
bool = fooProm.isFulfilled();
|
||||
bool = fooProm.isRejected();
|
||||
bool = fooProm.isPending();
|
||||
bool = fooProm.isResolved();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooInspection = fooProm.inspect();
|
||||
|
||||
anyProm = fooProm.call(str);
|
||||
anyProm = fooProm.call(str, 1, 2, 3);
|
||||
|
||||
//TODO enable get() test when implemented
|
||||
// barProm = fooProm.get(str);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.return(bar);
|
||||
barProm = fooProm.thenReturn(bar);
|
||||
|
||||
voidProm = fooProm.return();
|
||||
voidProm = fooProm.thenReturn();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooProm
|
||||
fooProm = fooProm.throw(err);
|
||||
fooProm = fooProm.thenThrow(err);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
str = fooProm.toString();
|
||||
|
||||
obj = fooProm.toJSON();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO fix collection inference
|
||||
|
||||
barArrProm = fooProm.all<Bar>();
|
||||
|
||||
objProm = fooProm.props();
|
||||
|
||||
barInspectionArrProm = fooProm.settle<Bar>();
|
||||
|
||||
barProm = fooProm.any<Bar>();
|
||||
|
||||
barArrProm = fooProm.some<Bar>(num);
|
||||
|
||||
barProm = fooProm.race<Bar>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO fix collection inference
|
||||
|
||||
barArrProm = fooProm.map<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = fooProm.map<Foo, Bar>((item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.reduce<Foo, Bar>((memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return memo;
|
||||
});
|
||||
barProm = fooProm.reduce<Foo, Bar>((memo: Bar, item: Foo) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooArrProm = fooArrProm.filter<Foo>((item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = fooArrProm.filter<Foo>((item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.try(() => {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
}, arr);
|
||||
fooProm = Promise.try(() => {
|
||||
return fooThen;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
});
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
}, arr);
|
||||
fooProm = Promise.attempt(() => {
|
||||
return foo;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
}, arr);
|
||||
fooProm = Promise.attempt(() => {
|
||||
return fooThen;
|
||||
}, arr, x);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
func = Promise.method(function () {
|
||||
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.resolve(foo);
|
||||
fooProm = Promise.resolve(fooThen);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
voidProm = Promise.reject(reason);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooResolver = Promise.defer<Foo>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = Promise.cast(foo);
|
||||
fooProm = Promise.cast(fooThen);
|
||||
|
||||
voidProm = Promise.bind(x);
|
||||
|
||||
bool = Promise.is(value);
|
||||
|
||||
Promise.longStackTraces();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO enable delay
|
||||
|
||||
fooProm = Promise.delay(fooThen, num);
|
||||
fooProm = Promise.delay(foo, num);
|
||||
voidProm = Promise.delay(num);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
func = Promise.promisify(f);
|
||||
func = Promise.promisify(f, obj);
|
||||
;
|
||||
|
||||
obj = Promise.promisifyAll(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO enable generator
|
||||
/*
|
||||
func = Promise.coroutine(f);
|
||||
|
||||
barProm = Promise.spawn<number>(f);
|
||||
*/
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
BlueBird = Promise.noConflict();
|
||||
|
||||
Promise.onPossiblyUnhandledRejection((reason: any) => {
|
||||
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooArrProm = Promise.all(fooThenArrThen);
|
||||
fooArrProm = Promise.all(fooArrProm);
|
||||
fooArrProm = Promise.all(fooThenArr);
|
||||
fooArrProm = Promise.all(fooArr);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
objProm = Promise.props(objProm);
|
||||
objProm = Promise.props(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooInspectionArrProm = Promise.settle(fooThenArrThen);
|
||||
fooInspectionArrProm = Promise.settle(fooArrProm);
|
||||
fooInspectionArrProm = Promise.settle(fooThenArr);
|
||||
fooInspectionArrProm = Promise.settle(fooArr);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooProm = Promise.any(fooThenArrThen);
|
||||
fooProm = Promise.any(fooArrProm);
|
||||
fooProm = Promise.any(fooThenArr);
|
||||
fooProm = Promise.any(fooArr);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooProm = Promise.race(fooThenArrThen);
|
||||
fooProm = Promise.race(fooArrProm);
|
||||
fooProm = Promise.race(fooThenArr);
|
||||
fooProm = Promise.race(fooArr);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
//TODO expand tests to overloads
|
||||
fooArrProm = Promise.some(fooThenArrThen, num);
|
||||
fooArrProm = Promise.some(fooArrThen, num);
|
||||
fooArrProm = Promise.some(fooThenArr, num);
|
||||
fooArrProm = Promise.some(fooArr, num);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooArrProm = Promise.join(foo, foo, foo);
|
||||
fooArrProm = Promise.join(fooThen, fooThen, fooThen);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// map()
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArrThen
|
||||
|
||||
barArrProm = Promise.map(fooThenArrThen, (item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArrThen, (item: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArrThen
|
||||
|
||||
barArrProm = Promise.map(fooArrThen, (item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooArrThen, (item: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
barArrProm = Promise.map(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArr
|
||||
|
||||
barArrProm = Promise.map(fooThenArr, (item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArr, (item: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArr
|
||||
|
||||
barArrProm = Promise.map(fooArr, (item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooArr, (item: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// reduce()
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArrThen
|
||||
|
||||
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArrThen
|
||||
|
||||
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArr
|
||||
|
||||
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArr
|
||||
|
||||
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return memo;
|
||||
}, bar);
|
||||
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
|
||||
return barThen;
|
||||
}, bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// filter()
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArrThen
|
||||
|
||||
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo) => {
|
||||
return boolThen;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return boolThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArrThen
|
||||
|
||||
fooArrProm = Promise.filter(fooArrThen, (item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArrThen, (item: Foo) => {
|
||||
return boolThen;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
|
||||
return boolThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooThenArr
|
||||
|
||||
fooArrProm = Promise.filter(fooThenArr, (item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArr, (item: Foo) => {
|
||||
return boolThen;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return boolThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooArr
|
||||
|
||||
fooArrProm = Promise.filter(fooArr, (item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArr, (item: Foo) => {
|
||||
return boolThen;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: number) => {
|
||||
return boolThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Vendored
+670
@@ -0,0 +1,670 @@
|
||||
// Type definitions for bluebird 1.0.0
|
||||
// Project: https://github.com/petkaantonov/bluebird
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts
|
||||
// By: Campredon <https://github.com/fdecampredon/>
|
||||
|
||||
// Warning: recommended to use `tsc > v0.9.7` (critical bugs in earlier generic code):
|
||||
// - https://github.com/borisyankov/DefinitelyTyped/issues/1563
|
||||
|
||||
// Note: replicate changes to all overloads in both definition and test file
|
||||
// Note: keep both static and instance members inline (so similar)
|
||||
|
||||
// TODO fix remaining TODO annotations in both definition and test
|
||||
|
||||
// TODO verify support to have no return statement in handlers to get a Promise<void> (more overloads?)
|
||||
|
||||
declare class Promise<R> implements Promise.Thenable<R> {
|
||||
/**
|
||||
* Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
|
||||
*/
|
||||
constructor(callback: (resolve: (thenable: Promise.Thenable<R>) => void, reject: (error: any) => void) => void);
|
||||
constructor(callback: (resolve: (result: R) => void, reject: (error: any) => void) => void);
|
||||
|
||||
/**
|
||||
* Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
|
||||
*/
|
||||
then<U>(onFulfill: (value: R) => Promise.Thenable<U>, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill: (value: R) => Promise.Thenable<U>, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill: (value: R) => U, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch<U>(onReject?: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
caught<U>(onReject?: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
|
||||
catch<U>(onReject?: (error: any) => U): Promise<U>;
|
||||
caught<U>(onReject?: (error: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
|
||||
*
|
||||
* This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
|
||||
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise<U>;
|
||||
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise<U>;
|
||||
|
||||
catch<U>(ErrorClass: Function, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
caught<U>(ErrorClass: Function, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
|
||||
catch<U>(ErrorClass: Function, onReject: (error: any) => U): Promise<U>;
|
||||
caught<U>(ErrorClass: Function, onReject: (error: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
|
||||
*/
|
||||
error<U>(onReject: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
error<U>(onReject: (reason: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
|
||||
*
|
||||
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
finally(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
|
||||
finally(handler: (value: R) => R): Promise<R>;
|
||||
finally(handler: (value: R) => void): Promise<R>;
|
||||
|
||||
lastly(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
|
||||
lastly(handler: (value: R) => R): Promise<R>;
|
||||
lastly(handler: (value: R) => void): Promise<R>;
|
||||
|
||||
/**
|
||||
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
|
||||
*/
|
||||
bind(thisArg: any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
|
||||
*/
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
|
||||
*/
|
||||
progressed(handler: (note: any) => any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
delay(ms: number): Promise<R>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
|
||||
*
|
||||
* You may specify a custom error message with the `message` parameter.
|
||||
*/
|
||||
timeout(ms: number, message?: string): Promise<R>;
|
||||
|
||||
/**
|
||||
* Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
|
||||
* Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
|
||||
*/
|
||||
nodeify(callback: (err: any, value?: R) => void): Promise<R>;
|
||||
nodeify(...sink: any[]): void;
|
||||
|
||||
/**
|
||||
* Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
|
||||
*/
|
||||
cancellable(): Promise<R>;
|
||||
|
||||
/**
|
||||
* Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending.
|
||||
*
|
||||
* That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason.
|
||||
*
|
||||
* In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`.
|
||||
*
|
||||
* Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable.
|
||||
*/
|
||||
// TODO what to do with this?
|
||||
cancel<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors.
|
||||
*/
|
||||
fork<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
fork<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
fork<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
fork<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Create an uncancellable promise based on this promise.
|
||||
*/
|
||||
uncancellable(): Promise<R>;
|
||||
|
||||
/**
|
||||
* See if this promise can be cancelled.
|
||||
*/
|
||||
isCancellable(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` has been fulfilled.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` has been rejected.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` is still defer.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` is resolved -> either fulfilled or rejected.
|
||||
*/
|
||||
isResolved(): boolean;
|
||||
|
||||
/**
|
||||
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
|
||||
*/
|
||||
inspect(): Promise.Inspection<R>;
|
||||
|
||||
/**
|
||||
* This is a convenience method for doing:
|
||||
*
|
||||
* <code>
|
||||
* promise.then(function(obj){
|
||||
* return obj[propertyName].call(obj, arg...);
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
call(propertyName: string, ...args: any[]): Promise<any>;
|
||||
|
||||
/**
|
||||
* This is a convenience method for doing:
|
||||
*
|
||||
* <code>
|
||||
* promise.then(function(obj){
|
||||
* return obj[propertyName];
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
// TODO find way to fix get()
|
||||
// get<U>(propertyName: string): Promise<U>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .then(function() {
|
||||
* return value;
|
||||
* });
|
||||
* </code>
|
||||
*
|
||||
* in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()`
|
||||
*
|
||||
* Alias `.thenReturn();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
return(): Promise<any>;
|
||||
thenReturn(): Promise<any>;
|
||||
return<U>(value: U): Promise<U>;
|
||||
thenReturn<U>(value: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .then(function() {
|
||||
* throw reason;
|
||||
* });
|
||||
* </code>
|
||||
* Same limitations apply as with `.return()`.
|
||||
*
|
||||
* Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
throw(reason: Error): Promise<R>;
|
||||
thenThrow(reason: Error): Promise<R>;
|
||||
|
||||
/**
|
||||
* Convert to String.
|
||||
*/
|
||||
toString(): string;
|
||||
|
||||
/**
|
||||
* This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
|
||||
*/
|
||||
toJSON(): Object;
|
||||
|
||||
/**
|
||||
* Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
|
||||
*/
|
||||
// TODO how to model instance.spread()? like Q?
|
||||
spread<U>(onFulfill: Function, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
spread<U>(onFulfill: Function, onReject?: (reason: any) => U): Promise<U>;
|
||||
/*
|
||||
// TODO or something like this?
|
||||
spread<U, W>(onFulfill: (...values: W[]) => Promise.Thenable<U>, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => Promise.Thenable<U>, onReject?: (reason: any) => U): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise<U>;
|
||||
*/
|
||||
/**
|
||||
* Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
all<U>(): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO how to model instance.props()?
|
||||
props(): Promise<Object>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
settle<U>(): Promise<Promise.Inspection<U>[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
any<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
some<U>(count: number): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
race<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<U[]>;
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
|
||||
*
|
||||
* Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call.
|
||||
*
|
||||
* Alias for `attempt();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
static try<R>(fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
|
||||
static try<R>(fn: () => R, args?: any[], ctx?: any): Promise<R>;
|
||||
|
||||
static attempt<R>(fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
|
||||
static attempt<R>(fn: () => R, args?: any[], ctx?: any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
|
||||
* This method is convenient when a function can sometimes return synchronously or throw synchronously.
|
||||
*/
|
||||
static method(fn: Function): Function;
|
||||
|
||||
/**
|
||||
* Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
|
||||
*/
|
||||
static resolve(): Promise<void>;
|
||||
static resolve<R>(value: Promise.Thenable<R>): Promise<R>;
|
||||
static resolve<R>(value: R): Promise<R>;
|
||||
|
||||
/**
|
||||
* Create a promise that is rejected with the given `reason`.
|
||||
*/
|
||||
static reject(reason: any): Promise<any>;
|
||||
static reject<R>(reason: any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution).
|
||||
*/
|
||||
static defer<R>(): Promise.Resolver<R>;
|
||||
|
||||
/**
|
||||
* Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable.
|
||||
*/
|
||||
static cast<R>(value: Promise.Thenable<R>): Promise<R>;
|
||||
static cast<R>(value: R): Promise<R>;
|
||||
|
||||
/**
|
||||
* Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`.
|
||||
*/
|
||||
static bind(thisArg: any): Promise<void>;
|
||||
|
||||
/**
|
||||
* See if `value` is a trusted Promise.
|
||||
*/
|
||||
static is(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
|
||||
*/
|
||||
static longStackTraces(): void;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise.
|
||||
*/
|
||||
// TODO enable more overloads
|
||||
static delay<R>(value: Promise.Thenable<R>, ms: number): Promise<R>;
|
||||
static delay<R>(value: R, ms: number): Promise<R>;
|
||||
static delay(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.
|
||||
*
|
||||
* If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them.
|
||||
*
|
||||
* If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
|
||||
*/
|
||||
// TODO how to model promisify?
|
||||
static promisify(nodeFunction: Function, receiver?: any): Function;
|
||||
|
||||
/**
|
||||
* Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
|
||||
*
|
||||
* Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
|
||||
*/
|
||||
// TODO how to model promisifyAll?
|
||||
static promisifyAll(target: Object): Object;
|
||||
|
||||
/**
|
||||
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
|
||||
*/
|
||||
// TODO fix coroutine GeneratorFunction
|
||||
static coroutine<R>(generatorFunction: Function): Function;
|
||||
|
||||
/**
|
||||
* Spawn a coroutine which may yield promises to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
|
||||
*/
|
||||
// TODO fix spawn GeneratorFunction
|
||||
static spawn<R>(generatorFunction: Function): Promise<R>;
|
||||
|
||||
/**
|
||||
* This is relevant to browser environments with no module loader.
|
||||
*
|
||||
* Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else.
|
||||
*/
|
||||
static noConflict(): typeof Promise;
|
||||
|
||||
/**
|
||||
* Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
|
||||
*
|
||||
* Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.
|
||||
*/
|
||||
static onPossiblyUnhandledRejection(handler: (reason: any) => any): void;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.
|
||||
*/
|
||||
// TODO enable more overloads
|
||||
// promise of array with promises of value
|
||||
static all<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R[]>;
|
||||
// promise of array with values
|
||||
static all<R>(values: Promise.Thenable<R[]>): Promise<R[]>;
|
||||
// array with promises of value
|
||||
static all<R>(values: Promise.Thenable<R>[]): Promise<R[]>;
|
||||
// array with values
|
||||
static all<R>(values: R[]): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
|
||||
*
|
||||
* If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
|
||||
*
|
||||
* *The original object is not modified.*
|
||||
*/
|
||||
// TODO verify this is correct
|
||||
// trusted promise for object
|
||||
static props(object: Promise<Object>): Promise<Object>;
|
||||
// object
|
||||
static props(object: Object): Promise<Object>;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array.
|
||||
*
|
||||
* *original: The array is not modified. The input array sparsity is retained in the resulting array.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static settle<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<Promise.Inspection<R>[]>;
|
||||
// promise of array with values
|
||||
static settle<R>(values: Promise.Thenable<R[]>): Promise<Promise.Inspection<R>[]>;
|
||||
// array with promises of value
|
||||
static settle<R>(values: Promise.Thenable<R>[]): Promise<Promise.Inspection<R>[]>;
|
||||
// array with values
|
||||
static settle<R>(values: R[]): Promise<Promise.Inspection<R>[]>;
|
||||
|
||||
/**
|
||||
* Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static any<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
|
||||
// promise of array with values
|
||||
static any<R>(values: Promise.Thenable<R[]>): Promise<R>;
|
||||
// array with promises of value
|
||||
static any<R>(values: Promise.Thenable<R>[]): Promise<R>;
|
||||
// array with values
|
||||
static any<R>(values: R[]): Promise<R>;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
|
||||
*
|
||||
* **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static race<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
|
||||
// promise of array with values
|
||||
static race<R>(values: Promise.Thenable<R[]>): Promise<R>;
|
||||
// array with promises of value
|
||||
static race<R>(values: Promise.Thenable<R>[]): Promise<R>;
|
||||
// array with values
|
||||
static race<R>(values: R[]): Promise<R>;
|
||||
|
||||
/**
|
||||
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
|
||||
*
|
||||
* If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static some<R>(values: Promise.Thenable<Promise.Thenable<R>[]>, count: number): Promise<R[]>;
|
||||
// promise of array with values
|
||||
static some<R>(values: Promise.Thenable<R[]>, count: number): Promise<R[]>;
|
||||
// array with promises of value
|
||||
static some<R>(values: Promise.Thenable<R>[], count: number): Promise<R[]>;
|
||||
// array with values
|
||||
static some<R>(values: R[], count: number): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments.
|
||||
*/
|
||||
// variadic array with promises of value
|
||||
static join<R>(...values: Promise.Thenable<R>[]): Promise<R[]>;
|
||||
// variadic array with values
|
||||
static join<R>(...values: R[]): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static map<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
// promise of array with values
|
||||
static map<R, U>(values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
// array with promises of value
|
||||
static map<R, U>(values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
// array with values
|
||||
static map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
static map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
|
||||
*
|
||||
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static reduce<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
// promise of array with values
|
||||
static reduce<R, U>(values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
// array with promises of value
|
||||
static reduce<R, U>(values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
// array with values
|
||||
static reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
static reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.
|
||||
*
|
||||
* *The original array is not modified.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
static filter<R>(values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
|
||||
// promise of array with values
|
||||
static filter<R>(values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
|
||||
// array with promises of value
|
||||
static filter<R>(values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
|
||||
// array with values
|
||||
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
|
||||
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
}
|
||||
|
||||
declare module Promise {
|
||||
export interface RangeError extends Error {
|
||||
}
|
||||
export interface CancellationError extends Error {
|
||||
}
|
||||
export interface TimeoutError extends Error {
|
||||
}
|
||||
export interface TypeError extends Error {
|
||||
}
|
||||
export interface RejectionError extends Error {
|
||||
}
|
||||
|
||||
export interface Thenable<R> {
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>;
|
||||
then<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable<U>;
|
||||
}
|
||||
|
||||
export interface Resolver<R> {
|
||||
/**
|
||||
* Returns a reference to the controlled promise that can be passed to clients.
|
||||
*/
|
||||
promise: Promise<R>;
|
||||
|
||||
/**
|
||||
* Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state.
|
||||
*/
|
||||
resolve(value: R): void;
|
||||
resolve(): void;
|
||||
|
||||
/**
|
||||
* Reject the underlying promise with `reason` as the rejection reason.
|
||||
*/
|
||||
reject(reason: any): void;
|
||||
|
||||
/**
|
||||
* Progress the underlying promise with `value` as the progression value.
|
||||
*/
|
||||
progress(value: any): void;
|
||||
|
||||
/**
|
||||
* Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
|
||||
*
|
||||
* If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values.
|
||||
*/
|
||||
// TODO specify resolver callback
|
||||
callback: (err: any, value: R, ...values: R[]) => void;
|
||||
}
|
||||
|
||||
export interface Inspection<R> {
|
||||
/**
|
||||
* See if the underlying promise was fulfilled at the creation time of this inspection object.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* See if the underlying promise was rejected at the creation time of this inspection object.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* See if the underlying promise was defer at the creation time of this inspection object.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
/**
|
||||
* Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
value(): R;
|
||||
|
||||
/**
|
||||
* Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
error(): any;
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'bluebird' {
|
||||
export = Promise;
|
||||
}
|
||||
+48
-33
@@ -20,6 +20,7 @@ var exp: RegExp;
|
||||
var anyArr: any[];
|
||||
var strArr: string[];
|
||||
var numArr: number[];
|
||||
var voidVar: void;
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -199,7 +200,7 @@ bool = fooInspection.isPending();
|
||||
|
||||
foo = fooInspection.value();
|
||||
|
||||
x = fooInspection.error();
|
||||
x = fooInspection.reason();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -244,9 +245,15 @@ barProm = fooProm.caught((reason: any) => {
|
||||
barProm = fooProm.catch(Error, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.catch(Promise.CancellationError, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.caught(Error, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.caught(Promise.CancellationError, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -256,36 +263,28 @@ barProm = fooProm.error((reason: any) => {
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
return foo;
|
||||
});
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.finally((value: Foo) => {
|
||||
// return is ignored
|
||||
fooProm = fooProm.finally(() => {
|
||||
// non-Thenable return is ignored
|
||||
return "foo";
|
||||
});
|
||||
fooProm = fooProm.finally(() => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.finally(() => {
|
||||
// non-Thenable return is ignored
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
return foo;
|
||||
});
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.lastly((value: Foo) => {
|
||||
// return is ignored
|
||||
fooProm = fooProm.lastly(() => {
|
||||
// non-Thenable return is ignored
|
||||
return "foo";
|
||||
});
|
||||
fooProm = fooProm.lastly(() => {
|
||||
// return is ignored
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.lastly(() => {
|
||||
// non-Thenable return is ignored
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@@ -294,40 +293,56 @@ fooProm = fooProm.bind(obj);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
}, (reason: any) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
}, (note: any) => {
|
||||
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
}, (reason: any) => {
|
||||
return barThen;
|
||||
});
|
||||
barProm = fooProm.done((value: Foo) => {
|
||||
voidVar = fooProm.done((value: Foo) => {
|
||||
return barThen;
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.tap((value: Foo) => {
|
||||
// non-Thenable return is ignored
|
||||
return "foo";
|
||||
});
|
||||
fooProm = fooProm.tap((value: Foo) => {
|
||||
return fooThen;
|
||||
});
|
||||
fooProm = fooProm.tap((value: Foo) => {
|
||||
return voidThen;
|
||||
});
|
||||
fooProm = fooProm.tap(() => {
|
||||
// non-Thenable return is ignored
|
||||
});
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.progressed((note: any) => {
|
||||
@@ -477,10 +492,10 @@ barProm = fooProm.race<Bar>();
|
||||
|
||||
//TODO fix collection inference
|
||||
|
||||
barProm = fooProm.map<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
|
||||
barArrProm = fooProm.map<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
|
||||
return bar;
|
||||
});
|
||||
barProm = fooProm.map<Foo, Bar>((item: Foo) => {
|
||||
barArrProm = fooProm.map<Foo, Bar>((item: Foo) => {
|
||||
return bar;
|
||||
});
|
||||
|
||||
@@ -495,10 +510,10 @@ barProm = fooProm.reduce<Foo, Bar>((memo: Bar, item: Foo) => {
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fooProm = fooProm.filter<Foo>((item: Foo, index: number, arrayLength: number) => {
|
||||
fooArrProm = fooArrProm.filter<Foo>((item: Foo, index: number, arrayLength: number) => {
|
||||
return bool;
|
||||
});
|
||||
fooProm = fooProm.filter<Foo>((item: Foo) => {
|
||||
fooArrProm = fooArrProm.filter<Foo>((item: Foo) => {
|
||||
return bool;
|
||||
});
|
||||
|
||||
|
||||
Vendored
+57
-17
@@ -1,4 +1,4 @@
|
||||
// Type definitions for bluebird 1.0.0
|
||||
// Type definitions for bluebird 2.0.0
|
||||
// Project: https://github.com/petkaantonov/bluebird
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// TODO verify support to have no return statement in handlers to get a Promise<void> (more overloads?)
|
||||
|
||||
declare class Promise<R> implements Promise.Thenable<R> {
|
||||
declare class Promise<R> implements Promise.Thenable<R>, Promise.Inspection<R> {
|
||||
/**
|
||||
* Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
|
||||
*/
|
||||
@@ -72,13 +72,11 @@ declare class Promise<R> implements Promise.Thenable<R> {
|
||||
*
|
||||
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
finally(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
|
||||
finally(handler: (value: R) => R): Promise<R>;
|
||||
finally(handler: (value: R) => void): Promise<R>;
|
||||
finally<U>(handler: () => Promise.Thenable<U>): Promise<R>;
|
||||
finally<U>(handler: () => U): Promise<R>;
|
||||
|
||||
lastly(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
|
||||
lastly(handler: (value: R) => R): Promise<R>;
|
||||
lastly(handler: (value: R) => void): Promise<R>;
|
||||
lastly<U>(handler: () => Promise.Thenable<U>): Promise<R>;
|
||||
lastly<U>(handler: () => U): Promise<R>;
|
||||
|
||||
/**
|
||||
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
|
||||
@@ -88,10 +86,16 @@ declare class Promise<R> implements Promise.Thenable<R> {
|
||||
/**
|
||||
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
|
||||
*/
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): void;
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): void;
|
||||
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): void;
|
||||
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): void;
|
||||
|
||||
/**
|
||||
* Like `.finally()`, but not called for rejections.
|
||||
*/
|
||||
tap<U>(onFulFill: (value: R) => Promise.Thenable<U>): Promise<R>;
|
||||
tap<U>(onFulfill: (value: R) => U): Promise<R>;
|
||||
|
||||
/**
|
||||
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
|
||||
@@ -172,6 +176,20 @@ declare class Promise<R> implements Promise.Thenable<R> {
|
||||
*/
|
||||
isResolved(): boolean;
|
||||
|
||||
/**
|
||||
* Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
value(): R;
|
||||
|
||||
/**
|
||||
* Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
reason(): any;
|
||||
|
||||
/**
|
||||
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
|
||||
*/
|
||||
@@ -296,8 +314,8 @@ declare class Promise<R> implements Promise.Thenable<R> {
|
||||
* Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U>;
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U): Promise<U>;
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
@@ -310,8 +328,8 @@ declare class Promise<R> implements Promise.Thenable<R> {
|
||||
* Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<U>;
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean): Promise<U>;
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<U[]>;
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
|
||||
@@ -594,6 +612,20 @@ declare module Promise {
|
||||
}
|
||||
export interface RejectionError extends Error {
|
||||
}
|
||||
export interface OperationalError extends Error {
|
||||
}
|
||||
|
||||
// Ideally, we'd define e.g. "export class RangeError extends Error {}",
|
||||
// but as Error is defined as an interface (not a class), TypeScript doesn't
|
||||
// allow extending Error, only implementing it.
|
||||
// However, if we want to catch() only a specific error type, we need to pass
|
||||
// a constructor function to it. So, as a workaround, we define them here as such.
|
||||
export function RangeError(): RangeError;
|
||||
export function CancellationError(): CancellationError;
|
||||
export function TimeoutError(): TimeoutError;
|
||||
export function TypeError(): TypeError;
|
||||
export function RejectionError(): RejectionError;
|
||||
export function OperationalError(): OperationalError;
|
||||
|
||||
export interface Thenable<R> {
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
@@ -661,8 +693,16 @@ declare module Promise {
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
error(): any;
|
||||
reason(): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes how bluebird schedules calls a-synchronously.
|
||||
*
|
||||
* @param scheduler Should be a function that asynchronously schedules
|
||||
* the calling of the passed in function
|
||||
*/
|
||||
export function setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void;
|
||||
}
|
||||
|
||||
declare module 'bluebird' {
|
||||
|
||||
+52
-49
@@ -2,73 +2,76 @@
|
||||
/// <reference path="bootbox.d.ts" />
|
||||
|
||||
bootbox.alert("Are we ok?");
|
||||
bootbox.alert("Are we ok with Test button?", "Test");
|
||||
bootbox.alert("Are we ok with callback?", function() {
|
||||
bootbox.alert("Are we ok with callback?", function () {
|
||||
console.log("Callback called!");
|
||||
});
|
||||
bootbox.alert("Are we ok with callback and custom button?", "Test", function() {
|
||||
console.log("Callback called!");
|
||||
bootbox.alert({
|
||||
message: "Are we ok with callback and custom button?",
|
||||
callback: function () {
|
||||
console.log("Callback called!");
|
||||
}
|
||||
});
|
||||
|
||||
bootbox.confirm("Click ok to pass test", function(result) {
|
||||
console.log(result);
|
||||
});
|
||||
bootbox.confirm("Click ok to pass test");
|
||||
|
||||
bootbox.confirm("Click cancel to pass test", function(result) {
|
||||
bootbox.confirm("Click cancel to pass test", function (result) {
|
||||
console.log(!result);
|
||||
});
|
||||
|
||||
bootbox.confirm("Click confirm to pass test", "Cancel?", "Confirm?", function(result) {
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
bootbox.confirm("Click cancel to pass test", "Cancel?", "Confirm?", function(result) {
|
||||
console.log(!result);
|
||||
bootbox.confirm({
|
||||
message: "Click confirm to pass test",
|
||||
callback: function (result) {
|
||||
console.log(result);
|
||||
}
|
||||
});
|
||||
|
||||
bootbox.prompt("Are we ok?");
|
||||
|
||||
bootbox.prompt("Enter 'ok' to pass test", function(result) {
|
||||
bootbox.prompt("Enter 'ok' to pass test", function (result) {
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
bootbox.prompt("Enter 'ok' to pass test", "Cancel?", "Confirm?", function(result) {
|
||||
console.log(result);
|
||||
bootbox.prompt({
|
||||
message: "Enter 'ok' to pass test", callback: function (result) {
|
||||
console.log(result);
|
||||
}
|
||||
});
|
||||
|
||||
bootbox.prompt("Keep default value and click ok", "Cancel?", "Confirm?", function(result) {
|
||||
console.log(result);
|
||||
}, "Test Value");
|
||||
|
||||
bootbox.dialog("Test Dialog");
|
||||
var handler = {
|
||||
label: "OK",
|
||||
class: "MyClass",
|
||||
|
||||
|
||||
bootbox.dialog("Test Dialog", function (result) {
|
||||
return result;
|
||||
});
|
||||
|
||||
bootbox.dialog({
|
||||
message: "Test Dialog",
|
||||
callback: function (result) { }
|
||||
});
|
||||
|
||||
var bdo: BootboxDialogOptions;
|
||||
var sampleButton: BootboxButton = {
|
||||
label: 'ButtonLabelToUse',
|
||||
callback: function () {
|
||||
console.log("Test Dialog");
|
||||
return 'callback of button click'
|
||||
},
|
||||
className: 'additionalButtonClassName'
|
||||
};
|
||||
|
||||
bdo = {
|
||||
message: '',
|
||||
className: 'callName',
|
||||
buttons: {
|
||||
'ButtonTextLabel': sampleButton
|
||||
}
|
||||
};
|
||||
|
||||
var option = {
|
||||
header: "header",
|
||||
headerCloseButton: true
|
||||
};
|
||||
bootbox.dialog(bdo);
|
||||
|
||||
bootbox.dialog("Test Dialog", handler);
|
||||
bootbox.dialog("Test Dialog", [handler], option);
|
||||
bootbox.setDefaults({
|
||||
locale: 'en_US',
|
||||
animate: false,
|
||||
backdrop: false,
|
||||
className: 'newClassName',
|
||||
closeButton: true,
|
||||
show: true
|
||||
})
|
||||
|
||||
bootbox.hideAll();
|
||||
bootbox.animate(false);
|
||||
bootbox.backdrop("backdrop");
|
||||
bootbox.classes("myClass");
|
||||
|
||||
var icons: BootboxIcons = {
|
||||
OK: "OK Icon",
|
||||
CANCEL: "Cancel Icon",
|
||||
CONFIRM: "Confirm Icon"
|
||||
};
|
||||
bootbox.setIcons(icons);
|
||||
|
||||
bootbox.setLocale("en");
|
||||
|
||||
bootbox.addLocale("klingon", { OK: "luq", CANCEL: "qIl", CONFIRM: "Confirm" });
|
||||
bootbox.hideAll();
|
||||
Vendored
+48
-33
@@ -1,48 +1,63 @@
|
||||
// Type definitions for Bootbox 3.0.0
|
||||
// Type definitions for Bootbox 4.0.0
|
||||
// Project: https://github.com/makeusabrew/bootbox
|
||||
// Definitions by: Vincent Bortone <https://github.com/vbortone/>
|
||||
// Definitions by: Vincent Bortone <https://github.com/vbortone/>, Kon Pik <https://github.com/konpikwastaken/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface BootboxLocale {
|
||||
OK: string;
|
||||
CANCEL: string;
|
||||
CONFIRM: string;
|
||||
|
||||
interface BootboxAlertOptions {
|
||||
message: string;
|
||||
callback?: () => any;
|
||||
}
|
||||
|
||||
interface BootboxIcons {
|
||||
OK: any;
|
||||
CANCEL: any;
|
||||
CONFIRM: any;
|
||||
interface BootboxConfirmOptions {
|
||||
message: string;
|
||||
callback?: (result: boolean) => any;
|
||||
}
|
||||
|
||||
interface BootboxHandler {
|
||||
label: string;
|
||||
class: string;
|
||||
callback: (result?: any) => void;
|
||||
interface BootboxPromptOptions {
|
||||
message: string;
|
||||
callback?: (result: string) => any;
|
||||
}
|
||||
|
||||
interface BootboxOption {
|
||||
header: string;
|
||||
headerCloseButton: boolean;
|
||||
interface BootboxButton {
|
||||
label?: string;
|
||||
className?: string;
|
||||
callback?: () => any;
|
||||
}
|
||||
|
||||
interface BootboxDialogOptions {
|
||||
message: any; // String | Element
|
||||
title?: any; // String | Element
|
||||
callback?: (result: boolean) => any;
|
||||
show?: boolean;
|
||||
onEscape?: () => any;
|
||||
backdrop?: boolean;
|
||||
closeButton?: boolean;
|
||||
animate?: boolean;
|
||||
className?: string;
|
||||
buttons?: Object; // complex object where each key is of type BootboxButton
|
||||
}
|
||||
|
||||
interface BootboxDefaultOptions {
|
||||
locale?: string;
|
||||
show?: boolean;
|
||||
backdrop?: boolean;
|
||||
closeButton?: boolean;
|
||||
animate?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
interface BootboxStatic {
|
||||
alert(message: string, callback: () => void): void;
|
||||
alert(message: string, customButtonText?: string, callback?: () => void): void;
|
||||
confirm(message: string, callback: (result: boolean) => void): void;
|
||||
confirm(message: string, cancelButtonText?: string, confirmButtonText?: string, callback?: (result: boolean) => void): void;
|
||||
prompt(message: string, callback: (result: string) => void, defaultValue?: string): void;
|
||||
prompt(message: string, cancelButtonText?: string, confirmButtonText?: string, callback?: (result: string) => void, defaultValue?: string): void;
|
||||
dialog(message: string, handlers: BootboxHandler[], options?: any): void;
|
||||
dialog(message: string, handler: BootboxHandler): void;
|
||||
dialog(message: string): void;
|
||||
alert(message: string, callback?: () => void): void;
|
||||
alert(options: BootboxAlertOptions): void;
|
||||
confirm(message: string, callback?: (result: boolean) => void): void;
|
||||
confirm(options: BootboxConfirmOptions): void;
|
||||
prompt(message: string, callback?: (result: string) => void): void;
|
||||
prompt(options: BootboxPromptOptions): void;
|
||||
dialog(message: string, callback?: (result: string) => void): void;
|
||||
dialog(options: BootboxDialogOptions): void;
|
||||
setDefaults(options: BootboxDefaultOptions): void;
|
||||
hideAll(): void;
|
||||
animate(shouldAnimate: boolean): void;
|
||||
backdrop(backdropValue: string): void;
|
||||
classes(customCssClasses: string): void;
|
||||
setIcons(icons: BootboxIcons): void;
|
||||
setLocale(localeName: string): void;
|
||||
addLocale(localeName: string, translations: BootboxLocale) : void;
|
||||
}
|
||||
|
||||
declare var bootbox : BootboxStatic;
|
||||
declare var bootbox: BootboxStatic;
|
||||
Vendored
+3
@@ -376,6 +376,7 @@ declare module breeze {
|
||||
clear(): void;
|
||||
createEmptyCopy(): EntityManager;
|
||||
createEntity(typeName: string, config?: {}, entityState?: EntityStateSymbol) : Entity;
|
||||
createEntity(typeName: string, config?: {}, entityState?: EntityStateSymbol, mergeStrategy?: StrategySymbol): Entity;
|
||||
createEntity(entityType: EntityType, config?: {}, entityState?: EntityStateSymbol): Entity;
|
||||
detachEntity(entity: Entity): boolean;
|
||||
executeQuery(query: string, callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): Q.Promise<QueryResult>;
|
||||
@@ -525,6 +526,7 @@ declare module breeze {
|
||||
where(property: string, operator: string, value: any): EntityQuery;
|
||||
where(property: string, operator: FilterQueryOpSymbol, value: any): EntityQuery;
|
||||
where(predicate: FilterQueryOpSymbol): EntityQuery;
|
||||
where(property: string, filterop: FilterQueryOpSymbol, property2: string, filterop2: FilterQueryOpSymbol,value:any): EntityQuery;
|
||||
withParameters(params: Object): EntityQuery;
|
||||
}
|
||||
|
||||
@@ -617,6 +619,7 @@ declare module breeze {
|
||||
LessThanOrEqual: FilterQueryOpSymbol;
|
||||
NotEquals: FilterQueryOpSymbol;
|
||||
StartsWith: FilterQueryOpSymbol;
|
||||
Any: FilterQueryOpSymbol;
|
||||
}
|
||||
var FilterQueryOp: FilterQueryOp;
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import browserify = require("browserify");
|
||||
import fs = require("fs");
|
||||
|
||||
var b = browserify();
|
||||
b.add('./browser/main.js');
|
||||
b.transform('deamdify');
|
||||
b.bundle().pipe(fs.createWriteStream('bundle.js'));
|
||||
/// <reference path="browserify.d.ts"/>
|
||||
|
||||
import browserify = require("browserify");
|
||||
import fs = require("fs");
|
||||
|
||||
var b: BrowserifyObject = browserify();
|
||||
b.add('./browser/main.js');
|
||||
b.transform('deamdify');
|
||||
b.bundle().pipe(fs.createWriteStream('bundle.js'));
|
||||
|
||||
var customBrowsify: Browserify = require("browserify");
|
||||
customBrowsify({entries: []});
|
||||
|
||||
Vendored
+41
-38
@@ -1,38 +1,41 @@
|
||||
// Type definitions for Browserify
|
||||
// Project: http://browserify.org/
|
||||
// Definitions by: Andrew Gaspar <https://github.com/AndrewGaspar/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
interface BrowserifyObject extends NodeJS.EventEmitter {
|
||||
add(file: string): BrowserifyObject;
|
||||
require(file: string, opts?: {
|
||||
expose: string;
|
||||
}): BrowserifyObject;
|
||||
bundle(opts?: {
|
||||
insertGlobals?: boolean;
|
||||
detectGlobals?: boolean;
|
||||
debug?: boolean;
|
||||
standalone?: string;
|
||||
insertGlobalVars?: any;
|
||||
}, cb?: (err: any, src: any) => void): NodeJS.ReadableStream;
|
||||
|
||||
external(file: string): BrowserifyObject;
|
||||
ignore(file: string): BrowserifyObject;
|
||||
transform(tr: string): BrowserifyObject;
|
||||
transform(tr: Function): BrowserifyObject;
|
||||
plugin(plugin: string, opts?: any): BrowserifyObject;
|
||||
plugin(plugin: Function, opts?: any): BrowserifyObject;
|
||||
}
|
||||
|
||||
declare module "browserify" {
|
||||
function browserify(): BrowserifyObject;
|
||||
function browserify(files: string[]): BrowserifyObject;
|
||||
function browserify(opts: {
|
||||
entries?: string[];
|
||||
noParse?: string[];
|
||||
}): BrowserifyObject;
|
||||
|
||||
export = browserify;
|
||||
}
|
||||
// Type definitions for Browserify
|
||||
// Project: http://browserify.org/
|
||||
// Definitions by: Andrew Gaspar <https://github.com/AndrewGaspar/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
interface BrowserifyObject extends NodeJS.EventEmitter {
|
||||
add(file:string): BrowserifyObject;
|
||||
require(file:string, opts?:{
|
||||
expose: string;
|
||||
}): BrowserifyObject;
|
||||
bundle(opts?:{
|
||||
insertGlobals?: boolean;
|
||||
detectGlobals?: boolean;
|
||||
debug?: boolean;
|
||||
standalone?: string;
|
||||
insertGlobalVars?: any;
|
||||
}, cb?:(err:any, src:any) => void): NodeJS.ReadableStream;
|
||||
|
||||
external(file:string): BrowserifyObject;
|
||||
ignore(file:string): BrowserifyObject;
|
||||
transform(tr:string): BrowserifyObject;
|
||||
transform(tr:Function): BrowserifyObject;
|
||||
plugin(plugin:string, opts?:any): BrowserifyObject;
|
||||
plugin(plugin:Function, opts?:any): BrowserifyObject;
|
||||
}
|
||||
|
||||
interface Browserify {
|
||||
(): BrowserifyObject;
|
||||
(files:string[]): BrowserifyObject;
|
||||
(opts:{
|
||||
entries?: string[];
|
||||
noParse?: string[];
|
||||
}): BrowserifyObject;
|
||||
}
|
||||
|
||||
declare module "browserify" {
|
||||
var browserify: Browserify;
|
||||
export = browserify;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for buffer-equal 1.0 0
|
||||
// Type definitions for buffer-equal 0.0.1
|
||||
// Project: https://github.com/substack/node-buffer-equal
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path="./bunyan-logentries.d.ts" />
|
||||
/// <reference path="../bunyan/bunyan.d.ts" />
|
||||
|
||||
import bunyan = require("bunyan");
|
||||
import bunyanLogentries = require("bunyan-logentries");
|
||||
|
||||
var logger: bunyan.Logger = bunyan.createLogger({
|
||||
name: "foobar",
|
||||
streams: [{
|
||||
level: "info",
|
||||
stream: bunyanLogentries.createStream({token: "foobar"}),
|
||||
type: "raw"
|
||||
}]
|
||||
});
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// Type definitions for node-bunyan-logentries v0.1.0
|
||||
// Project: https://github.com/nemtsov/node-bunyan-logentries
|
||||
// Definitions by: Aymeric Beaumet <http://aymericbeaumet.me>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../bunyan/bunyan.d.ts" />
|
||||
|
||||
declare module "bunyan-logentries" {
|
||||
import bunyan = require("bunyan");
|
||||
|
||||
interface StreamOptions {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export function createStream(options: StreamOptions): NodeJS.WritableStream;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/// <reference path="bunyan.d.ts" />
|
||||
|
||||
import bunyan = require('bunyan');
|
||||
|
||||
var ringBufferOptions:bunyan.RingBufferOptions = {
|
||||
limit: 100
|
||||
};
|
||||
var ringBuffer:bunyan.RingBuffer = new bunyan.RingBuffer(ringBufferOptions);
|
||||
ringBuffer.write("hello");
|
||||
ringBuffer.end();
|
||||
ringBuffer.destroy();
|
||||
ringBuffer.destroySoon();
|
||||
|
||||
var level:number;
|
||||
level = bunyan.resolveLevel("trace");
|
||||
level = bunyan.resolveLevel("debug");
|
||||
level = bunyan.resolveLevel("info");
|
||||
level = bunyan.resolveLevel("warn");
|
||||
level = bunyan.resolveLevel("error");
|
||||
level = bunyan.resolveLevel("fatal");
|
||||
level = bunyan.resolveLevel(bunyan.TRACE);
|
||||
level = bunyan.resolveLevel(bunyan.DEBUG);
|
||||
level = bunyan.resolveLevel(bunyan.INFO);
|
||||
level = bunyan.resolveLevel(bunyan.WARN);
|
||||
level = bunyan.resolveLevel(bunyan.ERROR);
|
||||
level = bunyan.resolveLevel(bunyan.FATAL);
|
||||
|
||||
var options:bunyan.LoggerOptions = {
|
||||
name: 'test-logger',
|
||||
streams: [{
|
||||
type: 'stream',
|
||||
stream: process.stdout,
|
||||
level: bunyan.TRACE
|
||||
}, {
|
||||
type: 'file',
|
||||
path: '/tmp/test.log',
|
||||
level: bunyan.DEBUG,
|
||||
closeOnExit: true
|
||||
}, {
|
||||
type: 'rotating-file',
|
||||
path: '/tmp/test2.log',
|
||||
level: bunyan.INFO,
|
||||
closeOnExit: false
|
||||
}, {
|
||||
type: 'raw',
|
||||
stream: process.stderr,
|
||||
level: bunyan.WARN
|
||||
}, {
|
||||
type: 'raw',
|
||||
stream: ringBuffer,
|
||||
level: bunyan.ERROR
|
||||
}]
|
||||
};
|
||||
|
||||
var log = bunyan.createLogger(options);
|
||||
|
||||
log.addSerializers(bunyan.stdSerializers);
|
||||
var child = log.child({name: 'child'});
|
||||
child.reopenFileStreams();
|
||||
log.addStream({path: '/dev/null', name: 'stream1'});
|
||||
child.level(bunyan.DEBUG);
|
||||
child.level('debug');
|
||||
child.levels(0, bunyan.ERROR);
|
||||
child.levels(0, 'error');
|
||||
child.levels('stream1', bunyan.FATAL);
|
||||
child.levels('stream1', 'fatal');
|
||||
|
||||
var buffer = new Buffer(0);
|
||||
var error = new Error('');
|
||||
var object = {
|
||||
test: 123
|
||||
};
|
||||
|
||||
log.trace(buffer);
|
||||
log.trace(error);
|
||||
log.trace(object);
|
||||
log.trace('Hello, %s', 'world!');
|
||||
log.debug(buffer);
|
||||
log.debug(error);
|
||||
log.debug(object);
|
||||
log.debug('Hello, %s', 'world!');
|
||||
log.info(buffer);
|
||||
log.info(error);
|
||||
log.info(object);
|
||||
log.info('Hello, %s', 'world!');
|
||||
log.warn(buffer);
|
||||
log.warn(error);
|
||||
log.warn(object);
|
||||
log.warn('Hello, %s', 'world!');
|
||||
log.error(buffer);
|
||||
log.error(error);
|
||||
log.error(object);
|
||||
log.error('Hello, %s', 'world!');
|
||||
log.fatal(buffer);
|
||||
log.fatal(error);
|
||||
log.fatal(object);
|
||||
log.fatal('Hello, %s', 'world!');
|
||||
|
||||
var recursive: any = {
|
||||
hello: 'world',
|
||||
whats: {
|
||||
huh: recursive
|
||||
}
|
||||
}
|
||||
|
||||
JSON.stringify(recursive, bunyan.safeCycles());
|
||||
Vendored
+101
@@ -0,0 +1,101 @@
|
||||
// Type definitions for node-bunyan
|
||||
// Project: https://github.com/trentm/node-bunyan
|
||||
// Definitions by: Alex Mikhalev <https://github.com/amikhalev>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "bunyan" {
|
||||
import events = require('events');
|
||||
import EventEmitter = events.EventEmitter;
|
||||
import WritableStream = NodeJS.WritableStream;
|
||||
|
||||
class Logger extends EventEmitter {
|
||||
constructor(options:LoggerOptions);
|
||||
addStream(stream:Stream):void;
|
||||
addSerializers(serializers:Serializers):void;
|
||||
child(options:LoggerOptions, simple?:boolean):Logger;
|
||||
child(obj:Object, simple?:boolean):Logger;
|
||||
reopenFileStreams():void;
|
||||
|
||||
level(value:any /* number | string */):void;
|
||||
levels(name:any /* number | string */, value:any /* number | string */):void;
|
||||
|
||||
trace(error:Error, format?:any, ...params:any[]):void;
|
||||
trace(buffer:Buffer, format?:any, ...params:any[]):void;
|
||||
trace(obj:Object, format?:any, ...params:any[]):void;
|
||||
trace(format:string, ...params:any[]):void;
|
||||
debug(error:Error, format?:any, ...params:any[]):void;
|
||||
debug(buffer:Buffer, format?:any, ...params:any[]):void;
|
||||
debug(obj:Object, format?:any, ...params:any[]):void;
|
||||
debug(format:string, ...params:any[]):void;
|
||||
info(error:Error, format?:any, ...params:any[]):void;
|
||||
info(buffer:Buffer, format?:any, ...params:any[]):void;
|
||||
info(obj:Object, format?:any, ...params:any[]):void;
|
||||
info(format:string, ...params:any[]):void;
|
||||
warn(error:Error, format?:any, ...params:any[]):void;
|
||||
warn(buffer:Buffer, format?:any, ...params:any[]):void;
|
||||
warn(obj:Object, format?:any, ...params:any[]):void;
|
||||
warn(format:string, ...params:any[]):void;
|
||||
error(error:Error, format?:any, ...params:any[]):void;
|
||||
error(buffer:Buffer, format?:any, ...params:any[]):void;
|
||||
error(obj:Object, format?:any, ...params:any[]):void;
|
||||
error(format:string, ...params:any[]):void;
|
||||
fatal(error:Error, format?:any, ...params:any[]):void;
|
||||
fatal(buffer:Buffer, format?:any, ...params:any[]):void;
|
||||
fatal(obj:Object, format?:any, ...params:any[]):void;
|
||||
fatal(format:string, ...params:any[]):void;
|
||||
}
|
||||
|
||||
interface LoggerOptions {
|
||||
name: string;
|
||||
streams?: Stream[];
|
||||
level?: string;
|
||||
stream?: WritableStream;
|
||||
serializers?: Serializers;
|
||||
src?: boolean;
|
||||
}
|
||||
|
||||
interface Serializers {
|
||||
[key:string]: (input:any) => string;
|
||||
}
|
||||
|
||||
interface Stream {
|
||||
type?: string;
|
||||
level?: any; // number | string
|
||||
path?: string;
|
||||
stream?: WritableStream;
|
||||
closeOnExit?: boolean;
|
||||
}
|
||||
|
||||
export var stdSerializers:Serializers;
|
||||
|
||||
export var TRACE:number;
|
||||
export var DEBUG:number;
|
||||
export var INFO:number;
|
||||
export var WARN:number;
|
||||
export var ERROR:number;
|
||||
export var FATAL:number;
|
||||
|
||||
export function resolveLevel(value:any /* number | string */):number;
|
||||
|
||||
export function createLogger(options:LoggerOptions):Logger;
|
||||
|
||||
class RingBuffer extends EventEmitter {
|
||||
constructor(options:RingBufferOptions);
|
||||
|
||||
writable:boolean;
|
||||
records:any[];
|
||||
|
||||
write(record:any):void;
|
||||
end(record?:any):void;
|
||||
destroy():void;
|
||||
destroySoon():void;
|
||||
}
|
||||
|
||||
interface RingBufferOptions {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export function safeCycles():(key:string, value:any) => any;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for business-rules-engine - v1.0.20
|
||||
// Type definitions for business-rules-engine v1.0.20
|
||||
// Project: https://github.com/rsamec/form
|
||||
// Definitions by: Roman Samec <https://github.com/rsamec>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
@@ -31,8 +31,8 @@ caml = new CamlBuilder().Where()
|
||||
)
|
||||
.ToString();
|
||||
|
||||
caml = new CamlBuilder().Where()
|
||||
.LookupIdField("Category").In([2, 3, 10])
|
||||
var caml = new CamlBuilder().Where()
|
||||
.LookupField("Category").Id().In([2, 3, 10])
|
||||
.And()
|
||||
.DateField("ExpirationDate").GreaterThan(CamlBuilder.CamlValues.Now)
|
||||
.OrderBy("ExpirationDate")
|
||||
|
||||
Vendored
+78
-58
@@ -4,48 +4,14 @@
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
declare module Sys {
|
||||
class StringBuilder {
|
||||
/** Appends a string to the string builder */
|
||||
public append(s: string): void;
|
||||
/** Appends a line to the string builder */
|
||||
public appendLine(s: string): void;
|
||||
/** Clears the contents of the string builder */
|
||||
public clear(): void;
|
||||
/** Indicates wherever the string builder is empty */
|
||||
public isEmpty(): boolean;
|
||||
/** Gets the contents of the string builder as a string */
|
||||
public toString(): string;
|
||||
}
|
||||
}
|
||||
declare module SP {
|
||||
/** Defines a writer that provides a set of methods to append text in XML format. Use the static SP.XmlWriter.create(sb) Method to create an SP.XmlWriter object with the Sys.StringBuilder object you pass in. */
|
||||
class XmlWriter {
|
||||
/** Creates a new instance of the XmlWriter class with the specified string builder. */
|
||||
static create(sb: Sys.StringBuilder): XmlWriter;
|
||||
/** Appends a start element tag with the specified name in XML format to the object?s string builder. */
|
||||
public writeStartElement(tagName: string): void;
|
||||
/** Appends an element with the specified tag name and value in XML format to the string builder. */
|
||||
public writeElementString(tagName: string, value: string): void;
|
||||
/** Appends an end element tag in XML format to the object?s string builder. This method appends the end element tag ?/>? if the start element tag is not closed; otherwise, it appends a full end element tag ?</tagName>? to the string builder. */
|
||||
public writeEndElement(): void;
|
||||
/** Appends an attribute with the specified name and value in XML format to the object?s string builder. */
|
||||
public writeAttributeString(localName: string, value: string): void;
|
||||
/** This method only appends the name of the attribute. You can append the value of the attribute by calling the SP.XmlWriter.writeString(value) Method, and close the attribute by calling the SP.XmlWriter.writeEndAttribute() Method. */
|
||||
public writeStartAttribute(localName: string): void;
|
||||
/** Appends an end of an attribute in XML format to the object?s string builder. */
|
||||
public writeEndAttribute(): void;
|
||||
/** Appends the specified value for an element tag or attribute to the object?s string builder. */
|
||||
public writeString(value: string): void;
|
||||
/** Appends the specified text to the object?s string builder. */
|
||||
public writeRaw(xml: string): void;
|
||||
/** This member is reserved for internal use and is not intended to be used directly from your code. */
|
||||
public close(): void;
|
||||
}
|
||||
}
|
||||
declare class CamlBuilder {
|
||||
constructor();
|
||||
/** Generate CAML Query, starting from <Where> tag */
|
||||
public Where(): CamlBuilder.IFieldExpression;
|
||||
/** Generate <View> tag for SP.CamlQuery
|
||||
@param viewFields If omitted, default view fields are requested; otherwise, only values for the fields with the specified internal names are returned.
|
||||
Specifying view fields is a good practice, as it decreases traffic between server and client. */
|
||||
public View(viewFields?: string[]): CamlBuilder.IView;
|
||||
/** Use for:
|
||||
1. SPServices CAMLQuery attribute
|
||||
2. Creating partial expressions
|
||||
@@ -54,8 +20,40 @@ declare class CamlBuilder {
|
||||
static Expression(): CamlBuilder.IFieldExpression;
|
||||
}
|
||||
declare module CamlBuilder {
|
||||
interface IView {
|
||||
interface IView extends IJoinable, IFinalizable {
|
||||
Query(): IQuery;
|
||||
RowLimit(limit: number, paged?: boolean): IView;
|
||||
Scope(scope: ViewScope): IView;
|
||||
}
|
||||
interface IJoinable {
|
||||
/** Join the list you're querying with another list.
|
||||
Joins are only allowed through a lookup field relation.
|
||||
@param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
|
||||
@alias alias for the joined list */
|
||||
InnerJoin(lookupFieldInternalName: string, alias: string): IJoin;
|
||||
/** Join the list you're querying with another list.
|
||||
Joins are only allowed through a lookup field relation.
|
||||
@param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
|
||||
@alias alias for the joined list */
|
||||
LeftJoin(lookupFieldInternalName: string, alias: string): IJoin;
|
||||
}
|
||||
interface IJoin extends IJoinable {
|
||||
/** Select projected field for using in the main Query body
|
||||
@param remoteFieldAlias By this alias, the field can be used in the main Query body. */
|
||||
Select(remoteFieldInternalName: string, remoteFieldAlias: string): IProjectableView;
|
||||
}
|
||||
interface IProjectableView extends IView {
|
||||
/** Select projected field for using in the main Query body
|
||||
@param remoteFieldAlias By this alias, the field can be used in the main Query body. */
|
||||
Select(remoteFieldInternalName: string, remoteFieldAlias: string): IProjectableView;
|
||||
}
|
||||
enum ViewScope {
|
||||
/** */
|
||||
Recursive = 0,
|
||||
/** */
|
||||
RecursiveAll = 1,
|
||||
/** */
|
||||
FilesOnly = 2,
|
||||
}
|
||||
interface IQuery {
|
||||
Where(): IFieldExpression;
|
||||
@@ -63,6 +61,8 @@ declare module CamlBuilder {
|
||||
interface IFinalizable {
|
||||
/** Get the resulting CAML query as string */
|
||||
ToString(): string;
|
||||
/** Get the resulting CAML query as SP.CamlQuery object */
|
||||
ToCamlQuery(): any;
|
||||
}
|
||||
interface ISortable extends IFinalizable {
|
||||
/** Adds OrderBy clause to the query
|
||||
@@ -81,7 +81,7 @@ declare module CamlBuilder {
|
||||
interface IGroupable extends ISortable {
|
||||
/** Adds GroupBy clause to the query.
|
||||
@param collapse If true, only information about the groups is retrieved, otherwise items are also retrieved. */
|
||||
GroupBy(fieldInternalName): IGroupedQuery;
|
||||
GroupBy(fieldInternalName: any): IGroupedQuery;
|
||||
}
|
||||
interface IExpression extends IGroupable {
|
||||
/** Adds And clause to the query. */
|
||||
@@ -122,12 +122,10 @@ declare module CamlBuilder {
|
||||
UserField(internalName: string): IUserFieldExpression;
|
||||
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Lookup */
|
||||
LookupField(internalName: string): ILookupFieldExpression;
|
||||
/** DEPRECATED. Please use LookupField(...).Id() instead */
|
||||
LookupIdField(internalName: string): INumberFieldExpression;
|
||||
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is LookupMulti */
|
||||
LookupMultiField(internalName: string): ILookupMultiFieldExpression;
|
||||
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is UserMulti */
|
||||
UserMultiField(internalName: string): ILookupMultiFieldExpression;
|
||||
UserMultiField(internalName: string): IUserMultiFieldExpression;
|
||||
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Date */
|
||||
DateField(internalName: string): IDateTimeFieldExpression;
|
||||
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is DateTime */
|
||||
@@ -289,30 +287,52 @@ declare module CamlBuilder {
|
||||
ValueAsBoolean(): IBooleanFieldExpression;
|
||||
}
|
||||
interface ILookupMultiFieldExpression {
|
||||
/** Checks whether the value of the field is equal to the specified value */
|
||||
EqualTo(value: string): IExpression;
|
||||
/** Checks whether the value of the field is not equal to the specified value */
|
||||
NotEqualTo(value: string): IExpression;
|
||||
/** Checks whether the values of the field includes the specified value */
|
||||
Includes(value): IExpression;
|
||||
/** Checks whether the values of the field not includes the specified value */
|
||||
NotIncludes(value): IExpression;
|
||||
/** Checks a condition against every item in the multi lookup value */
|
||||
IncludesSuchItemThat(): ILookupFieldExpression;
|
||||
/** Checks whether the field values collection is empty */
|
||||
IsNull(): IExpression;
|
||||
/** Checks whether the field values collection is not empty */
|
||||
IsNotNull(): IExpression;
|
||||
/** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().EqualTo(value)" instead. */
|
||||
Includes(value: any): IExpression;
|
||||
/** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().NotEqualTo(value)" instead. */
|
||||
NotIncludes(value: any): IExpression;
|
||||
/** DEPRECATED: "Eq" operation in CAML works exactly the same as "Includes". To avoid confusion, please use Includes. */
|
||||
EqualTo(value: any): IExpression;
|
||||
/** DEPRECATED: "Neq" operation in CAML works exactly the same as "NotIncludes". To avoid confusion, please use NotIncludes. */
|
||||
NotEqualTo(value: any): IExpression;
|
||||
}
|
||||
interface IUserMultiFieldExpression {
|
||||
/** Checks a condition against every item in the multi lookup value */
|
||||
IncludesSuchItemThat(): IUserFieldExpression;
|
||||
/** Checks whether the field values collection is empty */
|
||||
IsNull(): IExpression;
|
||||
/** Checks whether the field values collection is not empty */
|
||||
IsNotNull(): IExpression;
|
||||
/** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().EqualTo(value)" instead. */
|
||||
Includes(value: any): IExpression;
|
||||
/** DEPRECATED: use "IncludesSuchItemThat().ValueAsText().NotEqualTo(value)" instead. */
|
||||
NotIncludes(value: any): IExpression;
|
||||
/** DEPRECATED: "Eq" operation in CAML works exactly the same as "Includes". To avoid confusion, please use Includes. */
|
||||
EqualTo(value: any): IExpression;
|
||||
/** DEPRECATED: "Neq" operation in CAML works exactly the same as "NotIncludes". To avoid confusion, please use NotIncludes. */
|
||||
NotEqualTo(value: any): IExpression;
|
||||
}
|
||||
enum DateRangesOverlapType {
|
||||
/** Returns events for today */
|
||||
Now,
|
||||
Now = 0,
|
||||
/** Returns events for one day, specified by CalendarDate in QueryOptions */
|
||||
Day,
|
||||
Day = 1,
|
||||
/** Returns events for one week, specified by CalendarDate in QueryOptions */
|
||||
Week,
|
||||
Week = 2,
|
||||
/** Returns events for one month, specified by CalendarDate in QueryOptions.
|
||||
Caution: usually also returns few days from previous and next months */
|
||||
Month,
|
||||
Month = 3,
|
||||
/** Returns events for one year, specified by CalendarDate in QueryOptions */
|
||||
Year,
|
||||
Year = 4,
|
||||
}
|
||||
class Internal {
|
||||
static createView(): IView;
|
||||
static createView(viewFields?: string[]): IView;
|
||||
static createWhere(): IFieldExpression;
|
||||
static createExpression(): IFieldExpression;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,248 @@
|
||||
/// <reference path="canvasjs.d.ts" />
|
||||
|
||||
module CanvasJS.Tests {
|
||||
// Column Chart
|
||||
var columnChart = new CanvasJS.Chart("chartContainer",
|
||||
{
|
||||
title: {
|
||||
text: "Top Oil Reserves",
|
||||
},
|
||||
axisY: {
|
||||
title: "Reserves(MMbbl)"
|
||||
},
|
||||
legend: {
|
||||
verticalAlign: "bottom",
|
||||
horizontalAlign: "center"
|
||||
},
|
||||
theme: "theme2",
|
||||
data: [
|
||||
{
|
||||
type: "column",
|
||||
showInLegend: true,
|
||||
legendMarkerColor: "grey",
|
||||
legendText: "MMbbl = one million barrels",
|
||||
dataPoints: [
|
||||
{ y: 297571, label: "Venezuela" },
|
||||
{ y: 267017, label: "Saudi" },
|
||||
{ y: 175200, label: "Canada" },
|
||||
{ y: 154580, label: "Iran" },
|
||||
{ y: 116000, label: "Russia" },
|
||||
{ y: 97800, label: "UAE" },
|
||||
{ y: 20682, label: "US" },
|
||||
{ y: 20350, label: "China" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
columnChart.render();
|
||||
|
||||
// Line Chart
|
||||
var lineChart = new CanvasJS.Chart("chartContainer",
|
||||
{
|
||||
theme: "theme2",
|
||||
title: {
|
||||
text: "Earthquakes - per month"
|
||||
},
|
||||
axisX: {
|
||||
valueFormatString: "MMM",
|
||||
interval: 1,
|
||||
intervalType: "month"
|
||||
|
||||
},
|
||||
axisY: {
|
||||
includeZero: false
|
||||
|
||||
},
|
||||
data: [
|
||||
{
|
||||
type: "line",
|
||||
//lineThickness: 3,
|
||||
dataPoints: [
|
||||
{ x: new Date(2012, 0, 1), y: 450 },
|
||||
{ x: new Date(2012, 1, 1), y: 414 },
|
||||
{ x: new Date(2012, 2, 1), y: 520, indexLabel: "highest", markerColor: "red", markerType: "triangle" },
|
||||
{ x: new Date(2012, 3, 1), y: 460 },
|
||||
{ x: new Date(2012, 4, 1), y: 450 },
|
||||
{ x: new Date(2012, 5, 1), y: 500 },
|
||||
{ x: new Date(2012, 6, 1), y: 480 },
|
||||
{ x: new Date(2012, 7, 1), y: 480 },
|
||||
{ x: new Date(2012, 8, 1), y: 410, indexLabel: "lowest", markerColor: "DarkSlateGrey", markerType: "cross" },
|
||||
{ x: new Date(2012, 9, 1), y: 500 },
|
||||
{ x: new Date(2012, 10, 1), y: 480 },
|
||||
{ x: new Date(2012, 11, 1), y: 510 }
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
});
|
||||
lineChart.render();
|
||||
|
||||
// Spline Chart
|
||||
var splineChart = new CanvasJS.Chart("chartContainer",
|
||||
{
|
||||
theme: "theme2",
|
||||
title: {
|
||||
text: "Game of Thrones, Viewers of the first airing on HBO"
|
||||
},
|
||||
axisY: {
|
||||
includeZero: false,
|
||||
// suffix: " k",
|
||||
valueFormatString: "#,,.",
|
||||
suffix: " mn"
|
||||
},
|
||||
toolTip: {
|
||||
shared: true
|
||||
},
|
||||
data: [
|
||||
{
|
||||
type: "spline",
|
||||
showInLegend: true,
|
||||
name: "Season 2",
|
||||
// markerSize: 0,
|
||||
// color: "rgba(54,158,173,.6)",
|
||||
dataPoints: [
|
||||
{ label: "Ep. 1", y: 3858000 },
|
||||
{ label: "Ep. 2", y: 3759000 },
|
||||
{ label: "Ep. 3", y: 3766000 },
|
||||
{ label: "Ep. 4", y: 3654000 },
|
||||
{ label: "Ep. 5", y: 3903000 },
|
||||
{ label: "Ep. 6", y: 3879000 },
|
||||
{ label: "Ep. 7", y: 3694000 },
|
||||
{ label: "Ep. 8", y: 3864000 },
|
||||
{ label: "Ep. 9", y: 3384000 },
|
||||
{ label: "Ep. 10", y: 4200000 }
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "spline",
|
||||
showInLegend: true,
|
||||
// markerSize: 0,
|
||||
name: "Season 1",
|
||||
dataPoints: [
|
||||
{ label: "Ep. 1", y: 2220000 },
|
||||
{ label: "Ep. 2", y: 2200000 },
|
||||
{ label: "Ep. 3", y: 2440000 },
|
||||
{ label: "Ep. 4", y: 2450000 },
|
||||
{ label: "Ep. 5", y: 2580000 },
|
||||
{ label: "Ep. 6", y: 2440000 },
|
||||
{ label: "Ep. 7", y: 2400000 },
|
||||
{ label: "Ep. 8", y: 2720000 },
|
||||
{ label: "Ep. 9", y: 2660000 },
|
||||
{ label: "Ep. 10", y: 3040000 }
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
legend: {
|
||||
cursor: "pointer",
|
||||
itemclick: function (e) {
|
||||
if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
|
||||
e.dataSeries.visible = false;
|
||||
}
|
||||
else {
|
||||
e.dataSeries.visible = true;
|
||||
}
|
||||
splineChart.render();
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
splineChart.render();
|
||||
|
||||
// Bar Chart
|
||||
var barChart = new CanvasJS.Chart("chartContainer", {
|
||||
|
||||
title: {
|
||||
text: "Fortune Global 500 Companies by Country"
|
||||
},
|
||||
axisX: {
|
||||
interval: 1,
|
||||
gridThickness: 0,
|
||||
labelFontSize: 10,
|
||||
labelFontStyle: "normal",
|
||||
labelFontWeight: "normal",
|
||||
labelFontFamily: "Lucida Sans Unicode"
|
||||
},
|
||||
axisY: {
|
||||
interlacedColor: "rgba(1,77,101,.2)",
|
||||
gridColor: "rgba(1,77,101,.1)"
|
||||
},
|
||||
data: [
|
||||
{
|
||||
type: "bar",
|
||||
name: "companies",
|
||||
axisYType: "secondary",
|
||||
color: "#014D65",
|
||||
dataPoints: [
|
||||
{ y: 5, label: "Sweden" },
|
||||
{ y: 6, label: "Taiwan" },
|
||||
{ y: 7, label: "Russia" },
|
||||
{ y: 8, label: "Spain" },
|
||||
{ y: 8, label: "Brazil" },
|
||||
{ y: 8, label: "India" },
|
||||
{ y: 9, label: "Italy" },
|
||||
{ y: 9, label: "Australia" },
|
||||
{ y: 12, label: "Canada" },
|
||||
{ y: 13, label: "South Korea" },
|
||||
{ y: 13, label: "Netherlands" },
|
||||
{ y: 15, label: "Switzerland" },
|
||||
{ y: 28, label: "Britain" },
|
||||
{ y: 32, label: "Germany" },
|
||||
{ y: 32, label: "France" },
|
||||
{ y: 68, label: "Japan" },
|
||||
{ y: 73, label: "China" },
|
||||
{ y: 132, label: "US" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
barChart.render();
|
||||
|
||||
// Pie Chart
|
||||
var pieChart = new CanvasJS.Chart("chartContainer",
|
||||
{
|
||||
title: {
|
||||
text: "Desktop Search Engine Market Share, Dec-2012"
|
||||
},
|
||||
legend: {
|
||||
verticalAlign: "center",
|
||||
horizontalAlign: "left",
|
||||
fontSize: 20,
|
||||
fontFamily: "Helvetica"
|
||||
},
|
||||
theme: "theme2",
|
||||
data: [
|
||||
{
|
||||
type: "pie",
|
||||
indexLabelFontFamily: "Garamond",
|
||||
indexLabelFontSize: 20,
|
||||
indexLabel: "{label} {y}%",
|
||||
startAngle: -20,
|
||||
showInLegend: true,
|
||||
toolTipContent: "{legendText} {y}%",
|
||||
dataPoints: [
|
||||
{ y: 83.24, legendText: "Google", label: "Google" },
|
||||
{ y: 8.16, legendText: "Yahoo!", label: "Yahoo!" },
|
||||
{ y: 4.67, legendText: "Bing", label: "Bing" },
|
||||
{ y: 1.67, legendText: "Baidu", label: "Baidu" },
|
||||
{ y: 0.98, legendText: "Others", label: "Others" }
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
pieChart.render();
|
||||
|
||||
addColorSet("MyColorSet", [
|
||||
"123456",
|
||||
"blue",
|
||||
"red",
|
||||
"orange"
|
||||
]);
|
||||
|
||||
addCultureInfo("js", {
|
||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
|
||||
});
|
||||
}
|
||||
Vendored
+959
@@ -0,0 +1,959 @@
|
||||
// Type definitions for CanvasJS v1.5.1
|
||||
// Project: http://canvasjs.com/
|
||||
// Definitions by: Mark Overholt <https://github.com/mover5>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module CanvasJS {
|
||||
class Chart {
|
||||
|
||||
/**
|
||||
* The current options of the chart.
|
||||
*/
|
||||
options: ChartOptions;
|
||||
|
||||
/**
|
||||
* Initializes a new instance of CanvasJS Chart.
|
||||
* @param containerId the DOM ID of the location where the chart is to be rendered
|
||||
* @param options the options used to render the chart
|
||||
*/
|
||||
constructor(containerId: string, options?: ChartOptions);
|
||||
|
||||
/**
|
||||
* Renders the chart.
|
||||
* @param options an optional set of options that will override the constructed values.
|
||||
*/
|
||||
render(options?: ChartOptions): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new chart color set
|
||||
* @param the name of the color set
|
||||
* @param an array of colors.
|
||||
*/
|
||||
function addColorSet(colorSetName: string, colorSetArray: string[]): void;
|
||||
|
||||
|
||||
/**
|
||||
* Adds a new culture info for your chart
|
||||
* @param culture the name of the culture
|
||||
* @param the information used by this culture
|
||||
*/
|
||||
function addCultureInfo(culture: string, info: CultureInfo): void;
|
||||
|
||||
interface CultureInfo {
|
||||
/**
|
||||
* Character used to separate fractional part from the whole number.
|
||||
*/
|
||||
decimalSeparator?: string;
|
||||
/**
|
||||
* Also referred to as Thousand Separator
|
||||
*/
|
||||
digitGroupSeparator?: string;
|
||||
/**
|
||||
* Text is shown inside the Button till v1.4
|
||||
* v1.5 onwards Text is shown as tooltip.
|
||||
*/
|
||||
zoomText?: string;
|
||||
/**
|
||||
* Text is shown inside the Button till v1.4
|
||||
* v1.5 onwards Text is shown as tooltip.
|
||||
*/
|
||||
panText?: string;
|
||||
/**
|
||||
* Text is shown inside the Button till v1.4
|
||||
* v1.5 onwards Text is shown as tooltip.
|
||||
*/
|
||||
resetText?: string;
|
||||
/**
|
||||
* Set text is shown instead of Save as PNG.
|
||||
*/
|
||||
savePNGText?: string;
|
||||
/**
|
||||
* Set text is shown instead of Save as JPG.
|
||||
*/
|
||||
saveJPGText?: string;
|
||||
/**
|
||||
* Tool Tip for Menu Button.
|
||||
*/
|
||||
menuText?: string;
|
||||
/**
|
||||
* Day names starting from Sunday. Should be exactly 7 in total.
|
||||
*/
|
||||
days?: string[];
|
||||
/**
|
||||
* Short Day names starting from Sunday. Should be exactly 7 in total.
|
||||
*/
|
||||
shortDays?: string[];
|
||||
/**
|
||||
* Month Names starting from January
|
||||
*/
|
||||
months?: string[];
|
||||
/**
|
||||
* Short Month Names starting from January
|
||||
*/
|
||||
shortMonths?: string[];
|
||||
}
|
||||
|
||||
interface ChartOptions {
|
||||
/**
|
||||
* Enables / Disables Chart interactivity like toolTip, mouse and touch events
|
||||
* Default: true
|
||||
* Example: false, true
|
||||
*/
|
||||
interactivityEnabled?: boolean;
|
||||
/**
|
||||
* Enables Animation while rendering the Chart.
|
||||
* Default: true
|
||||
* Example: false, true
|
||||
*/
|
||||
animationEnabled?: boolean;
|
||||
/**
|
||||
* While exporting any chart, “Chart” is used as the default fine name with corresponding extension “jpg” or “png”. You can override this name using exportFileName property.
|
||||
* Default: Chart
|
||||
*/
|
||||
exportFileName?: string;
|
||||
/**
|
||||
* Setting exportEnabled to true enables the export feature. As of now JPG & PNG formats are supported. Export feature is available in all Chart Types.
|
||||
* Default: false
|
||||
* Options: true, false
|
||||
*/
|
||||
exportEnabled?: boolean;
|
||||
/**
|
||||
* Setting zoomEnabled to true enables zooming and panning feature of Chart. This way you can zoom into an area of interest when there is a large amount of data. This will also allow you to pan through the chart. If not set, the property is automatically enabled for large number of dataPoints. You can switch between zooming & panning using the toolbar that appears on the chart. After Zooming in, you can reset the chart by clicking the reset button.
|
||||
* Default: false
|
||||
* Options: true, false
|
||||
*/
|
||||
zoomEnabled?: boolean;
|
||||
/**
|
||||
* Sets the theme of the Chart. Various predefined themes are bundled along with the library. User can easily switch these themes by changing theme property to the below mentioned options.
|
||||
* Default: “theme1″
|
||||
* Options: “theme1″,”theme2″, “theme3″
|
||||
*/
|
||||
theme?: string;
|
||||
/**
|
||||
* Sets the background color of entire Chart Area. Values can be “HTML Color Name”, “hex code” or “rgba values”
|
||||
* Default: “white”
|
||||
* Example: “yellow”, “#F5DEB3″..
|
||||
*/
|
||||
backgroundColor?: string;
|
||||
/**
|
||||
* Sets the colorSet of the Chart. Color Set is an array of colors that are used to render data. Various predefined Color Sets are bundled along with the library. You can either choose from the pre-defined Color Sets or define your own Color Set.
|
||||
* Default: “colorset1″ or as defined in the selected theme
|
||||
* Example: “colorSet1″, “colorSet2″, “colorSet3″
|
||||
*/
|
||||
colorSet?: string;
|
||||
/**
|
||||
* CanvasJS allows you to localize various culture / language / country specific elements in the Chart like number formatting style – where you can choose which character to use as a decimal separator and as a digit group separator (also referred to as a thousand separator). By default CanvasJS is set to Neutral English Culture – “en”.
|
||||
* Default: “en”
|
||||
*/
|
||||
culture?: string;
|
||||
/**
|
||||
* Sets the width of the Chart.
|
||||
* Default: Takes chart container’s width by default. If the width is not set for the chart container, defaults to 500.
|
||||
* Example: 380, 500, 720
|
||||
*/
|
||||
width?: number;
|
||||
/**
|
||||
* Sets the width of the Chart
|
||||
* Default: Takes chart container’s height by default. If the height is not set for the chart container, defaults to 400.
|
||||
* Example: 260, 300, 400
|
||||
*/
|
||||
height?: number;
|
||||
/**
|
||||
* Title allows you to set content, appearance and position of Chart’s Title.
|
||||
*/
|
||||
title: ChartTitleOptions;
|
||||
/**
|
||||
* Whenever the chart contains multiple dataSeries, it is recommended to represent each dataSeries in a legend. This way it becomes easier for the user to know what exactly is represented by each of the dataSeries. In case of Pie and Doughnut charts, an entry is created for each dataPoint and in rest of the chart types entries are created for each dataSeries.
|
||||
* You can selectively show or hide a dataSeries in the Legend using showInLegend property of dataSeries.
|
||||
*/
|
||||
legend?: ChartLegendOptions;
|
||||
/**
|
||||
* axisX object lets you set various parameters of X Axis like interval, grid lines, etc. It is mostly horizontal, except when we are working with Bar Charts, where axisX is vertical.
|
||||
*/
|
||||
axisX?: ChartAxisXOptions;
|
||||
/**
|
||||
* axisY object lets you set various parameters of Y Axis like interval, grid lines, etc. It is mostly vertical, except when we are working with Bar Charts, where axisY is horizontal.
|
||||
*/
|
||||
axisY?: ChartAxisYOptions;
|
||||
/**
|
||||
* toolTip object lets user set behaviour of toolTip at global level like enabling/disabling animation, setting Border Color, sharing toolTip between multiple dataSeries, etc. You can also disable the toolTip by setting enabled property to false.
|
||||
*/
|
||||
toolTip?: ChartToolTipOptions;
|
||||
/**
|
||||
* data is an array of dataSeries Objects.
|
||||
*/
|
||||
data: ChartDataOptions[];
|
||||
}
|
||||
|
||||
interface ChartTitleOptions {
|
||||
/**
|
||||
* Sets the Title’s text.
|
||||
* Default: null
|
||||
* Example: “Chart title”
|
||||
*/
|
||||
text?: string;
|
||||
/**
|
||||
* This property lets you align the Chart Title vertically.
|
||||
* Default: “top”
|
||||
* Options: “top”, “center”, “bottom”
|
||||
*/
|
||||
verticalAlign?: string;
|
||||
/**
|
||||
* This property lets you align the Chart Title horizontally.
|
||||
* Default: “center”
|
||||
* Options: “left”, “right”, “center”
|
||||
*/
|
||||
horizontalAlign?: string;
|
||||
/**
|
||||
* Sets the font Size of Chart Title in pixels.
|
||||
* Default: Automatically Calculated based on Chart Size
|
||||
* Example: 16,18,22 ..
|
||||
*/
|
||||
fontSize?: number;
|
||||
/**
|
||||
* Sets the Font Family of Chart Title.
|
||||
* Default: “Calibri, Optima, Candara, Verdana, Geneva, sans-serif”
|
||||
* Example: “arial” , “tahoma”, “verdana” ..
|
||||
*/
|
||||
fontFamily?: string;
|
||||
/**
|
||||
* Sets the Font Weight used in the Chart Title.
|
||||
* Default: “bold”
|
||||
* Options: “lighter”, “normal”, “bold” , “bolder”
|
||||
*/
|
||||
fontWeight?: string;
|
||||
/**
|
||||
* Sets the font color of Chart Title. The value of fontColor can be a “HTML Color Name” or “hex” code .
|
||||
* Default: “#3A3A3A”
|
||||
* Example: “red”, “#FAC003″ ..
|
||||
*/
|
||||
fontColor?: string;
|
||||
/**
|
||||
* Sets the fontStyle of Chart Title. fontStyle can be set to one of the below options.
|
||||
* Default: “normal”
|
||||
* Options: “normal”, “italic” , “oblique”
|
||||
*/
|
||||
fontStyle?: string;
|
||||
/**
|
||||
* Sets the thickness of border around the Title in pixels. To display border around title, set the borderThickness to a number greater than zero.
|
||||
* Default: 0
|
||||
* Example: 2,4 ..
|
||||
*/
|
||||
borderThickness?: number;
|
||||
/**
|
||||
* To display rounded borders around the title, set the cornerRadius of title. Higher the value, more rounded are the corners.
|
||||
* Default: 0
|
||||
* Options: 5,8 ..
|
||||
*/
|
||||
cornerRadius?: number;
|
||||
/**
|
||||
* Sets the color of border around Chart Title. Values of borderColor can be “HTML Color Name” or “hex” code .
|
||||
* Default: “black”
|
||||
* Example: “red”, “#FF0000″ ..
|
||||
*/
|
||||
borderColor?: string;
|
||||
/**
|
||||
* Sets the background color of Chart Title. Values can be “HTML Color Name” or “hex” code.
|
||||
* Default: null
|
||||
* Example: “red”, “#FF0000″ ..
|
||||
*/
|
||||
backgroundColor?: string;
|
||||
/**
|
||||
* This property lets you set margin around the Chart Title in pixels.
|
||||
* Default: 10
|
||||
* Example: 4,12 ..
|
||||
*/
|
||||
margin?: number;
|
||||
/**
|
||||
* This property allows you to set the padding for Chart Title
|
||||
* Default: 0
|
||||
* Example: 5, 8 ..
|
||||
*/
|
||||
padding?: number;
|
||||
}
|
||||
|
||||
interface ChartLegendOptions {
|
||||
/**
|
||||
* Sets the font Size of Legend Text in pixels.
|
||||
* Default: 12
|
||||
* Example: 16,18,22 ..
|
||||
*/
|
||||
fontSize?: number;
|
||||
/**
|
||||
* Sets the Font Family of Legend Text.
|
||||
* Default: “calibri”
|
||||
* Example: “arial” , “tahoma”, “verdana” ..
|
||||
*/
|
||||
fontFamily?: string;
|
||||
/**
|
||||
* Sets the font color of Legend Text . The value of fontColor can be a “HTML Color Name” or “hex” code .
|
||||
* Default: “black”
|
||||
* Example: “red”, “#FAC003″ ..
|
||||
*/
|
||||
fontColor?: string;
|
||||
/**
|
||||
* Sets the Font Weight of Legend Text.
|
||||
* Default: “normal”
|
||||
* Example: “lighter”, “normal”, “bold” , “bolder”
|
||||
*/
|
||||
fontWeight?: string;
|
||||
/**
|
||||
* Sets the fontStyle of Legend Text. fontStyle can be set to one of the below options.
|
||||
* Default: “normal”
|
||||
* Example: “normal”, “italic” , “oblique”
|
||||
*/
|
||||
fontStyle?: string;
|
||||
/**
|
||||
* This property lets you align the Legend Position vertically.
|
||||
* Default: “bottom”
|
||||
* Example: “top”, “center”, “bottom”
|
||||
*/
|
||||
verticalAlign?: string;
|
||||
/**
|
||||
* This property lets you align the Legend Position horizontally.
|
||||
* Default: “right”
|
||||
* Example: “left”, “right”, “center”
|
||||
*/
|
||||
horizontalAlign?: string;
|
||||
/**
|
||||
* Sets the mouseover event handler for the legend, which is triggered when the user moves the mouse(input device) over a legend item. After the event is triggered, the event related data is passed as a parameter to the assigned event handler. Parameters passed to the function are shown in the Event Object section below.
|
||||
* @param event a chart event
|
||||
*/
|
||||
itemmouseover?: (event: ChartEvent) => void;
|
||||
/**
|
||||
* Sets the mousemove event handler for the legend, which is triggered when the user moves the mouse(input device) within a legend item. When the event is triggered, the event related data is passed as a parameter to the assigned event handler. Parameters passed to the function are shown in the Event Object section below.
|
||||
* @param event a chart event
|
||||
*/
|
||||
itemmousemove?: (event: ChartEvent) => void;
|
||||
/**
|
||||
* Sets the mouseout event handler for the legend, which is triggered when the user moves the mouse pointer outside a legend item. After the event is triggered, the event related data is passed as a parameter to the assigned event handler. Parameters passed to the function are shown in the Event Object section below.
|
||||
* @param event a chart event
|
||||
*/
|
||||
itemmouseout?: (event: ChartEvent) => void;
|
||||
/**
|
||||
* Sets the click event handler for the legend, which is triggered when the user clicks on a legend item. After the event is triggered, the event related data is passed as a parameter to the assigned event handler. Parameters passed to the function are shown in the Event Object section below.
|
||||
* @param event a chart event
|
||||
*/
|
||||
itemclick?: (event: ChartEvent) => void;
|
||||
}
|
||||
|
||||
interface ChartEvent {
|
||||
/**
|
||||
* The x value of the item
|
||||
*/
|
||||
x: any;
|
||||
/**
|
||||
* The y value of the item
|
||||
*/
|
||||
y: number;
|
||||
/**
|
||||
* The chart object
|
||||
*/
|
||||
chart: Chart;
|
||||
/**
|
||||
* The datapoint options
|
||||
*/
|
||||
dataPoint: ChartDataPoint;
|
||||
/**
|
||||
* The data series options
|
||||
*/
|
||||
dataSeries: ChartDataOptions;
|
||||
/**
|
||||
* The index of the data point
|
||||
*/
|
||||
dataPointIndex: number;
|
||||
/**
|
||||
* The index of the data series
|
||||
*/
|
||||
dataSeriesIndex: number;
|
||||
}
|
||||
|
||||
interface ChartAxisXOptions {
|
||||
/**
|
||||
* Sets the Axis Title.
|
||||
* Default: null
|
||||
* Example: “Axis X Title”
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* Sets the Font Color of Axis Title. The value of titleFontColor can be a “HTML Color Name” or “hex” code .
|
||||
* Default: “#666666″
|
||||
* Example: “red”, “#006400″ .
|
||||
*/
|
||||
titleFontColor?: string;
|
||||
/**
|
||||
* Sets the Font Size of Axis Title in pixels.
|
||||
* Default: Automatically Calculated based on Chart Size
|
||||
* Example: 16, 25 ..
|
||||
*/
|
||||
titleFontSize?: number;
|
||||
/**
|
||||
* Sets the Font Family of Axis Title.
|
||||
* Default: “Calibri, Optima, Candara, Verdana, Geneva, sans-serif”
|
||||
* Example: “calibri”, “tahoma, “verdana” ..
|
||||
*/
|
||||
titleFontFamily?: string;
|
||||
/**
|
||||
* Sets the Font Weight used in the Axis Title. It can be set to one of the options below.
|
||||
* Default: “normal”
|
||||
* Options: “lighter”, “normal”, “bold” , “bolder”
|
||||
*/
|
||||
titleFontWeight?: string;
|
||||
/**
|
||||
* Sets the Font Style of Axis Title. It can be set to one of the below options.
|
||||
* Default: “normal”
|
||||
* Options: “normal”, “italic” , “oblique”
|
||||
*/
|
||||
titleFontStyle?: string;
|
||||
/**
|
||||
* This property lets you set margin between chart’s boundary and Axis.
|
||||
* Default: 2
|
||||
* Example: 8, 10..
|
||||
*/
|
||||
margin?: number;
|
||||
/**
|
||||
* Sets the angle for Axis Labels.
|
||||
* Default: null
|
||||
* Example: 20, 45, -30 ..
|
||||
*/
|
||||
labelAngle?: number;
|
||||
/**
|
||||
* Sets the Axis Label color. The value of labelFontColor can be a “HTML Color Name” or “hex” code .
|
||||
* Default: “grey”
|
||||
* Example: “red”, “#FAC003″ ..
|
||||
*/
|
||||
labelFontColor?: string;
|
||||
/**
|
||||
* Sets the Axis Label Font Size in pixels.
|
||||
* Default: Automatically Calculated based on Chart Size
|
||||
* Example: 16, 18, 22..
|
||||
*/
|
||||
labelFontSize?: number;
|
||||
/**
|
||||
* Sets the Font Family of Axis labels.
|
||||
* Default: “Calibri, Optima, Candara, Verdana, Geneva, sans-serif”
|
||||
* Example: “calibri”, “tahoma”, “verdana” ..
|
||||
*/
|
||||
labelFontFamily?: string;
|
||||
/**
|
||||
* Set the font Weight used in Axis Labels. It can be set to one of the options below.
|
||||
* Default: “normal”
|
||||
* Options: “lighter”, “normal”, “bold” , “bolder”
|
||||
*/
|
||||
labelFontWeight?: string;
|
||||
/**
|
||||
* Sets the Font Style of Axis Labels. It can be set to one of the below options.
|
||||
* Default: “normal”
|
||||
* Options: “italic”, “oblique”, “normal”
|
||||
*/
|
||||
labelFontStyle?: string;
|
||||
/**
|
||||
* A string that prepends all the labels on axisX.
|
||||
* Default: null
|
||||
* Example: “$”,”cat”..
|
||||
*/
|
||||
prefix?: string;
|
||||
/**
|
||||
* A string that appends all the labels on axisX.
|
||||
* Default: null
|
||||
* Example: “$”,”cat”..
|
||||
*/
|
||||
suffix?: string;
|
||||
/**
|
||||
* Defines how values must be formatted before they appear on Axis X. You can format numbers and date time values using this property. Below you will find descriptive table explaining various specifiers with example.
|
||||
*/
|
||||
valueFormatString?: string;
|
||||
/**
|
||||
* Sets the minimum value of Axis. Values smaller than minimum are clipped.
|
||||
* Default: Automatically Calculated based on the data
|
||||
* Example: 100, 350..
|
||||
*/
|
||||
minimum?: number;
|
||||
/**
|
||||
* Sets the maximum value permitted on Axis. Values greater than maximum are clipped.
|
||||
* Default: Automatically Calculated based on the data
|
||||
* Example: 100, 350..
|
||||
*/
|
||||
maximum?: number;
|
||||
/**
|
||||
* Sets the distance between Tick Marks, Grid Lines and Interlaced Colors.
|
||||
* Default: Automatically Calculated
|
||||
* Example: 50, 75..
|
||||
*/
|
||||
interval?: number;
|
||||
/**
|
||||
* intervalType is the unit of interval property. intervalType is by default set to “number” and hence you need to specify the interval type (eg “week”, “month”, etc) depending on the type of interval you intend to set. If required interval is 3 months, you need to provide interval as 3 and intervalType as “month”
|
||||
* Default: Automatically handled when interval property is not set. Defaults to “number” when you set the interval.
|
||||
* Option: “number”,”millisecond” ,”second”,” minute”, “hour”, “day”, “month” ,”year”
|
||||
* Example: for interval as 15 minutes, set interval as 15, and set intervalType as “minute”,
|
||||
*/
|
||||
intervalType?: string;
|
||||
/**
|
||||
* Sets the length of Tick Marks that are drawn on the Axis.
|
||||
* Default: 5
|
||||
* Example: 10, 14..
|
||||
*/
|
||||
tickLength?: number;
|
||||
/**
|
||||
* Sets the color of Tick Marks drawn on the axis. The value of tickColor can be a “HTML Color Name” or “hex” code .
|
||||
* Default: “#BBBBBB”
|
||||
* Example: “red”, “#006400″.
|
||||
*/
|
||||
tickColor?: string;
|
||||
/**
|
||||
* Sets the thickness of the Tick Marks in pixels.
|
||||
* Default: 2
|
||||
* Example: 3, 4..
|
||||
*/
|
||||
tickThickness?: number;
|
||||
/**
|
||||
* Sets the color of Axis line. Axis line color can be a “HTML Color Name” or “hex” code .
|
||||
* Default: “#BBBBBB”
|
||||
* Example: “blue”,”#21AB13″..
|
||||
*/
|
||||
lineColor?: string;
|
||||
/**
|
||||
* Sets the Thickness of Axis line in pixels.
|
||||
* Default: 2
|
||||
* Example: 2, 4..
|
||||
*/
|
||||
lineThickness?: string;
|
||||
/**
|
||||
* Sets the Interlacing Color that alternates between the set interval. If the interval is not set explicitly, then the auto calculated interval is considered. The value of interlacedColor can be a “HTML Color Name” or “hex” code .
|
||||
* Default: null
|
||||
* Example: “#F8F1E4″, “#FEFDDF” ….
|
||||
*/
|
||||
interlaceColor?: string;
|
||||
/**
|
||||
* Sets the Thickness of Grid Lines. To display grid on Axis X, set the Grid Thickness to a number greater than zero.
|
||||
* Default: 0
|
||||
* Example: 2,4 ..
|
||||
*/
|
||||
gridThickness?: number;
|
||||
/**
|
||||
* Sets the Color of Grid Lines. Value of gridColor can be a “HTML Color Name” or “hex” code .
|
||||
* Default: “#BBBBBB”
|
||||
* Example: “red”, “#FEFDDF” ..
|
||||
*/
|
||||
gridColor?: string;
|
||||
/**
|
||||
* Strip Lines are vertical or horizontal lines used to highlight/mark a certain region on the plot area. You can choose whether to draw a line at a specific position or shade a region on the plot area. Strip Lines are sometimes referred to as trend lines.
|
||||
* If you want to just mark a certain position on the axis, you can set the value attribute and it’ll draw a line at that position with the set thickness. If you want to shade a region instead, you need to set startValue and endValue attributes. This will fill the area within the specified range.
|
||||
* In the case you set startValue and endValue attributes, value and thickness attributes are ignored (as either a single thread of line can exist, or a shaded region between two given points).
|
||||
* Strip Lines can be displayed using AxisX or AxisY’s stripLines array. This allows you to have one or more strip lines on both x & y axis.
|
||||
*/
|
||||
stripLines?: ChartStripLines;
|
||||
}
|
||||
|
||||
interface ChartStripLines {
|
||||
/**
|
||||
* Sets the point where the stripLine has to be plotted or drawn along the axis X.
|
||||
* Default: null
|
||||
* Example: 20,30,100,50
|
||||
*/
|
||||
value?: number;
|
||||
/**
|
||||
* Sets the point where the stripLine’s shaded region begins on the x-axis.
|
||||
* Default: null
|
||||
* Example: 20,30,100,50
|
||||
*/
|
||||
startValue?: number;
|
||||
/**
|
||||
* Sets the point where the stripLine’s shaded region ends on the x-axis.
|
||||
* Default: null
|
||||
* Example: 50,60,200,300
|
||||
*/
|
||||
endValue?: number;
|
||||
/**
|
||||
* Sets the thickness of the stripLine in pixels.
|
||||
* Default: 2
|
||||
* Example: 2,4,5,6
|
||||
*/
|
||||
thickness?: number;
|
||||
/**
|
||||
* Sets the color of the stripLine.
|
||||
* Default: “orange”
|
||||
* Example: “green”, “#23EA23″
|
||||
*/
|
||||
color?: string;
|
||||
/**
|
||||
* Sets the label of the stripLine. These are shown on top of axis labels.
|
||||
* Default: “” (empty string)
|
||||
* Example: “Threshold”, “Deaths in 1920″
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* Sets the background color of stripLine’s label.
|
||||
* Default: “#eeeeee”
|
||||
* Example: “red”,”#fabd76″
|
||||
*/
|
||||
labelBackgroundColor?: string;
|
||||
/**
|
||||
* Sets the font-family of stripLine’s label. If the first font is not found in the system from the specified font-family list, it tries to use the next font in the list.
|
||||
* Default: “arial”
|
||||
* Example: “Arial, Trebuchet MS, Tahoma, sans-serif”
|
||||
*/
|
||||
labelFontFamily?: string;
|
||||
/**
|
||||
* Sets the font color of label.
|
||||
* Default: “orange”
|
||||
* Example: “blue”,”#4135e9″
|
||||
*/
|
||||
labelFontColor?: string;
|
||||
/**
|
||||
* Sets the font size of the label in pixels.
|
||||
* Default: 12
|
||||
* Example: 18,19,20,22
|
||||
*/
|
||||
labelFontSize?: number;
|
||||
/**
|
||||
* Sets the font weight of stripLine’s label.
|
||||
* Default: “normal”
|
||||
* Example: “lighter”,”normal”,”bold”,”bolder”
|
||||
*/
|
||||
labelFontWeight?: string;
|
||||
/**
|
||||
* Sets the font style of stripLine’s label.
|
||||
* Default: “normal”
|
||||
* Example: “normal”,”italic”,”oblique”
|
||||
*/
|
||||
labelFontStyle?: string;
|
||||
}
|
||||
|
||||
interface ChartAxisYOptions extends ChartAxisXOptions {
|
||||
/**
|
||||
* When includeZero is set to true, axisY sets the range in such a way that Zero is a part of it. It is set to true by default. But, whenever y values are very big and difference among dataPoints are hard to judge, setting includeZero to false makes axisY to set a range that makes the differences prominently visible.
|
||||
* Default: true
|
||||
* Example: true, false
|
||||
*/
|
||||
includeZero?: boolean;
|
||||
}
|
||||
|
||||
interface ChartToolTipOptions {
|
||||
/**
|
||||
* Enables or Disables the toolTip for the chart.
|
||||
* Default: True
|
||||
* Example: True, False
|
||||
*/
|
||||
enabled?: boolean;
|
||||
/**
|
||||
* In a Multi-Series or a Combination Chart, it is often required to display all values common to x value in a single bubble. Setting shared to true will show in a common bubble all the values of y from each series next to their name.
|
||||
* Default: True
|
||||
* Example: True, False
|
||||
*/
|
||||
shared?: boolean;
|
||||
/**
|
||||
* toolTip for entire chart can be set by adding content at toolTip object. content can either be a string or a custom function that returns HTML/String to be displayed inside the toolTip.
|
||||
* Default: auto
|
||||
*/
|
||||
content?: string;
|
||||
/**
|
||||
* While mouse hovers from one dataPoint to another there is a smooth transition in toolTip. This effect can be controlled by animationEnabled Property. Setting it to false, will disable the animation and toolTip will directly switch from one dataPoint to the other.
|
||||
* Default: True
|
||||
* Example: True, False
|
||||
*/
|
||||
animationEnabled?: boolean;
|
||||
/**
|
||||
* Sets the border color around Tool Tip. When not set it takes the color of corresponding dataSeries or dataPoint.
|
||||
* Default: dataSeries color/ dataPoint color
|
||||
* Example: “red”, “#808080″..
|
||||
*/
|
||||
borderColor?: string;
|
||||
}
|
||||
|
||||
interface ChartDataCommon {
|
||||
/**
|
||||
* Sets the dataPoint Name. dataPoint name is shown in various places like toolTip & legend unless overridden.
|
||||
* Default: Automatically Named (“dataPoint 1″, “dataPoint 2″ .. )
|
||||
* Example: “apple”, “mango” ..
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* Sets the color of dataSeries. The value of tickColor can be a “HTML Color Name” or “Hex Code”.
|
||||
* Default: Automatically set from Theme.
|
||||
* Example: “red”, “green” ..
|
||||
*/
|
||||
color?: string;
|
||||
/**
|
||||
* Instead of setting string values for all indexLabels, you can also use keywords like x, y, etc that will automatically show corresponding properties as indexLabel. This will allow you to define indexLabel at the series level once. While setting indexLabel you specify a keyword by enclosing it in flower brackets like {x}, {y}, {color}, etc.
|
||||
* Range Charts have two indexLabels – one for each y value. This requires the use of a special keyword #index to show index label on either sides of the column/bar/area.
|
||||
* eg: indexLabel: “{x}: {y[#index]}”
|
||||
* Important keywords to keep in mind are. {x}, {y}, {name}, {label}.
|
||||
* Default: null
|
||||
* Example: “{label}”, “Win”, “x: {x}, y: {y} ”
|
||||
*/
|
||||
indexLabel?: string;
|
||||
/**
|
||||
* Using this property you can define whether to render indexLabel “inside” or “outside” the dataPoint.
|
||||
* Default: “outside”
|
||||
* Example: “outside”, “inside”
|
||||
*/
|
||||
indexLabelPlacement?: string;
|
||||
/**
|
||||
* Sets the Orientation of indexLabel to “horizontal” or “vertical”.
|
||||
* Default: “horizontal”
|
||||
* Options: “horizontal”, “vertical”
|
||||
*/
|
||||
indexLabelOrientation?: string;
|
||||
/**
|
||||
* Sets the Background color of Index Labels. The value of indexLabelBackgroundColor can be a “HTML Color Name” or “Hex Code”.
|
||||
* Default: null
|
||||
* Example: “red”, “#FAC003″ ..
|
||||
*/
|
||||
indexLabelBackgroundColor?: string;
|
||||
/**
|
||||
* Sets the Index Label’s Font Style. It can be set to one of the below options.
|
||||
* Default: “normal”
|
||||
* Options: “italic”, “oblique”, “normal”
|
||||
*/
|
||||
indexLabelFontStyle?: string;
|
||||
/**
|
||||
* Sets the Index Label’s Font color. The value of IndexLabelFontColor can be a “HTML Color Name” or “Hex Code”.
|
||||
* Default: “grey”
|
||||
* Example: “red”, “#FAC003″ ..
|
||||
*/
|
||||
indexLabelFontColor?: string;
|
||||
/**
|
||||
* Sets the Index Label’s Font Size in pixels.
|
||||
* Default: 18
|
||||
* Example: 12, 16, 22..
|
||||
*/
|
||||
indexLabelFontSize?: number;
|
||||
/**
|
||||
* Sets the Index Label’s Font Family.
|
||||
* Default: “Calibri, Optima, Candara, Verdana, Geneva, sans-serif”
|
||||
* Example: “calibri”, “tahoma”, “verdana”..
|
||||
*/
|
||||
indexLabelFontFamily?: string;
|
||||
/**
|
||||
* Sets the Index Label’s Font Weight. It can be set to one of the below options.
|
||||
* Default: “normal”
|
||||
* Example: “lighter”, “normal” ,”bold” , “bolder”
|
||||
*/
|
||||
indexLabelFontWeight?: string;
|
||||
/**
|
||||
* Sets the color of line connecting index labels with their dataPoint. It is only applicable for pie and doughnut chart when indexLabelPlacment is outside. The value of indexLineColor can be a “HTML Color Name” or “Hex Code”.
|
||||
* Default: “lightgrey”
|
||||
* Example: “red”, “#FAC003″ ..
|
||||
*/
|
||||
indexLabelLineColor?: string;
|
||||
/**
|
||||
* Sets the thickness of line connecting indexLabel with its corresponding dataPoint. It is only applicable for pie and doughnut chart when indexLabelPlacement is set to “outside”.
|
||||
* Default: 2
|
||||
* Example: 4, 6
|
||||
*/
|
||||
indexLabelLineThickness?: string;
|
||||
/**
|
||||
* Default Tooltip can be modified at dataSeries or dataPoint level. You can add content to be displayed in toolTip using toolTipContent. toolTipContent set at dataPoint will override toolTipContent set at dataSeries level.
|
||||
* Default: auto set depending on chart type.
|
||||
*/
|
||||
toolTipContent?: string;
|
||||
/**
|
||||
* Sets marker type to be rendered at each dataPoint. While markers are helpful in highlighting individual dataPoints, they do not help much when the dataPoints are crowded. In case of large number of dataPoints it is recommended to disable markers in order to improve the appearance and performance of chart.
|
||||
* Same marker type is also used in legend unless overridden by legendMarkerType property.
|
||||
* Default: “circle”
|
||||
* Options: “none”, “circle”, “square”, “triangle” and “cross”
|
||||
*/
|
||||
markerType?: string;
|
||||
/**
|
||||
* Sets the color of marker that is displayed on the Chart. Legend Marker for the series uses the same Color as set here unless overridden using legendMarkerColor property.
|
||||
* Default: dataSeries Color
|
||||
* Example: “red”, “#008000″ ..
|
||||
*/
|
||||
markerColor?: string;
|
||||
/**
|
||||
* Sets the Size of the marker that is drawn. To display marker in area Chart, set markerSize to a value greater than zero. For line, scatter chart, size it is automatically set unless overridden.
|
||||
* Default: auto. Zero for area chart
|
||||
* Example: 5, 10..
|
||||
*/
|
||||
markerSize?: number;
|
||||
/**
|
||||
* Sets the border color around marker. Value of markerBorderColor can be “HTML Color Name” or “hex code”.
|
||||
* Default: dataSeries color.
|
||||
* Example: “red”, “#008000″ ..
|
||||
*/
|
||||
markerBorderColor?: string;
|
||||
/**
|
||||
* Sets the thickness of the Marker’s Border in pixels.
|
||||
* Default: 1
|
||||
* Example: 2,4 ..
|
||||
*/
|
||||
markerBorderThickness?: number;
|
||||
/**
|
||||
* Sets the text that describes the dataSeries in legend.
|
||||
* Default: “DataSeries 1″, “DataSeries 2″ ..etc
|
||||
* Example: “2010″, “2011″..
|
||||
*/
|
||||
legendText?: string;
|
||||
/**
|
||||
* Sets the Legend Marker to one of the options below. This property is used to override the default marker in legend, which is same as dataSeries Marker Type.
|
||||
* Default: same as markerType
|
||||
* Options: “circle”, “square”, “cross” and “triangle”
|
||||
*/
|
||||
legendMarkerType?: string;
|
||||
/**
|
||||
* Sets the click event handler for dataSeries which is triggered when user clicks on a dataSeries. Upon event, a parameter that contains event related data is sent to the assigned event handler. Parameter includes dataPoint and dataSeries corresponding to the event.
|
||||
* Default: null
|
||||
*/
|
||||
click?: (event: ChartEvent) => void;
|
||||
/**
|
||||
* Sets the color of marker that is displayed on legend. This property overrides default Marker’s Color in Legend, which is same as dataSeries Marker Color. Value of legendMarkerColor can be “HTML Color Name” or “hex code”.
|
||||
* Default: dataSeries marker color
|
||||
* Example: “red”, “#008000″ ..
|
||||
*/
|
||||
legendMarkerColor?: string;
|
||||
/**
|
||||
* Sets the mouseover event handler for dataSeries which is triggered when user moves Mouse Over a dataSeries. Upon event, a parameter that contains event related data is sent to the assigned event handler. Parameter includes dataPoint and dataSeries corresponding to the event.
|
||||
* Default: null
|
||||
*/
|
||||
mouseover?: (event: ChartEvent) => void;
|
||||
/**
|
||||
* Sets the mousemove event handler for dataSeries which is triggered when user Moves mouse on a dataSeries. Upon event, a parameter that contains event related data is sent to the assigned event handler. Parameter includes dataPoint and dataSeries corresponding to the event.
|
||||
* Default: null
|
||||
*/
|
||||
mousemove?: (event: ChartEvent) => void;
|
||||
/**
|
||||
* Sets the mouseout event handler for dataSeries which is triggered when user moves mouse out of a dataSeries. Upon event, a parameter that contains event related data is sent to the assigned event handler. Parameter includes dataPoint and dataSeries corresponding to the event.
|
||||
* Default: null
|
||||
*/
|
||||
mouseout?: (event: ChartEvent) => void;
|
||||
}
|
||||
|
||||
interface ChartDataOptions extends ChartDataCommon {
|
||||
/**
|
||||
* Sets the visibility of dataSeries. Data Series is visible by default and you can hide the same by setting visible property to false.
|
||||
* Default: true
|
||||
* Example: true, false
|
||||
*/
|
||||
visible?: boolean;
|
||||
/**
|
||||
* Sets the type of chart to be rendered for corresponding dataSeries. One can choose from the following options.
|
||||
* Default: “column”
|
||||
* Options:
|
||||
* “line”
|
||||
* “column”
|
||||
* “bar”
|
||||
* “area”
|
||||
* “spline”
|
||||
* “splineArea”
|
||||
* “stepLine”
|
||||
* “scatter”
|
||||
* “bubble”
|
||||
* “stackedColumn”
|
||||
* “stackedBar”
|
||||
* “stackedArea”
|
||||
* “stackedColumn100″
|
||||
* “stackedBar100″
|
||||
* “stackedArea100″
|
||||
* “pie”
|
||||
* “doughnut”
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* Setting axisYType lets you choose between primary and secondary Y Axis for a dataSeries to plot against. By choosing “secondary” Axis you can plot the series against axisY2.
|
||||
* In case of Multi-Series or Combinational Charts, one can assign primary axis to some series and secondary axis to other series.
|
||||
* This is helpful when dataSeries objects use different unit of measurement or range of data. By default, all series are plotted against primary Y axis.
|
||||
* Default: “primary”
|
||||
* Options: “primary”, “secondary”
|
||||
*/
|
||||
axisYType?: string;
|
||||
/**
|
||||
* This defines the data type of x values. Data Type is normally figured out by default based on the object type that is assigned to x. But if you are providing time stamp (which is integer) values instead of Date objects, you’ll have to explicitly set the xValueType to “dateTime”.
|
||||
* Default: Automatically Calculated
|
||||
* Options: “number”, “dateTime”
|
||||
*/
|
||||
xValueType?: string;
|
||||
/**
|
||||
* Defines how y axis values must be formatted before they appear on the indexLabel or toolTip. You can format numbers and date time values using this property.
|
||||
*/
|
||||
yValueFormatString?: string;
|
||||
/**
|
||||
* Defines how x axis values must be formatted before they appear on the indexLabel or toolTip. You can format numbers and date time values using this property.
|
||||
*/
|
||||
xValueFormatString?: string;
|
||||
/**
|
||||
* Defines how z values is formatted before they appear on the indexLabel or toolTip. You can format numbers using this property.
|
||||
*/
|
||||
zValueFormatString?: string;
|
||||
/**
|
||||
* Sets the bevel property, which creates a chiselled effect at the corners of a Column Charts and Bar Charts.
|
||||
* Default: “true”
|
||||
* Example: “true”, “false”
|
||||
*/
|
||||
bevelEnabled?: boolean;
|
||||
/**
|
||||
* Sets opacity of the filled color.
|
||||
* Default: .7 for Area Charts and 1 for all other chart types.
|
||||
*/
|
||||
fillOpacity?: number;
|
||||
/**
|
||||
* Sets the starting Angle of the Pie or Doughnut Chart in degrees.
|
||||
* Default: 0
|
||||
* Example: 30, 240, -100..
|
||||
*/
|
||||
startAngle?: number;
|
||||
/**
|
||||
* Sets the thickness of line in line charts and area charts.
|
||||
* Default: 2
|
||||
* Example: 3,4..
|
||||
*/
|
||||
lineThickness?: number;
|
||||
/**
|
||||
* Setting this property to true makes the dataSeries to appear in legend. In case of pie/ doughnut chart, dataPoints of the single series chart appear in legend.
|
||||
* Default: false
|
||||
* Options: false, true
|
||||
*/
|
||||
showInLegend?: boolean;
|
||||
/**
|
||||
* In candle Stick chart, when Closing Price is greater than Opening price, the body is filled with white by default and it can be overridden by risingColor property.
|
||||
* Default: “white”
|
||||
* Options: “red”, “#DD7E86″, etc.
|
||||
*/
|
||||
risingColor?: string;
|
||||
/**
|
||||
* It represents collection dataPoint inside dataSeries .
|
||||
*/
|
||||
dataPoints: ChartDataPoint[];
|
||||
}
|
||||
|
||||
interface ChartDataPoint extends ChartDataCommon {
|
||||
/**
|
||||
* Sets the x value. It determines the position of the dataPoint on X Axis. It can be numeric or a dateTime value. Values can be positive or Negative.
|
||||
* Default: null
|
||||
* Example: 10, 20, 30 ..
|
||||
* new Date(2011, 08, 01)
|
||||
*/
|
||||
x?: any;
|
||||
/**
|
||||
* Sets the y value of dataPoint. It determines the position of dataPoint on Y Axis. Values can be positive or Negative
|
||||
* Default: null
|
||||
* Example: 5, 20, -30 ..
|
||||
*/
|
||||
y?: number;
|
||||
/**
|
||||
* Sets the z value of dataPoint. It is only applicable in case of Bubble chart. This value determines the size of the bubble.
|
||||
* Default: 1
|
||||
* Example: 10, 20, 35..
|
||||
*/
|
||||
z?: number;
|
||||
/**
|
||||
* Sets label value of a dataPoint. The value appears next to the dataPoint on axisX Line. If not provided, it takes x value for label.
|
||||
* Default: x value
|
||||
* Example: “label1″, “label2″..
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* Sets the exploded value of dataPoint. It is applicable only in case of Pie and Doughnut Charts. This property causes the Pie/Doughnut slice to separate out.
|
||||
* Default: true
|
||||
* Example: true, false
|
||||
*/
|
||||
exploded?: boolean;
|
||||
/**
|
||||
* Sets the color of marker that is displayed on legend. This property works only with Pie and Doughnut charts. Value of legendMarkerColor can be “HTML Color Name” or “hex” code.
|
||||
* Default: dataSeries marker color
|
||||
* Example: “red”, “#008000″..
|
||||
*/
|
||||
legendMarkerColor?: string;
|
||||
}
|
||||
}
|
||||
Vendored
+2
-2
@@ -1,6 +1,6 @@
|
||||
// Type definitions for CasperJS v1.0.0 API
|
||||
// Type definitions for CasperJS v1.0.0
|
||||
// Project: http://casperjs.org/
|
||||
// Definitions by: Jed Hunsaker <https://github.com/jedhunsaker>
|
||||
// Definitions by: Jed Mao <https://github.com/jedmao>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../phantomjs/phantomjs.d.ts" />
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for chai-fuzzy 1.3.0 assert style
|
||||
// Type definitions for chai-fuzzy 1.3.0
|
||||
// Project: http://chaijs.com/plugins/chai-fuzzy
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
Vendored
+1
@@ -94,6 +94,7 @@ declare module chai {
|
||||
that: Expect;
|
||||
and: Expect;
|
||||
have: Expect;
|
||||
has: Expect;
|
||||
with: Expect;
|
||||
at: Expect;
|
||||
of: Expect;
|
||||
|
||||
Vendored
+1
@@ -41,6 +41,7 @@ declare module Chalk {
|
||||
cyan: ChalkChain;
|
||||
white: ChalkChain;
|
||||
gray: ChalkChain;
|
||||
grey: ChalkChain;
|
||||
|
||||
// Background colors
|
||||
bgBlack: ChalkChain;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/// <reference path="change-case.d.ts"/>
|
||||
|
||||
import changeCase = require("change-case");
|
||||
|
||||
var s: string;
|
||||
var b: boolean;
|
||||
|
||||
s = changeCase.dot(s);
|
||||
s = changeCase.dotCase(s);
|
||||
s = changeCase.swap(s);
|
||||
s = changeCase.swapCase(s);
|
||||
s = changeCase.path(s);
|
||||
s = changeCase.pathCase(s);
|
||||
s = changeCase.upper(s);
|
||||
s = changeCase.upperCase(s);
|
||||
s = changeCase.lower(s);
|
||||
s = changeCase.lowerCase(s);
|
||||
s = changeCase.camel(s);
|
||||
s = changeCase.camelCase(s);
|
||||
s = changeCase.snake(s);
|
||||
s = changeCase.snakeCase(s);
|
||||
s = changeCase.title(s);
|
||||
s = changeCase.titleCase(s);
|
||||
s = changeCase.param(s);
|
||||
s = changeCase.paramCase(s);
|
||||
s = changeCase.pascal(s);
|
||||
s = changeCase.pascalCase(s);
|
||||
s = changeCase.constant(s);
|
||||
s = changeCase.constantCase(s);
|
||||
s = changeCase.sentence(s);
|
||||
s = changeCase.sentenceCase(s);
|
||||
b = changeCase.isUpper(s);
|
||||
b = changeCase.isUpperCase(s);
|
||||
b = changeCase.isLower(s);
|
||||
b = changeCase.isLowerCase(s);
|
||||
s = changeCase.ucFirst(s);
|
||||
s = changeCase.upperCaseFirst(s);
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
// Type definitions for change-case
|
||||
// Project: https://github.com/blakeembrey/change-case
|
||||
// Definitions by: Asana <https://asana.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "change-case" {
|
||||
function dot(s: string): string;
|
||||
function dotCase(s: string): string;
|
||||
function swap(s: string): string;
|
||||
function swapCase(s: string): string;
|
||||
function path(s: string): string;
|
||||
function pathCase(s: string): string;
|
||||
function upper(s: string): string;
|
||||
function upperCase(s: string): string;
|
||||
function lower(s: string): string;
|
||||
function lowerCase(s: string): string;
|
||||
function camel(s: string): string;
|
||||
function camelCase(s: string): string;
|
||||
function snake(s: string): string;
|
||||
function snakeCase(s: string): string;
|
||||
function title(s: string): string;
|
||||
function titleCase(s: string): string;
|
||||
function param(s: string): string;
|
||||
function paramCase(s: string): string;
|
||||
function pascal(s: string): string;
|
||||
function pascalCase(s: string): string;
|
||||
function constant(s: string): string;
|
||||
function constantCase(s: string): string;
|
||||
function sentence(s: string): string;
|
||||
function sentenceCase(s: string): string;
|
||||
function isUpper(s: string): boolean;
|
||||
function isUpperCase(s: string): boolean;
|
||||
function isLower(s: string): boolean;
|
||||
function isLowerCase(s: string): boolean;
|
||||
function ucFirst(s: string): string;
|
||||
function upperCaseFirst(s: string): string;
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
/// <reference path="chart.d.ts" />
|
||||
|
||||
var canvas = <HTMLCanvasElement>document.getElementById('example-chart');
|
||||
var ctx = canvas.getContext('2d');
|
||||
|
||||
Chart.defaults.global = {
|
||||
animation: true,
|
||||
animationSteps: 60,
|
||||
animationEasing: "easeOutQuart",
|
||||
showScale: true,
|
||||
scaleOverride: false,
|
||||
scaleSteps: null,
|
||||
scaleStepWidth: null,
|
||||
scaleStartValue: null,
|
||||
scaleLineColor: "rgba(0,0,0,.1)",
|
||||
scaleLineWidth: 1,
|
||||
scaleShowLabels: true,
|
||||
scaleLabel: "<%=value%>",
|
||||
scaleIntegersOnly: true,
|
||||
scaleBeginAtZero: false,
|
||||
scaleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
|
||||
scaleFontSize: 12,
|
||||
scaleFontStyle: "normal",
|
||||
scaleFontColor: "#666",
|
||||
responsive: false,
|
||||
maintainAspectRatio: true,
|
||||
showTooltips: true,
|
||||
tooltipEvents: ["mousemove", "touchstart", "touchmove"],
|
||||
tooltipFillColor: "rgba(0,0,0,0.8)",
|
||||
tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
|
||||
tooltipFontSize: 14,
|
||||
tooltipFontStyle: "normal",
|
||||
tooltipFontColor: "#fff",
|
||||
tooltipTitleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
|
||||
tooltipTitleFontSize: 14,
|
||||
tooltipTitleFontStyle: "bold",
|
||||
tooltipTitleFontColor: "#fff",
|
||||
tooltipYPadding: 6,
|
||||
tooltipXPadding: 6,
|
||||
tooltipCaretSize: 8,
|
||||
tooltipCornerRadius: 6,
|
||||
tooltipXOffset: 10,
|
||||
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>",
|
||||
multiTooltipTemplate: "<%= value %>",
|
||||
onAnimationProgress: function () { },
|
||||
onAnimationComplete: function () { }
|
||||
}
|
||||
|
||||
var lineData: LinearChartData = {
|
||||
labels: ['03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00'],
|
||||
datasets: [
|
||||
{
|
||||
label: 'Accepted',
|
||||
fillColor: 'rgba(220,220,220,0.2)',
|
||||
strokeColor: 'rgba(220,220,220,1)',
|
||||
pointColor: 'rgba(220,220,220,1)',
|
||||
pointStrokeColor: '#fff',
|
||||
pointHighlightFill: '#fff',
|
||||
pointHighlightStroke: 'rgba(220,220,220,1)',
|
||||
data: [65, 59, 80, 81, 56, 55, 40]
|
||||
},
|
||||
{
|
||||
label: 'Quarantined',
|
||||
fillColor: 'rgba(151,187,205,0.2)',
|
||||
strokeColor: 'rgba(151,187,205,1)',
|
||||
pointColor: 'rgba(151,187,205,1)',
|
||||
pointStrokeColor: '#fff',
|
||||
pointHighlightFill: '#fff',
|
||||
pointHighlightStroke: 'rgba(151,187,205,1)',
|
||||
data: [28, 48, 40, 19, 86, 27, 90]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var myLineChart = new Chart(ctx).Line(lineData, {
|
||||
scaleShowGridLines: true,
|
||||
scaleGridLineColor: "rgba(0,0,0,.05)",
|
||||
scaleGridLineWidth: 1,
|
||||
bezierCurve: true,
|
||||
bezierCurveTension: 0.4,
|
||||
pointDot: true,
|
||||
pointDotRadius: 4,
|
||||
pointDotStrokeWidth: 1,
|
||||
pointHitDetectionRadius: 20,
|
||||
datasetStroke: true,
|
||||
datasetStrokeWidth: 2,
|
||||
datasetFill: true,
|
||||
legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
|
||||
});
|
||||
|
||||
var myLineChartLegend: string = myLineChart.generateLegend();
|
||||
var myLineChartImage: string = myLineChart.toBase64Image();
|
||||
myLineChart.addData([1, 2, 3, 4, 5, 6, 7], 'new');
|
||||
myLineChart.clear();
|
||||
myLineChart.removeData();
|
||||
myLineChart.resize();
|
||||
myLineChart.update();
|
||||
myLineChart.stop();
|
||||
myLineChart.destroy();
|
||||
|
||||
var barData: LinearChartData = {
|
||||
labels: ["January", "February", "March", "April", "May", "June", "July"],
|
||||
datasets: [
|
||||
{
|
||||
label: "My First dataset",
|
||||
fillColor: "rgba(220,220,220,0.5)",
|
||||
strokeColor: "rgba(220,220,220,0.8)",
|
||||
highlightFill: "rgba(220,220,220,0.75)",
|
||||
highlightStroke: "rgba(220,220,220,1)",
|
||||
data: [65, 59, 80, 81, 56, 55, 40]
|
||||
},
|
||||
{
|
||||
label: "My Second dataset",
|
||||
fillColor: "rgba(151,187,205,0.5)",
|
||||
strokeColor: "rgba(151,187,205,0.8)",
|
||||
highlightFill: "rgba(151,187,205,0.75)",
|
||||
highlightStroke: "rgba(151,187,205,1)",
|
||||
data: [28, 48, 40, 19, 86, 27, 90]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var myBarChart = new Chart(ctx).Bar(barData, {
|
||||
scaleBeginAtZero: true,
|
||||
scaleShowGridLines: true,
|
||||
scaleGridLineColor: "rgba(0,0,0,.05)",
|
||||
scaleGridLineWidth: 1,
|
||||
barShowStroke: true,
|
||||
barStrokeWidth: 2,
|
||||
barValueSpacing: 5,
|
||||
barDatasetSpacing: 1,
|
||||
legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
|
||||
});
|
||||
|
||||
var myBarChartLegend: string = myBarChart.generateLegend();
|
||||
var myBarChartImage: string = myBarChart.toBase64Image();
|
||||
myBarChart.addData([1, 2, 3, 4, 5, 6, 7], 'new');
|
||||
myBarChart.clear();
|
||||
myBarChart.removeData();
|
||||
myBarChart.resize();
|
||||
myBarChart.update();
|
||||
myBarChart.stop();
|
||||
myBarChart.destroy();
|
||||
|
||||
var radarData: LinearChartData = {
|
||||
labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
|
||||
datasets: [
|
||||
{
|
||||
label: "My First dataset",
|
||||
fillColor: "rgba(220,220,220,0.2)",
|
||||
strokeColor: "rgba(220,220,220,1)",
|
||||
pointColor: "rgba(220,220,220,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(220,220,220,1)",
|
||||
data: [65, 59, 90, 81, 56, 55, 40]
|
||||
},
|
||||
{
|
||||
label: "My Second dataset",
|
||||
fillColor: "rgba(151,187,205,0.2)",
|
||||
strokeColor: "rgba(151,187,205,1)",
|
||||
pointColor: "rgba(151,187,205,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(151,187,205,1)",
|
||||
data: [28, 48, 40, 19, 96, 27, 100]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var myRadarChart = new Chart(ctx).Radar(radarData, {
|
||||
scaleShowLine: true,
|
||||
angleShowLineOut: true,
|
||||
scaleShowLabels: false,
|
||||
scaleBeginAtZero: true,
|
||||
angleLineColor: "rgba(0,0,0,.1)",
|
||||
angleLineWidth: 1,
|
||||
pointLabelFontFamily: "'Arial'",
|
||||
pointLabelFontStyle: "normal",
|
||||
pointLabelFontSize: 10,
|
||||
pointLabelFontColor: "#666",
|
||||
pointDot: true,
|
||||
pointDotRadius: 3,
|
||||
pointDotStrokeWidth: 1,
|
||||
pointHitDetectionRadius: 20,
|
||||
datasetStroke: true,
|
||||
datasetStrokeWidth: 2,
|
||||
datasetFill: true,
|
||||
legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
|
||||
});
|
||||
|
||||
var myRadarChartLegend: string = myRadarChart.generateLegend();
|
||||
var myRadarChartImage: string = myRadarChart.toBase64Image();
|
||||
myRadarChart.addData([1, 2, 3, 4, 5, 6, 7], 'new');
|
||||
myRadarChart.clear();
|
||||
myRadarChart.removeData();
|
||||
myRadarChart.resize();
|
||||
myRadarChart.update();
|
||||
myRadarChart.stop();
|
||||
myRadarChart.destroy();
|
||||
|
||||
var polarAreaData: CircularChartData[] = [
|
||||
{
|
||||
value: 300,
|
||||
color: "#F7464A",
|
||||
highlight: "#FF5A5E",
|
||||
label: "Red"
|
||||
},
|
||||
{
|
||||
value: 50,
|
||||
color: "#46BFBD",
|
||||
highlight: "#5AD3D1",
|
||||
label: "Green"
|
||||
},
|
||||
{
|
||||
value: 100,
|
||||
color: "#FDB45C",
|
||||
highlight: "#FFC870",
|
||||
label: "Yellow"
|
||||
},
|
||||
{
|
||||
value: 40,
|
||||
color: "#949FB1",
|
||||
highlight: "#A8B3C5",
|
||||
label: "Grey"
|
||||
},
|
||||
{
|
||||
value: 120,
|
||||
color: "#4D5360",
|
||||
highlight: "#616774",
|
||||
label: "Dark Grey"
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
var myPolarAreaChart = new Chart(ctx).PolarArea(polarAreaData, {
|
||||
scaleShowLabelBackdrop: true,
|
||||
scaleBackdropColor: "rgba(255,255,255,0.75)",
|
||||
scaleBeginAtZero: true,
|
||||
scaleBackdropPaddingY: 2,
|
||||
scaleBackdropPaddingX: 2,
|
||||
scaleShowLine: true,
|
||||
segmentShowStroke: true,
|
||||
segmentStrokeColor: "#fff",
|
||||
segmentStrokeWidth: 2,
|
||||
animationSteps: 100,
|
||||
animationEasing: "easeOutBounce",
|
||||
animateRotate: true,
|
||||
animateScale: false,
|
||||
legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"
|
||||
});
|
||||
|
||||
var myPolarAreaChartLegend: string = myPolarAreaChart.generateLegend();
|
||||
var myPolarAreaChartImage: string = myPolarAreaChart.toBase64Image();
|
||||
myPolarAreaChart.addData([{
|
||||
value: 120,
|
||||
color: "#4D5360",
|
||||
highlight: "#616774",
|
||||
label: "Dark Grey"
|
||||
}], 0);
|
||||
myPolarAreaChart.clear();
|
||||
myPolarAreaChart.removeData(0);
|
||||
myPolarAreaChart.resize();
|
||||
myPolarAreaChart.update();
|
||||
myPolarAreaChart.stop();
|
||||
myPolarAreaChart.destroy();
|
||||
|
||||
var pieData: CircularChartData[] = [
|
||||
{
|
||||
value: 300,
|
||||
color: "#F7464A",
|
||||
highlight: "#FF5A5E",
|
||||
label: "Red"
|
||||
},
|
||||
{
|
||||
value: 50,
|
||||
color: "#46BFBD",
|
||||
highlight: "#5AD3D1",
|
||||
label: "Green"
|
||||
},
|
||||
{
|
||||
value: 100,
|
||||
color: "#FDB45C",
|
||||
highlight: "#FFC870",
|
||||
label: "Yellow"
|
||||
}
|
||||
];
|
||||
|
||||
// For a pie chart
|
||||
var myPieChart = new Chart(ctx).Pie(pieData, {
|
||||
segmentShowStroke: true,
|
||||
segmentStrokeColor: "#fff",
|
||||
segmentStrokeWidth: 2,
|
||||
percentageInnerCutout: 0,
|
||||
animationSteps: 100,
|
||||
animationEasing: "easeOutBounce",
|
||||
animateRotate: true,
|
||||
animateScale: false,
|
||||
legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"
|
||||
});
|
||||
|
||||
var myPieChartLegend: string = myPieChart.generateLegend();
|
||||
var myPieChartImage: string = myPieChart.toBase64Image();
|
||||
myPieChart.addData([{
|
||||
value: 120,
|
||||
color: "#4D5360",
|
||||
highlight: "#616774",
|
||||
label: "Dark Grey"
|
||||
}], 0);
|
||||
myPieChart.clear();
|
||||
myPieChart.removeData(0);
|
||||
myPieChart.resize();
|
||||
myPieChart.update();
|
||||
myPieChart.stop();
|
||||
myPieChart.destroy();
|
||||
|
||||
// And for a doughnut chart
|
||||
var myDoughnutChart = new Chart(ctx).Doughnut(pieData, {
|
||||
segmentShowStroke: true,
|
||||
segmentStrokeColor: "#fff",
|
||||
segmentStrokeWidth: 2,
|
||||
percentageInnerCutout: 50,
|
||||
animationSteps: 100,
|
||||
animationEasing: "easeOutBounce",
|
||||
animateRotate: true,
|
||||
animateScale: false,
|
||||
legendTemplate: "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"
|
||||
});
|
||||
|
||||
var myDoughnutChartLegend: string = myDoughnutChart.generateLegend();
|
||||
var myDoughnutChartImage: string = myDoughnutChart.toBase64Image();
|
||||
myPieChart.addData([{
|
||||
value: 120,
|
||||
color: "#4D5360",
|
||||
highlight: "#616774",
|
||||
label: "Dark Grey"
|
||||
}], 0);
|
||||
myDoughnutChart.clear();
|
||||
myDoughnutChart.removeData(0);
|
||||
myDoughnutChart.resize();
|
||||
myDoughnutChart.update();
|
||||
myDoughnutChart.stop();
|
||||
myDoughnutChart.destroy();
|
||||
Vendored
+205
@@ -0,0 +1,205 @@
|
||||
// Type definitions for Chart.js
|
||||
// Project: https://github.com/nnnick/Chart.js
|
||||
// Definitions by: Steve Fenton <https://github.com/Steve-Fenton>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface ChartDataSet {
|
||||
label: string;
|
||||
fillColor: string;
|
||||
strokeColor: string;
|
||||
|
||||
/* Line, Radar */
|
||||
pointColor?: string;
|
||||
pointStrokeColor?: string;
|
||||
pointHighlightFill?: string;
|
||||
pointHighlightStroke?: string;
|
||||
|
||||
/* Bar */
|
||||
highlightFill?: string;
|
||||
highlightStroke?: string;
|
||||
data: number[];
|
||||
}
|
||||
|
||||
interface LinearChartData {
|
||||
labels: string[];
|
||||
datasets: ChartDataSet[];
|
||||
}
|
||||
|
||||
interface CircularChartData {
|
||||
value: number;
|
||||
color: string;
|
||||
highlight: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
interface ChartSettings {
|
||||
animation: boolean;
|
||||
animationSteps: number;
|
||||
animationEasing: string;
|
||||
showScale: boolean;
|
||||
scaleOverride: boolean;
|
||||
scaleSteps: number;
|
||||
scaleStepWidth: number;
|
||||
scaleStartValue: number;
|
||||
scaleLineColor: string;
|
||||
scaleLineWidth: number;
|
||||
scaleShowLabels: boolean;
|
||||
scaleLabel: string;
|
||||
scaleIntegersOnly: boolean;
|
||||
scaleBeginAtZero: boolean;
|
||||
scaleFontFamily: string;
|
||||
scaleFontSize: number;
|
||||
scaleFontStyle: string;
|
||||
scaleFontColor: string;
|
||||
responsive: boolean;
|
||||
maintainAspectRatio: boolean;
|
||||
showTooltips: boolean;
|
||||
tooltipEvents: string[];
|
||||
tooltipFillColor: string;
|
||||
tooltipFontFamily: string;
|
||||
tooltipFontSize: number;
|
||||
tooltipFontStyle: string;
|
||||
tooltipFontColor: string;
|
||||
tooltipTitleFontFamily: string;
|
||||
tooltipTitleFontSize: number;
|
||||
tooltipTitleFontStyle: string;
|
||||
tooltipTitleFontColor: string;
|
||||
tooltipYPadding: number;
|
||||
tooltipXPadding: number;
|
||||
tooltipCaretSize: number;
|
||||
tooltipCornerRadius: number;
|
||||
tooltipXOffset: number;
|
||||
tooltipTemplate: string;
|
||||
multiTooltipTemplate: string;
|
||||
onAnimationProgress: () => any;
|
||||
onAnimationComplete: () => any;
|
||||
}
|
||||
|
||||
interface ChartOptions {
|
||||
scaleShowGridLines?: boolean;
|
||||
scaleGridLineColor?: string;
|
||||
scaleGridLineWidth?: number;
|
||||
legendTemplate?: string;
|
||||
}
|
||||
|
||||
interface PointsAtEvent {
|
||||
value: number;
|
||||
label: string;
|
||||
datasetLabel: string;
|
||||
strokeColor: string;
|
||||
fillColor: string;
|
||||
highlightFill: string;
|
||||
highlightStroke: string;
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
interface ChartInstance {
|
||||
clear: () => void;
|
||||
stop: () => void;
|
||||
resize: () => void;
|
||||
destroy: () => void;
|
||||
toBase64Image: () => string;
|
||||
generateLegend: () => string;
|
||||
}
|
||||
|
||||
interface LinearInstance extends ChartInstance {
|
||||
getPointsAtEvent: (event: Event) => PointsAtEvent[];
|
||||
update: () => void;
|
||||
addData: (valuesArray: number[], label: string) => void;
|
||||
removeData: () => void;
|
||||
}
|
||||
|
||||
interface CircularInstance extends ChartInstance {
|
||||
getSegmentsAtEvent: (event: Event) => {}[];
|
||||
update: () => void;
|
||||
addData: (valuesArray: CircularChartData[], index: number) => void;
|
||||
removeData: (index: number) => void;
|
||||
}
|
||||
|
||||
interface LineChartOptions extends ChartOptions {
|
||||
bezierCurve?: boolean;
|
||||
bezierCurveTension?: number;
|
||||
pointDot?: boolean;
|
||||
pointDotRadius?: number;
|
||||
pointDotStrokeWidth?: number;
|
||||
pointHitDetectionRadius?: number;
|
||||
datasetStroke?: boolean;
|
||||
datasetStrokeWidth?: number;
|
||||
datasetFill?: boolean;
|
||||
}
|
||||
|
||||
interface BarChartOptions extends ChartOptions {
|
||||
scaleBeginAtZero?: boolean;
|
||||
barShowStroke?: boolean;
|
||||
barStrokeWidth?: number;
|
||||
barValueSpacing?: number;
|
||||
barDatasetSpacing?: number;
|
||||
}
|
||||
|
||||
interface RadarChartOptions {
|
||||
scaleShowLine?: boolean;
|
||||
angleShowLineOut?: boolean;
|
||||
scaleShowLabels?: boolean;
|
||||
scaleBeginAtZero?: boolean;
|
||||
angleLineColor?: string;
|
||||
angleLineWidth?: number;
|
||||
pointLabelFontFamily?: string;
|
||||
pointLabelFontStyle?: string;
|
||||
pointLabelFontSize?: number;
|
||||
pointLabelFontColor?: string;
|
||||
pointDot?: boolean;
|
||||
pointDotRadius?: number;
|
||||
pointDotStrokeWidth?: number;
|
||||
pointHitDetectionRadius?: number;
|
||||
datasetStroke?: boolean;
|
||||
datasetStrokeWidth?: number;
|
||||
datasetFill?: boolean;
|
||||
legendTemplate?: string;
|
||||
}
|
||||
|
||||
interface PolarAreaChartOptions {
|
||||
scaleShowLabelBackdrop?: boolean;
|
||||
scaleBackdropColor?: string;
|
||||
scaleBeginAtZero?: boolean;
|
||||
scaleBackdropPaddingY?: number;
|
||||
scaleBackdropPaddingX?: number;
|
||||
scaleShowLine?: boolean;
|
||||
segmentShowStroke?: boolean;
|
||||
segmentStrokeColor?: string;
|
||||
segmentStrokeWidth?: number;
|
||||
animationSteps?: number;
|
||||
animationEasing?: string;
|
||||
animateRotate?: boolean;
|
||||
animateScale?: boolean;
|
||||
legendTemplate?: string;
|
||||
}
|
||||
|
||||
interface PieChartOptions {
|
||||
segmentShowStroke?: boolean;
|
||||
segmentStrokeColor?: string;
|
||||
segmentStrokeWidth?: number;
|
||||
percentageInnerCutout?: number;
|
||||
animationSteps?: number;
|
||||
animationEasing?: string;
|
||||
animateRotate?: boolean;
|
||||
animateScale?: boolean;
|
||||
legendTemplate?: string;
|
||||
}
|
||||
|
||||
interface Chart {
|
||||
Line(data: LinearChartData, options?: LineChartOptions): LinearInstance;
|
||||
Bar(data: LinearChartData, options?: BarChartOptions): LinearInstance;
|
||||
Radar(data: LinearChartData, options?: RadarChartOptions): LinearInstance;
|
||||
|
||||
PolarArea(data: CircularChartData[], options?: PolarAreaChartOptions): CircularInstance;
|
||||
Pie(data: CircularChartData[], options?: PieChartOptions): CircularInstance;
|
||||
Doughnut(data: CircularChartData[], options?: PieChartOptions): CircularInstance;
|
||||
}
|
||||
|
||||
declare var Chart: {
|
||||
new (context: CanvasRenderingContext2D): Chart;
|
||||
defaults: {
|
||||
global: ChartSettings;
|
||||
}
|
||||
};
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
// Type definitions for ChartJS
|
||||
// Project: http://js.devexpress.com/WebDevelopment/Charts/
|
||||
// Definitions by: DevExpress Inc. <http://devexpress.com/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../devextreme/dx.chartjs.d.ts" />
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path="checksum.d.ts" />
|
||||
|
||||
import checksum = require("checksum");
|
||||
|
||||
var s: string = checksum("abcd");
|
||||
var t: string = checksum("abcd", { algorithm: 'sha1' });
|
||||
|
||||
checksum.file("myfile.txt", (error: Error, hash: string): void => {
|
||||
// do nothing
|
||||
});
|
||||
|
||||
checksum.file("myfile.txt", { algorithm: 'sha1' }, (error: Error, hash: string): void => {
|
||||
// do nothing
|
||||
});
|
||||
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
// Type definitions for checksum 0.1.1
|
||||
// Project: https://github.com/dshaw/checksum
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "checksum" {
|
||||
|
||||
module checksum {
|
||||
/**
|
||||
* Options object for all functions
|
||||
*/
|
||||
interface ChecksumOptions {
|
||||
/**
|
||||
* Algorithm to use, default 'sha1'
|
||||
* Can be 'sha1' or 'md5' (see module 'crypto').
|
||||
*/
|
||||
algorithm?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the checksum for a file on disk
|
||||
* @param filename The file name
|
||||
* @param callback Callback which is called with the result or an error
|
||||
*/
|
||||
function file(filename: string, callback: (error: Error, hash: string) => void): void;
|
||||
/**
|
||||
* Generate the checksum for a file on disk
|
||||
* @param filename The file name
|
||||
* @param options Options object to indicate hash algo
|
||||
* @param callback Callback which is called with the result or an error
|
||||
*/
|
||||
function file(filename: string, options: ChecksumOptions, callback: (error: Error, hash: string) => void): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a checksum for the given value
|
||||
* @param value Any value
|
||||
* @param options Allows to set the algorithm
|
||||
* @returns Checksum
|
||||
*/
|
||||
function checksum(value: any, options?: checksum.ChecksumOptions): string;
|
||||
|
||||
export = checksum;
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
import runtime = chrome.app.runtime;
|
||||
import cwindow = chrome.app.window;
|
||||
|
||||
var createOptions: cwindow.CreateOptions = {
|
||||
var createOptions: cwindow.CreateWindowOptions = {
|
||||
id: "My Window",
|
||||
bounds: {
|
||||
left: 0,
|
||||
@@ -26,6 +26,35 @@ chrome.app.runtime.onRestarted.addListener(function () { return; });
|
||||
// Get Current Window
|
||||
var currentWindow: cwindow.AppWindow = chrome.app.window.current();
|
||||
|
||||
// FileSystem
|
||||
// https://developer.chrome.com/apps/fileSystem
|
||||
|
||||
function test_fileSystem(): void {
|
||||
var accepts: chrome.fileSystem.AcceptOptions[] = [
|
||||
{mimeTypes: ["text/*"], extensions: ['js', 'css', 'txt', 'html', 'xml', 'tsv', 'csv', 'rtf']}
|
||||
];
|
||||
var chooseOption: chrome.fileSystem.ChooseEntryOptions = {
|
||||
type: "openFile",
|
||||
suggestedName: "foo.txt",
|
||||
accepts: accepts,
|
||||
acceptsAllTypes: false,
|
||||
acceptsMultiple: false
|
||||
};
|
||||
chrome.fileSystem.chooseEntry(chooseOption, (entry: Entry) => {
|
||||
chrome.fileSystem.getDisplayPath(entry, (displayPath: string) => { });
|
||||
|
||||
var retainedId = chrome.fileSystem.retainEntry(entry);
|
||||
chrome.fileSystem.isRestorable(retainedId, (isRestorable: boolean) => {
|
||||
if(isRestorable){
|
||||
chrome.fileSystem.restoreEntry(retainedId, (restoredEntry: Entry) => { });
|
||||
}
|
||||
});
|
||||
|
||||
chrome.fileSystem.getWritableEntry(entry, (writableEntry: Entry) => {});
|
||||
chrome.fileSystem.isWritableEntry(entry, (isWritable: boolean) => {});
|
||||
});
|
||||
}
|
||||
|
||||
// Sockets
|
||||
// https://developer.chrome.com/apps/sockets_tcp
|
||||
function test_socketsTcp(): void {
|
||||
|
||||
Vendored
+111
-22
@@ -1,8 +1,10 @@
|
||||
// Type definitions for Chrome packaged application development
|
||||
// Project: http://developer.chrome.com/apps/
|
||||
// Definitions by: Adam Lay <https://github.com/AdamLay>, MIZUNE Pine <https://github.com/pine613>
|
||||
// Definitions by: Adam Lay <https://github.com/AdamLay>, MIZUNE Pine <https://github.com/pine613>, MIZUSHIMA Junki <https://github.com/mzsm>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path='../filesystem/filesystem.d.ts'/>
|
||||
|
||||
////////////////////
|
||||
// App Runtime
|
||||
////////////////////
|
||||
@@ -21,11 +23,11 @@ declare module chrome.app.runtime {
|
||||
}
|
||||
|
||||
interface LaunchedEvent {
|
||||
addListener(callback: (launchData: LaunchData) => void);
|
||||
addListener(callback: (launchData: LaunchData) => void): void;
|
||||
}
|
||||
|
||||
interface RestartedEvent {
|
||||
addListener(callback: () => void);
|
||||
addListener(callback: () => void): void;
|
||||
}
|
||||
|
||||
var onLaunched: LaunchedEvent;
|
||||
@@ -36,13 +38,65 @@ declare module chrome.app.runtime {
|
||||
// App Window
|
||||
////////////////////
|
||||
declare module chrome.app.window {
|
||||
interface Bounds {
|
||||
interface ContentBounds {
|
||||
left?: number;
|
||||
top?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
interface BoundsSpecification {
|
||||
left?: number;
|
||||
top?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
minWidth?: number;
|
||||
minHeight?: number;
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
}
|
||||
|
||||
interface Bounds {
|
||||
left: number;
|
||||
top: number;
|
||||
width: number;
|
||||
height: number;
|
||||
minWidth?: number;
|
||||
minHeight?: number;
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
setPosition(left: number, top: number): void;
|
||||
setSize(width: number, height: number): void;
|
||||
setMinimumSize(minWidth: number, minHeight: number): void;
|
||||
setMaximumSize(maxWidth: number, maxHeight: number): void;
|
||||
}
|
||||
interface FrameOptions {
|
||||
type?: string;
|
||||
color?: string;
|
||||
activeColor?: string;
|
||||
inactiveColor?: string;
|
||||
}
|
||||
|
||||
interface CreateWindowOptions {
|
||||
id?: string;
|
||||
innerBounds?: BoundsSpecification;
|
||||
outerBounds?: BoundsSpecification;
|
||||
minWidth?: number;
|
||||
minHeight?: number;
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
frame?: any; // string ("none", "chrome") or FrameOptions
|
||||
bounds?: ContentBounds;
|
||||
alphaEnabled?: boolean;
|
||||
state?: string; // "normal", "fullscreen", "maximized", "minimized"
|
||||
hidden?: boolean;
|
||||
resizable?: boolean;
|
||||
singleton?: boolean;
|
||||
alwaysOnTop?: boolean;
|
||||
focused?: boolean;
|
||||
visibleOnAllWorkspaces?: boolean;
|
||||
}
|
||||
|
||||
interface AppWindow {
|
||||
focus: () => void;
|
||||
fullscreen: () => void;
|
||||
@@ -59,27 +113,18 @@ declare module chrome.app.window {
|
||||
close: () => void;
|
||||
show: () => void;
|
||||
hide: () => void;
|
||||
getBounds: () => Bounds;
|
||||
setBounds: (bounds: Bounds) => void;
|
||||
getBounds: () => ContentBounds;
|
||||
setBounds: (bounds: ContentBounds) => void;
|
||||
isAlwaysOnTop: () => boolean;
|
||||
setAlwaysOnTop: (alwaysOnTop: boolean) => void;
|
||||
setVisibleOnAllWorkspaces: (alwaysVisible: boolean) => void;
|
||||
contentWindow: Window;
|
||||
id: string;
|
||||
innerBounds: Bounds;
|
||||
outerBounds: Bounds;
|
||||
}
|
||||
|
||||
interface CreateOptions {
|
||||
id?: string;
|
||||
minWidth?: number;
|
||||
minHeight?: number;
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
frame?: string; // "none", "chrome"
|
||||
bounds?: Bounds;
|
||||
transparentBackground?: boolean;
|
||||
state?: string; // "normal", "fullscreen", "maximized", "minimized"
|
||||
hidden?: boolean;
|
||||
resizable?: boolean;
|
||||
singleton?: boolean;
|
||||
}
|
||||
|
||||
export function create(url: string, options?: CreateOptions, callback?: (created_window: AppWindow) => void): void;
|
||||
export function create(url: string, options?: CreateWindowOptions, callback?: (created_window: AppWindow) => void): void;
|
||||
export function current(): AppWindow;
|
||||
|
||||
interface WindowEvent {
|
||||
@@ -94,6 +139,50 @@ declare module chrome.app.window {
|
||||
var onRestored: WindowEvent;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// fileSystem
|
||||
////////////////////
|
||||
declare module chrome.fileSystem {
|
||||
|
||||
interface ChildChangeInfo {
|
||||
entry: Entry;
|
||||
type: string;
|
||||
}
|
||||
|
||||
interface EntryChangedEvent {
|
||||
target: Entry;
|
||||
childChanges?: ChildChangeInfo[];
|
||||
}
|
||||
|
||||
interface EntryRemovedEvent {
|
||||
target: Entry;
|
||||
}
|
||||
|
||||
interface AcceptOptions {
|
||||
description?: string;
|
||||
mimeTypes?: string[];
|
||||
extensions?: string[];
|
||||
}
|
||||
|
||||
interface ChooseEntryOptions {
|
||||
type?: string;
|
||||
suggestedName?: string;
|
||||
accepts?: AcceptOptions[];
|
||||
acceptsAllTypes?: boolean;
|
||||
acceptsMultiple?: boolean;
|
||||
}
|
||||
|
||||
export function getDisplayPath(entry: Entry, callback: (displayPath: string) => void): void;
|
||||
export function getWritableEntry(entry: Entry, callback: (entry: Entry) => void): void;
|
||||
export function isWritableEntry(entry: Entry, callback: (isWritable: boolean) => void): void;
|
||||
export function chooseEntry(callback: (entry: Entry) => void): void;
|
||||
export function chooseEntry(callback: (fileEntries: FileEntry[]) => void): void;
|
||||
export function chooseEntry(options: ChooseEntryOptions, callback: (entry: Entry) => void): void;
|
||||
export function chooseEntry(options: ChooseEntryOptions, callback: (fileEntries: FileEntry[]) => void): void;
|
||||
export function restoreEntry(id: string, callback: (entry: Entry) => void): void;
|
||||
export function isRestorable(id: string, callback: (isRestorable: boolean) => void): void;
|
||||
export function retainEntry(entry: Entry): string;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// Sockets
|
||||
|
||||
+22
-1
@@ -152,4 +152,25 @@ function printPage() {
|
||||
var action_url = "javascript:window.print();";
|
||||
chrome.tabs.update(tab.id, { url: action_url });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// https://developer.chrome.com/extensions/examples/extensions/catblock/background.js
|
||||
function catBlock () {
|
||||
var loldogs: string[];
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function(info) {
|
||||
console.log("Cat intercepted: " + info.url);
|
||||
// Redirect the lolcal request to a random loldog URL.
|
||||
var i = Math.round(Math.random() * loldogs.length);
|
||||
return {redirectUrl: loldogs[i]};
|
||||
},
|
||||
// filters
|
||||
{
|
||||
urls: [
|
||||
"https://i.chzbgr.com/*"
|
||||
],
|
||||
types: ["image"]
|
||||
},
|
||||
// extraInfoSpec
|
||||
["blocking"]);
|
||||
}
|
||||
|
||||
Vendored
+12
-11
@@ -1053,6 +1053,7 @@ declare module chrome.identity {
|
||||
declare module chrome.i18n {
|
||||
export function getMessage(messageName: string, substitutions?: any): string;
|
||||
export function getAcceptLanguages(callback: (languages: string[]) => void): void;
|
||||
export function getUILanguage(): string;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
@@ -1616,8 +1617,8 @@ declare module chrome.runtime {
|
||||
var onStartup: RuntimeStartupEvent;
|
||||
var onInstalled: RuntimeInstalledEvent;
|
||||
var onSuspendCanceled: RuntimeSuspendCanceledEvent;
|
||||
var onMessage: RuntimeMessageEvent;
|
||||
var onMessageExternal: RuntimeMessageEvent;
|
||||
var onMessage: ExtensionMessageEvent;
|
||||
var onMessageExternal: ExtensionMessageExternalEvent;
|
||||
var onRestartRequired: RuntimeRestartRequiredEvent;
|
||||
var onUpdateAvailable: RuntimeUpdateAvailableEvent;
|
||||
|
||||
@@ -2247,7 +2248,7 @@ declare module chrome.webRequest {
|
||||
|
||||
interface RequestFilter {
|
||||
tabId?: number;
|
||||
types?: string;
|
||||
types?: string[];
|
||||
urls: string[];
|
||||
windowId?: number;
|
||||
}
|
||||
@@ -2395,15 +2396,15 @@ declare module chrome.webRequest {
|
||||
}
|
||||
|
||||
interface WebRequestCompletedEvent extends chrome.events.Event {
|
||||
addListener(callback: (details: OnCompletedDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
addListener(callback: (details: OnCompletedDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
}
|
||||
|
||||
interface WebRequestHeadersReceivedEvent extends chrome.events.Event {
|
||||
addListener(callback: (details: OnHeadersReceivedDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
addListener(callback: (details: OnHeadersReceivedDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
}
|
||||
|
||||
interface WebRequestBeforeRedirectEvent extends chrome.events.Event {
|
||||
addListener(callback: (details: OnBeforeRedirectDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
addListener(callback: (details: OnBeforeRedirectDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
}
|
||||
|
||||
interface WebRequestAuthRequiredEvent extends chrome.events.Event {
|
||||
@@ -2411,23 +2412,23 @@ declare module chrome.webRequest {
|
||||
}
|
||||
|
||||
interface WebRequestBeforeSendHeadersEvent extends chrome.events.Event {
|
||||
addListener(callback: (details: OnBeforeSendHeadersDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
addListener(callback: (details: OnBeforeSendHeadersDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
}
|
||||
|
||||
interface WebRequestErrorOccurredEvent extends chrome.events.Event {
|
||||
addListener(callback: (details: OnErrorOccurredDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
addListener(callback: (details: OnErrorOccurredDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
}
|
||||
|
||||
interface WebRequestResponseStartedEvent extends chrome.events.Event {
|
||||
addListener(callback: (details: OnResponseStartedDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
addListener(callback: (details: OnResponseStartedDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
}
|
||||
|
||||
interface WebRequestSendHeadersEvent extends chrome.events.Event {
|
||||
addListener(callback: (details: OnSendHeadersDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
addListener(callback: (details: OnSendHeadersDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
}
|
||||
|
||||
interface WebRequestBeforeRequestEvent extends chrome.events.Event {
|
||||
addListener(callback: (details: OnBeforeRequestDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
addListener(callback: (details: OnBeforeRequestDetails) => BlockingResponse, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
|
||||
}
|
||||
|
||||
var MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: number;
|
||||
|
||||
@@ -251,4 +251,53 @@ function test_dom_window() {
|
||||
var size = win.getViewPaneSize();
|
||||
alert(size.width);
|
||||
alert(size.height);
|
||||
}
|
||||
}
|
||||
|
||||
function test_adding_dialog_by_path() {
|
||||
CKEDITOR.dialog.add( 'abbrDialog', this.path + 'dialogs/abbr.js' );
|
||||
}
|
||||
|
||||
function test_adding_dialog_by_definition() {
|
||||
CKEDITOR.dialog.add( 'abbrDialog', function ( editor: CKEDITOR.editor ) {
|
||||
return {
|
||||
title: 'Abbreviation Properties',
|
||||
minWidth: 400,
|
||||
minHeight: 200,
|
||||
|
||||
contents: [
|
||||
{
|
||||
id: 'tab-basic',
|
||||
label: 'Basic Settings',
|
||||
elements: <any[]>[]
|
||||
},
|
||||
{
|
||||
id: 'tab-adv',
|
||||
label: 'Advanced Settings',
|
||||
elements: []
|
||||
}
|
||||
]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function test_adding_plugin() {
|
||||
CKEDITOR.plugins.add( 'abbr', {
|
||||
icons: 'abbr',
|
||||
init: function( editor: CKEDITOR.editor ) {
|
||||
// empty logic
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function test_adding_widget() {
|
||||
function wrapper(editor: CKEDITOR.editor) {
|
||||
editor.widgets.add("widgetty", {
|
||||
button: "Activate widgetty",
|
||||
template: "<imaginary-element>",
|
||||
dialog: "widgetty",
|
||||
init: function() {
|
||||
// no logic
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+178
-6
@@ -9,6 +9,7 @@ declare module CKEDITOR {
|
||||
|
||||
// Config options
|
||||
var disableAutoInline: boolean;
|
||||
var disableObjectResizing: boolean;
|
||||
var replaceClass: string;
|
||||
var skinName: string;
|
||||
|
||||
@@ -549,11 +550,28 @@ declare module CKEDITOR {
|
||||
|
||||
}
|
||||
|
||||
interface toolbarGroups {
|
||||
name?: string;
|
||||
groups?: string[];
|
||||
}
|
||||
|
||||
interface config {
|
||||
startupMode: string;
|
||||
removeButtons: string;
|
||||
startupMode?: string;
|
||||
removeButtons?: string;
|
||||
removePlugins?: string;
|
||||
toolbar?: any;
|
||||
toolbarGroups?: toolbarGroups[];
|
||||
skin?: string;
|
||||
language?: string;
|
||||
plugins?: string;
|
||||
font_names?: string;
|
||||
font_defaultLabel?: string;
|
||||
fontSize_sizes?: string;
|
||||
fontSize_defaultLabel?: string;
|
||||
colorButton_enableMore?: boolean;
|
||||
colorButton_colors?: string;
|
||||
startupFocus?: boolean;
|
||||
on?: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -602,11 +620,134 @@ declare module CKEDITOR {
|
||||
|
||||
|
||||
module widget {
|
||||
class repository {
|
||||
interface IWidget {
|
||||
allowedContent: any;
|
||||
button: string;
|
||||
contentForms: Object;
|
||||
contentTransformations: Object;
|
||||
data: Function;
|
||||
defaults: Object;
|
||||
dialog: String;
|
||||
downcast: any; // should be string | Function
|
||||
downcasts: Object;
|
||||
draggable: boolean;
|
||||
editables: Object;
|
||||
init: Function;
|
||||
inline: Boolean;
|
||||
insert: Function;
|
||||
mask: Boolean;
|
||||
name: String;
|
||||
parts: Object;
|
||||
pathName: string;
|
||||
requiredContent: any;
|
||||
styleToAllowedContentRules: Function;
|
||||
styleableElements: string;
|
||||
template: string;
|
||||
upcast: any; // should be string | Function
|
||||
upcasts: Object;
|
||||
|
||||
addClass(className: string): void;
|
||||
applyStyle(style: any): void; // any should be CKEDITOR.style
|
||||
capture(): void;
|
||||
checkStyleActive(style: any): boolean; // any should be CKEDITOR.style
|
||||
define(name: string, meta: {errorProof?: boolean}): void;
|
||||
destroy(offline?: boolean): void;
|
||||
destroyEditable(editableName:string, offline?: boolean): void;
|
||||
edit(): boolean;
|
||||
fire(eventName: string, data?: Object, editor?: editor): any; // should be boolean | Object
|
||||
fireOnce(eventName: string, data?: Object, editor?: editor): any; // should be boolean | Object
|
||||
focus(): void;
|
||||
getClasses(): Object;
|
||||
hasClass(className: string, Whether: boolean): void;
|
||||
hasListeners(eventName: string): boolean;
|
||||
initEditable(editableName: string, definition: any): boolean; // any should be CKEDITOR.plugins.widget.nestedEditable.definition
|
||||
isInited(): boolean;
|
||||
isReady(): boolean;
|
||||
on(eventName: string, listenerFunction: Function,
|
||||
scopeObj: Object, listenerData: Object, priority: number): Object;
|
||||
once(): void;
|
||||
removeAllListeners(): void;
|
||||
removeClass(className: string): void;
|
||||
removeListener(evnetName: string, listenerFunction: Function): void;
|
||||
removeStyle(style: any): void; // any should be CKEDITOR.style
|
||||
setData(keyOrData: any, value?: Object): IWidget; // any should be string | Object
|
||||
setFocused(selected: boolean): IWidget;
|
||||
setSelected(selected: boolean): IWidget;
|
||||
toFeature(): any; // should be CKEDITOR.feature
|
||||
updateDragHandlerPosition(): void;
|
||||
}
|
||||
|
||||
interface IWidgetDefinition {
|
||||
allowedContent?: any;
|
||||
button?: string;
|
||||
contentForms?: Object;
|
||||
contentTransformations?: Object;
|
||||
data?: Function;
|
||||
defaults?: Object;
|
||||
dialog?: String;
|
||||
downcast?: any; // should be string | Function
|
||||
downcasts?: Object;
|
||||
draggable?: boolean;
|
||||
edit?: Function;
|
||||
editables?: Object;
|
||||
init?: Function;
|
||||
inline?: Boolean;
|
||||
insert?: Function;
|
||||
mask?: Boolean;
|
||||
name?: String;
|
||||
parts?: Object;
|
||||
pathName?: string;
|
||||
requiredContent?: any;
|
||||
styleToAllowedContentRules?: Function;
|
||||
styleableElements?: string;
|
||||
template?: string;
|
||||
upcast?: any; // should be string | Function
|
||||
upcasts?: Object;
|
||||
toFeature?(): any; // should be CKEDITOR.feature
|
||||
}
|
||||
|
||||
class repository {
|
||||
add(name: string, widgetDef: IWidgetDefinition): void;
|
||||
addUpcastCallback(callback: Function): void;
|
||||
capture(): void;
|
||||
checkSelection(): void;
|
||||
checkWidgets(options?: {initOnlyNew?: boolean; focusInited?: boolean}): void;
|
||||
define(name: string, meta?: {errorProof?: boolean}): void;
|
||||
del(widget: IWidget): void;
|
||||
destroy(widget: IWidget, offline?: boolean): void;
|
||||
destroyAll(offline?: boolean): void;
|
||||
finalizeCreation(container: any): void;
|
||||
fire(eventName: string, data: Object, editor: editor): any; // should be boolean | Object
|
||||
getByElement(element: any, checkWrapperOnly: boolean): IWidget;
|
||||
hasListeners(eventName: string): boolean;
|
||||
initOn(element: any, widgetDef?: IWidgetDefinition, startupData?: Object): IWidget;
|
||||
initOnAll(container?: any): IWidget[];
|
||||
on(eventName: string, listenerFunction: Function, scopeObj?: Object, listenerData?: Object, priority?: number): Object;
|
||||
once(): void;
|
||||
parseElementClasses(classes: string): Object;
|
||||
removeAllListeners(eventName: string, listenerFunction: Function): void;
|
||||
wrapElement(element: any, widgetName?: string): any;
|
||||
}
|
||||
}
|
||||
|
||||
interface IPluginDefinition {
|
||||
hidpi?: boolean;
|
||||
lang?: any; // should be string | string[]
|
||||
requires?: any; // should be string | string[]a
|
||||
afterInit?(editor: editor): any;
|
||||
beforeInit?(editor: editor): any;
|
||||
init?(editor: editor): any;
|
||||
onLoad?(): any;
|
||||
}
|
||||
|
||||
function add(name: string, definition?: IPluginDefinition): void;
|
||||
function addExternal(name: string, path: string, fileName: string): void;
|
||||
function get(name: string): any;
|
||||
function getFilePath(name: string): string;
|
||||
function getPath(name: string): string;
|
||||
function load(name: string, callback: string, scope: any): void;
|
||||
function setLang(pluginName: string, languageCode: string, languageEntries: any): void;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -666,7 +807,7 @@ declare module CKEDITOR {
|
||||
getClipboardData(options: Object, callback: Function): void;
|
||||
getColorFromDialog(callback: Function, scope?: Object): void;
|
||||
getCommand(commandName: string): command;
|
||||
getData(noEvents: Object): string;
|
||||
getData(noEvents?: Object): string;
|
||||
getMenuItem(name: string): Object;
|
||||
getResizable(forContents: boolean): dom.element;
|
||||
getSelection(forceRealSelection?: boolean): dom.selection;
|
||||
@@ -695,7 +836,7 @@ declare module CKEDITOR {
|
||||
selectionChange(checkNow?: boolean): void;
|
||||
setActiveEnterMode(enterMode: number, shiftEnterMode: number): void;
|
||||
setActiveFilter(filter: filter): void;
|
||||
setData(data: string, callback: Function, internal: boolean): void;
|
||||
setData(data: string, options?: { internal?: boolean; callback?: Function; noSnapshot?: boolean; }): void;
|
||||
setKeystroke(keystroke: number, behavior?: string): void;
|
||||
setKeystroke(keystroke: any[], behavior?: string): void;
|
||||
setKeystroke(keystroke: number, behavior?: boolean): void;
|
||||
@@ -951,4 +1092,35 @@ declare module CKEDITOR {
|
||||
addFocusable(element: CKEDITOR.dom.element, index: number): void;
|
||||
}
|
||||
|
||||
}
|
||||
module tools {
|
||||
var callFunction: Function;
|
||||
}
|
||||
|
||||
module dialog {
|
||||
interface IDialogDefinition {
|
||||
buttons?: any[];
|
||||
contents?: any[];
|
||||
height?: number;
|
||||
minHeight?: number;
|
||||
minWidth?: number;
|
||||
onCancel?: Function;
|
||||
onLoad?: Function;
|
||||
onOk?: Function;
|
||||
onShow?: Function;
|
||||
resizable?: number;
|
||||
title?: string;
|
||||
width?: number;
|
||||
}
|
||||
|
||||
function add(name: string, path: string): void;
|
||||
function add(name: string, dialogDefinition: IDialogDefinition): void;
|
||||
function addIframe(name: string, title: string, minWidth: number,
|
||||
minHeight: number, onContentLoad: Function, userDefinition: any): void;
|
||||
function addUIElement(typeName: string, builder: Function): void;
|
||||
function cancelButton(): void;
|
||||
function exists(name: string): void;
|
||||
function getCurrent(): void;
|
||||
function isTabEnabled(editor: editor, dialogName: string, tabName: string): boolean;
|
||||
function okButton(): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@ var original = {
|
||||
|
||||
var copy = clone(original);
|
||||
copy = clone(original, false);
|
||||
copy = clone(original, true);
|
||||
copy = clone(original, true, 1);
|
||||
copy = clone.clonePrototype(original);
|
||||
|
||||
Vendored
+11
-3
@@ -8,10 +8,18 @@
|
||||
*/
|
||||
declare module "clone" {
|
||||
/**
|
||||
* @param parent
|
||||
* @param circular If not given, defaults to true in JS lib.
|
||||
* @param val the value that you want to clone, any type allowed
|
||||
* @param circular Call clone with circular set to false if you are certain that obj contains no circular references. This will give better performance if needed. There is no error if undefined or null is passed as obj.
|
||||
* @param depth to wich the object is to be cloned (optional, defaults to infinity)
|
||||
*/
|
||||
function clone(parent: Object, circular?: boolean): Object
|
||||
function clone<T>(val: T, circular?: boolean, depth?: number): T;
|
||||
|
||||
module clone {
|
||||
/**
|
||||
* @param obj the object that you want to clone
|
||||
*/
|
||||
function clonePrototype<T>(obj: T): T;
|
||||
}
|
||||
|
||||
export = clone
|
||||
}
|
||||
|
||||
Vendored
+110
@@ -806,4 +806,114 @@ declare module CodeMirror {
|
||||
By default, a marker appears only in its target document. */
|
||||
shared?: boolean;
|
||||
}
|
||||
|
||||
interface StringStream {
|
||||
lastColumnPos: number;
|
||||
lastColumnValue: number;
|
||||
lineStart: number;
|
||||
|
||||
/**
|
||||
* Current position in the string.
|
||||
*/
|
||||
pos: number;
|
||||
|
||||
/**
|
||||
* Where the stream's position was when it was first passed to the token function.
|
||||
*/
|
||||
start: number;
|
||||
|
||||
/**
|
||||
* The current line's content.
|
||||
*/
|
||||
string: string;
|
||||
|
||||
/**
|
||||
* Number of spaces per tab character.
|
||||
*/
|
||||
tabSize: number;
|
||||
|
||||
/**
|
||||
* Returns true only if the stream is at the end of the line.
|
||||
*/
|
||||
eol(): boolean;
|
||||
|
||||
/**
|
||||
* Returns true only if the stream is at the start of the line.
|
||||
*/
|
||||
sol(): boolean;
|
||||
|
||||
/**
|
||||
* Returns the next character in the stream without advancing it. Will return an null at the end of the line.
|
||||
*/
|
||||
peek(): string;
|
||||
|
||||
/**
|
||||
* Returns the next character in the stream and advances it. Also returns null when no more characters are available.
|
||||
*/
|
||||
next(): string;
|
||||
|
||||
/**
|
||||
* match can be a character, a regular expression, or a function that takes a character and returns a boolean.
|
||||
* If the next character in the stream 'matches' the given argument, it is consumed and returned.
|
||||
* Otherwise, undefined is returned.
|
||||
*/
|
||||
eat(match: string): string;
|
||||
eat(match: RegExp): string;
|
||||
eat(match: (char: string) => boolean): string;
|
||||
|
||||
/**
|
||||
* Repeatedly calls eat with the given argument, until it fails. Returns true if any characters were eaten.
|
||||
*/
|
||||
eatWhile(match: string): boolean;
|
||||
eatWhile(match: RegExp): boolean;
|
||||
eatWhile(match: (char: string) => boolean): boolean;
|
||||
|
||||
/**
|
||||
* Shortcut for eatWhile when matching white-space.
|
||||
*/
|
||||
eatSpace(): boolean;
|
||||
|
||||
/**
|
||||
* Moves the position to the end of the line.
|
||||
*/
|
||||
skipToEnd(): void;
|
||||
|
||||
/**
|
||||
* Skips to the next occurrence of the given character, if found on the current line (doesn't advance the stream if
|
||||
* the character does not occur on the line).
|
||||
*
|
||||
* Returns true if the character was found.
|
||||
*/
|
||||
skipTo(ch: string): boolean;
|
||||
|
||||
/**
|
||||
* Act like a multi-character eat - if consume is true or not given - or a look-ahead that doesn't update the stream
|
||||
* position - if it is false. pattern can be either a string or a regular expression starting with ^. When it is a
|
||||
* string, caseFold can be set to true to make the match case-insensitive. When successfully matching a regular
|
||||
* expression, the returned value will be the array returned by match, in case you need to extract matched groups.
|
||||
*/
|
||||
match(pattern: string, consume?: boolean, caseFold?: boolean): boolean;
|
||||
match(pattern: RegExp, consume?: boolean): string[];
|
||||
|
||||
/**
|
||||
* Backs up the stream n characters. Backing it up further than the start of the current token will cause things to
|
||||
* break, so be careful.
|
||||
*/
|
||||
backUp(n: number): void;
|
||||
|
||||
/**
|
||||
* Returns the column (taking into account tabs) at which the current token starts.
|
||||
*/
|
||||
column(): number;
|
||||
|
||||
/**
|
||||
* Tells you how far the current line has been indented, in spaces. Corrects for tab characters.
|
||||
*/
|
||||
indentation(): number;
|
||||
|
||||
/**
|
||||
* Get the string between the start of the current token and the current stream position.
|
||||
*/
|
||||
current(): string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,100 @@
|
||||
///<reference path="commander.d.ts"/>
|
||||
|
||||
//
|
||||
// TODO: improve tests
|
||||
// [the code below was extracted from the documentation and examples, but does not seem to cover all cases]
|
||||
//
|
||||
// NOTE: import statement can not use in TypeScript 1.0.1
|
||||
var program:commander.IExportedCommand = require('commander');
|
||||
|
||||
import program = require("commander");
|
||||
declare module commander {
|
||||
interface IExportedCommand {
|
||||
peppers:boolean;
|
||||
pineapple:boolean;
|
||||
bbq:boolean;
|
||||
cheese:string;
|
||||
}
|
||||
}
|
||||
|
||||
program
|
||||
.version('0.0.1')
|
||||
.option('-C, --chdir <path>', 'change the working directory')
|
||||
.option('-c, --config <path>', 'set config path [./deploy.conf]')
|
||||
.option('-T, --no-tests', 'ignore test hook')
|
||||
.version('0.0.1')
|
||||
.option('-p, --peppers', 'Add peppers')
|
||||
.option('-P, --pineapple', 'Add pineapple')
|
||||
.option('-b, --bbq', 'Add bbq sauce')
|
||||
.option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
|
||||
.parse(process.argv);
|
||||
|
||||
console.log('you ordered a pizza with:');
|
||||
if (program.peppers) console.log(' - peppers');
|
||||
if (program.pineapple) console.log(' - pineapple');
|
||||
if (program.bbq) console.log(' - bbq');
|
||||
console.log(' - %s cheese', program.cheese);
|
||||
|
||||
function range(val:string) {
|
||||
return val.split('..').map(Number);
|
||||
}
|
||||
|
||||
function list(val:string) {
|
||||
return val.split(',');
|
||||
}
|
||||
|
||||
function collect(val:string, memo:string[]) {
|
||||
memo.push(val);
|
||||
return memo;
|
||||
}
|
||||
|
||||
function increaseVerbosity(v:any, total:number) {
|
||||
return total + 1;
|
||||
}
|
||||
|
||||
declare module commander {
|
||||
interface IExportedCommand {
|
||||
integer:number;
|
||||
float:number;
|
||||
optional:string;
|
||||
range:number[];
|
||||
list:string[];
|
||||
collect:string[];
|
||||
verbose:number;
|
||||
}
|
||||
}
|
||||
|
||||
// $ deploy setup stage
|
||||
// $ deploy setup
|
||||
program
|
||||
.command('setup [env]')
|
||||
.description('run setup commands for all envs')
|
||||
.action(function (env?) {
|
||||
env = env || 'all';
|
||||
console.log('setup for %s env(s)', env);
|
||||
});
|
||||
.version('0.0.1')
|
||||
.usage('[options] <file ...>')
|
||||
.option('-i, --integer <n>', 'An integer argument', parseInt)
|
||||
.option('-f, --float <n>', 'A float argument', parseFloat)
|
||||
.option('-r, --range <a>..<b>', 'A range', range)
|
||||
.option('-l, --list <items>', 'A list', list)
|
||||
.option('-o, --optional [value]', 'An optional value')
|
||||
.option('-c, --collect [value]', 'A repeatable value', collect, [])
|
||||
.option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)
|
||||
.parse(process.argv);
|
||||
|
||||
console.log(' int: %j', program.integer);
|
||||
console.log(' float: %j', program.float);
|
||||
console.log(' optional: %j', program.optional);
|
||||
program.range = program.range || [];
|
||||
console.log(' range: %j..%j', program.range[0], program.range[1]);
|
||||
console.log(' list: %j', program.list);
|
||||
console.log(' collect: %j', program.collect);
|
||||
console.log(' verbosity: %j', program.verbose);
|
||||
console.log(' args: %j', program.args);
|
||||
|
||||
|
||||
// $ deploy stage
|
||||
// $ deploy production
|
||||
program
|
||||
.command('*')
|
||||
.action(function (env?) {
|
||||
console.log('deploying "%s"', env);
|
||||
});
|
||||
.version('0.0.1')
|
||||
.option('-f, --foo', 'enable some foo')
|
||||
.option('-b, --bar', 'enable some bar')
|
||||
.option('-B, --baz', 'enable some baz');
|
||||
|
||||
program.option('-p, --pepper', 'add pepper');
|
||||
// must be before .parse() since
|
||||
// node's emit() is immediate
|
||||
|
||||
program.option('-C, --chdir <path>', 'change the working directory');
|
||||
|
||||
program.prompt('Username: ', function (name) {
|
||||
console.log('hi %s', name);
|
||||
program.on('--help', () => {
|
||||
console.log(' Examples:');
|
||||
console.log('');
|
||||
console.log(' $ custom-help --help');
|
||||
console.log(' $ custom-help -h');
|
||||
console.log('');
|
||||
});
|
||||
|
||||
program.prompt('Description:', function (desc) {
|
||||
console.log('description was "%s"', desc.trim());
|
||||
});
|
||||
program.parse(process.argv);
|
||||
|
||||
program.promptForNumber("Enter a number:", (n) => { });
|
||||
|
||||
program.confirm("Confirm? ", (f) => { });
|
||||
|
||||
program.choose(["a", "b", "c"], (i) => { });
|
||||
console.log('stuff');
|
||||
|
||||
Vendored
+383
-209
@@ -1,228 +1,402 @@
|
||||
// Type definitions for commanderjs 1.1.1
|
||||
// Type definitions for commanderjs 2.3.0
|
||||
// Project: https://github.com/visionmedia/commander.js
|
||||
// Definitions by: Marcelo Dezem <http://github.com/mdezem>
|
||||
// Definitions by: Marcelo Dezem <http://github.com/mdezem>, vvakame <http://github.com/vvakame>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "commander" {
|
||||
export interface Command {
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module commander {
|
||||
interface ICommandStatic {
|
||||
/**
|
||||
* The command name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
//
|
||||
//
|
||||
// NOTE: the methods below are COPIED to the module
|
||||
// as functions exports. If changes need to be made here,
|
||||
// remember to re-paste the definitions in the module.
|
||||
// Read below to know why such ugly thing is required.
|
||||
//
|
||||
//
|
||||
|
||||
/**
|
||||
* Register callback fn for the command.
|
||||
*/
|
||||
action(fn: (...args: any[]) => any): Command;
|
||||
|
||||
/**
|
||||
* Define option with flags, description and optional coercion function and default value.
|
||||
* The flags string should contain both the short and long flags
|
||||
* separated by comma, a pipe or space. The following are all valid
|
||||
* all will output this way when --help is used.
|
||||
*
|
||||
* "-p, --pepper"
|
||||
* "-p|--pepper"
|
||||
* "-p --pepper"
|
||||
*
|
||||
* @param flags the option flags.
|
||||
* @param description the option description. The description is printed when "--help" is used.
|
||||
* @param coerceFn (optional) specifies a callback function to coerce the option arg.
|
||||
* @param defaultValue (optional) specifies a default value.
|
||||
*/
|
||||
option(flags: string, description: string, coerceFn?: (value: string) => any, defaultValue?: any): Command;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the command version
|
||||
*/
|
||||
version(version: string): Command;
|
||||
|
||||
/**
|
||||
* Parse the arguments array and invokes the commands passing the parsed options.
|
||||
* @param argv the arguments array.
|
||||
*/
|
||||
parse(argv: string[]): Command;
|
||||
|
||||
/**
|
||||
* Gets or sets the command description.
|
||||
* @param description the new description for the command. When ommited this returns the current description, otherwise returns the current Command.
|
||||
*/
|
||||
description(description: string): Command;
|
||||
description(): string;
|
||||
|
||||
/**
|
||||
* Gets or sets the usage help string.
|
||||
*/
|
||||
usage(usage: string): Command;
|
||||
usage(): string;
|
||||
|
||||
/*
|
||||
* Prompt the user for a value, calling the callback function.
|
||||
*
|
||||
* Supports single-line and multi-line prompts.
|
||||
* To issue a single-line prompt simply add a whitespace
|
||||
* to the end of label, something like "name: ", whereas
|
||||
* for a multi-line prompt omit this "description:".
|
||||
* @param label the label string to be printed in console.
|
||||
* @param callback a callback function to handle the inputed string.
|
||||
*/
|
||||
prompt(label: string, callback: (value: string) => any): void;
|
||||
|
||||
promptForNumber(label: string, callback: (value: number) => any): void;
|
||||
promptForDate(label: string, callback: (value: Date) => any): void;
|
||||
promptSingleLine(label: string, callback: (value: string) => any): void;
|
||||
promptMultiLine(label: string, callback: (value: string) => any): void;
|
||||
|
||||
/**
|
||||
* Prompt for password with a label, a optional mask char and callback function.
|
||||
* The mask string defaults to '', aka no output is written while typing, you may want to use "*" etc.
|
||||
*/
|
||||
password(label: string, mask: string, callback: (value: string) => any): void;
|
||||
password(label: string, callback: (value: string) => any): void;
|
||||
|
||||
/**
|
||||
* Prompts the user for a confirmation.
|
||||
*/
|
||||
confirm(label: string, callback: (flag: boolean) => any): void;
|
||||
|
||||
/**
|
||||
* Prompt for password with str, mask char and callback fn(val).
|
||||
* The mask string defaults to '', aka no output is written while typing, you may want to use "*" etc.
|
||||
*/
|
||||
choose(options: string[], callback: (idx: number) => any): void;
|
||||
choose(options: any[], callback: (idx: number) => any): void;
|
||||
|
||||
/**
|
||||
* Add command with the specified name. Returns a new instance of Command.
|
||||
*
|
||||
* The .action() callback is invoked when the
|
||||
* command name is specified via ARGV,
|
||||
* and the remaining arguments are applied to the
|
||||
* function for access.
|
||||
|
||||
* When the name is "*" an un-matched command
|
||||
* will be passed as the first arg, followed by
|
||||
* the rest of ARGV remaining.
|
||||
*
|
||||
* @param name the name of the command. Pass "*" to trap un-matched commands.
|
||||
*/
|
||||
command(name: string): Command;
|
||||
* Initialize a new `Command`.
|
||||
*
|
||||
* @param {String} name
|
||||
* @api public
|
||||
*/
|
||||
new (name?:string):ICommand;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// since TypeScript (and ECMA6) does not supports module.exports,
|
||||
// there is no way to set the default Command instance as the module itself.
|
||||
// It's ugly but the only way is to copy all the methods from Command
|
||||
// and paste it in the module as functions exports.
|
||||
//
|
||||
//
|
||||
interface ICommand extends NodeJS.EventEmitter {
|
||||
args: string[];
|
||||
_args: { required:boolean; name: string; }[];
|
||||
|
||||
/**
|
||||
* Register callback fn for the command.
|
||||
*/
|
||||
export function action(fn: (...args: any[]) => any): Command;
|
||||
/**
|
||||
* Add command `name`.
|
||||
*
|
||||
* The `.action()` callback is invoked when the
|
||||
* command `name` is specified via __ARGV__,
|
||||
* and the remaining arguments are applied to the
|
||||
* function for access.
|
||||
*
|
||||
* When the `name` is "*" an un-matched command
|
||||
* will be passed as the first arg, followed by
|
||||
* the rest of __ARGV__ remaining.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* program
|
||||
* .version('0.0.1')
|
||||
* .option('-C, --chdir <path>', 'change the working directory')
|
||||
* .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
|
||||
* .option('-T, --no-tests', 'ignore test hook')
|
||||
*
|
||||
* program
|
||||
* .command('setup')
|
||||
* .description('run remote setup commands')
|
||||
* .action(function(){
|
||||
* console.log('setup');
|
||||
* });
|
||||
*
|
||||
* program
|
||||
* .command('exec <cmd>')
|
||||
* .description('run the given remote command')
|
||||
* .action(function(cmd){
|
||||
* console.log('exec "%s"', cmd);
|
||||
* });
|
||||
*
|
||||
* program
|
||||
* .command('*')
|
||||
* .description('deploy the given env')
|
||||
* .action(function(env){
|
||||
* console.log('deploying "%s"', env);
|
||||
* });
|
||||
*
|
||||
* program.parse(process.argv);
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {String} [desc]
|
||||
* @return {Command} the new command
|
||||
* @api public
|
||||
*/
|
||||
command(name:string, desc?:string):ICommand;
|
||||
|
||||
/**
|
||||
* Define option with flags, description and optional coercion function and default value.
|
||||
* The flags string should contain both the short and long flags
|
||||
* separated by comma, a pipe or space. The following are all valid
|
||||
* all will output this way when --help is used.
|
||||
*
|
||||
* "-p, --pepper"
|
||||
* "-p|--pepper"
|
||||
* "-p --pepper"
|
||||
*
|
||||
* @param flags the option flags.
|
||||
* @param description the option description. The description is printed when "--help" is used.
|
||||
* @param coerceFn (optional) specifies a callback function to coerce the option arg.
|
||||
* @param defaultValue (optional) specifies a default value.
|
||||
*/
|
||||
export function option(flags: string, description: string, coerceFn?: (value: string) => any, defaultValue?: any): Command;
|
||||
/**
|
||||
* Add an implicit `help [cmd]` subcommand
|
||||
* which invokes `--help` for the given command.
|
||||
*
|
||||
* @api private
|
||||
*/
|
||||
addImplicitHelpCommand():void;
|
||||
|
||||
/**
|
||||
* Parse expected `args`.
|
||||
*
|
||||
* For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
|
||||
*
|
||||
* @param {Array} args
|
||||
* @return {Command} for chaining
|
||||
* @api public
|
||||
*/
|
||||
parseExpectedArgs(args:string[]):ICommand;
|
||||
|
||||
/**
|
||||
* Sets the command version
|
||||
*/
|
||||
export function version(version: string): Command;
|
||||
/**
|
||||
* Register callback `fn` for the command.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* program
|
||||
* .command('help')
|
||||
* .description('display verbose help')
|
||||
* .action(function(){
|
||||
* // output help here
|
||||
* });
|
||||
*
|
||||
* @param {Function} fn
|
||||
* @return {Command} for chaining
|
||||
* @api public
|
||||
*/
|
||||
action(fn:(...args:any[])=>void):ICommand;
|
||||
|
||||
/**
|
||||
* Parse the arguments array and invokes the commands passing the parsed options.
|
||||
* @param argv the arguments array.
|
||||
*/
|
||||
export function parse(argv: string[]): Command;
|
||||
/**
|
||||
* Define option with `flags`, `description` and optional
|
||||
* coercion `fn`.
|
||||
*
|
||||
* The `flags` string should contain both the short and long flags,
|
||||
* separated by comma, a pipe or space. The following are all valid
|
||||
* all will output this way when `--help` is used.
|
||||
*
|
||||
* "-p, --pepper"
|
||||
* "-p|--pepper"
|
||||
* "-p --pepper"
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // simple boolean defaulting to false
|
||||
* program.option('-p, --pepper', 'add pepper');
|
||||
*
|
||||
* --pepper
|
||||
* program.pepper
|
||||
* // => Boolean
|
||||
*
|
||||
* // simple boolean defaulting to true
|
||||
* program.option('-C, --no-cheese', 'remove cheese');
|
||||
*
|
||||
* program.cheese
|
||||
* // => true
|
||||
*
|
||||
* --no-cheese
|
||||
* program.cheese
|
||||
* // => false
|
||||
*
|
||||
* // required argument
|
||||
* program.option('-C, --chdir <path>', 'change the working directory');
|
||||
*
|
||||
* --chdir /tmp
|
||||
* program.chdir
|
||||
* // => "/tmp"
|
||||
*
|
||||
* // optional argument
|
||||
* program.option('-c, --cheese [type]', 'add cheese [marble]');
|
||||
*
|
||||
* @param {String} flags
|
||||
* @param {String} description
|
||||
* @param {Function|Mixed} fn or default
|
||||
* @param {Mixed} defaultValue
|
||||
* @return {Command} for chaining
|
||||
* @api public
|
||||
*/
|
||||
option(flags:string, description?:string, fn?:(arg1:any, arg2:any)=>void, defaultValue?:any):ICommand;
|
||||
option(flags:string, description?:string, defaultValue?:any):ICommand;
|
||||
|
||||
/**
|
||||
* Gets or sets the command description.
|
||||
* @param description the new description for the command. When ommited this returns the current description, otherwise returns the current Command.
|
||||
*/
|
||||
export function description(description: string): Command;
|
||||
export function description(): string;
|
||||
/**
|
||||
* Parse `argv`, settings options and invoking commands when defined.
|
||||
*
|
||||
* @param {Array} argv
|
||||
* @return {Command} for chaining
|
||||
* @api public
|
||||
*/
|
||||
parse(argv:string[]):ICommand;
|
||||
|
||||
/**
|
||||
* Gets or sets the usage help string.
|
||||
*/
|
||||
export function usage(usage: string): Command;
|
||||
export function usage(): string;
|
||||
/**
|
||||
* Execute a sub-command executable.
|
||||
*
|
||||
* @param {Array} argv
|
||||
* @param {Array} args
|
||||
* @param {Array} unknown
|
||||
* @api private
|
||||
*/
|
||||
executeSubCommand(argv:string[], args:string[], unknown:string[]):any; /* child_process.ChildProcess */
|
||||
|
||||
/*
|
||||
* Prompt the user for a value, calling the callback function.
|
||||
*
|
||||
* Supports single-line and multi-line prompts.
|
||||
* To issue a single-line prompt simply add a whitespace
|
||||
* to the end of label, something like "name: ", whereas
|
||||
* for a multi-line prompt omit this "description:".
|
||||
* @param label the label string to be printed in console.
|
||||
* @param callback a callback function to handle the inputed string.
|
||||
*/
|
||||
export function prompt(label: string, callback: (value: string) => any): void;
|
||||
/**
|
||||
* Normalize `args`, splitting joined short flags. For example
|
||||
* the arg "-abc" is equivalent to "-a -b -c".
|
||||
* This also normalizes equal sign and splits "--abc=def" into "--abc def".
|
||||
*
|
||||
* @param {Array} args
|
||||
* @return {Array}
|
||||
* @api private
|
||||
*/
|
||||
normalize(args:string[]):string[];
|
||||
|
||||
export function promptForNumber(label: string, callback: (value: number) => any): void;
|
||||
export function promptForDate(label: string, callback: (value: Date) => any): void;
|
||||
export function promptSingleLine(label: string, callback: (value: string) => any): void;
|
||||
export function promptMultiLine(label: string, callback: (value: string) => any): void;
|
||||
/**
|
||||
* Prompt for password with a label, a optional mask char and callback function.
|
||||
* The mask string defaults to '', aka no output is written while typing, you may want to use "*" etc.
|
||||
*/
|
||||
export function password(label: string, mask: string, callback: (value: string) => any): void;
|
||||
export function password(label: string, callback: (value: string) => any): void;
|
||||
/**
|
||||
* Parse command `args`.
|
||||
*
|
||||
* When listener(s) are available those
|
||||
* callbacks are invoked, otherwise the "*"
|
||||
* event is emitted and those actions are invoked.
|
||||
*
|
||||
* @param {Array} args
|
||||
* @return {Command} for chaining
|
||||
* @api private
|
||||
*/
|
||||
parseArgs(args:string[], unknown:string[]):ICommand;
|
||||
|
||||
/**
|
||||
* Prompts the user for a confirmation.
|
||||
*/
|
||||
export function confirm(label: string, callback: (flag: boolean) => any): void;
|
||||
/**
|
||||
* Return an option matching `arg` if any.
|
||||
*
|
||||
* @param {String} arg
|
||||
* @return {Option}
|
||||
* @api private
|
||||
*/
|
||||
optionFor(arg:string):IOption;
|
||||
|
||||
/**
|
||||
* Prompt for password with str, mask char and callback fn(val).
|
||||
* The mask string defaults to '', aka no output is written while typing, you may want to use "*" etc.
|
||||
*/
|
||||
export function choose(options: string[], callback: (idx: number) => any): void;
|
||||
export function choose(options: any[], callback: (idx: number) => any): void;
|
||||
/**
|
||||
* Parse options from `argv` returning `argv`
|
||||
* void of these options.
|
||||
*
|
||||
* @param {Array} argv
|
||||
* @return {Array}
|
||||
* @api public
|
||||
*/
|
||||
parseOptions(argv:string[]): {args:string[]; unknown:string[];};
|
||||
|
||||
/**
|
||||
* Add command with the specified name. Returns a new instance of Command.
|
||||
*
|
||||
* The .action() callback is invoked when the
|
||||
* command name is specified via ARGV,
|
||||
* and the remaining arguments are applied to the
|
||||
* function for access.
|
||||
/**
|
||||
* Return an object containing options as key-value pairs
|
||||
*
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
opts():any;
|
||||
|
||||
* When the name is "*" an un-matched command
|
||||
* will be passed as the first arg, followed by
|
||||
* the rest of ARGV remaining.
|
||||
*
|
||||
* @param name the name of the command. Pass "*" to trap un-matched commands.
|
||||
*/
|
||||
export function command(name: string): Command;
|
||||
}
|
||||
/**
|
||||
* Argument `name` is missing.
|
||||
*
|
||||
* @param {String} name
|
||||
* @api private
|
||||
*/
|
||||
missingArgument(name:string):void;
|
||||
|
||||
/**
|
||||
* `Option` is missing an argument, but received `flag` or nothing.
|
||||
*
|
||||
* @param {String} option
|
||||
* @param {String} flag
|
||||
* @api private
|
||||
*/
|
||||
optionMissingArgument(option:{flags:string;}, flag?:string):void;
|
||||
|
||||
/**
|
||||
* Unknown option `flag`.
|
||||
*
|
||||
* @param {String} flag
|
||||
* @api private
|
||||
*/
|
||||
unknownOption(flag:string):void;
|
||||
|
||||
/**
|
||||
* Set the program version to `str`.
|
||||
*
|
||||
* This method auto-registers the "-V, --version" flag
|
||||
* which will print the version number when passed.
|
||||
*
|
||||
* @param {String} str
|
||||
* @param {String} flags
|
||||
* @return {Command} for chaining
|
||||
* @api public
|
||||
*/
|
||||
version(str:string, flags?:string):ICommand;
|
||||
|
||||
/**
|
||||
* Set the description to `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {String|Command}
|
||||
* @api public
|
||||
*/
|
||||
description(str:string):ICommand;
|
||||
description():string;
|
||||
|
||||
/**
|
||||
* Set an alias for the command
|
||||
*
|
||||
* @param {String} alias
|
||||
* @return {String|Command}
|
||||
* @api public
|
||||
*/
|
||||
alias(alias:string):ICommand;
|
||||
alias():string;
|
||||
|
||||
/**
|
||||
* Set / get the command usage `str`.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {String|Command}
|
||||
* @api public
|
||||
*/
|
||||
usage(str:string):ICommand;
|
||||
usage():string;
|
||||
|
||||
/**
|
||||
* Get the name of the command
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {String|Command}
|
||||
* @api public
|
||||
*/
|
||||
name():string;
|
||||
|
||||
/**
|
||||
* Return the largest option length.
|
||||
*
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
largestOptionLength():number;
|
||||
|
||||
/**
|
||||
* Return help for options.
|
||||
*
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
optionHelp():string;
|
||||
|
||||
/**
|
||||
* Return command help documentation.
|
||||
*
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
commandHelp():string;
|
||||
|
||||
/**
|
||||
* Return program help documentation.
|
||||
*
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
helpInformation():string;
|
||||
|
||||
/**
|
||||
* Output help information for this command
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
outputHelp():void;
|
||||
|
||||
/**
|
||||
* Output help information and exit.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
help():void;
|
||||
}
|
||||
|
||||
interface IOptionStatic {
|
||||
/**
|
||||
* Initialize a new `Option` with the given `flags` and `description`.
|
||||
*
|
||||
* @param {String} flags
|
||||
* @param {String} description
|
||||
* @api public
|
||||
*/
|
||||
new (flags:string, description?:string):IOption;
|
||||
}
|
||||
|
||||
interface IOption {
|
||||
flags:string;
|
||||
required:boolean;
|
||||
optional:boolean;
|
||||
bool:boolean;
|
||||
short?:string;
|
||||
long:string;
|
||||
description:string;
|
||||
|
||||
/**
|
||||
* Return option name.
|
||||
*
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
name():string;
|
||||
|
||||
/**
|
||||
* Check if `arg` matches the short or long flag.
|
||||
*
|
||||
* @param {String} arg
|
||||
* @return {Boolean}
|
||||
* @api private
|
||||
*/
|
||||
is(arg:string):boolean;
|
||||
}
|
||||
|
||||
interface IExportedCommand extends ICommand {
|
||||
Command: commander.ICommandStatic;
|
||||
Option: commander.IOptionStatic;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "commander" {
|
||||
var _tmp:commander.IExportedCommand;
|
||||
export = _tmp;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/// <reference path="content-type.d.ts" />
|
||||
|
||||
import MediaType = require('content-type');
|
||||
|
||||
// https://github.com/deoxxa/content-type/blob/master/README.md
|
||||
function new_test(): void {
|
||||
var p = new MediaType('text/html;level=1;q=0.5');
|
||||
p.q === 0.5;
|
||||
p.params.level === "1";
|
||||
|
||||
var q = new MediaType('application/json', { profile: 'http://example.com/schema.json' });
|
||||
q.type === "application/json";
|
||||
q.params.profile === "http://example.com/schema.json";
|
||||
|
||||
q.q = 1;
|
||||
q.toString() === 'application/json;q=1;profile="http://example.com/schema.json"';
|
||||
}
|
||||
|
||||
function mediaCmp_test(): void {
|
||||
MediaType.mediaCmp(MediaType.parseMedia('text/html'), MediaType.parseMedia('text/html')) === 0;
|
||||
MediaType.mediaCmp(MediaType.parseMedia('*/*'), MediaType.parseMedia('text/html')) === 1;
|
||||
MediaType.mediaCmp(MediaType.parseMedia('text/html;level=1'), MediaType.parseMedia('text/html')) === -1;
|
||||
MediaType.mediaCmp(MediaType.parseMedia('application/json;profile="v1.json"'), MediaType.parseMedia('application/json;profile="v2.json"')) === null;
|
||||
}
|
||||
|
||||
// https://github.com/deoxxa/content-type/blob/master/example.js
|
||||
function example(): void {
|
||||
var representations = [
|
||||
'application/json',
|
||||
'text/html',
|
||||
'application/json;profile="schema.json"',
|
||||
'application/json;profile="different.json"',
|
||||
];
|
||||
|
||||
var accept = [
|
||||
'text/html;q=0.50',
|
||||
'*/*;q=0.01',
|
||||
'application/json;profile=different.json',
|
||||
'application/json;profile="a,b;c.json?d=1;f=2";q=0.2',
|
||||
];
|
||||
|
||||
console.log('Formats:\n\t' + representations.map(MediaType.parseMedia).join('\n\t'));
|
||||
|
||||
console.log('Accept:\n\t' + accept.map(MediaType.parseMedia).join('\n\t'));
|
||||
|
||||
console.log('Selected:', (MediaType.select(representations.map(MediaType.parseMedia), accept.map(MediaType.parseMedia)) || 'None').toString());
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// Type definitions for content-type v0.0.1
|
||||
// Project: https://github.com/deoxxa/content-type
|
||||
// Definitions by: Pine Mizune <https://github.com/pine613>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module ContentType {
|
||||
interface MediaType {
|
||||
type: string;
|
||||
q?: number;
|
||||
params: any;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
interface SelectOptions {
|
||||
sortAvailable?: boolean;
|
||||
sortAccepted?: boolean;
|
||||
}
|
||||
|
||||
interface MediaTypeStatic {
|
||||
new (s: string, p?: any): MediaType;
|
||||
parseMedia(type: string): MediaType;
|
||||
splitQuotedString(str: string, delimiter?: string, quote?: string): string[];
|
||||
splitContentTypes(str: string): string[];
|
||||
select(availableTypes: MediaType[], acceptedTypes: MediaType[], options?: SelectOptions): string;
|
||||
mediaCmp(a: MediaType, b: MediaType): number;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "content-type" {
|
||||
var x: ContentType.MediaTypeStatic;
|
||||
export = x;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user