mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -23,6 +23,8 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [async](https://github.com/caolan/async) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [atmosphere](https://github.com/Atmosphere/atmosphere-javascript) (by [Kai Toedter](https://github.com/toedter))
|
||||
* [Atom](https://atom.io/) (by [vvakame](https://github.com/vvakame))
|
||||
* [Auth0](https://auth0.com/) (by [Robert McLaws](https://github.com/advancedrei))
|
||||
* [Auth0.Widget](https://auth0.com/) (by [Robert McLaws](https://github.com/advancedrei))
|
||||
* [aws-sdk-js](https://github.com/aws/aws-sdk-js) (by [midknight41](https://github.com/midknight41))
|
||||
* [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Backbone Relational](http://backbonerelational.org/) (by [Eirik Hoem](https://github.com/eirikhm))
|
||||
@@ -143,6 +145,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [jQuery.dataTables](http://www.datatables.net) (by [Armin Sander](https://github.com/pragmatrix))
|
||||
* [jQuery.datetimepicker](http://trentrichardson.com/examples/timepicker/) (by [Doug McDonald](https://github.com/dougajmcdonald))
|
||||
* [jQuery.dynatree](http://code.google.com/p/dynatree/) (by [François de Campredon](https://github.com/fdecampredon))
|
||||
* [jQuery.Fileupload](https://github.com/blueimp/jQuery-File-Upload/) (by [Rob Alarcon](https://github.com/rob-alarcon))
|
||||
* [jQuery.Finger](http://ngryman.sh/jquery.finger/) (by [Max Ackley](https://github.com/maxackley))
|
||||
* [jQuery.Flot](http://www.flotcharts.org/) (by [Matt Burland](https://github.com/burlandm))
|
||||
* [jQuery.form](http://malsup.com/jquery/form/) (by [François Guillot](http://fguillot.developpez.com/))
|
||||
@@ -211,6 +214,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [MathJax](https://github.com/mathjax/MathJax) (by [Roland Zwaga](https://github.com/rolandzwaga))
|
||||
* [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg))
|
||||
* [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave))
|
||||
* [Microsoft Ajax](http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx) (by [Patrick Magee](https://github.com/pjmagee))
|
||||
* [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk))
|
||||
* [Minimatch](https://github.com/isaacs/minimatch) (by [vvakame](https://github.com/vvakame))
|
||||
* [minimist](https://github.com/substack/minimist) (by [Bart van der Schoor](https://github.com/Bartvds))
|
||||
@@ -282,6 +286,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev))
|
||||
* [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [sqlite3](https://github.com/mapbox/node-sqlite3) (by [Nick Malaguti](https://github.com/nmalaguti))
|
||||
* [status-bar](https://github.com/atom/status-bar) (by [vvakame](https://github.com/vvakame))
|
||||
* [stripe](https://stripe.com/) (by [Eric J. Smith](https://github.com/ejsmith/))
|
||||
* [Store.js](https://github.com/marcuswestin/store.js/) (by [Vincent Bortone](https://github.com/vbortone))
|
||||
@@ -319,6 +324,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [WinJS](http://msdn.microsoft.com/en-us/library/windows/apps/br229773.aspx) (from TypeScript samples)
|
||||
* [WinRT](http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx) (from TypeScript samples)
|
||||
* [ws](http://einaros.github.io/ws/) (by [Paul Loyd](https://github.com/loyd))
|
||||
* [x2js](https://code.google.com/p/x2js/) (by [Hiroki Horiuchi](https://github.com/horiuchi/))
|
||||
* [XRegExp](http://xregexp.com/) (by [Bart van der Schoor](https://github.com/Bartvds))
|
||||
* [YouTube](https://developers.google.com/youtube/) (by [Daz Wilkin](https://github.com/DazWilkin/))
|
||||
* [YouTube Analytics API](https://developers.google.com/youtube/analytics/) (by [Frank M](https://github.com/sgtfrankieboy))
|
||||
|
||||
@@ -223,6 +223,8 @@ function TestLocatorStrategies() {
|
||||
webElement = ptor.findElement(protractor.By.model('model'));
|
||||
webElement = ptor.findElement(protractor.By.textarea('textarea'));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater'));
|
||||
webElement = ptor.findElement(protractor.By.buttonText('buttonText'));
|
||||
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
|
||||
}
|
||||
|
||||
// This function tests the methods that were added to the base WebElement class
|
||||
|
||||
+4
@@ -646,6 +646,10 @@ declare module protractor {
|
||||
* var rows = element(by.repeater("cat in pets"));
|
||||
*/
|
||||
repeater(repeatDescriptor: string): webdriver.Locator;
|
||||
|
||||
buttonText(searchText: string): webdriver.Locator;
|
||||
|
||||
partialButtonText(searchText: string): webdriver.Locator;
|
||||
}
|
||||
|
||||
var By: IProtractorLocatorStrategy;
|
||||
|
||||
@@ -21,6 +21,15 @@ mock.inject(
|
||||
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; },
|
||||
|
||||
Vendored
+1
@@ -30,6 +30,7 @@ declare module ng {
|
||||
|
||||
// see http://docs.angularjs.org/api/angular.mock.inject
|
||||
inject(...fns: Function[]): any;
|
||||
inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works
|
||||
|
||||
// see http://docs.angularjs.org/api/angular.mock.module
|
||||
module(...modules: string[]): any;
|
||||
|
||||
@@ -98,12 +98,12 @@ module HttpAndRegularPromiseTests {
|
||||
}
|
||||
|
||||
var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => {
|
||||
$http.get("http://somewhere/some/resource")
|
||||
$http.get<ExpectedResponse>("http://somewhere/some/resource")
|
||||
.success((data: ExpectedResponse) => {
|
||||
$scope.person = data;
|
||||
});
|
||||
|
||||
$http.get("http://somewhere/some/resource")
|
||||
$http.get<ExpectedResponse>("http://somewhere/some/resource")
|
||||
.then((response: ng.IHttpPromiseCallbackArg<ExpectedResponse>) => {
|
||||
// typing lost, so something like
|
||||
// var i: number = response.data
|
||||
@@ -111,7 +111,7 @@ module HttpAndRegularPromiseTests {
|
||||
$scope.person = response.data;
|
||||
});
|
||||
|
||||
$http.get("http://somewhere/some/resource")
|
||||
$http.get<ExpectedResponse>("http://somewhere/some/resource")
|
||||
.then((response: ng.IHttpPromiseCallbackArg<ExpectedResponse>) => {
|
||||
// typing lost, so something like
|
||||
// var i: number = response.data
|
||||
@@ -148,7 +148,7 @@ module HttpAndRegularPromiseTests {
|
||||
var buildFooData: Function = () => 42;
|
||||
|
||||
var doFoo: Function = (callback: ng.IHttpPromiseCallback<ExpectedResponse>) => {
|
||||
$http.get('/foo', buildFooData())
|
||||
$http.get<ExpectedResponse>('/foo', buildFooData())
|
||||
.success(callback);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+136
-23
@@ -236,7 +236,7 @@ declare module ng {
|
||||
$watchCollection(watchExpression: string, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
|
||||
$watchCollection(watchExpression: (scope: IScope) => any, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
|
||||
|
||||
$watchGroup(watchExpressions: string[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
|
||||
$watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
|
||||
$watchGroup(watchExpressions: {(scope: IScope) : any}[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
|
||||
|
||||
$parent: IScope;
|
||||
@@ -589,44 +589,157 @@ declare module ng {
|
||||
register(name: string, dependencyAnnotatedConstructor: any[]): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// HttpService
|
||||
// see http://docs.angularjs.org/api/ng.$http
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* HttpService
|
||||
* see http://docs.angularjs.org/api/ng/service/$http
|
||||
*/
|
||||
interface IHttpService {
|
||||
// At least moethod and url must be provided...
|
||||
(config: IRequestConfig): IHttpPromise<any>;
|
||||
get (url: string, RequestConfig?: any): IHttpPromise<any>;
|
||||
delete (url: string, RequestConfig?: any): IHttpPromise<any>;
|
||||
head(url: string, RequestConfig?: any): IHttpPromise<any>;
|
||||
jsonp(url: string, RequestConfig?: any): IHttpPromise<any>;
|
||||
post(url: string, data: any, RequestConfig?: any): IHttpPromise<any>;
|
||||
put(url: string, data: any, RequestConfig?: any): IHttpPromise<any>;
|
||||
/**
|
||||
* Object describing the request to be made and how it should be processed.
|
||||
*/
|
||||
<T>(config: IRequestConfig): IHttpPromise<T>;
|
||||
|
||||
/**
|
||||
* Shortcut method to perform GET request.
|
||||
*
|
||||
* @param url Relative or absolute URL specifying the destination of the request
|
||||
* @param config Optional configuration object
|
||||
*/
|
||||
get<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
|
||||
|
||||
/**
|
||||
* Shortcut method to perform DELETE request.
|
||||
*
|
||||
* @param url Relative or absolute URL specifying the destination of the request
|
||||
* @param config Optional configuration object
|
||||
*/
|
||||
delete<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
|
||||
|
||||
/**
|
||||
* Shortcut method to perform HEAD request.
|
||||
*
|
||||
* @param url Relative or absolute URL specifying the destination of the request
|
||||
* @param config Optional configuration object
|
||||
*/
|
||||
head<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
|
||||
|
||||
/**
|
||||
* Shortcut method to perform JSONP request.
|
||||
*
|
||||
* @param url Relative or absolute URL specifying the destination of the request
|
||||
* @param config Optional configuration object
|
||||
*/
|
||||
jsonp<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
|
||||
|
||||
/**
|
||||
* Shortcut method to perform POST request.
|
||||
*
|
||||
* @param url Relative or absolute URL specifying the destination of the request
|
||||
* @param data Request content
|
||||
* @param config Optional configuration object
|
||||
*/
|
||||
post<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
|
||||
|
||||
/**
|
||||
* Shortcut method to perform PUT request.
|
||||
*
|
||||
* @param url Relative or absolute URL specifying the destination of the request
|
||||
* @param data Request content
|
||||
* @param config Optional configuration object
|
||||
*/
|
||||
put<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
|
||||
|
||||
/**
|
||||
* Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations.
|
||||
*/
|
||||
defaults: IRequestConfig;
|
||||
|
||||
// For debugging, BUT it is documented as public, so...
|
||||
/**
|
||||
* Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes.
|
||||
*/
|
||||
pendingRequests: any[];
|
||||
}
|
||||
|
||||
// This is just for hinting.
|
||||
// Some opetions might not be available depending on the request.
|
||||
// see http://docs.angularjs.org/api/ng.$http#Usage for options explanations
|
||||
interface IRequestConfig {
|
||||
method: string;
|
||||
url: string;
|
||||
/**
|
||||
* Object describing the request to be made and how it should be processed.
|
||||
* see http://docs.angularjs.org/api/ng/service/$http#usage
|
||||
*/
|
||||
interface IRequestShortcutConfig {
|
||||
/**
|
||||
* {Object.<string|Object>}
|
||||
* Map of strings or objects which will be turned to ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified.
|
||||
*/
|
||||
params?: any;
|
||||
|
||||
// XXX it has it's own structure... perhaps we should define it in the future
|
||||
/**
|
||||
* Map of strings or functions which return strings representing HTTP headers to send to the server. If the return value of a function is null, the header will not be sent.
|
||||
*/
|
||||
headers?: any;
|
||||
|
||||
/**
|
||||
* Name of HTTP header to populate with the XSRF token.
|
||||
*/
|
||||
xsrfHeaderName?: string;
|
||||
|
||||
/**
|
||||
* Name of cookie containing the XSRF token.
|
||||
*/
|
||||
xsrfCookieName?: string;
|
||||
|
||||
/**
|
||||
* {boolean|Cache}
|
||||
* If true, a default $http cache will be used to cache the GET request, otherwise if a cache instance built with $cacheFactory, this cache will be used for caching.
|
||||
*/
|
||||
cache?: any;
|
||||
|
||||
/**
|
||||
* whether to to set the withCredentials flag on the XHR object. See [requests with credentials]https://developer.mozilla.org/en/http_access_control#section_5 for more information.
|
||||
*/
|
||||
withCredentials?: boolean;
|
||||
|
||||
// These accept multiple types, so let's define them as any
|
||||
/**
|
||||
* {string|Object}
|
||||
* Data to be sent as the request message data.
|
||||
*/
|
||||
data?: any;
|
||||
|
||||
/**
|
||||
* {function(data, headersGetter)|Array.<function(data, headersGetter)>}
|
||||
* Transform function or an array of such functions. The transform function takes the http request body and headers and returns its transformed (typically serialized) version.
|
||||
*/
|
||||
transformRequest?: any;
|
||||
|
||||
/**
|
||||
* {function(data, headersGetter)|Array.<function(data, headersGetter)>}
|
||||
* Transform function or an array of such functions. The transform function takes the http response body and headers and returns its transformed (typically deserialized) version.
|
||||
*/
|
||||
transformResponse?: any;
|
||||
timeout?: any; // number | promise
|
||||
|
||||
/**
|
||||
* {number|Promise}
|
||||
* Timeout in milliseconds, or promise that should abort the request when resolved.
|
||||
*/
|
||||
timeout?: any;
|
||||
|
||||
/**
|
||||
* See requestType.
|
||||
*/
|
||||
responseType?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object describing the request to be made and how it should be processed.
|
||||
* see http://docs.angularjs.org/api/ng/service/$http#usage
|
||||
*/
|
||||
interface IRequestConfig extends IRequestShortcutConfig {
|
||||
/**
|
||||
* HTTP method (e.g. 'GET', 'POST', etc)
|
||||
*/
|
||||
method: string;
|
||||
/**
|
||||
* Absolute or relative URL of the resource that is being requested.
|
||||
*/
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface IHttpPromiseCallback<T> {
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
declare module "ansicolors" {
|
||||
var colors: {[index: string]: (s: string) => string;};
|
||||
export = colors;
|
||||
}
|
||||
Vendored
+22
-22
@@ -27,28 +27,28 @@ interface Async {
|
||||
forEach<T,R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): void;
|
||||
forEachSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): void;
|
||||
forEachLimit<T, R>(arr: T[], limit: number, iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): void;
|
||||
map<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>);
|
||||
mapSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>);
|
||||
filter<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
select<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
filterSeries<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
selectSeries<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
reject<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
rejectSeries<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>);
|
||||
inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>);
|
||||
foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>);
|
||||
reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>);
|
||||
foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>);
|
||||
detect<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
detectSeries<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
sortBy<T, V>(arr: T[], iterator: AsyncIterator<T, V>, callback: AsyncMultipleResultsCallback<T>);
|
||||
some<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
any<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
every<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any);
|
||||
all<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any);
|
||||
concat<T, R>(arr: T[], iterator: AsyncIterator<T, R[]>, callback: AsyncMultipleResultsCallback<R>);
|
||||
concatSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R[]>, callback: AsyncMultipleResultsCallback<R>);
|
||||
map<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): any;
|
||||
mapSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): any;
|
||||
filter<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
select<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
filterSeries<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
selectSeries<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
reject<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
rejectSeries<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
|
||||
inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
|
||||
foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
|
||||
reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
|
||||
foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
|
||||
detect<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
detectSeries<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
sortBy<T, V>(arr: T[], iterator: AsyncIterator<T, V>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
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;
|
||||
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;
|
||||
|
||||
// Control Flow
|
||||
series<T>(tasks: T[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
/// <reference path="auth0.widget.d.ts" />
|
||||
|
||||
var widget: Auth0WidgetStatic = new Auth0Widget({
|
||||
domain: 'mine.auth0.com',
|
||||
clientID: 'dsa7d77dsa7d7',
|
||||
callbackURL: 'http://my-app.com/callback',
|
||||
callbackOnLocationHash: true
|
||||
});
|
||||
|
||||
widget.signin({
|
||||
connections: ['facebook', 'google-oauth2', 'twitter', 'Username-Password-Authentication'],
|
||||
icon: 'https://contoso.com/logo-32.png',
|
||||
showIcon: true
|
||||
},
|
||||
() => {
|
||||
// The Auth0 Widget is now loaded.
|
||||
});
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// Type definitions for Auth0Widget.js
|
||||
// Project: Auth0.com
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
|
||||
|
||||
interface Auth0WidgetStatic {
|
||||
new(params: Auth0Constructor): Auth0WidgetStatic;
|
||||
|
||||
getClient(): Auth0Static;
|
||||
getProfile(token: string, callback: Function): Auth0UserProfile;
|
||||
parseHash(hash: string): Auth0DecodedHash;
|
||||
reset(options: Auth0Options, callback?: Function): Auth0WidgetStatic;
|
||||
signin(options: Auth0Options, widgetLoadedCallback?: Function, popupCallback?: Function): Auth0WidgetStatic;
|
||||
signup(options: Auth0Options, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): Auth0WidgetStatic;
|
||||
}
|
||||
|
||||
interface Auth0Constructor extends Auth0ClientOptions {
|
||||
assetsUrl?: string;
|
||||
cdn?: string;
|
||||
dict?: any;
|
||||
}
|
||||
|
||||
interface Auth0Options {
|
||||
access_token?: string;
|
||||
connections?: string[];
|
||||
container?: string;
|
||||
enableReturnUserExperience?: boolean;
|
||||
extraParameters?: any;
|
||||
icon?: string;
|
||||
protocol?: string;
|
||||
request_id?: string;
|
||||
scope?: string;
|
||||
showIcon?: boolean;
|
||||
showForgot?: boolean;
|
||||
showSignup?: boolean;
|
||||
state?: any;
|
||||
userPwdConnectionName?: string;
|
||||
username_style?: string;
|
||||
}
|
||||
|
||||
declare var Auth0Widget: Auth0WidgetStatic;
|
||||
|
||||
declare module "Auth0Widget" {
|
||||
export = Auth0Widget
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference path="../auth0/auth0.d.ts" />
|
||||
|
||||
var auth0 = new Auth0({
|
||||
domain: 'mine.auth0.com',
|
||||
clientID: 'dsa7d77dsa7d7',
|
||||
callbackURL: 'http://my-app.com/callback',
|
||||
callbackOnLocationHash: true
|
||||
});
|
||||
|
||||
auth0.login({
|
||||
connection: 'google-oauth2',
|
||||
popup: true,
|
||||
popupOptions: {
|
||||
width: 450,
|
||||
height: 800
|
||||
}
|
||||
}, (err, profile, idToken, accessToken, state) => {
|
||||
if (err) {
|
||||
alert("something went wrong: " + err.message);
|
||||
return;
|
||||
}
|
||||
alert('hello ' + profile.name);
|
||||
});
|
||||
Vendored
+133
@@ -0,0 +1,133 @@
|
||||
// Type definitions for Auth0.js
|
||||
// Project: Auth0.com
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/** Extensions to the browser Window object. */
|
||||
interface Window {
|
||||
/** Allows you to pass the id_token to other APIs, as specified in https://docs.auth0.com/apps-apis */
|
||||
token: string;
|
||||
}
|
||||
|
||||
interface Location {
|
||||
origin: string;
|
||||
}
|
||||
|
||||
/** This is the interface for the main Auth0 client. */
|
||||
interface Auth0Static {
|
||||
|
||||
new(options: Auth0ClientOptions): Auth0Static;
|
||||
changePassword(options: any, callback?: Function): void;
|
||||
decodeJwt(jwt: string): any;
|
||||
login(options: any, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
loginWithPopup(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
loginWithResourceOwner(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: any) => any): void;
|
||||
loginWithUsernamePassword(options: Auth0LoginOptions, callback: (error?: Auth0Error, profile?: Auth0UserProfile, id_token?: string, access_token?: string, state?: string) => any): void;
|
||||
logout(query: string): void;
|
||||
getConnections(callback?: Function): void;
|
||||
getDelegationToken(targetClientId: string, id_token: string, options: any, callback: (error?: Auth0Error, delegationResult?: Auth0DelegationToken) => any): void;
|
||||
getProfile(id_token: string, callback?: Function): Auth0UserProfile;
|
||||
getSSOData(withActiveDirectories: any, callback?: Function): void;
|
||||
parseHash(hash: string): Auth0DecodedHash;
|
||||
signup(options: Auth0SignupOptions, callback: Function): void;
|
||||
validateUser(options: any, callback: (error?: Auth0Error, valid?: any) => any): void;
|
||||
}
|
||||
|
||||
/** Represents constructor options for the Auth0 client. */
|
||||
interface Auth0ClientOptions {
|
||||
clientID: string;
|
||||
callbackURL: string;
|
||||
callbackOnLoactionHash?: boolean;
|
||||
domain: string;
|
||||
forceJSONP?: boolean;
|
||||
}
|
||||
|
||||
/** Represents a normalized UserProfile. */
|
||||
interface Auth0UserProfile {
|
||||
email: string;
|
||||
family_name: string;
|
||||
gender: string;
|
||||
given_name: string;
|
||||
locale: string;
|
||||
name: string;
|
||||
nickname: string;
|
||||
picture: string;
|
||||
user_id: string;
|
||||
/** Represents one or more Identities that may be associated with the User. */
|
||||
identities: Auth0Identity[];
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has a Microsoft Account as the primary identity. */
|
||||
interface MicrosoftUserProfile extends Auth0UserProfile {
|
||||
emails: string[];
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has an Office365 account as the primary identity. */
|
||||
interface Office365UserProfile extends Auth0UserProfile {
|
||||
tenantid: string;
|
||||
upn: string;
|
||||
}
|
||||
|
||||
/** Represents an Auth0UserProfile that has an Active Directory account as the primary identity. */
|
||||
interface AdfsUserProfile extends Auth0UserProfile {
|
||||
issuer: string;
|
||||
}
|
||||
|
||||
/** Represents multiple identities assigned to a user. */
|
||||
interface Auth0Identity {
|
||||
access_token: string;
|
||||
connection: string;
|
||||
isSocial: boolean;
|
||||
provider: string;
|
||||
user_id: string;
|
||||
}
|
||||
|
||||
interface Auth0DecodedHash {
|
||||
access_token: string;
|
||||
id_token: string;
|
||||
profile: Auth0UserProfile;
|
||||
state: any;
|
||||
}
|
||||
|
||||
interface Auth0PopupOptions {
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface Auth0LoginOptions {
|
||||
auto_login?: boolean;
|
||||
connection?: string;
|
||||
email?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
popup?: boolean;
|
||||
popupOptions?: Auth0PopupOptions;
|
||||
}
|
||||
|
||||
interface Auth0SignupOptions extends Auth0LoginOptions {
|
||||
auto_login: boolean;
|
||||
}
|
||||
|
||||
interface Auth0Error {
|
||||
code: any;
|
||||
details: any;
|
||||
name: string;
|
||||
message: string;
|
||||
status: any;
|
||||
}
|
||||
|
||||
/** Represents the response from an API Token Delegation request. */
|
||||
interface Auth0DelegationToken {
|
||||
/** The length of time in seconds the token is valid for. */
|
||||
expires_in: string;
|
||||
/** The JWT for delegated access. */
|
||||
id_token: string;
|
||||
/** The type of token being returned. Possible values: "Bearer" */
|
||||
token_type: string;
|
||||
}
|
||||
|
||||
declare var Auth0: Auth0Static;
|
||||
|
||||
declare module "Auth0" {
|
||||
export = Auth0
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/// <reference path="./bl.d.ts" />
|
||||
|
||||
import BufferList = require('bl');
|
||||
|
||||
var bl: BufferList;
|
||||
var buffer: Buffer;
|
||||
var offset: number;
|
||||
var num: number;
|
||||
var str: string;
|
||||
var noAssert: boolean;
|
||||
|
||||
bl = new BufferList();
|
||||
bl = new BufferList((err:Error, buffer:Buffer) => {
|
||||
|
||||
});
|
||||
|
||||
bl.append(buffer);
|
||||
num = bl.get(num);
|
||||
|
||||
buffer = bl.slice(num, num);
|
||||
buffer = bl.slice(num);
|
||||
buffer = bl.slice();
|
||||
|
||||
bl.copy(buffer, num, num, num);
|
||||
bl.copy(buffer, num, num);
|
||||
bl.copy(buffer, num);
|
||||
bl.copy(buffer);
|
||||
|
||||
bl = bl.duplicate();
|
||||
|
||||
bl.consume();
|
||||
bl.consume(num);
|
||||
|
||||
str = bl.toString(str, num, num);
|
||||
str = bl.toString(str, num);
|
||||
str = bl.toString(str);
|
||||
str = bl.toString();
|
||||
|
||||
num = bl.length;
|
||||
|
||||
buffer = bl.readDoubleBE(offset, noAssert);
|
||||
buffer = bl.readDoubleBE(offset);
|
||||
buffer = bl.readDoubleLE(offset, noAssert);
|
||||
buffer = bl.readDoubleLE(offset);
|
||||
buffer = bl.readFloatBE(offset, noAssert);
|
||||
buffer = bl.readFloatBE(offset);
|
||||
buffer = bl.readFloatLE(offset, noAssert);
|
||||
buffer = bl.readFloatLE(offset);
|
||||
buffer = bl.readInt32BE(offset, noAssert);
|
||||
buffer = bl.readInt32BE(offset);
|
||||
buffer = bl.readInt32LE(offset, noAssert);
|
||||
buffer = bl.readInt32LE(offset);
|
||||
buffer = bl.readUInt32BE(offset, noAssert);
|
||||
buffer = bl.readUInt32BE(offset);
|
||||
buffer = bl.readUInt32LE(offset, noAssert);
|
||||
buffer = bl.readUInt32LE(offset);
|
||||
buffer = bl.readInt16BE(offset, noAssert);
|
||||
buffer = bl.readInt16BE(offset);
|
||||
buffer = bl.readInt16LE(offset, noAssert);
|
||||
buffer = bl.readInt16LE(offset);
|
||||
buffer = bl.readUInt16BE(offset, noAssert);
|
||||
buffer = bl.readUInt16BE(offset);
|
||||
buffer = bl.readUInt16LE(offset, noAssert);
|
||||
buffer = bl.readUInt16LE(offset);
|
||||
buffer = bl.readInt8(offset, noAssert);
|
||||
buffer = bl.readInt8(offset);
|
||||
buffer = bl.readUInt8(offset, noAssert);
|
||||
buffer = bl.readUInt8(offset);
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
// Type definitions for BufferList v0.8.0
|
||||
// Project: https://github.com/rvagg/bl
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module 'bl' {
|
||||
import stream = require('stream');
|
||||
|
||||
class BufferList extends stream.Duplex {
|
||||
new (callback?:(err:Error, buffer:Buffer) => void): void;
|
||||
|
||||
append(buffer: Buffer):void;
|
||||
get(index: number): number;
|
||||
slice(start?: number, end?: number): Buffer;
|
||||
copy(dest: Buffer, destStart?: number, srcStart?: number, srcEnd?: number): void;
|
||||
duplicate(): BufferList;
|
||||
consume(bytes?: number): void;
|
||||
toString(encoding?: string, start?: number, end?: number): string;
|
||||
length: number;
|
||||
|
||||
readDoubleBE(offset: number, noAssert?: boolean): Buffer;
|
||||
readDoubleLE(offset: number, noAssert?: boolean): Buffer;
|
||||
readFloatBE(offset: number, noAssert?: boolean): Buffer;
|
||||
readFloatLE(offset: number, noAssert?: boolean): Buffer;
|
||||
readInt32BE(offset: number, noAssert?: boolean): Buffer;
|
||||
readInt32LE(offset: number, noAssert?: boolean): Buffer;
|
||||
readUInt32BE(offset: number, noAssert?: boolean): Buffer;
|
||||
readUInt32LE(offset: number, noAssert?: boolean): Buffer;
|
||||
readInt16BE(offset: number, noAssert?: boolean): Buffer;
|
||||
readInt16LE(offset: number, noAssert?: boolean): Buffer;
|
||||
readUInt16BE(offset: number, noAssert?: boolean): Buffer;
|
||||
readUInt16LE(offset: number, noAssert?: boolean): Buffer;
|
||||
readInt8(offset: number, noAssert?: boolean): Buffer;
|
||||
readUInt8(offset: number, noAssert?: boolean): Buffer;
|
||||
}
|
||||
|
||||
export = BufferList;
|
||||
}
|
||||
+16
-32
@@ -33,17 +33,25 @@ THE SOFTWARE.
|
||||
///<reference path="chai-assert.d.ts" />
|
||||
|
||||
//stubs
|
||||
declare module chai {
|
||||
var AssertionError;
|
||||
function expect(body):any;
|
||||
}
|
||||
|
||||
//tdd
|
||||
declare function suite(description, action):void;
|
||||
declare function test(description, action):void;
|
||||
declare function err(action, msg?):void;
|
||||
declare function suite(description: string, action: Function):void;
|
||||
declare function test(description: string, action: Function):void;
|
||||
declare function err(action: any, msg?: string):void;
|
||||
interface FieldObj {
|
||||
field: any;
|
||||
}
|
||||
class Foo {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class CrashyObject {
|
||||
inspect (): void {
|
||||
throw new Error("Arg's inspect() called even though the test passed");
|
||||
}
|
||||
}
|
||||
|
||||
suite('assert', function () {
|
||||
|
||||
@@ -56,12 +64,6 @@ suite('assert', function () {
|
||||
}, "expected foo to equal `bar`");
|
||||
});
|
||||
|
||||
test('fail', function () {
|
||||
chai.expect(function () {
|
||||
assert.fail();
|
||||
}).to.throw(chai.AssertionError);
|
||||
});
|
||||
|
||||
test('isTrue', function () {
|
||||
assert.isTrue(true);
|
||||
|
||||
@@ -109,7 +111,7 @@ suite('assert', function () {
|
||||
});
|
||||
|
||||
test('equal', function () {
|
||||
var foo;
|
||||
var foo: any;
|
||||
assert.equal(foo, undefined);
|
||||
});
|
||||
|
||||
@@ -133,27 +135,15 @@ suite('assert', function () {
|
||||
});
|
||||
|
||||
test('instanceOf', function () {
|
||||
function Foo() {
|
||||
}
|
||||
|
||||
assert.instanceOf(new Foo(), Foo);
|
||||
|
||||
err(function () {
|
||||
assert.instanceOf(5, Foo);
|
||||
}, "expected 5 to be an instance of Foo");
|
||||
|
||||
function CrashyObject() {
|
||||
};
|
||||
CrashyObject.prototype.inspect = function () {
|
||||
throw new Error("Arg's inspect() called even though the test passed");
|
||||
};
|
||||
assert.instanceOf(new CrashyObject(), CrashyObject);
|
||||
});
|
||||
|
||||
test('notInstanceOf', function () {
|
||||
function Foo() {
|
||||
}
|
||||
|
||||
assert.notInstanceOf(new Foo(), String);
|
||||
|
||||
err(function () {
|
||||
@@ -162,9 +152,6 @@ suite('assert', function () {
|
||||
});
|
||||
|
||||
test('isObject', function () {
|
||||
function Foo() {
|
||||
}
|
||||
|
||||
assert.isObject({});
|
||||
assert.isObject(new Foo());
|
||||
|
||||
@@ -182,9 +169,6 @@ suite('assert', function () {
|
||||
});
|
||||
|
||||
test('isNotObject', function () {
|
||||
function Foo() {
|
||||
}
|
||||
|
||||
assert.isNotObject(5);
|
||||
|
||||
err(function () {
|
||||
|
||||
Vendored
+96
-75
@@ -1,114 +1,135 @@
|
||||
// Type definitions for chai v1.7.0 assert style
|
||||
// Type definitions for chai v1.9.0 assert style
|
||||
// Project: http://chaijs.com/
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module chai
|
||||
{
|
||||
interface Assert
|
||||
{
|
||||
(express:any, msg?:string):void;
|
||||
declare module chai {
|
||||
export class AssertionError {
|
||||
constructor(message: string, _props?: any, ssf?: Function);
|
||||
name: string;
|
||||
message: string;
|
||||
showDiff: boolean;
|
||||
stack: string;
|
||||
}
|
||||
export function use(plugin: any): void;
|
||||
|
||||
fail(actual?:any, expected?:any, msg?:string, operator?:string):void;
|
||||
export var Assertion: ChaiAssertion;
|
||||
export var assert: Assert;
|
||||
export var config: ChaiConfig;
|
||||
|
||||
ok(val:any, msg?:string):void;
|
||||
notOk(val:any, msg?:string):void;
|
||||
export interface ChaiConfig {
|
||||
includeStack: boolean;
|
||||
}
|
||||
|
||||
equal(act:any, exp:any, msg?:string):void;
|
||||
notEqual(act:any, exp:any, msg?:string):void;
|
||||
export interface ChaiAssertion {
|
||||
// what?
|
||||
}
|
||||
|
||||
strictEqual(act:any, exp:any, msg?:string):void;
|
||||
notStrictEqual(act:any, exp:any, msg?:string):void;
|
||||
export interface Assert {
|
||||
(express: any, msg?: string):void;
|
||||
|
||||
deepEqual(act:any, exp:any, msg?:string):void;
|
||||
notDeepEqual(act:any, exp:any, msg?:string):void;
|
||||
fail(actual?: any, expected?: any, msg?: string, operator?: string):void;
|
||||
|
||||
isTrue(val:any, msg?:string):void;
|
||||
isFalse(val:any, msg?:string):void;
|
||||
ok(val: any, msg?: string):void;
|
||||
notOk(val: any, msg?: string):void;
|
||||
|
||||
isNull(val:any, msg?:string):void;
|
||||
isNotNull(val:any, msg?:string):void;
|
||||
equal(act: any, exp: any, msg?: string):void;
|
||||
notEqual(act: any, exp: any, msg?: string):void;
|
||||
|
||||
isUndefined(val:any, msg?:string):void;
|
||||
isDefined(val:any, msg?:string):void;
|
||||
strictEqual(act: any, exp: any, msg?: string):void;
|
||||
notStrictEqual(act: any, exp: any, msg?: string):void;
|
||||
|
||||
isFunction(val:any, msg?:string):void;
|
||||
isNotFunction(val:any, msg?:string):void;
|
||||
deepEqual(act: any, exp: any, msg?: string):void;
|
||||
notDeepEqual(act: any, exp: any, msg?: string):void;
|
||||
|
||||
isObject(val:any, msg?:string):void;
|
||||
isNotObject(val:any, msg?:string):void;
|
||||
isTrue(val: any, msg?: string):void;
|
||||
isFalse(val: any, msg?: string):void;
|
||||
|
||||
isArray(val:any, msg?:string):void;
|
||||
isNotArray(val:any, msg?:string):void;
|
||||
isNull(val: any, msg?: string):void;
|
||||
isNotNull(val: any, msg?: string):void;
|
||||
|
||||
isString(val:any, msg?:string):void;
|
||||
isNotString(val:any, msg?:string):void;
|
||||
isUndefined(val: any, msg?: string):void;
|
||||
isDefined(val: any, msg?: string):void;
|
||||
|
||||
isNumber(val:any, msg?:string):void;
|
||||
isNotNumber(val:any, msg?:string):void;
|
||||
isFunction(val: any, msg?: string):void;
|
||||
isNotFunction(val: any, msg?: string):void;
|
||||
|
||||
isBoolean(val:any, msg?:string):void;
|
||||
isNotBoolean(val:any, msg?:string):void;
|
||||
isObject(val: any, msg?: string):void;
|
||||
isNotObject(val: any, msg?: string):void;
|
||||
|
||||
typeOf(val:any, type:string, msg?:string):void;
|
||||
notTypeOf(val:any, type:string, msg?:string):void;
|
||||
isArray(val: any, msg?: string):void;
|
||||
isNotArray(val: any, msg?: string):void;
|
||||
|
||||
instanceOf(val:any, type:Function, msg?:string):void;
|
||||
notInstanceOf(val:any, type:Function, msg?:string):void;
|
||||
isString(val: any, msg?: string):void;
|
||||
isNotString(val: any, msg?: string):void;
|
||||
|
||||
include(exp:string, inc:any, msg?:string):void;
|
||||
include(exp:any[], inc:any, msg?:string):void;
|
||||
isNumber(val: any, msg?: string):void;
|
||||
isNotNumber(val: any, msg?: string):void;
|
||||
|
||||
notInclude(exp:string, inc:any, msg?:string):void;
|
||||
notInclude(exp:any[], inc:any, msg?:string):void;
|
||||
isBoolean(val: any, msg?: string):void;
|
||||
isNotBoolean(val: any, msg?: string):void;
|
||||
|
||||
match(exp:any, re:RegExp, msg?:string):void;
|
||||
notMatch(exp:any, re:RegExp, msg?:string):void;
|
||||
typeOf(val: any, type: string, msg?: string):void;
|
||||
notTypeOf(val: any, type: string, msg?: string):void;
|
||||
|
||||
property(obj:Object, prop:string, msg?:string):void;
|
||||
notProperty(obj:Object, prop:string, msg?:string):void;
|
||||
deepProperty(obj:Object, prop:string, msg?:string):void;
|
||||
notDeepProperty(obj:Object, prop:string, msg?:string):void;
|
||||
instanceOf(val: any, type: Function, msg?: string):void;
|
||||
notInstanceOf(val: any, type: Function, msg?: string):void;
|
||||
|
||||
propertyVal(obj:Object, prop:string, val:any, msg?:string):void;
|
||||
propertyNotVal(obj:Object, prop:string, val:any, msg?:string):void;
|
||||
include(exp: string, inc: any, msg?: string):void;
|
||||
include(exp: any[], inc: any, msg?: string):void;
|
||||
|
||||
deepPropertyVal(obj:Object, prop:string, val:any, msg?:string):void;
|
||||
deepPropertyNotVal(obj:Object, prop:string, val:any, msg?:string):void;
|
||||
notInclude(exp: string, inc: any, msg?: string):void;
|
||||
notInclude(exp: any[], inc: any, msg?: string):void;
|
||||
|
||||
lengthOf(exp:any, len:number, msg?:string):void;
|
||||
match(exp: any, re: RegExp, msg?: string):void;
|
||||
notMatch(exp: any, re: RegExp, msg?: string):void;
|
||||
|
||||
property(obj: Object, prop: string, msg?: string):void;
|
||||
notProperty(obj: Object, prop: string, msg?: string):void;
|
||||
deepProperty(obj: Object, prop: string, msg?: string):void;
|
||||
notDeepProperty(obj: Object, prop: string, msg?: string):void;
|
||||
|
||||
propertyVal(obj: Object, prop: string, val: any, msg?: string):void;
|
||||
propertyNotVal(obj: Object, prop: string, val: any, msg?: string):void;
|
||||
|
||||
deepPropertyVal(obj: Object, prop: string, val: any, msg?: string):void;
|
||||
deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string):void;
|
||||
|
||||
lengthOf(exp: any, len: number, msg?: string):void;
|
||||
//alias frenzy
|
||||
throw(fn:Function, msg?:string):void;
|
||||
throw(fn:Function, regExp:RegExp):void;
|
||||
throw(fn:Function, errType:Function, msg?:string):void;
|
||||
throw(fn:Function, errType:Function, regExp:RegExp):void;
|
||||
throw(fn: Function, msg?: string):void;
|
||||
throw(fn: Function, regExp: RegExp):void;
|
||||
throw(fn: Function, errType: Function, msg?: string):void;
|
||||
throw(fn: Function, errType: Function, regExp: RegExp):void;
|
||||
|
||||
throws(fn:Function, msg?:string):void;
|
||||
throws(fn:Function, regExp:RegExp):void;
|
||||
throws(fn:Function, errType:Function, msg?:string):void;
|
||||
throws(fn:Function, errType:Function, regExp:RegExp):void;
|
||||
throws(fn: Function, msg?: string):void;
|
||||
throws(fn: Function, regExp: RegExp):void;
|
||||
throws(fn: Function, errType: Function, msg?: string):void;
|
||||
throws(fn: Function, errType: Function, regExp: RegExp):void;
|
||||
|
||||
Throw(fn:Function, msg?:string):void;
|
||||
Throw(fn:Function, regExp:RegExp):void;
|
||||
Throw(fn:Function, errType:Function, msg?:string):void;
|
||||
Throw(fn:Function, errType:Function, regExp:RegExp):void;
|
||||
Throw(fn: Function, msg?: string):void;
|
||||
Throw(fn: Function, regExp: RegExp):void;
|
||||
Throw(fn: Function, errType: Function, msg?: string):void;
|
||||
Throw(fn: Function, errType: Function, regExp: RegExp):void;
|
||||
|
||||
doesNotThrow(fn:Function, msg?:string):void;
|
||||
doesNotThrow(fn:Function, regExp:RegExp):void;
|
||||
doesNotThrow(fn:Function, errType:Function, msg?:string):void;
|
||||
doesNotThrow(fn:Function, errType:Function, regExp:RegExp):void;
|
||||
doesNotThrow(fn: Function, msg?: string):void;
|
||||
doesNotThrow(fn: Function, regExp: RegExp):void;
|
||||
doesNotThrow(fn: Function, errType: Function, msg?: string):void;
|
||||
doesNotThrow(fn: Function, errType: Function, regExp: RegExp):void;
|
||||
|
||||
operator(val:any, operator:string, val2:any, msg?:string):void;
|
||||
closeTo(act:number, exp:number, delta:number, msg?:string):void;
|
||||
operator(val: any, operator: string, val2: any, msg?: string):void;
|
||||
closeTo(act: number, exp: number, delta: number, msg?: string):void;
|
||||
|
||||
sameMembers(set1:any[], set2:any[], msg?:string):void;
|
||||
includeMembers(set1:any[], set2:any[], msg?:string):void;
|
||||
sameMembers(set1: any[], set2: any[], msg?: string):void;
|
||||
includeMembers(set1: any[], set2: any[], msg?: string):void;
|
||||
|
||||
ifError(val:any, msg?:string):void;
|
||||
ifError(val: any, msg?: string):void;
|
||||
}
|
||||
//node module
|
||||
var assert:Assert;
|
||||
}
|
||||
|
||||
//browser global
|
||||
declare var assert:chai.Assert;
|
||||
|
||||
declare module 'chai' {
|
||||
export = chai;
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -767,7 +767,7 @@ declare module D3 {
|
||||
//(filter: string): UpdateSelection;
|
||||
};
|
||||
|
||||
call(callback: (selection: Selection) => void ): Selection;
|
||||
call(callback: (selection: Selection, ...args: any[]) => void, ...args: any[]): Selection;
|
||||
each(eachFunction: (data: any, index: number) => any): Selection;
|
||||
on: {
|
||||
(type: string): (data: any, index: number) => any;
|
||||
@@ -2743,7 +2743,7 @@ declare module D3 {
|
||||
clamp(clamp: boolean): TimeScale;
|
||||
ticks: {
|
||||
(count: number): any[];
|
||||
(range: Range, count: number): any[];
|
||||
(range: D3.Time.Range, count: number): any[];
|
||||
};
|
||||
tickFormat(count: number): (n: number) => string;
|
||||
copy(): TimeScale;
|
||||
|
||||
Vendored
+2
-2
@@ -18,11 +18,11 @@ interface ElmComponent<P> {
|
||||
ports: P;
|
||||
}
|
||||
|
||||
interface PortToElm<V> {
|
||||
interface PortToElm<V> {
|
||||
send(value: V): void;
|
||||
}
|
||||
|
||||
interface PortFromElm<V> {
|
||||
subscribe(handler: (value: V) => void): void;
|
||||
unsubscribe(handler: (value: V) => void): void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/// <reference path="./findup-sync.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import findup = require('findup-sync');
|
||||
|
||||
var str: string;
|
||||
|
||||
str = findup('foo');
|
||||
str = findup(['foo', 'bar']);
|
||||
|
||||
str = findup('foo', {
|
||||
debug: true
|
||||
});
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// Type definitions for findup-sync v0.1.3
|
||||
// Project: https://github.com/cowboy/node-findup-sync
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../minimatch/minimatch.d.ts" />
|
||||
|
||||
declare module 'findup-sync' {
|
||||
import minimatch = require('minimatch');
|
||||
|
||||
function mod(pattern: string, opts?: minimatch.IOptions): string;
|
||||
function mod(pattern: string[], opts?: minimatch.IOptions): string;
|
||||
|
||||
export = mod;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path="./from.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import from = require('from');
|
||||
|
||||
var rs: NodeJS.ReadableStream;
|
||||
|
||||
rs = from([]);
|
||||
rs = from(function (count: number, next: () => any) {
|
||||
this.emit('end');
|
||||
});
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// Type definitions for from v0.1.3
|
||||
// Project: https://github.com/dominictarr/from
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module 'from' {
|
||||
|
||||
var mod: mod.From;
|
||||
|
||||
module mod {
|
||||
interface From {
|
||||
(getChunk: (count: number, next: () => any) => any): NodeJS.ReadableStream;
|
||||
(chunks: any[]): NodeJS.ReadableStream;
|
||||
emit(type: string, data: any): void;
|
||||
}
|
||||
}
|
||||
|
||||
export = mod;
|
||||
}
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for aws-sdk
|
||||
// Type definitions for fs-extra
|
||||
// Project: https://github.com/jprichardson/node-fs-extra
|
||||
// Definitions by: midknight41 <https://github.com/midknight41>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/// <reference path="jquery.fileupload.d.ts" />
|
||||
|
||||
/*
|
||||
* Handle the event of adding a file to the jQuery Upload plugin.
|
||||
*
|
||||
*/
|
||||
var __handleAddingFile = function (event:any, data:any)
|
||||
{
|
||||
event.preventDefault();
|
||||
|
||||
// [PERFORM VALIDATION]
|
||||
// If the data is valid submit the document
|
||||
data.submit();
|
||||
};
|
||||
|
||||
class TestFileInput {
|
||||
|
||||
// The whole body will be the container for this test
|
||||
$el = $('body');
|
||||
|
||||
// Reference to the whole jQueryFileUpload object of the class
|
||||
fileInput:JQueryFileUpload;
|
||||
|
||||
constructor() {
|
||||
|
||||
// The file upload object receives a fileInputOptions configuration object
|
||||
this.fileInput = <JQueryFileUpload>this.$el.fileupload({
|
||||
|
||||
dataType: 'json',
|
||||
|
||||
// By default, each file of a selection is uploaded using an individual
|
||||
// request for XHR type uploads. Set to false to upload file
|
||||
// selections in one request each:
|
||||
singleFileUploads: true,
|
||||
// To limit the number of files uploaded with one XHR request,
|
||||
// set the following option to an integer greater than 0:
|
||||
limitMultiFileUploads: 1,
|
||||
|
||||
add: __handleAddingFile
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
// Type definitions for jQuery File Upload Plugin 5.40.1
|
||||
// Project: https://github.com/blueimp/jQuery-File-Upload
|
||||
// Definitions by: Rob Alarcon <https://github.com/rob-alarcon/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
|
||||
|
||||
// Interface options for the plugin
|
||||
interface JQueryFileInputOptions {
|
||||
|
||||
// The drop target element(s), by the default the complete document.
|
||||
// Set to null to disable drag & drop support:
|
||||
dropZone?: HTMLElement;
|
||||
|
||||
// The paste target element(s), by the default the complete document.
|
||||
// Set to null to disable paste support:
|
||||
pasteZone?: HTMLElement;
|
||||
|
||||
// The file input field(s), that are listened to for change events.
|
||||
// If undefined, it is set to the file input fields inside
|
||||
// of the widget element on plugin initialization.
|
||||
// Set to null to disable the change listener.
|
||||
fileInput?: HTMLElement;
|
||||
|
||||
// By default, the file input field is replaced with a clone after
|
||||
// each input field change event. This is required for iframe transport
|
||||
// queues and allows change events to be fired for the same file
|
||||
// selection, but can be disabled by setting the following option to false:
|
||||
replaceFileInput?: boolean;
|
||||
|
||||
|
||||
// The parameter name for the file form data (the request argument name).
|
||||
// If undefined or empty, the name property of the file input field is
|
||||
// used, or "files[]" if the file input name property is also empty,
|
||||
// can be a string or an array of strings:
|
||||
paramName?: any;
|
||||
|
||||
// By default, each file of a selection is uploaded using an individual
|
||||
// request for XHR type uploads. Set to false to upload file
|
||||
// selections in one request each:
|
||||
singleFileUploads?: boolean;
|
||||
|
||||
// To limit the number of files uploaded with one XHR request,
|
||||
// set the following option to an integer greater than 0:
|
||||
limitMultiFileUploads?: number;
|
||||
|
||||
// The following option limits the number of files uploaded with one
|
||||
// XHR request to keep the request size under or equal to the defined
|
||||
// limit in bytes:
|
||||
limitMultiFileUploadSize?: number;
|
||||
|
||||
// Multipart file uploads add a number of bytes to each uploaded file,
|
||||
// therefore the following option adds an overhead for each file used
|
||||
// in the limitMultiFileUploadSize configuration:
|
||||
limitMultiFileUploadSizeOverhead?: number;
|
||||
|
||||
// Set the following option to true to issue all file upload requests
|
||||
// in a sequential order:
|
||||
sequentialUploads?: boolean;
|
||||
|
||||
// To limit the number of concurrent uploads,
|
||||
// set the following option to an integer greater than 0:
|
||||
limitConcurrentUploads?: number;
|
||||
|
||||
// Set the following option to true to force iframe transport uploads:
|
||||
forceIframeTransport?: boolean;
|
||||
|
||||
// Set the following option to the location of a redirect url on the
|
||||
// origin server, for cross-domain iframe transport uploads:
|
||||
redirect?: string;
|
||||
|
||||
// The parameter name for the redirect url, sent as part of the form
|
||||
// data and set to 'redirect' if this option is empty:
|
||||
redirectParamName?: string;
|
||||
|
||||
// Set the following option to the location of a postMessage window,
|
||||
// to enable postMessage transport uploads:
|
||||
postMessage?: string;
|
||||
|
||||
// By default, XHR file uploads are sent as multipart/form-data.
|
||||
// The iframe transport is always using multipart/form-data.
|
||||
// Set to false to enable non-multipart XHR uploads:
|
||||
multipart?: boolean;
|
||||
|
||||
// To upload large files in smaller chunks, set the following option
|
||||
// to a preferred maximum chunk size. If set to 0, null or undefined,
|
||||
// or the browser does not support the required Blob API, files will
|
||||
// be uploaded as a whole.
|
||||
maxChunkSize?: number;
|
||||
|
||||
// When a non-multipart upload or a chunked multipart upload has been
|
||||
// aborted, this option can be used to resume the upload by setting
|
||||
// it to the size of the already uploaded bytes. This option is most
|
||||
// useful when modifying the options object inside of the "add" or
|
||||
// "send" callbacks, as the options are cloned for each file upload.
|
||||
uploadedBytes?: number;
|
||||
|
||||
// By default, failed (abort or error) file uploads are removed from the
|
||||
// global progress calculation. Set the following option to false to
|
||||
// prevent recalculating the global progress data:
|
||||
recalculateProgress?: boolean;
|
||||
|
||||
// Interval in milliseconds to calculate and trigger progress events:
|
||||
progressInterval?: number;
|
||||
|
||||
// Interval in milliseconds to calculate progress bitrate:
|
||||
bitrateInterval?: number;
|
||||
|
||||
// By default, uploads are started automatically when adding files:
|
||||
autoUpload?: boolean;
|
||||
|
||||
// Error and info messages:
|
||||
messages?: any;
|
||||
|
||||
// Translation function, gets the message key to be translated
|
||||
// and an object with context specific data as arguments:
|
||||
i18n?: any;
|
||||
|
||||
// Additional form data to be sent along with the file uploads can be set
|
||||
// using this option, which accepts an array of objects with name and
|
||||
// value properties, a function returning such an array, a FormData
|
||||
// object (for XHR file uploads), or a simple object.
|
||||
// The form of the first fileInput is given as parameter to the function:
|
||||
formData?: any;
|
||||
|
||||
// The add callback is invoked as soon as files are added to the fileupload
|
||||
// widget (via file input selection, drag & drop, paste or add API call).
|
||||
// If the singleFileUploads option is enabled, this callback will be
|
||||
// called once for each file in the selection for XHR file uploads, else
|
||||
// once for each file selection.
|
||||
//
|
||||
// The upload starts when the submit method is invoked on the data parameter.
|
||||
// The data object contains a files property holding the added files
|
||||
// and allows you to override plugin options as well as define ajax settings.
|
||||
//
|
||||
// Listeners for this callback can also be bound the following way:
|
||||
// .bind('fileuploadadd', func);
|
||||
//
|
||||
// data.submit() returns a Promise object and allows to attach additional
|
||||
// handlers using jQuery's Deferred callbacks:
|
||||
// data.submit().done(func).fail(func).always(func);
|
||||
add?: any;
|
||||
|
||||
// The plugin options are used as settings object for the ajax calls.
|
||||
// The following are jQuery ajax settings required for the file uploads:
|
||||
processData?: boolean;
|
||||
|
||||
contentType?: string;
|
||||
|
||||
cache?: boolean;
|
||||
|
||||
}
|
||||
|
||||
interface JQueryFileUpload {
|
||||
|
||||
contentType:string;
|
||||
}
|
||||
|
||||
interface JQuery
|
||||
{
|
||||
// Interface to the main method of jQuery File Upload
|
||||
fileupload(settings: JQueryFileInputOptions): JQueryFileUpload;
|
||||
}
|
||||
Vendored
+1
-1
@@ -274,7 +274,7 @@ interface KnockoutUtils {
|
||||
|
||||
stringTrim(str: string): string;
|
||||
|
||||
stringTokenize(str: string, delimiter: string): string;
|
||||
stringTokenize(str: string, delimiter: string): string[];
|
||||
|
||||
stringStartsWith(str: string, startsWith: string): string;
|
||||
|
||||
|
||||
@@ -30,6 +30,22 @@ function test_asyncCommand() {
|
||||
});
|
||||
}
|
||||
|
||||
function test_asyncCommand_isExecuting() {
|
||||
var primaryCommand = ko.asyncCommand({
|
||||
execute: (complete) => {
|
||||
$.when().always(complete);
|
||||
},
|
||||
canExecute: (isExecuting) => {
|
||||
return !isExecuting;
|
||||
}
|
||||
});
|
||||
|
||||
var firstRun = true;
|
||||
var canCancel = ko.computed(() => {
|
||||
return firstRun && !primaryCommand.isExecuting();
|
||||
});
|
||||
}
|
||||
|
||||
function test_dirtyFlag() {
|
||||
var viewModel;
|
||||
viewModel.dirtyFlag = new ko.DirtyFlag(viewModel.model);
|
||||
|
||||
Vendored
+5
-1
@@ -58,6 +58,10 @@ interface KoliteCommand {
|
||||
execute(...args: any[]): any;
|
||||
}
|
||||
|
||||
interface KoliteAsyncCommand extends KoliteCommand {
|
||||
isExecuting: KnockoutObservable<boolean>;
|
||||
}
|
||||
|
||||
interface KoLiteCommandOptions {
|
||||
execute?: any;
|
||||
canExecute?: (isExecuting: boolean) => any;
|
||||
@@ -65,7 +69,7 @@ interface KoLiteCommandOptions {
|
||||
|
||||
interface KnockoutStatic {
|
||||
command(options: KoLiteCommandOptions): KoliteCommand;
|
||||
asyncCommand(optons: KoLiteCommandOptions): KoliteCommand;
|
||||
asyncCommand(optons: KoLiteCommandOptions): KoliteAsyncCommand;
|
||||
}
|
||||
|
||||
interface KnockoutUtils {
|
||||
|
||||
Vendored
+6
-4
@@ -3655,25 +3655,27 @@ declare module L {
|
||||
}
|
||||
}
|
||||
|
||||
export class tileLayer {
|
||||
export interface TileLayerFactory {
|
||||
|
||||
/**
|
||||
* Instantiates a tile layer object given a URL template and optionally an options
|
||||
* object.
|
||||
*/
|
||||
function (urlTemplate: string, options?: TileLayerOptions): TileLayer;
|
||||
(urlTemplate: string, options?: TileLayerOptions): TileLayer;
|
||||
|
||||
/**
|
||||
* Instantiates a WMS tile layer object given a base URL of the WMS service and
|
||||
* a WMS parameters/options object.
|
||||
*/
|
||||
static wms(baseUrl: string, options: WMSOptions): L.TileLayer.WMS;
|
||||
wms(baseUrl: string, options: WMSOptions): L.TileLayer.WMS;
|
||||
|
||||
/**
|
||||
* Instantiates a Canvas tile layer object given an options object (optionally).
|
||||
*/
|
||||
static canvas(options?: TileLayerOptions): L.TileLayer.Canvas;
|
||||
canvas(options?: TileLayerOptions): L.TileLayer.Canvas;
|
||||
}
|
||||
|
||||
export var tileLayer: TileLayerFactory;
|
||||
}
|
||||
|
||||
declare module L {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import Long = require("long");
|
||||
// --- browser ---
|
||||
//var Long = dcodeIO.Long;
|
||||
|
||||
var val:Long;
|
||||
var val:dcodeIO.Long;
|
||||
var n:number;
|
||||
var b:boolean;
|
||||
var s:string;
|
||||
|
||||
Vendored
+67
-67
@@ -3,78 +3,78 @@
|
||||
// Definitions by: Toshihide Hara <https://github.com/kerug/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface LongStatic {
|
||||
new(low:number, high:number, unsigned?:boolean):Long;
|
||||
|
||||
MAX_SIGNED_VALUE:Long;
|
||||
MAX_UNSIGNED_VALUE:Long;
|
||||
MAX_VALUE:Long;
|
||||
MIN_SIGNED_VALUE:Long;
|
||||
MIN_UNSIGNED_VALUE:Long;
|
||||
MIN_VALUE:Long;
|
||||
NEG_ONE:Long;
|
||||
ONE:Long;
|
||||
ZERO:Long;
|
||||
|
||||
from28Bits(part0:number, part1:number, part2:number, unsigned?:boolean):Long;
|
||||
fromBits(lowBits:number, highBits:number, unsigned?:boolean):Long;
|
||||
fromInt(value:number, unsigned?:boolean):Long;
|
||||
fromNumber(value:number, unsigned?:boolean):Long;
|
||||
fromString(str:string, unsigned?:boolean, radix?:number):Long;
|
||||
fromString(str:string, unsigned?:number, radix?:number):Long;
|
||||
fromString(str:string, unsigned?:any, radix?:number):Long;
|
||||
}
|
||||
|
||||
interface Long {
|
||||
high:number;
|
||||
low:number;
|
||||
unsigned:boolean;
|
||||
|
||||
add(other:Long):Long;
|
||||
and(other:Long):Long;
|
||||
clone():Long;
|
||||
compare(other:Long):number;
|
||||
div(other:Long):Long;
|
||||
equals(other:Long):boolean;
|
||||
getHighBits():number;
|
||||
getHighBitsUnsigned():number;
|
||||
getLowBits():number;
|
||||
getLowBitsUnsigned():number;
|
||||
getNumBitsAbs():number;
|
||||
greaterThan(other:Long):boolean;
|
||||
greaterThanOrEqual(other:Long):boolean;
|
||||
isEven():boolean;
|
||||
isNegative():boolean;
|
||||
isOdd():boolean;
|
||||
isZero():boolean;
|
||||
lessThan(other:Long):boolean;
|
||||
lessThanOrEqual(other:Long):boolean;
|
||||
modulo(other:Long):Long;
|
||||
multiply(other:Long):Long;
|
||||
negate():Long;
|
||||
not():Long;
|
||||
notEquals(other:Long):boolean;
|
||||
or(other:Long):Long;
|
||||
shiftLeft(numBits:number):Long;
|
||||
shiftRight(numBits:number):Long;
|
||||
shiftRightUnsigned(numBits:number):Long;
|
||||
subtract(other:Long):Long;
|
||||
toInt():number;
|
||||
toNumber():number;
|
||||
toSigned():Long;
|
||||
toString(radix?:number):string;
|
||||
toUnsigned():Long;
|
||||
xor(other:Long):Long;
|
||||
}
|
||||
|
||||
// for browser
|
||||
declare module dcodeIO {
|
||||
|
||||
interface LongStatic {
|
||||
new(low:number, high:number, unsigned?:boolean):Long;
|
||||
|
||||
MAX_SIGNED_VALUE:Long;
|
||||
MAX_UNSIGNED_VALUE:Long;
|
||||
MAX_VALUE:Long;
|
||||
MIN_SIGNED_VALUE:Long;
|
||||
MIN_UNSIGNED_VALUE:Long;
|
||||
MIN_VALUE:Long;
|
||||
NEG_ONE:Long;
|
||||
ONE:Long;
|
||||
ZERO:Long;
|
||||
|
||||
from28Bits(part0:number, part1:number, part2:number, unsigned?:boolean):Long;
|
||||
fromBits(lowBits:number, highBits:number, unsigned?:boolean):Long;
|
||||
fromInt(value:number, unsigned?:boolean):Long;
|
||||
fromNumber(value:number, unsigned?:boolean):Long;
|
||||
fromString(str:string, unsigned?:boolean, radix?:number):Long;
|
||||
fromString(str:string, unsigned?:number, radix?:number):Long;
|
||||
fromString(str:string, unsigned?:any, radix?:number):Long;
|
||||
}
|
||||
|
||||
interface Long {
|
||||
high:number;
|
||||
low:number;
|
||||
unsigned:boolean;
|
||||
|
||||
add(other:Long):Long;
|
||||
and(other:Long):Long;
|
||||
clone():Long;
|
||||
compare(other:Long):number;
|
||||
div(other:Long):Long;
|
||||
equals(other:Long):boolean;
|
||||
getHighBits():number;
|
||||
getHighBitsUnsigned():number;
|
||||
getLowBits():number;
|
||||
getLowBitsUnsigned():number;
|
||||
getNumBitsAbs():number;
|
||||
greaterThan(other:Long):boolean;
|
||||
greaterThanOrEqual(other:Long):boolean;
|
||||
isEven():boolean;
|
||||
isNegative():boolean;
|
||||
isOdd():boolean;
|
||||
isZero():boolean;
|
||||
lessThan(other:Long):boolean;
|
||||
lessThanOrEqual(other:Long):boolean;
|
||||
modulo(other:Long):Long;
|
||||
multiply(other:Long):Long;
|
||||
negate():Long;
|
||||
not():Long;
|
||||
notEquals(other:Long):boolean;
|
||||
or(other:Long):Long;
|
||||
shiftLeft(numBits:number):Long;
|
||||
shiftRight(numBits:number):Long;
|
||||
shiftRightUnsigned(numBits:number):Long;
|
||||
subtract(other:Long):Long;
|
||||
toInt():number;
|
||||
toNumber():number;
|
||||
toSigned():Long;
|
||||
toString(radix?:number):string;
|
||||
toUnsigned():Long;
|
||||
xor(other:Long):Long;
|
||||
}
|
||||
|
||||
// for browser
|
||||
export var Long:LongStatic;
|
||||
}
|
||||
|
||||
// for node, commonjs
|
||||
declare module "long" {
|
||||
var Long:dcodeIO.LongStatic;
|
||||
export = Long;
|
||||
}
|
||||
|
||||
declare var Long:LongStatic;
|
||||
|
||||
@@ -0,0 +1,853 @@
|
||||
// Type definitions for Microsoft ASP.NET Ajax client side library
|
||||
// Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx
|
||||
// Definitions by: Patrick Magee <https://github.com/pjmagee/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
/// <reference path="microsoft.ajax.d.ts" />
|
||||
|
||||
function GlobalNamespace_Tests() {
|
||||
|
||||
var arrayVar = new Array("Saturn", "Mars", "Jupiter");
|
||||
|
||||
// Get
|
||||
$get("Button1");
|
||||
$get("Button1", $get("Button2"));
|
||||
|
||||
// Add handler
|
||||
$addHandler($get("Button1"), "click", () => { });
|
||||
$addHandlers($get("Button1"), {});
|
||||
|
||||
// Remove handler
|
||||
$removeHandler($get("Button1"), "click", () => { });
|
||||
|
||||
// Find
|
||||
$find('MyComponent');
|
||||
$find('MyComponent', $find('#test'));
|
||||
|
||||
// Clear
|
||||
$clearHandlers($get("Button1"));
|
||||
|
||||
}
|
||||
|
||||
function BaseClassExtensions_Error_Tests() {
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx
|
||||
|
||||
function validateNumberRange(input: any, min: number, max: number) {
|
||||
|
||||
// Verify the required parameters were defined.
|
||||
if (input === undefined) {
|
||||
// Throw a standard exception type.
|
||||
var err = (<MicrosoftAjaxBaseTypeExtensions.Error>Error).argumentNull("input", "A parameter was undefined.");
|
||||
throw err;
|
||||
}
|
||||
else if (min === undefined) {
|
||||
var err = (<MicrosoftAjaxBaseTypeExtensions.Error>Error).argumentNull("min", "A parameter was undefined.");
|
||||
throw err;
|
||||
}
|
||||
else if (max === undefined) {
|
||||
var err = (<MicrosoftAjaxBaseTypeExtensions.Error>Error).argumentNull("max", "A parameter was undefined.");
|
||||
throw err;
|
||||
}
|
||||
else if (min >= max) {
|
||||
var err = (<MicrosoftAjaxBaseTypeExtensions.Error>Error).invalidOperation("The min parameter must be smaller than max parameter.");
|
||||
throw err;
|
||||
}
|
||||
else if (isNaN(input)) {
|
||||
var msg = "A number was not entered. ";
|
||||
msg += (<MicrosoftAjaxBaseTypeExtensions.String>String).format("Please enter a number between {0} and {1}.", min, max);
|
||||
|
||||
var err = (<MicrosoftAjaxBaseTypeExtensions.Error>Error).create(msg);
|
||||
throw err;
|
||||
}
|
||||
else if (input < min || input > max) {
|
||||
msg = "The number entered was outside the acceptable range. ";
|
||||
msg += (<MicrosoftAjaxBaseTypeExtensions.String>String).format("Please enter a number between {0} and {1}.", min, max);
|
||||
|
||||
var err = (<MicrosoftAjaxBaseTypeExtensions.Error>Error).create(msg);
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
alert("The number entered was within the acceptable range.");
|
||||
}
|
||||
|
||||
var input: any = undefined;
|
||||
var min = -10;
|
||||
var max = 10;
|
||||
|
||||
// Result: A thrown ErrorArgumentNull exception with the following Error object message:
|
||||
// "Sys.ArgumentNullException: A parameter was undefined. Parameter name: input"
|
||||
validateNumberRange(input, min, max);
|
||||
}
|
||||
|
||||
function BaseClassExtensions_String_Tests() {
|
||||
|
||||
(<MicrosoftAjaxBaseTypeExtensions.String>String).format("Please enter a number between {0} and {1}.", 1, 2);
|
||||
(<MicrosoftAjaxBaseTypeExtensions.String>String).endsWith("test");
|
||||
(<MicrosoftAjaxBaseTypeExtensions.String>String).localeFormat("Please enter a number between {0} and {1}", 1, 2);
|
||||
(<MicrosoftAjaxBaseTypeExtensions.String>String).trim();
|
||||
(<MicrosoftAjaxBaseTypeExtensions.String>String).trimEnd();
|
||||
(<MicrosoftAjaxBaseTypeExtensions.String>String).trimStart();
|
||||
}
|
||||
|
||||
function BaseClassExtensions_Function_Tests() {
|
||||
|
||||
/** Sample code from http://msdn.microsoft.com/en-us/library/dd409287(v=vs.100).aspx */
|
||||
var createDelegateTest = function () {
|
||||
var context = "";
|
||||
var method: MicrosoftAjaxBaseTypeExtensions.Function;
|
||||
var a = (<MicrosoftAjaxBaseTypeExtensions.Function>Function).createCallback(method, context);
|
||||
}
|
||||
|
||||
/** Sample code from http://msdn.microsoft.com/en-us/library/dd393582(v=vs.100).aspx */
|
||||
var createDelegateTest = function () {
|
||||
var instance = this;
|
||||
var method: MicrosoftAjaxBaseTypeExtensions.Function;
|
||||
var a = (<MicrosoftAjaxBaseTypeExtensions.Function>Function).createDelegate(instance, method);
|
||||
}
|
||||
|
||||
/** Sample code from http://msdn.microsoft.com/en-us/library/dd393712(v=vs.100).aspx */
|
||||
var validateParametersTest = function () {
|
||||
var arguments = ['test1', 'test2'];
|
||||
var insert = function Array$insert(array: any[], index: number, item: any) {
|
||||
var e = (<MicrosoftAjaxBaseTypeExtensions.Function>Function).validateParameters(arguments, [
|
||||
{ name: "array", type: Array, elementMayBeNull: true },
|
||||
{ name: "index", mayBeNull: true },
|
||||
{ name: "item", mayBeNull: true }
|
||||
]);
|
||||
if (e) throw e;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function BaseClassExtensions_Array_Tests() {
|
||||
|
||||
var arrayVar = Array<string>("one", "two", "three");
|
||||
|
||||
arrayVar.add(["one"], {});
|
||||
arrayVar.addRange({}, ["one", "two", "three"]);
|
||||
arrayVar.clear();
|
||||
arrayVar.clone();
|
||||
arrayVar.contains({});
|
||||
arrayVar.dequeue();
|
||||
arrayVar.enqueue({});
|
||||
arrayVar.insert([1, 2, 3], 1, {});
|
||||
arrayVar.isArray({});
|
||||
arrayVar.parse("1, 2, 3, 4, 5");
|
||||
arrayVar.remove([1, 2, 3], 2);
|
||||
arrayVar.removeAt([1, 2, 3], 1);
|
||||
|
||||
}
|
||||
|
||||
function BaseClassExtensions_Date_Tests() {
|
||||
|
||||
var date = new Date(2014, 5, 25);
|
||||
date.format("g");
|
||||
date.localeFormat("g");
|
||||
date.parseLocale("2014/05/25");
|
||||
date.parseInvariant("2014/05/25");
|
||||
}
|
||||
|
||||
function BaseClassExtensions_Boolean_Tests() {
|
||||
|
||||
(<MicrosoftAjaxBaseTypeExtensions.Boolean>Boolean).parse("false");
|
||||
}
|
||||
|
||||
function BaseClassExtensions_Number_Tests() {
|
||||
|
||||
var x: number = 5;
|
||||
|
||||
x.format("d");
|
||||
x.localeFormat("c");
|
||||
x.parseInvariant("1");
|
||||
x.parseLocale("1");
|
||||
}
|
||||
|
||||
function Sys_Application_Tests() {
|
||||
|
||||
var component = new Sys.Component();
|
||||
var element = document.getElementById("#test");
|
||||
var id = "#test";
|
||||
var propertyName = "test";
|
||||
var registerObject = new Object();
|
||||
|
||||
function loadHandler() { }
|
||||
function initHandler() { }
|
||||
function navigateHandler() { }
|
||||
function unloadHandler() { }
|
||||
|
||||
Sys.Application.add_load(loadHandler);
|
||||
Sys.Application.remove_load(loadHandler);
|
||||
Sys.Application.add_init(initHandler);
|
||||
Sys.Application.remove_init(initHandler);
|
||||
Sys.Application.add_navigate(navigateHandler);
|
||||
Sys.Application.remove_navigate(navigateHandler);
|
||||
Sys.Application.add_unload(unloadHandler);
|
||||
Sys.Application.remove_unload(unloadHandler);
|
||||
Sys.Application.addComponent(component);
|
||||
Sys.Application.addHistoryPoint("state", "title");
|
||||
Sys.Application.beginCreateComponents();
|
||||
Sys.Application.beginUpdate();
|
||||
Sys.Application.dispose();
|
||||
Sys.Application.disposeElement(element, false);
|
||||
Sys.Application.endCreateComponents();
|
||||
Sys.Application.endUpdate();
|
||||
Sys.Application.findComponent(id, element);
|
||||
Sys.Application.findComponent(id, component);
|
||||
Sys.Application.findComponent(id);
|
||||
|
||||
$find(id, element);
|
||||
|
||||
var componentArray = Sys.Application.getComponents();
|
||||
for (var i = 0; i < componentArray.length; i++) {
|
||||
var cid = componentArray[i].get_id();
|
||||
}
|
||||
|
||||
Sys.Application.initialize();
|
||||
Sys.Application.notifyScriptLoaded();
|
||||
Sys.Application.raiseLoad();
|
||||
Sys.Application.raisePropertyChanged(propertyName);
|
||||
Sys.Application.registerDisposableObject(registerObject);
|
||||
Sys.Application.removeComponent(component);
|
||||
Sys.Application.unregisterDisposableObject(registerObject);
|
||||
Sys.Application.endUpdate();
|
||||
Sys.Application.get_enableHistory();
|
||||
Sys.Application.set_enableHistory(true);
|
||||
Sys.Application.get_isCreatingComponents();
|
||||
Sys.Application.get_isDisposing();
|
||||
}
|
||||
|
||||
function Sys_Application_LoadEventArgs_Tests() {
|
||||
|
||||
var a = new Sys.ApplicationLoadEventArgs(new Array<Sys.Component>(), true);
|
||||
|
||||
var components = a.get_components();
|
||||
var isPartialReload = a.get_isPartialLoad();
|
||||
}
|
||||
|
||||
function Sys_Browser_Tests() {
|
||||
|
||||
var browser = Sys.Browser();
|
||||
var agent = browser.agent;
|
||||
var name = browser.name;
|
||||
var version = browser.version;
|
||||
var hasDebuggerStatement = browser.hasDebuggerStatement;
|
||||
|
||||
}
|
||||
|
||||
function Sys_EventArgs_Tests() {
|
||||
|
||||
var anEventArgs = new Sys.EventArgs();
|
||||
var eventArgs = anEventArgs.Empty;
|
||||
|
||||
}
|
||||
|
||||
function Sys_CancelEventArgs_Tests() {
|
||||
|
||||
var args = new Sys.CancelEventArgs();
|
||||
|
||||
var divElem = 'AlertDiv';
|
||||
var messageElem = 'AlertMessage';
|
||||
|
||||
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus);
|
||||
|
||||
var CheckStatus = function (sender: any, args: any) {
|
||||
|
||||
var prm = Sys.WebForms.PageRequestManager.getInstance();
|
||||
|
||||
if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'CancelRefresh') {
|
||||
prm.abortPostBack();
|
||||
}
|
||||
else if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') {
|
||||
|
||||
args.set_cancel(true);
|
||||
ActivateAlertDiv('visible', 'Still working on previous request.');
|
||||
}
|
||||
else if (!prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') {
|
||||
ActivateAlertDiv('visible', 'Processing....');
|
||||
}
|
||||
}
|
||||
|
||||
var ActivateAlertDiv = function (visString: string, msg: string) {
|
||||
var adiv = <HTMLElement> $get(divElem);
|
||||
var aspan = <HTMLElement> $get(messageElem);
|
||||
adiv.style.visibility = visString;
|
||||
aspan.innerHTML = msg;
|
||||
}
|
||||
}
|
||||
|
||||
function Sys_CollectionChange_Tests() {
|
||||
|
||||
var action = Sys.NotifyCollectionChangedAction.add;
|
||||
var newItems: any[] = [];
|
||||
var newStartingIndex = 1;
|
||||
var oldItems: any[] = [];
|
||||
var oldStartingIndex = 2;
|
||||
|
||||
var MyCChg = new Sys.CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex);
|
||||
|
||||
action = MyCChg.action;
|
||||
newItems = MyCChg.newItems;
|
||||
newStartingIndex = MyCChg.newStartingIndex;
|
||||
oldItems = MyCChg.oldItems;
|
||||
oldStartingIndex = MyCChg.oldStartingIndex;
|
||||
}
|
||||
|
||||
function Sys_CommandEventArg_Tests() {
|
||||
|
||||
var commandName = "command name";
|
||||
var commandArgument = "command argument";
|
||||
var commandSource = "command source";
|
||||
var argsObj = new Sys.CommandEventArgs(commandName, commandArgument, commandSource);
|
||||
var empty = argsObj.Empty;
|
||||
commandName = argsObj.get_commandName();
|
||||
commandArgument = argsObj.get_commandArgument();
|
||||
}
|
||||
|
||||
function Sys_Component_Tests() {
|
||||
|
||||
var aComponent = new Sys.Component();
|
||||
var properties: any;
|
||||
var events: any;
|
||||
var references: any;
|
||||
var element: HTMLElement;
|
||||
var handler: Function;
|
||||
var MyControl = new Type;
|
||||
|
||||
aComponent.add_disposing(() => { });
|
||||
aComponent.remove_disposing(() => { });
|
||||
|
||||
aComponent.add_propertyChanged(() => { });
|
||||
aComponent.remove_propertyChanged(() => { });
|
||||
|
||||
aComponent.beginUpdate();
|
||||
|
||||
var component = $create(MyControl, { id: 'c1', visible: true }, { click: handler }, null, $get('button1'));
|
||||
|
||||
aComponent.dispose();
|
||||
aComponent.endUpdate();
|
||||
aComponent.initialize();
|
||||
aComponent.raisePropertyChanged("propertyName");
|
||||
aComponent.updated();
|
||||
|
||||
var id = aComponent.get_id();
|
||||
aComponent.set_id("#button1");
|
||||
var isInitialized = aComponent.get_isInitialized();
|
||||
var isUpdating = aComponent.get_isUpdating();
|
||||
}
|
||||
|
||||
function Sys_UI_Key_Tests() {
|
||||
|
||||
var backspace: number = Sys.UI.Key.backspace;
|
||||
var del: number = Sys.UI.Key.del;
|
||||
var down: number = Sys.UI.Key.down;
|
||||
var end: number = Sys.UI.Key.end;
|
||||
var pageDown: number = Sys.UI.Key.pageDown;
|
||||
var pageUp: number = Sys.UI.Key.pageUp;
|
||||
var home: number = Sys.UI.Key.home;
|
||||
var enter: number = Sys.UI.Key.enter;
|
||||
var esc: number = Sys.UI.Key.esc;
|
||||
var tab: number = Sys.UI.Key.tab;
|
||||
var key: number = Sys.UI.Key.up;
|
||||
var left: number = Sys.UI.Key.left;
|
||||
var right: number = Sys.UI.Key.right;
|
||||
var space: number = Sys.UI.Key.space;
|
||||
|
||||
}
|
||||
|
||||
function Sys_UI_Control_Tests() {
|
||||
|
||||
var domElementObj: any;
|
||||
var className = "class Name";
|
||||
|
||||
var a = new Sys.UI.Control(domElementObj);
|
||||
|
||||
a.addCssClass(className);
|
||||
a.toggleCssClass(className);
|
||||
a.removeCssClass(className);
|
||||
|
||||
a.initialize();
|
||||
a.raiseBubbleEvent(domElementObj, className);
|
||||
a.onBubbleEvent(domElementObj, className);
|
||||
a.dispose();
|
||||
}
|
||||
|
||||
function Sy_UI_Point_Tests() {
|
||||
|
||||
var elementRef: Sys.UI.DomElement;
|
||||
var result: string;
|
||||
// Get the location of the element
|
||||
var elementLoc = Sys.UI.DomElement.getLocation(elementRef);
|
||||
result += "Before move - Label1 location (x,y) = (" +
|
||||
elementLoc.x + "," + elementLoc.y + ")<br/>";
|
||||
// Move the element
|
||||
Sys.UI.DomElement.setLocation(elementRef, 100, elementLoc.y);
|
||||
elementLoc = Sys.UI.DomElement.getLocation(elementRef);
|
||||
result += "After move - Label1 location (x,y) = (" +
|
||||
elementLoc.x + "," + elementLoc.y + ")<br/>";
|
||||
|
||||
}
|
||||
|
||||
function Sys_UI_DomEvent_Tests() {
|
||||
|
||||
var object: any;
|
||||
|
||||
Sys.UI.DomEvent.addHandler(object, "eventName", () => { });
|
||||
Sys.UI.DomEvent.addHandler(object, "eventName", () => { }, true);
|
||||
|
||||
Sys.UI.DomEvent.addHandlers(object, object, object, true);
|
||||
Sys.UI.DomEvent.removeHandler(object, "eventName", () => { });
|
||||
Sys.UI.DomEvent.clearHandlers(object);
|
||||
|
||||
var domEvent = new Sys.UI.DomEvent(object);
|
||||
var altKey: boolean = domEvent.altKey;
|
||||
var mouseButton: Sys.UI.MouseButton = domEvent.button;
|
||||
var charCode: number = domEvent.charCode;
|
||||
var clientX: number = domEvent.clientX;
|
||||
var ctrlKey: boolean = domEvent.ctrlKey;
|
||||
var screenX: number = domEvent.screenX;
|
||||
var screenY: number = domEvent.screenY;
|
||||
var target: any = domEvent.target;
|
||||
var shiftKey: boolean = domEvent.shiftKey;
|
||||
var type: string = domEvent.type;
|
||||
}
|
||||
|
||||
function Sys_UI_DomElement_Tests() {
|
||||
|
||||
// Add CSS class
|
||||
Sys.UI.DomElement.addCssClass($get("Button1"), "redBackgroundColor");
|
||||
|
||||
var elementRef: Sys.UI.DomElement = $get("Label1");
|
||||
var elementBounds = Sys.UI.DomElement.getBounds(elementRef);
|
||||
var toggleCssClassMethod = () => {};
|
||||
var removeCssClassMethod = () => {};
|
||||
var containsClass = Sys.UI.DomElement.containsCssClass(elementRef, "class-name");
|
||||
|
||||
// Add handler using the getElementById method
|
||||
$addHandler(Sys.UI.DomElement.getElementById("Button1"), "click", toggleCssClassMethod);
|
||||
// Add handler using the shortcut to the getElementById method
|
||||
$addHandler($get("Button2"), "click", removeCssClassMethod);
|
||||
|
||||
Sys.UI.DomElement.toggleCssClass($get("id"), "redBackgroundColor");
|
||||
|
||||
|
||||
// Add handlers using the $get shortcut to the
|
||||
// Sys.UI.DomElement.getElementById method
|
||||
$addHandler($get("Button1"), "click", toggleVisible);
|
||||
$addHandler($get("Button2"), "click", toggleVisibilityMode);
|
||||
|
||||
// This method is called when Button2 is clicked.
|
||||
function toggleVisible() {
|
||||
var anElement = $get("Label1");
|
||||
if (Sys.UI.DomElement.getVisible(anElement)) {
|
||||
Sys.UI.DomElement.setVisible(anElement, false);
|
||||
}
|
||||
else {
|
||||
Sys.UI.DomElement.setVisible(anElement, true);
|
||||
}
|
||||
}
|
||||
|
||||
// This method is called when Button1 is clicked.
|
||||
function toggleVisibilityMode() {
|
||||
|
||||
var anElement = $get("Label1");
|
||||
|
||||
var visMode = Sys.UI.DomElement.getVisibilityMode(anElement);
|
||||
|
||||
var status = visMode;
|
||||
|
||||
if (visMode === 0) {
|
||||
Sys.UI.DomElement.setVisibilityMode(anElement, Sys.UI.VisibilityMode.collapse);
|
||||
if (document.all) {
|
||||
anElement.innerText =
|
||||
"Label1 VisibilityMode: Sys.UI.VisibilityMode.collapse";
|
||||
}
|
||||
else {
|
||||
//Firefox
|
||||
anElement.textContent =
|
||||
"Label1 VisibilityMode: Sys.UI.VisibilityMode.collapse";
|
||||
}
|
||||
}
|
||||
else {
|
||||
Sys.UI.DomElement.setVisibilityMode(anElement, Sys.UI.VisibilityMode.hide);
|
||||
if (document.all) {
|
||||
anElement.innerText = "Label1 VisibilityMode: Sys.UI.VisibilityMode.hide";
|
||||
}
|
||||
else {
|
||||
//Firefox
|
||||
anElement.textContent = "Label1 VisibilityMode: Sys.UI.VisibilityMode.hide";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function Sys_Debug_Tests() {
|
||||
|
||||
var condition = true;
|
||||
|
||||
Sys.Debug.assert(condition);
|
||||
Sys.Debug.assert(condition, "true");
|
||||
Sys.Debug.assert(condition, "true", true);
|
||||
|
||||
var obj = {};
|
||||
Sys.Debug.traceDump(obj, "Name");
|
||||
Sys.Debug.trace("Trace text");
|
||||
Sys.Debug.fail("Fail message");
|
||||
|
||||
Sys.Debug.clearTrace();
|
||||
}
|
||||
|
||||
function Sys_CultureInfo_Tests() {
|
||||
|
||||
var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture;
|
||||
var dtfCCObject = currentCultureInfoObj.dateTimeFormat;
|
||||
var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture;
|
||||
var dtfICObject = invariantCultureInfoObj.dateTimeFormat;
|
||||
|
||||
var newCulture = new Sys.CultureInfo("name", "numberFormat", "dateTimeFormat");
|
||||
|
||||
var format = newCulture.dateTimeFormat;
|
||||
var name = newCulture.name;
|
||||
var numberFormat = newCulture.numberFormat;
|
||||
}
|
||||
|
||||
function Sys_Res_Tests() {
|
||||
|
||||
var actualValue = Sys.Res.actualValue;
|
||||
var appLoadTimedout = Sys.Res.appLoadTimedout;
|
||||
var argument = Sys.Res.argument;
|
||||
var argumentNull = Sys.Res.argumentNull;
|
||||
var argumentOutOfRange = Sys.Res.argumentOutOfRange;
|
||||
var argumentType = Sys.Res.argumentType;
|
||||
var argumentTypeWithTypes = Sys.Res.argumentTypeWithTypes;
|
||||
var argumentUndefined = Sys.Res.argumentUndefined;
|
||||
var assertFailed = Sys.Res.assertFailed;
|
||||
var assetFailedCaller = Sys.Res.assetFailedCaller;
|
||||
var badBaseUrl1 = Sys.Res.badBaseUrl1;
|
||||
var badBaseUrl2 = Sys.Res.badBaseUrl2;
|
||||
var badBaseUrl3 = Sys.Res.badBaseUrl3;
|
||||
var breakIntoDebugger = Sys.Res.breakIntoDebugger;
|
||||
var cannotAbortBeforeStart = Sys.Res.cannotAbortBeforeStart;
|
||||
var cannotCallBeforeResponse = Sys.Res.cannotCallBeforeResponse;
|
||||
var cannotCallOnceStarted = Sys.Res.cannotCallOnceStarted;
|
||||
var cannotCallOutsideHandler = Sys.Res.cannotCallOutsideHandler;
|
||||
var cannotDeserializeEmptyString = Sys.Res.cannotDeserializeEmptyString;
|
||||
var cannotSerializeNonFiniteNumbers = Sys.Res.cannotSerializeNonFiniteNumbers;
|
||||
var controlCantSetId = Sys.Res.controlCantSetId;
|
||||
var enumInvalidValue = Sys.Res.enumInvalidValue;
|
||||
var eventHandlerInvalid = Sys.Res.eventHandlerInvalid;
|
||||
var format = Sys.Res.format;
|
||||
var formatBadDate = Sys.Res.formatBadDate;
|
||||
var formatBadFormatSpecifier = Sys.Res.formatBadFormatSpecifier;
|
||||
var formatInvalidString = Sys.Res.formatInvalidString;
|
||||
var invalidExecutorType = Sys.Res.invalidExecutorType;
|
||||
var invalidHttpVerb = Sys.Res.invalidHttpVerb;
|
||||
var invalidOperation = Sys.Res.invalidOperation;
|
||||
var invalidTimeout = Sys.Res.invalidTimeout;
|
||||
var invokeCalledTwice = Sys.Res.invokeCalledTwice;
|
||||
var notImplemented = Sys.Res.notImplemented;
|
||||
var nullWebRequest = Sys.Res.nullWebRequest;
|
||||
}
|
||||
|
||||
function Sys_StringBuilder_Tests() {
|
||||
|
||||
// Example taken from http://msdn.microsoft.com/en-us/library/bb310852(v=vs.100).aspx
|
||||
function buildAString(title: string) {
|
||||
var headTagStart = "<head>";
|
||||
var headTagEnd = "</head>";
|
||||
var titleTagStart = "<title>";
|
||||
var titleTagEnd = "</title>";
|
||||
|
||||
var sb = new Sys.StringBuilder(this._headTagStart);
|
||||
sb.append(titleTagEnd);
|
||||
sb.append(title);
|
||||
sb.append(titleTagEnd);
|
||||
sb.append(headTagEnd);
|
||||
// Displays: "The result: <head><title>A Title</title></head>"
|
||||
alert("The result" + sb.toString());
|
||||
}
|
||||
|
||||
var title = "A Title";
|
||||
buildAString(title);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function Sys_Services_Profile_Service_Group_Tests() {
|
||||
|
||||
var Street = Sys.Services.ProfileService.properties.Address.Street;
|
||||
var City = Sys.Services.ProfileService.properties.Address.City;
|
||||
|
||||
Sys.Services.ProfileService.properties.Address = new Sys.Services.ProfileGroup();
|
||||
Sys.Services.ProfileService.properties.Address.Street = "street name";
|
||||
Sys.Services.ProfileService.properties.Address.City = "city name";
|
||||
Sys.Services.ProfileService.properties.Address.State = "state name";
|
||||
|
||||
var SaveCompletedCallback = () => { };
|
||||
var ProfileFailedCallback = () => { };
|
||||
var LoadCompletedCallback = () => { };
|
||||
|
||||
Sys.Services.ProfileService.save(null, SaveCompletedCallback, ProfileFailedCallback, null);
|
||||
Sys.Services.ProfileService.load(null, LoadCompletedCallback, ProfileFailedCallback, null);
|
||||
|
||||
Sys.Services.ProfileService.set_defaultFailedCallback("Function");
|
||||
var defaultFailedCallback = Sys.Services.ProfileService.get_defaultFailedCallback();
|
||||
|
||||
Sys.Services.ProfileService.set_defaultLoadCompletedCallback("Function");
|
||||
var defaultLoadCompletedCallback = Sys.Services.ProfileService.get_defaultLoadCompletedCallback();
|
||||
|
||||
Sys.Services.ProfileService.set_defaultSaveCompletedCallback("Function");
|
||||
var defaultSaveCompletedCallback = Sys.Services.ProfileService.get_defaultSaveCompletedCallback();
|
||||
|
||||
Sys.Services.ProfileService.set_path("path");
|
||||
Sys.Services.ProfileService.get_path();
|
||||
|
||||
var timeout = Sys.Services.ProfileService.get_timeout();
|
||||
|
||||
}
|
||||
|
||||
function Sys_Net_NetworkRequestEventArgs_Tests() {
|
||||
|
||||
var value = new Sys.Net.WebRequest();
|
||||
var netWorkEventArgs = new Sys.Net.NetWorkRequestEventArgs(value);
|
||||
var webRequest = netWorkEventArgs.get_webRequest();
|
||||
}
|
||||
|
||||
function Sys_Net_WebRequestManager_Tests() {
|
||||
|
||||
var handler = (sender: any, args: any) => { }
|
||||
|
||||
Sys.Net.WebRequestManager.add_completedRequest(handler);
|
||||
Sys.Net.WebRequestManager.add_invokingRequest(handler);
|
||||
Sys.Net.WebRequestManager.executeRequest(new Sys.Net.WebRequest());
|
||||
Sys.Net.WebRequestManager.remove_completedRequest(handler);
|
||||
Sys.Net.WebRequestManager.set_defaultTimeout(100);
|
||||
var customDefaultTimeout = Sys.Net.WebRequestManager.get_defaultTimeout();
|
||||
|
||||
}
|
||||
|
||||
function Sys_WebForms_PageRequestManager_Tests() {
|
||||
|
||||
var pageRequestManager: Sys.WebForms.PageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
|
||||
|
||||
var beginRequestHandler = (sender: any, args: Sys.WebForms.BeginRequestEventArgs) => {
|
||||
var postBackElement: HTMLElement = args.get_postBackElement();
|
||||
var webRequest: Sys.Net.WebRequest = args.get_request();
|
||||
var updatePanelsToUpdate: string[] = args.get_updatePanelsToUpdate();
|
||||
var empty: Sys.EventArgs = args.Empty;
|
||||
}
|
||||
var endRequestHandler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => {
|
||||
var dataItems: any = args.get_dataItems();
|
||||
var error: Error = args.get_error();
|
||||
var errorHandled: boolean = args.get_errorHandled();
|
||||
var webRequestExecutor: Sys.Net.WebRequestExecutor = args.get_response();
|
||||
args.set_errorHandled(true);
|
||||
|
||||
}
|
||||
var initializeRequestHandler = (sender: any, args: Sys.WebForms.InitializeRequestEventArgs) => {
|
||||
var postBackElement: HTMLElement = args.get_postBackElement();
|
||||
var webRequestExecutor: Sys.Net.WebRequestExecutor = args.get_request();
|
||||
var updatePanelsToUpdate: string[] = args.get_updatePanelsToUpdate();
|
||||
var empty: Sys.EventArgs = args.Empty;
|
||||
}
|
||||
var pageLoadedRequestHandler = (sender: any, args: Sys.WebForms.PageLoadedEventArgs) => {
|
||||
var dataItems: any = args.get_dataItems();
|
||||
var panelsCreated: HTMLDivElement[] = args.get_panelsCreated();
|
||||
var panelsUpdated: HTMLDivElement[] = args.get_panelsUpdated();
|
||||
var empty: Sys.EventArgs = args.Empty;
|
||||
}
|
||||
var pageLoadingRequestHandler = (sender: any, args: Sys.WebForms.PageLoadingEventArgs) => {
|
||||
var dataItems: any = args.get_dataItems();
|
||||
var panelsDeleted: HTMLDivElement[] = args.get_panelsDeleted();
|
||||
var panelsUpdating = args.get_panelsUpdating();
|
||||
var empty: Sys.EventArgs = args.Empty;
|
||||
}
|
||||
|
||||
|
||||
var isInAsyncPostBack: boolean = pageRequestManager.get_isInAsyncPostBack();
|
||||
|
||||
pageRequestManager.add_beginRequest(beginRequestHandler);
|
||||
pageRequestManager.add_endRequest(endRequestHandler);
|
||||
pageRequestManager.add_initializeRequest(initializeRequestHandler);
|
||||
pageRequestManager.add_pageLoading(pageLoadingRequestHandler);
|
||||
pageRequestManager.add_pageLoaded(pageLoadedRequestHandler);
|
||||
pageRequestManager.remove_beginRequest(beginRequestHandler);
|
||||
pageRequestManager.remove_pageLoaded(pageLoadedRequestHandler);
|
||||
pageRequestManager.remove_pageLoading(pageLoadingRequestHandler);
|
||||
pageRequestManager.beginAsyncPostBack();
|
||||
pageRequestManager.abortPostBack();
|
||||
pageRequestManager.dispose();
|
||||
}
|
||||
|
||||
function Sys_WebForms_EndRequestEventArgs_Tests() {
|
||||
|
||||
var pageRequestManager: Sys.WebForms.PageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
|
||||
|
||||
var handler = (sender: any, args: Sys.WebForms.EndRequestEventArgs) => {
|
||||
|
||||
var error: Error = args.get_error();
|
||||
var message: string = error.message;
|
||||
var name: string = error.name;
|
||||
var response: Sys.Net.WebRequestExecutor = args.get_response();
|
||||
var dataItems: any = args.get_dataItems();
|
||||
var eventArgs: Sys.EventArgs = args.Empty;
|
||||
|
||||
args.set_errorHandled(true);
|
||||
var errorHandled: boolean = args.get_errorHandled();
|
||||
}
|
||||
|
||||
pageRequestManager.add_endRequest(handler);
|
||||
}
|
||||
|
||||
function AspNetTypes_Tests() {
|
||||
|
||||
Type.registerNamespace("Samples");
|
||||
|
||||
var Samples: any;
|
||||
|
||||
Samples.A = function () { };
|
||||
var a = <Type> Samples.A;
|
||||
a.registerClass('Samples.A');
|
||||
|
||||
|
||||
Samples.B = function () { };
|
||||
var b = <Type> Samples.B;
|
||||
b.registerClass('Samples.B');
|
||||
|
||||
Samples.C = function () {
|
||||
var c = <Type> Samples.C;
|
||||
c.initializeBase(this);
|
||||
};
|
||||
|
||||
Samples.C.registerClass('Samples.C', Samples.A, Samples.B);
|
||||
|
||||
var isDerived: boolean;
|
||||
isDerived = Samples.B.inheritsFrom(Samples.A);
|
||||
// Output: "false".
|
||||
alert(isDerived);
|
||||
|
||||
isDerived = Samples.C.inheritsFrom(Samples.A);
|
||||
// Output: "true".
|
||||
alert(isDerived);
|
||||
|
||||
var implementsInterface: boolean;
|
||||
implementsInterface = Samples.C.implementsInterface(Samples.B);
|
||||
// Output: "true".
|
||||
alert(implementsInterface);
|
||||
}
|
||||
|
||||
/** Sample code from http://msdn.microsoft.com/en-us/library/bb386520(v=vs.100).aspx */
|
||||
function CreatingCustomNonVisualClientComponentsTests() {
|
||||
|
||||
var Demo: any;
|
||||
Type.registerNamespace("Demo");
|
||||
|
||||
Demo.Timer = function () {
|
||||
Demo.Timer.initializeBase(this);
|
||||
|
||||
this._interval = 1000;
|
||||
this._enabled = false;
|
||||
this._timer = null;
|
||||
}
|
||||
|
||||
Demo.Timer.prototype = {
|
||||
// OK to declare value types in the prototype
|
||||
|
||||
get_interval: function () {
|
||||
/// <value type="Number">Interval in milliseconds</value>
|
||||
return this._interval;
|
||||
},
|
||||
set_interval: function (value: any) {
|
||||
if (this._interval !== value) {
|
||||
this._interval = value;
|
||||
this.raisePropertyChanged('interval');
|
||||
|
||||
if (!this.get_isUpdating() && (this._timer !== null)) {
|
||||
this._restartTimer();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
get_enabled: function () {
|
||||
/// <value type="Boolean">True if timer is enabled, false if disabled.</value>
|
||||
return this._enabled;
|
||||
},
|
||||
set_enabled: function (value: any) {
|
||||
if (value !== this.get_enabled()) {
|
||||
this._enabled = value;
|
||||
this.raisePropertyChanged('enabled');
|
||||
if (!this.get_isUpdating()) {
|
||||
if (value) {
|
||||
this._startTimer();
|
||||
}
|
||||
else {
|
||||
this._stopTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// events
|
||||
add_tick: function (handler: Function) {
|
||||
/// <summary>Adds a event handler for the tick event.</summary>
|
||||
/// <param name="handler" type="Function">The handler to add to the event.</param>
|
||||
this.get_events().addHandler("tick", handler);
|
||||
},
|
||||
remove_tick: function (handler: Function) {
|
||||
/// <summary>Removes a event handler for the tick event.</summary>
|
||||
/// <param name="handler" type="Function">The handler to remove from the event.</param>
|
||||
this.get_events().removeHandler("tick", handler);
|
||||
},
|
||||
|
||||
dispose: function () {
|
||||
// call set_enabled so the property changed event fires, for potentially attached listeners.
|
||||
this.set_enabled(false);
|
||||
// make sure it stopped so we aren't called after disposal
|
||||
this._stopTimer();
|
||||
// be sure to call base.dispose()
|
||||
Demo.Timer.callBaseMethod(this, 'dispose');
|
||||
},
|
||||
|
||||
updated: function () {
|
||||
Demo.Timer.callBaseMethod(this, 'updated');
|
||||
// called after batch updates, this.beginUpdate(), this.endUpdate().
|
||||
if (this._enabled) {
|
||||
this._restartTimer();
|
||||
}
|
||||
},
|
||||
|
||||
_timerCallback: function () {
|
||||
var handler = this.get_events().getHandler("tick");
|
||||
if (handler) {
|
||||
handler(this, Sys.EventArgs.Empty);
|
||||
}
|
||||
},
|
||||
|
||||
_restartTimer: function () {
|
||||
this._stopTimer();
|
||||
this._startTimer();
|
||||
},
|
||||
|
||||
_startTimer: function () {
|
||||
// save timer cookie for removal later
|
||||
this._timer = window.setInterval((<MicrosoftAjaxBaseTypeExtensions.Function>Function).createDelegate(this, this._timerCallback), this._interval);
|
||||
},
|
||||
|
||||
_stopTimer: function () {
|
||||
if (this._timer) {
|
||||
window.clearInterval(this._timer);
|
||||
this._timer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Demo.Timer.registerClass('Demo.Timer', Sys.Component);
|
||||
|
||||
// Since this script is not loaded by System.Web.Handlers.ScriptResourceHandler
|
||||
// invoke Sys.Application.notifyScriptLoaded to notify ScriptManager
|
||||
// that this is the end of the script.
|
||||
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
|
||||
|
||||
}
|
||||
Vendored
+4012
File diff suppressed because it is too large
Load Diff
@@ -11,3 +11,5 @@ var r = m.makeRe();
|
||||
|
||||
var f = ["test.ts"];
|
||||
mm.match(f, pattern, options);
|
||||
|
||||
mm.filter('foo')('bar');
|
||||
|
||||
Vendored
+7
-6
@@ -8,7 +8,8 @@ declare module "minimatch" {
|
||||
function M(target:string, pattern:string, options?:M.IOptions):void;
|
||||
|
||||
module M {
|
||||
function match(filenames:string[], pattern:string, options:IOptions):string[];
|
||||
function match(filenames:string[], pattern:string, options?:IOptions):string[];
|
||||
function filter(pattern:string, options?:IOptions): (target: string) => boolean;
|
||||
|
||||
var Minimatch:IMinimatchStatic;
|
||||
|
||||
@@ -27,7 +28,7 @@ declare module "minimatch" {
|
||||
}
|
||||
|
||||
interface IMinimatchStatic {
|
||||
new (pattern:string, options:IOptions):IMinimatch;
|
||||
new (pattern:string, options?:IOptions):IMinimatch;
|
||||
}
|
||||
|
||||
interface IMinimatch {
|
||||
@@ -36,11 +37,11 @@ declare module "minimatch" {
|
||||
parseNegate():void;
|
||||
braceExpand(pattern:string, options:IOptions):void;
|
||||
parse(pattern:string, isSub?:boolean):void;
|
||||
makeRe():any; // regexp or boolean
|
||||
match(file:string, pattern:string, options:IOptions):boolean;
|
||||
matchOne(file:string, pattern:string, partial:any):boolean;
|
||||
makeRe():RegExp; // regexp or boolean
|
||||
match(file:string):boolean;
|
||||
matchOne(files:string[], pattern:string[], partial:any):boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export = M;
|
||||
export = M;
|
||||
}
|
||||
|
||||
@@ -100,3 +100,13 @@ var request = http.request('http://0.0.0.0');
|
||||
request.once('error', function () {});
|
||||
request.setNoDelay(true);
|
||||
request.abort();
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// Http tests : http://nodejs.org/api/http.html
|
||||
////////////////////////////////////////////////////
|
||||
module http_tests {
|
||||
// Status codes
|
||||
var code = 100;
|
||||
var codeMessage = http.STATUS_CODES['400'];
|
||||
var codeMessage = http.STATUS_CODES[400];
|
||||
}
|
||||
Vendored
+4
-1
@@ -348,7 +348,10 @@ declare module "http" {
|
||||
}
|
||||
export interface Agent { maxSockets: number; sockets: any; requests: any; }
|
||||
|
||||
export var STATUS_CODES: any;
|
||||
export var STATUS_CODES: {
|
||||
[errorCode: number]: string;
|
||||
[errorCode: string]: string;
|
||||
};
|
||||
export function createServer(requestListener?: (request: ServerRequest, response: ServerResponse) =>void ): Server;
|
||||
export function createClient(port?: number, host?: string): any;
|
||||
export function request(options: any, callback?: Function): ClientRequest;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/// <reference path="pg.d.ts" />
|
||||
import pg = require("pg");
|
||||
var conString = "postgres://username:password@localhost/database";
|
||||
|
||||
// Client pooling
|
||||
pg.connect(conString, (err, client, done) => {
|
||||
if (err) {
|
||||
return console.error("Error fetching client from pool", err);
|
||||
}
|
||||
client.query("SELECT $1::int AS number", ["1"], (err, result) => {
|
||||
done();
|
||||
if (err) {
|
||||
return console.error("Error running query", err);
|
||||
}
|
||||
console.log(result.rows[0]["number"]);
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
});
|
||||
|
||||
// Simple
|
||||
var client = new pg.Client(conString);
|
||||
client.connect((err) => {
|
||||
if (err) {
|
||||
return console.error("Could not connect to postgres", err);
|
||||
}
|
||||
client.query("SELECT NOW() AS 'theTime'", (err, result) => {
|
||||
if (err) {
|
||||
return console.error("Error running query", err);
|
||||
}
|
||||
console.log(result.rows[0]["theTime"]);
|
||||
client.end();
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
});
|
||||
Vendored
+88
@@ -0,0 +1,88 @@
|
||||
// Type definitions for pg
|
||||
// Project: https://github.com/brianc/node-postgres
|
||||
// Definitions by: Phips Peter <http://pspeter3.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "pg" {
|
||||
import events = require("events");
|
||||
import stream = require("stream");
|
||||
|
||||
export function connect(connection: string, callback: (err: Error, client: Client, done: () => void) => void): void;
|
||||
export function connect(config: ClientConfig, callback: (err: Error, client: Client, done: () => void) => void): void;
|
||||
export function end(): void;
|
||||
|
||||
export interface ConnectionConfig {
|
||||
user?: string;
|
||||
database?: string;
|
||||
password?: string;
|
||||
port?: number;
|
||||
host?: string;
|
||||
}
|
||||
|
||||
export interface Defaults extends ConnectionConfig {
|
||||
poolSize?: number;
|
||||
poolIdleTimeout?: number;
|
||||
reapIntervalMillis?: number;
|
||||
binary?: boolean;
|
||||
parseInt8?: boolean;
|
||||
}
|
||||
|
||||
export interface ClientConfig extends ConnectionConfig {
|
||||
ssl?: boolean;
|
||||
}
|
||||
|
||||
export interface QueryConfig {
|
||||
name?: string;
|
||||
text: string;
|
||||
values?: any[];
|
||||
}
|
||||
|
||||
export interface QueryResult {
|
||||
rows: any[];
|
||||
}
|
||||
|
||||
export interface ResultBuilder extends QueryResult {
|
||||
command: string;
|
||||
rowCount: number;
|
||||
oid: number;
|
||||
addRow(row: any): void;
|
||||
}
|
||||
|
||||
export class Client extends events.EventEmitter {
|
||||
constructor(connection: string);
|
||||
constructor(config: ClientConfig);
|
||||
|
||||
connect(callback?: (err:Error) => void): void;
|
||||
end(): void;
|
||||
|
||||
query(queryText: string, callback?: (err: Error, result: QueryResult) => void): Query;
|
||||
query(config: QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query;
|
||||
query(queryText: string, values: any[], callback?: (err: Error, result: QueryResult) => void): Query;
|
||||
|
||||
copyFrom(queryText: string): stream.Writable;
|
||||
copyTo(queryText: string): stream.Readable;
|
||||
|
||||
pauseDrain(): void;
|
||||
resumeDrain(): void;
|
||||
|
||||
public on(event: "drain", listener: () => void): Client;
|
||||
public on(event: "error", listener: (err: Error) => void): Client;
|
||||
public on(event: "notification", listener: (message: any) => void): Client;
|
||||
public on(event: "notice", listener: (message: any) => void): Client;
|
||||
public on(event: string, listener: Function): Client;
|
||||
}
|
||||
|
||||
export class Query extends events.EventEmitter {
|
||||
public on(event: "row", listener: (row: any, result?: ResultBuilder) => void): Query;
|
||||
public on(event: "error", listener: (err: Error) => void): Query;
|
||||
public on(event: "end", listener: (result: ResultBuilder) => void): Query;
|
||||
public on(event: string, listener: Function): Query;
|
||||
}
|
||||
|
||||
export class Events extends events.EventEmitter {
|
||||
public on(event: "error", listener: (err: Error, client: Client) => void): Events;
|
||||
public on(event: string, listener: Function): Events;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/// <reference path="./readdir-stream.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import readdir = require('readdir-stream');
|
||||
|
||||
var rs: NodeJS.ReadableStream;
|
||||
|
||||
rs = readdir('foo');
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// Type definitions for readdir-stream v0.1.0
|
||||
// Project: https://github.com/logicalparadox/readdir-stream
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module 'readdir-stream' {
|
||||
function readdir(dir: string): NodeJS.ReadableStream;
|
||||
export = readdir;
|
||||
}
|
||||
Vendored
+12
@@ -262,6 +262,18 @@ interface Require {
|
||||
**/
|
||||
toUrl(module: string): string;
|
||||
|
||||
/**
|
||||
* Returns true if the module has already been loaded and defined.
|
||||
* @param module Module to check
|
||||
**/
|
||||
defined(module: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the module has already been requested or is in the process of loading and should be available at some point.
|
||||
* @param module Module to check
|
||||
**/
|
||||
specified(module: string): boolean;
|
||||
|
||||
/**
|
||||
* On Error override
|
||||
* @param err
|
||||
|
||||
@@ -10,7 +10,7 @@ var exp:RegExp;
|
||||
var strArr:string[];
|
||||
var numArr:string[];
|
||||
|
||||
var mod:typeof SemverModule;
|
||||
var mod:typeof SemVerModule;
|
||||
|
||||
var v1:string, v2:string;
|
||||
var version:string;
|
||||
@@ -42,7 +42,7 @@ bool = mod.gtr(version, str, loose);
|
||||
bool = mod.ltr(version, str, loose);
|
||||
bool = mod.outside(version, str, str, loose);
|
||||
|
||||
var ver = new mod.Semver(str, bool);
|
||||
var ver = new mod.SemVer(str, bool);
|
||||
str = ver.raw;
|
||||
bool = ver.loose;
|
||||
str = ver.format();
|
||||
@@ -62,7 +62,7 @@ num = ver.comparePre(ver);
|
||||
ver = ver.inc(str);
|
||||
|
||||
|
||||
var comp = new SemverModule.Comparator(str, bool);
|
||||
var comp = new SemVerModule.Comparator(str, bool);
|
||||
str = comp.raw;
|
||||
bool = comp.loose;
|
||||
str = comp.format();
|
||||
@@ -76,7 +76,7 @@ comp.parse(str);
|
||||
bool = comp.test(ver);
|
||||
|
||||
|
||||
var range = new SemverModule.Range(str, bool);
|
||||
var range = new SemVerModule.Range(str, bool);
|
||||
str = range.raw;
|
||||
bool = range.loose;
|
||||
str = range.format();
|
||||
@@ -85,8 +85,8 @@ str = range.toString();
|
||||
|
||||
bool = range.test(ver);
|
||||
|
||||
var sets:SemverModule.Comparator[][];
|
||||
sets = range.set();
|
||||
var sets:SemVerModule.Comparator[][];
|
||||
sets = range.set;
|
||||
|
||||
var lims:SemverModule.Comparator[];
|
||||
var lims:SemVerModule.Comparator[];
|
||||
lims = range.parseRange(str);
|
||||
|
||||
Vendored
+14
-14
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module SemverModule {
|
||||
declare module SemVerModule {
|
||||
|
||||
function valid(v:string, loose?:boolean):string; // Return the parsed version, or null if it's not valid.
|
||||
//TODO maybe add an enum for release?
|
||||
@@ -28,7 +28,7 @@ declare module SemverModule {
|
||||
function ltr(version:string, range:string, loose?:boolean):boolean; // Return true if version is less than all the versions possible in the range.
|
||||
function outside(version:string, range:string, hilo:string, loose?:boolean):boolean; // Return true if the version is outside the bounds of the range in either the high or low direction. The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
|
||||
|
||||
class SemverBase {
|
||||
class SemVerBase {
|
||||
raw:string;
|
||||
loose:boolean;
|
||||
format():string;
|
||||
@@ -36,7 +36,7 @@ declare module SemverModule {
|
||||
toString():string;
|
||||
}
|
||||
|
||||
class Semver extends SemverBase {
|
||||
class SemVer extends SemVerBase {
|
||||
constructor(version:string, loose?:boolean);
|
||||
|
||||
major:number;
|
||||
@@ -46,30 +46,30 @@ declare module SemverModule {
|
||||
build:string[];
|
||||
prerelease:string[];
|
||||
|
||||
compare(other:Semver):number;
|
||||
compareMain(other:Semver):number;
|
||||
comparePre(other:Semver):number;
|
||||
inc(release:string):Semver;
|
||||
compare(other:SemVer):number;
|
||||
compareMain(other:SemVer):number;
|
||||
comparePre(other:SemVer):number;
|
||||
inc(release:string):SemVer;
|
||||
}
|
||||
|
||||
class Comparator extends SemverBase {
|
||||
class Comparator extends SemVerBase {
|
||||
constructor(comp:string, loose?:boolean);
|
||||
|
||||
semver:Semver;
|
||||
semver:SemVer;
|
||||
operator:string;
|
||||
value:boolean;
|
||||
parse(comp:string) :void;
|
||||
test(version:Semver):boolean;
|
||||
test(version:SemVer):boolean;
|
||||
}
|
||||
|
||||
class Range extends SemverBase {
|
||||
class Range extends SemVerBase {
|
||||
constructor(range:string, loose?:boolean);
|
||||
|
||||
set():Comparator[][];
|
||||
set:Comparator[][];
|
||||
parseRange(range:string):Comparator[];
|
||||
test(version:Semver):boolean;
|
||||
test(version:SemVer):boolean;
|
||||
}
|
||||
}
|
||||
declare module "semver" {
|
||||
export = SemverModule;
|
||||
export = SemVerModule;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@
|
||||
declare module Slick {
|
||||
|
||||
export interface Column<T extends SlickData> {
|
||||
header: Header;
|
||||
header?: Header;
|
||||
}
|
||||
|
||||
export interface Header {
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/// <reference path="sqlite3.d.ts" />
|
||||
|
||||
import sqlite3 = require('sqlite3');
|
||||
sqlite3.verbose();
|
||||
|
||||
var db: sqlite3.Database;
|
||||
|
||||
function createDb() {
|
||||
console.log("createDb chain");
|
||||
db = new sqlite3.Database('chain.sqlite3', createTable);
|
||||
}
|
||||
|
||||
function createTable() {
|
||||
console.log("createTable lorem");
|
||||
db.run("CREATE TABLE IF NOT EXISTS lorem (info TEXT)", insertRows);
|
||||
}
|
||||
|
||||
function insertRows() {
|
||||
console.log("insertRows Ipsum i");
|
||||
var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
|
||||
|
||||
for (var i = 0; i < 10; i++) {
|
||||
stmt.run("Ipsum " + i);
|
||||
}
|
||||
|
||||
stmt.finalize(readAllRows);
|
||||
}
|
||||
|
||||
function readAllRows() {
|
||||
console.log("readAllRows lorem");
|
||||
db.all("SELECT rowid AS id, info FROM lorem", function(err, rows) {
|
||||
rows.forEach(function (row) {
|
||||
console.log(row.id + ": " + row.info);
|
||||
});
|
||||
closeDb();
|
||||
});
|
||||
}
|
||||
|
||||
function closeDb() {
|
||||
console.log("closeDb");
|
||||
db.close();
|
||||
}
|
||||
|
||||
function runChainExample() {
|
||||
createDb();
|
||||
}
|
||||
|
||||
runChainExample();
|
||||
|
||||
db.serialize(function() {
|
||||
db.run("CREATE TABLE lorem (info TEXT)");
|
||||
|
||||
var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
|
||||
for (var i = 0; i < 10; i++) {
|
||||
stmt.run("Ipsum " + i);
|
||||
}
|
||||
stmt.finalize();
|
||||
|
||||
db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
|
||||
console.log(row.id + ": " + row.info);
|
||||
});
|
||||
});
|
||||
|
||||
db.serialize(function() {
|
||||
// These two queries will run sequentially.
|
||||
db.run("CREATE TABLE foo (num)");
|
||||
db.run("INSERT INTO foo VALUES (?)", 1, function() {
|
||||
// These queries will run in parallel and the second query will probably
|
||||
// fail because the table might not exist yet.
|
||||
db.run("CREATE TABLE bar (num)");
|
||||
db.run("INSERT INTO bar VALUES (?)", 1);
|
||||
});
|
||||
});
|
||||
|
||||
// Directly in the function arguments.
|
||||
db.run("UPDATE tbl SET name = ? WHERE id = ?", "bar", 2);
|
||||
|
||||
// As an array.
|
||||
db.run("UPDATE tbl SET name = ? WHERE id = ?", [ "bar", 2 ]);
|
||||
|
||||
// As an object with named parameters.
|
||||
db.run("UPDATE tbl SET name = $name WHERE id = $id", {
|
||||
$id: 2,
|
||||
$name: "bar"
|
||||
});
|
||||
|
||||
db.run("UPDATE tbl SET name = ?5 WHERE id = ?", {
|
||||
1: 2,
|
||||
5: "bar"
|
||||
});
|
||||
|
||||
db.close();
|
||||
Vendored
+81
@@ -0,0 +1,81 @@
|
||||
// Type definitions for sqlite3 2.2.3
|
||||
// Project: https://github.com/mapbox/node-sqlite3
|
||||
// Definitions by: Nick Malaguti <https://github.com/nmalaguti/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "sqlite3" {
|
||||
import events = require("events");
|
||||
|
||||
export var OPEN_READONLY: number;
|
||||
export var OPEN_READWRITE: number;
|
||||
export var OPEN_CREATE: number;
|
||||
|
||||
export var cached: {
|
||||
Database(filename: string, callback?: (err: Error) => void): Database;
|
||||
Database(filename: string, mode?: number, callback?: (err: Error) => void): Database;
|
||||
};
|
||||
|
||||
export interface RunResult {
|
||||
lastID: number;
|
||||
changes: number;
|
||||
}
|
||||
|
||||
export class Statement {
|
||||
public bind(callback?: (err: Error) => void): Statement;
|
||||
public bind(...params: any[]): Statement;
|
||||
|
||||
public reset(callback?: (err: Error) => void): Statement;
|
||||
|
||||
public finalize(callback?: (err: Error) => void): Statement;
|
||||
|
||||
public run(callback?: (err: Error) => void): Statement;
|
||||
public run(...params: any[]): Statement;
|
||||
|
||||
public get(callback?: (err: Error, row: any) => void): Statement;
|
||||
public get(...params: any[]): Statement;
|
||||
|
||||
public all(callback?: (err: Error, rows: any[]) => void): Statement;
|
||||
public all(...params: any[]): Statement;
|
||||
|
||||
public each(callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Statement;
|
||||
public each(...params: any[]): Statement;
|
||||
}
|
||||
|
||||
export class Database extends events.EventEmitter {
|
||||
constructor(filename: string, callback?: (err: Error) => void);
|
||||
constructor(filename: string, mode?: number, callback?: (err: Error) => void);
|
||||
|
||||
public close(callback?: (err: Error) => void): void;
|
||||
|
||||
public run(sql: string, callback?: (err: Error) => void): Database;
|
||||
public run(sql: string, ...params: any[]): Database;
|
||||
|
||||
public get(sql: string, callback?: (err: Error, row: any) => void): Database;
|
||||
public get(sql: string, ...params: any[]): Database;
|
||||
|
||||
public all(sql: string, callback?: (err: Error, rows: any[]) => void): Database;
|
||||
public all(sql: string, ...params: any[]): Database;
|
||||
|
||||
public each(sql: string, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Database;
|
||||
public each(sql: string, ...params: any[]): Database;
|
||||
|
||||
public exec(sql: string, callback?: (err: Error) => void): Database;
|
||||
|
||||
public prepare(sql: string, callback?: (err: Error) => void): Statement;
|
||||
public prepare(sql: string, ...params: any[]): Statement;
|
||||
|
||||
public serialize(callback?: () => void): void;
|
||||
public parallelize(callback?: () => void): void;
|
||||
|
||||
public on(event: "trace", listener: (sql: string) => void): Database;
|
||||
public on(event: "profile", listener: (sql: string, time: number) => void): Database;
|
||||
public on(event: "error", listener: (err: Error) => void): Database;
|
||||
public on(event: "open", listener: () => void): Database;
|
||||
public on(event: "close", listener: () => void): Database;
|
||||
public on(event: string, listener: Function): Database;
|
||||
}
|
||||
|
||||
function verbose(): void;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path="./stream-to-array.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import toArray = require('stream-to-array');
|
||||
|
||||
var rs: NodeJS.ReadableStream;
|
||||
|
||||
toArray(rs, (err, arr) => {
|
||||
|
||||
});
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module 'stream-to-array' {
|
||||
function toArray(stream: NodeJS.ReadableStream, callback: (err: any, arr: any[]) => void): NodeJS.ReadWriteStream;
|
||||
export = toArray;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/// <reference path="./through2.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import through2 = require('through2');
|
||||
|
||||
var rws: NodeJS.ReadWriteStream;
|
||||
|
||||
rws = through2({
|
||||
objectMode: true,
|
||||
allowHalfOpen: true
|
||||
}, function (entry: any, enc: string, callback: () => void) {
|
||||
this.push('foo');
|
||||
callback();
|
||||
}, () => {
|
||||
|
||||
});
|
||||
|
||||
rws = through2(function (entry: any, enc: string, callback: () => void) {
|
||||
this.push('foo');
|
||||
callback();
|
||||
}, () => {
|
||||
|
||||
});
|
||||
|
||||
rws = through2(function (entry: any, enc: string, callback: () => void) {
|
||||
this.push('foo');
|
||||
callback();
|
||||
});
|
||||
|
||||
rws = through2();
|
||||
|
||||
// obj
|
||||
rws = through2.obj(function (entry: any, enc: string, callback: () => void) {
|
||||
this.push('foo');
|
||||
callback();
|
||||
}, () => {
|
||||
|
||||
});
|
||||
|
||||
rws = through2.obj(function (entry: any, enc: string, callback: () => void) {
|
||||
this.push('foo');
|
||||
callback();
|
||||
});
|
||||
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// Type definitions for through2 v 0.4.2
|
||||
// Project: https://github.com/rvagg/through2
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module 'through2' {
|
||||
import stream = require('stream');
|
||||
|
||||
var mod: mod.Through2;
|
||||
|
||||
module mod {
|
||||
interface Through2 {
|
||||
(transform?: (entry: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
|
||||
(opts: stream.DuplexOptions, transform?: (entry: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
|
||||
obj(transform: (entry: any, enc: string, callback: () => void) => void, flush?: () => void): NodeJS.ReadWriteStream;
|
||||
push(data: any): void;
|
||||
}
|
||||
}
|
||||
export = mod;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
///<reference path="xml2json.d.ts" />
|
||||
|
||||
// Create x2js instance with default config
|
||||
var x2js = new X2JS();
|
||||
|
||||
// JSON to DOM
|
||||
var xmlDoc = x2js.json2xml(
|
||||
{
|
||||
MyRoot: {
|
||||
MyChild: 'my_child_value',
|
||||
MyAnotherChild: 10,
|
||||
MyArray: [ 'test', 'test2' ],
|
||||
MyArrayRecords: [
|
||||
{
|
||||
ttt: 'vvvv'
|
||||
},
|
||||
{
|
||||
ttt: 'vvvv2'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// JSON to XML string
|
||||
var xmlDocStr = x2js.json2xml_str(
|
||||
{
|
||||
MyRoot: {
|
||||
MyChild: 'my_child_value',
|
||||
MyAnotherChild: 10,
|
||||
MyArray: [ 'test', 'test2' ],
|
||||
MyArrayRecords: [
|
||||
{
|
||||
ttt: 'vvvv'
|
||||
},
|
||||
{
|
||||
ttt: 'vvvv2'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
console.log(xmlDocStr);
|
||||
|
||||
// JSON arrays to string
|
||||
var xmlDocStr = x2js.json2xml_str(
|
||||
{
|
||||
MyRoot: {
|
||||
namedItemArray: {
|
||||
item: [
|
||||
{ first: 'success1' } ,
|
||||
{ first: 'success2' }
|
||||
]
|
||||
},
|
||||
namedArray: [
|
||||
{ first: 'success1' } ,
|
||||
{ first: 'success2' }
|
||||
],
|
||||
justArray: [ 'just success1', 'just success2' ],
|
||||
arrayWithAttrs: [
|
||||
{
|
||||
_test: 'successAttr',
|
||||
__text: 'success',
|
||||
temp: 'successTemp'
|
||||
},
|
||||
{
|
||||
_test: 'successAttr2',
|
||||
__text: 'success2',
|
||||
temp: 'successTemp2'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
console.log(xmlDocStr);
|
||||
|
||||
// XML string to JSON
|
||||
var xmlText = "<MyOperation><test>Success</test><test2><item>ddsfg</item><item>dsdgfdgfd</item></test2></MyOperation>";
|
||||
var jsonObj = x2js.xml_str2json<any>(xmlText);
|
||||
console.log(jsonObj.MyOperation.test);
|
||||
|
||||
// Array access form examples
|
||||
console.log(x2js.asArray(jsonObj.MyOperation.test)[0]);
|
||||
// Or old style (1.0.+):
|
||||
var x2jsOld = new X2JS({arrayAccessForm: "property"});
|
||||
jsonObj = x2jsOld.xml_str2json(xmlText);
|
||||
console.log("Old is " + jsonObj.MyOperation.test_asArray[0]);
|
||||
|
||||
// XML/DOM to JSON
|
||||
var xmlText = " <MyOperation> <test>- Success -</test> <test2> TestText <item> ddsfg </item> TestText2 <item>dsdgfdgfd</item></test2></MyOperation>"
|
||||
xmlDoc = x2js.parseXmlString(xmlText);
|
||||
|
||||
var jsonObj = x2js.xml2json<any>(xmlDoc);
|
||||
console.log(jsonObj.MyOperation.test);
|
||||
|
||||
// Parsing XML attrs
|
||||
var xmlText = "<MyOperation myAttr='SuccessAttrValue'><txtAttrChild sAttr='SUCCESS TXT ATTR CHILD'>SUCCESS TXT</txtAttrChild><test>Success</test><test2 myAttr='SuccessAttrValueTest2'><item>ddsfg</item><item>dsdgfdgfd</item></test2></MyOperation>";
|
||||
var jsonObj = x2js.xml_str2json<any>(xmlText);
|
||||
console.log(jsonObj.MyOperation._myAttr);
|
||||
console.log(jsonObj.MyOperation.test2._myAttr);
|
||||
console.log(jsonObj.MyOperation.txtAttrChild._sAttr);
|
||||
console.log(jsonObj.MyOperation.txtAttrChild.__text);
|
||||
console.log(jsonObj.MyOperation.txtAttrChild.toString());
|
||||
|
||||
// JSON to XML attrs
|
||||
var xmlDocStr = x2js.json2xml_str(
|
||||
{
|
||||
TestAttrRoot: {
|
||||
_myAttr: 'myAttrValue',
|
||||
MyChild: 'my_child_value',
|
||||
MyAnotherChild: 10,
|
||||
MyTextAttrChild: {
|
||||
_myTextAttr: 'myTextAttrValue',
|
||||
__text: 'HelloText'
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
console.log(xmlDocStr);
|
||||
|
||||
//Change prefix for attributes
|
||||
var x2jsChangedAttrs = new X2JS({
|
||||
// XML attributes. Default is "_"
|
||||
attributePrefix: "$"
|
||||
});
|
||||
jsonObj = x2jsChangedAttrs.xml_str2json(xmlText);
|
||||
console.log(jsonObj.MyOperation.$myAttr);
|
||||
console.log(jsonObj.MyOperation.test2.$myAttr);
|
||||
console.log(jsonObj.MyOperation.txtAttrChild.$sAttr);
|
||||
|
||||
xmlDocStr = x2jsChangedAttrs.json2xml_str({
|
||||
TestAttrRoot: {
|
||||
_myAttr: 'myAttrValue',
|
||||
MyChild: 'my_child_value',
|
||||
MyAnotherChild: 10,
|
||||
MyTextAttrChild: {
|
||||
$myTextAttr: 'myTextAttrValue',
|
||||
__text: 'HelloText'
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
console.log(xmlDocStr);
|
||||
|
||||
|
||||
// Parse XML with namespaces
|
||||
var xmlText = "<testns:MyOperation xmlns:testns='http://www.example.org'><test>Success</test><test2 myAttr='SuccessAttrValueTest2'><item>ddsfg</item><item>dsdgfdgfd</item><item2>testArrSize</item2></test2></testns:MyOperation>";
|
||||
var jsonObj = x2js.xml_str2json<any>(xmlText);
|
||||
console.log(jsonObj.MyOperation.test);
|
||||
if (jsonObj.MyOperation.test2.item.length > 2)
|
||||
console.log("Error! Incorrect array len!");
|
||||
|
||||
var testObjC = {
|
||||
'm:TestAttrRoot': {
|
||||
'_tns:m': 'http://www.example.org',
|
||||
'_tns:cms': 'http://www.example.org',
|
||||
MyChild: 'my_child_value',
|
||||
'cms:MyAnotherChild': 'vdfd'
|
||||
}
|
||||
}
|
||||
|
||||
// Parse JSON object with namespaces
|
||||
var xmlDocStr = x2js.json2xml_str(
|
||||
testObjC
|
||||
);
|
||||
|
||||
console.log(xmlDocStr);
|
||||
|
||||
// Parse JSON object constructed with another NS-style
|
||||
var testObjNew = {
|
||||
TestAttrRoot: {
|
||||
__prefix: 'm',
|
||||
'_tns:m': 'http://www.example.org',
|
||||
'_tns:cms': 'http://www.example.org',
|
||||
MyChild: 'my_child_value',
|
||||
MyAnotherChild: {
|
||||
__prefix: 'cms',
|
||||
__text: 'vdfd'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse JSON object with namespaces
|
||||
var xmlDocStr = x2js.json2xml_str(
|
||||
testObjNew
|
||||
);
|
||||
|
||||
console.log(xmlDocStr);
|
||||
|
||||
// Parse XML with header
|
||||
var xmlText = "<?xml version='1.0' encoding='utf-8' ?>\n" +
|
||||
"<test>XML HEADER SUCCESS!</test>";
|
||||
|
||||
var jsonObj = x2js.xml_str2json<any>(xmlText);
|
||||
console.log(jsonObj.test);
|
||||
|
||||
// Parse XML with CDATA
|
||||
var xmlText = "<test><simple>simple success</simple><data><![CDATA[<success/>]]></data> </test>";
|
||||
|
||||
var jsonObj = x2js.xml_str2json<any>(xmlText);
|
||||
console.log(jsonObj.test.data.toString());
|
||||
console.log(jsonObj.test.data.__cdata);
|
||||
console.log(jsonObj.test.simple);
|
||||
|
||||
|
||||
// Parse JSON object with CDATA
|
||||
var xmlDocStr = x2js.json2xml_str(
|
||||
jsonObj
|
||||
);
|
||||
console.log(xmlDocStr);
|
||||
|
||||
// Parse JSON with emtpy attributes
|
||||
var xmlDocStr = x2js.json2xml_str(
|
||||
{
|
||||
MyRoot: {
|
||||
MyNullChild: null,
|
||||
MyNullChild2: undefined,
|
||||
MyAnotherChild: 10,
|
||||
MyEmptyChild: {
|
||||
_attr: "test"
|
||||
},
|
||||
MyEmptyChild2: {
|
||||
_attr: "test",
|
||||
__text: "Empty Nodes Test"
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
console.log(xmlDocStr);
|
||||
|
||||
// Escaping XML characters
|
||||
xmlDocStr = x2js.json2xml_str(
|
||||
{
|
||||
MyRoot: {
|
||||
MyEscapeXmlChild: "<success> & \" ' / </success>",
|
||||
MyEscapeXmlChild2: {
|
||||
_attr: "success",
|
||||
__text: "<success> & \" ' / </success>"
|
||||
},
|
||||
MyEscapeXmlChildNonString: false
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
console.log(xmlDocStr);
|
||||
|
||||
jsonObj = x2js.xml_str2json(xmlDocStr);
|
||||
console.log(jsonObj.MyRoot.MyEscapeXmlChild);
|
||||
console.log(jsonObj.MyRoot.MyEscapeXmlChild2.toString());
|
||||
|
||||
console.log(x2js.getVersion());
|
||||
|
||||
// Array access path demos
|
||||
x2js = new X2JS({
|
||||
arrayAccessFormPaths: [
|
||||
"MyArrays.test4.item",
|
||||
/.*\.test3\.item/
|
||||
]
|
||||
});
|
||||
|
||||
xmlText = "<MyArrays>" +
|
||||
"<test2><item>success</item><item>second</item></test2>" +
|
||||
"<test3><item>success</item></test3>" +
|
||||
"<test4><item>success</item></test4>" +
|
||||
"<test5><item>success</item></test5>" +
|
||||
"</MyArrays>";
|
||||
|
||||
|
||||
jsonObj = x2js.xml_str2json(xmlText);
|
||||
console.log(jsonObj.MyArrays.test3.item[0]);
|
||||
console.log(jsonObj.MyArrays.test4.item[0]);
|
||||
console.log(jsonObj.MyArrays.test5.item);
|
||||
|
||||
// Working with datetimes
|
||||
x2js = new X2JS({
|
||||
datetimeAccessFormPaths: [
|
||||
"MyDts.testds",
|
||||
/.*\.testdt.*/
|
||||
]
|
||||
});
|
||||
|
||||
xmlText = "<MyDts>" +
|
||||
"<testds>2002-10-10T12:00:00+04:00</testds>" +
|
||||
"<testdt1>2002-10-10T12:00:00Z</testdt1>" +
|
||||
"<testdt2>2002-10-10T12:00:00</testdt2>" +
|
||||
"<testdc>2002-10-10T12:00:00Z</testdc>" +
|
||||
"</MyDts>";
|
||||
jsonObj = x2js.xml_str2json(xmlText);
|
||||
|
||||
console.log(jsonObj.MyDts.testds);
|
||||
console.log(jsonObj.MyDts.testdt1);
|
||||
console.log(jsonObj.MyDts.testdt2);
|
||||
console.log(x2js.asDateTime(jsonObj.MyDts.testdc));
|
||||
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
|
||||
interface IX2JS {
|
||||
new (config?: IX2JSOption): IX2JS;
|
||||
|
||||
getVersion(): string;
|
||||
|
||||
xml2json<T>(dom: Node): T;
|
||||
json2xml<T>(json: T): Node;
|
||||
xml_str2json<T>(xml: string): T;
|
||||
json2xml_str<T>(json: T): string;
|
||||
parseXmlString(xml: string): Node;
|
||||
|
||||
asArray(prop: any): any[];
|
||||
asDateTime(key: string): string;
|
||||
asXmlDateTime(date: Date): string;
|
||||
asXmlDateTime(date: number): string;
|
||||
}
|
||||
|
||||
interface IX2JSOption {
|
||||
escapeMode?: boolean;
|
||||
attributePrefix?: string;
|
||||
arrayAccessForm?: string;
|
||||
emptyNodeForm?: string;
|
||||
enableToStringFunc?: boolean;
|
||||
arrayAccessFormPaths?: any[];
|
||||
skipEmptyTextNodesForObj?: boolean;
|
||||
stripWhitespaces?: boolean;
|
||||
datetimeAccessFormPaths?: any[];
|
||||
}
|
||||
|
||||
declare var X2JS: IX2JS;
|
||||
|
||||
Reference in New Issue
Block a user