mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-28 12:43:06 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -39,6 +39,7 @@ List of Definitions
|
||||
* [bootstrap.datepicker](https://github.com/eternicode/bootstrap-datepicker) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Box2DWeb](http://code.google.com/p/box2dweb/) (by [Josh Baldwin](https://github.com/jbaldwin/))
|
||||
* [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Browser Harness](https://github.com/scriby/browser-harness) (by [Chris Scribner](https://github.com/scriby))
|
||||
* [CasperJS](http://casperjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker))
|
||||
* [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle))
|
||||
* [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
@@ -145,6 +146,7 @@ List of Definitions
|
||||
* [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown))
|
||||
* [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Numeral.js](https://github.com/adamwdraper/Numeral-js) (by [Vincent Bortone](https://github.com/vbortone/))
|
||||
* [Persona](http://www.mozilla.org/en-US/persona) (by [James Frasca](https://github.com/Nycto))
|
||||
* [PhantomJS](http://phantomjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker))
|
||||
* [PhoneGap](http://phonegap.com) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH))
|
||||
|
||||
@@ -648,7 +648,7 @@ var DefinitelyTyped;
|
||||
|
||||
Print.prototype.printHeader = function () {
|
||||
this.out('=============================================================================\n');
|
||||
this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.2.0\33[0m\n');
|
||||
this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.2.1\33[0m\n');
|
||||
this.out('=============================================================================\n');
|
||||
this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n');
|
||||
this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n');
|
||||
@@ -980,7 +980,7 @@ var DefinitelyTyped;
|
||||
this.dtPath = dtPath;
|
||||
this.typings = [];
|
||||
this.fh = new FileHandler(dtPath, /.\.ts/g);
|
||||
this.out = new Print('0.9.0.0', this.fh.allTypings().length, this.fh.allTS().length);
|
||||
this.out = new Print('0.9.1.0', this.fh.allTypings().length, this.fh.allTS().length);
|
||||
this.sc = new SyntaxChecking(this.fh, this.out);
|
||||
this.te = new TestEval(this.fh, this.out);
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ module DefinitelyTyped {
|
||||
|
||||
public printHeader() {
|
||||
this.out('=============================================================================\n');
|
||||
this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.2.0\33[0m\n');
|
||||
this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.2.1\33[0m\n');
|
||||
this.out('=============================================================================\n');
|
||||
this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n');
|
||||
this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n');
|
||||
@@ -504,7 +504,7 @@ module DefinitelyTyped {
|
||||
|
||||
constructor(public dtPath: string) {
|
||||
this.fh = new FileHandler(dtPath, /.\.ts/g);
|
||||
this.out = new Print('0.9.0.0', this.fh.allTypings().length, this.fh.allTS().length);
|
||||
this.out = new Print('0.9.1.0', this.fh.allTypings().length, this.fh.allTS().length);
|
||||
this.sc = new SyntaxChecking(this.fh, this.out);
|
||||
this.te = new TestEval(this.fh, this.out);
|
||||
|
||||
|
||||
+9178
-9074
File diff suppressed because it is too large
Load Diff
+56015
-56803
File diff suppressed because one or more lines are too long
+54655
-55609
File diff suppressed because one or more lines are too long
+120
-124
@@ -9,148 +9,144 @@ https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth.
|
||||
*/
|
||||
angular.module('http-auth-interceptor', [])
|
||||
|
||||
.provider('authService', function () {
|
||||
/**
|
||||
* Holds all the requests which failed due to 401 response,
|
||||
* so they can be re-requested in future, once login is completed.
|
||||
*/
|
||||
var buffer = [];
|
||||
.provider('authService', function () {
|
||||
/**
|
||||
* Holds all the requests which failed due to 401 response,
|
||||
* so they can be re-requested in future, once login is completed.
|
||||
*/
|
||||
var buffer = [];
|
||||
|
||||
/**
|
||||
* Required by HTTP interceptor.
|
||||
* Function is attached to provider to be invisible for regular users of this service.
|
||||
*/
|
||||
this.pushToBuffer = function (config: ng.IRequestConfig, deferred: ng.IDeferred) {
|
||||
buffer.push({
|
||||
config: config,
|
||||
deferred: deferred
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Required by HTTP interceptor.
|
||||
* Function is attached to provider to be invisible for regular users of this service.
|
||||
*/
|
||||
this.pushToBuffer = function (config: ng.IRequestConfig, deferred: ng.IDeferred) {
|
||||
buffer.push({
|
||||
config: config,
|
||||
deferred: deferred
|
||||
});
|
||||
}
|
||||
|
||||
this.$get = ['$rootScope', '$injector', <any>function ($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) {
|
||||
var $http: ng.IHttpService; //initialized later because of circular dependency problem
|
||||
function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) {
|
||||
$http = $http || $injector.get('$http');
|
||||
$http(config).then(function (response) {
|
||||
deferred.resolve(response);
|
||||
});
|
||||
}
|
||||
function retryAll() {
|
||||
for (var i = 0; i < buffer.length; ++i) {
|
||||
retry(buffer[i].config, buffer[i].deferred);
|
||||
}
|
||||
buffer = [];
|
||||
}
|
||||
var $http: ng.IHttpService; //initialized later because of circular dependency problem
|
||||
function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) {
|
||||
$http = $http || $injector.get('$http');
|
||||
$http(config).then(function (response) {
|
||||
deferred.resolve(response);
|
||||
});
|
||||
}
|
||||
function retryAll() {
|
||||
for (var i = 0; i < buffer.length; ++i) {
|
||||
retry(buffer[i].config, buffer[i].deferred);
|
||||
}
|
||||
buffer = [];
|
||||
}
|
||||
|
||||
return {
|
||||
loginConfirmed: function () {
|
||||
$rootScope.$broadcast('event:auth-loginConfirmed');
|
||||
retryAll();
|
||||
}
|
||||
}
|
||||
loginConfirmed: function () {
|
||||
$rootScope.$broadcast('event:auth-loginConfirmed');
|
||||
retryAll();
|
||||
}
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
/**
|
||||
* $http interceptor.
|
||||
* On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'.
|
||||
*/
|
||||
.config(['$httpProvider', 'authServiceProvider', <any>function ($httpProvider: ng.IHttpProvider, authServiceProvider) {
|
||||
/**
|
||||
* $http interceptor.
|
||||
* On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'.
|
||||
*/
|
||||
.config(['$httpProvider', 'authServiceProvider', <any>function ($httpProvider: ng.IHttpProvider, authServiceProvider) {
|
||||
|
||||
var interceptor = ['$rootScope', '$q', <any>function ($rootScope: ng.IScope, $q: ng.IQService) {
|
||||
function success(response: ng.IHttpPromiseCallbackArg) {
|
||||
return response;
|
||||
}
|
||||
var interceptor = ['$rootScope', '$q', <any>function ($rootScope: ng.IScope, $q: ng.IQService) {
|
||||
function success(response: ng.IHttpPromiseCallbackArg<any>) {
|
||||
return response;
|
||||
}
|
||||
|
||||
function error(response: ng.IHttpPromiseCallbackArg) {
|
||||
if (response.status === 401) {
|
||||
var deferred = $q.defer();
|
||||
authServiceProvider.pushToBuffer(response.config, deferred);
|
||||
$rootScope.$broadcast('event:auth-loginRequired');
|
||||
return deferred.promise;
|
||||
}
|
||||
// otherwise
|
||||
return $q.reject(response);
|
||||
}
|
||||
function error(response: ng.IHttpPromiseCallbackArg<any>) {
|
||||
if (response.status === 401) {
|
||||
var deferred = $q.defer();
|
||||
authServiceProvider.pushToBuffer(response.config, deferred);
|
||||
$rootScope.$broadcast('event:auth-loginRequired');
|
||||
return deferred.promise;
|
||||
}
|
||||
// otherwise
|
||||
return $q.reject(response);
|
||||
}
|
||||
|
||||
return function (promise: ng.IHttpPromise) {
|
||||
return promise.then(success, error);
|
||||
}
|
||||
return function (promise: ng.IHttpPromise<any>) {
|
||||
return promise.then(success, error);
|
||||
}
|
||||
|
||||
}];
|
||||
$httpProvider.responseInterceptors.push(interceptor);
|
||||
}]);
|
||||
$httpProvider.responseInterceptors.push(interceptor);
|
||||
}]);
|
||||
|
||||
|
||||
module HttpAndRegularPromiseTests {
|
||||
interface Person {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}
|
||||
interface Person {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}
|
||||
|
||||
interface ExpectedResponse extends Person {}
|
||||
interface ExpectedResponse extends Person { }
|
||||
|
||||
interface SomeControllerScope extends ng.IScope {
|
||||
person: Person;
|
||||
theAnswer: number;
|
||||
letters: string[];
|
||||
}
|
||||
interface SomeControllerScope extends ng.IScope {
|
||||
person: Person;
|
||||
theAnswer: number;
|
||||
letters: string[];
|
||||
}
|
||||
|
||||
interface OurApiPromiseCallbackArg extends ng.IHttpPromiseCallbackArg {
|
||||
data?: ExpectedResponse;
|
||||
}
|
||||
var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => {
|
||||
$http.get("http://somewhere/some/resource")
|
||||
.success((data: ExpectedResponse) => {
|
||||
$scope.person = data;
|
||||
});
|
||||
|
||||
var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => {
|
||||
$http.get("http://somewhere/some/resource")
|
||||
.success((data: ExpectedResponse) => {
|
||||
$scope.person = data;
|
||||
});
|
||||
$http.get("http://somewhere/some/resource")
|
||||
.then((response: ng.IHttpPromiseCallbackArg<ExpectedResponse>) => {
|
||||
// typing lost, so something like
|
||||
// var i: number = response.data
|
||||
// would type check
|
||||
$scope.person = response.data;
|
||||
});
|
||||
|
||||
$http.get("http://somewhere/some/resource")
|
||||
.then((response: ng.IHttpPromiseCallbackArg) => {
|
||||
// typing lost, so something like
|
||||
// var i: number = response.data
|
||||
// would type check
|
||||
$scope.person = response.data;
|
||||
});
|
||||
$http.get("http://somewhere/some/resource")
|
||||
.then((response: ng.IHttpPromiseCallbackArg<ExpectedResponse>) => {
|
||||
// typing lost, so something like
|
||||
// var i: number = response.data
|
||||
// would NOT type check
|
||||
$scope.person = response.data;
|
||||
});
|
||||
|
||||
$http.get("http://somewhere/some/resource")
|
||||
.then((response: OurApiPromiseCallbackArg) => {
|
||||
// typing lost, so something like
|
||||
// var i: number = response.data
|
||||
// would NOT type check
|
||||
$scope.person = response.data;
|
||||
});
|
||||
var aPromise: ng.IPromise = $q.when({ firstName: "Jack", lastName: "Sparrow" });
|
||||
aPromise.then((person: Person) => {
|
||||
$scope.person = person;
|
||||
});
|
||||
|
||||
var aPromise: ng.IPromise = $q.when({firstName: "Jack", lastName: "Sparrow"});
|
||||
aPromise.then((person: Person) => {
|
||||
$scope.person = person;
|
||||
});
|
||||
var bPromise: ng.IPromise = $q.when(42);
|
||||
bPromise.then((answer: number) => {
|
||||
$scope.theAnswer = answer;
|
||||
});
|
||||
|
||||
var bPromise: ng.IPromise = $q.when(42);
|
||||
bPromise.then((answer: number) => {
|
||||
$scope.theAnswer = answer;
|
||||
});
|
||||
|
||||
var cPromise: ng.IPromise = $q.when(["a", "b", "c"]);
|
||||
cPromise.then((letters: string[]) => {
|
||||
$scope.letters = letters;
|
||||
});
|
||||
}
|
||||
var cPromise: ng.IPromise = $q.when(["a", "b", "c"]);
|
||||
cPromise.then((letters: string[]) => {
|
||||
$scope.letters = letters;
|
||||
});
|
||||
}
|
||||
|
||||
// Test that we can pass around a type-checked success/error Promise Callback
|
||||
var anotherController: Function = ($scope: SomeControllerScope, $http:
|
||||
ng.IHttpService, $q: ng.IQService) => {
|
||||
ng.IHttpService, $q: ng.IQService) => {
|
||||
|
||||
var buildFooData: Function = () => 42;
|
||||
var buildFooData: Function = () => 42;
|
||||
|
||||
var doFoo: Function = (callback: ng.IHttpPromiseCallback) => {
|
||||
$http.get('/foo', buildFooData())
|
||||
.success(callback);
|
||||
}
|
||||
var doFoo: Function = (callback: ng.IHttpPromiseCallback<ExpectedResponse>) => {
|
||||
$http.get('/foo', buildFooData())
|
||||
.success(callback);
|
||||
}
|
||||
|
||||
doFoo((data) => console.log(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test for AngularJS Syntac
|
||||
@@ -160,24 +156,24 @@ module My.Namespace {
|
||||
}
|
||||
|
||||
// IModule Registering Test
|
||||
var mod = angular.module('tests',[]);
|
||||
mod.controller('name', function($scope : ng.IScope) {})
|
||||
mod.controller('name', ['$scope', <any>function($scope : ng.IScope) {}])
|
||||
var mod = angular.module('tests', []);
|
||||
mod.controller('name', function ($scope: ng.IScope) { })
|
||||
mod.controller('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.controller(My.Namespace);
|
||||
mod.directive('name', <any>function ($scope: ng.IScope) {})
|
||||
mod.directive('name', ['$scope', <any>function($scope : ng.IScope) {}])
|
||||
mod.directive('name', <any>function ($scope: ng.IScope) { })
|
||||
mod.directive('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.directive(My.Namespace);
|
||||
mod.factory('name', function($scope : ng.IScope) {})
|
||||
mod.factory('name', ['$scope', <any>function($scope : ng.IScope) {}])
|
||||
mod.factory('name', function ($scope: ng.IScope) { })
|
||||
mod.factory('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.factory(My.Namespace);
|
||||
mod.filter('name', function($scope : ng.IScope) {})
|
||||
mod.filter('name', ['$scope', <any>function($scope : ng.IScope) {}])
|
||||
mod.filter('name', function ($scope: ng.IScope) { })
|
||||
mod.filter('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.filter(My.Namespace);
|
||||
mod.provider('name', function($scope : ng.IScope) {})
|
||||
mod.provider('name', ['$scope', <any>function($scope : ng.IScope) {}])
|
||||
mod.provider('name', function ($scope: ng.IScope) { })
|
||||
mod.provider('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.provider(My.Namespace);
|
||||
mod.service('name', function($scope : ng.IScope) {})
|
||||
mod.service('name', ['$scope', <any>function($scope : ng.IScope) {}])
|
||||
mod.service('name', function ($scope: ng.IScope) { })
|
||||
mod.service('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.service(My.Namespace);
|
||||
mod.constant('name', 23);
|
||||
mod.constant('name', "23");
|
||||
|
||||
Vendored
+18
-9
@@ -8,6 +8,11 @@
|
||||
|
||||
declare var angular: ng.IAngularStatic;
|
||||
|
||||
// Support for painless dependency injection
|
||||
interface Function {
|
||||
$inject:string[];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ng module (angular.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -532,21 +537,21 @@ declare module ng {
|
||||
transformResponse?: any;
|
||||
}
|
||||
|
||||
interface IHttpPromiseCallback {
|
||||
(data: any, status: number, headers: (headerName: string) => string, config: IRequestConfig): any;
|
||||
interface IHttpPromiseCallback<T> {
|
||||
(data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): any;
|
||||
}
|
||||
|
||||
interface IHttpPromiseCallbackArg {
|
||||
data?: any;
|
||||
interface IHttpPromiseCallbackArg<T> {
|
||||
data?: T;
|
||||
status?: number;
|
||||
headers?: (headerName: string) => string;
|
||||
config?: IRequestConfig;
|
||||
}
|
||||
|
||||
interface IHttpPromise extends IPromise {
|
||||
success(callback: IHttpPromiseCallback): IHttpPromise;
|
||||
error(callback: IHttpPromiseCallback): IHttpPromise;
|
||||
then(successCallback: (response: IHttpPromiseCallbackArg) => any, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise;
|
||||
interface IHttpPromise<T> extends IPromise {
|
||||
success(callback: IHttpPromiseCallback<T>): IHttpPromise;
|
||||
error(callback: IHttpPromiseCallback<T>): IHttpPromise;
|
||||
then(successCallback: (response: IHttpPromiseCallbackArg<T>) => any, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise;
|
||||
}
|
||||
|
||||
interface IHttpProvider extends IServiceProvider {
|
||||
@@ -621,8 +626,9 @@ declare module ng {
|
||||
// see http://docs.angularjs.org/api/ng.$routeProvider#when for options explanations
|
||||
interface IRoute {
|
||||
controller?: any;
|
||||
name?: string;
|
||||
template?: string;
|
||||
templateUrl?: string;
|
||||
templateUrl?: any;
|
||||
resolve?: any;
|
||||
redirectTo?: any;
|
||||
reloadOnSearch?: boolean;
|
||||
@@ -634,6 +640,8 @@ declare module ng {
|
||||
$scope: IScope;
|
||||
$template: string;
|
||||
};
|
||||
|
||||
params: any;
|
||||
}
|
||||
|
||||
interface IRouteProvider extends IServiceProvider {
|
||||
@@ -688,6 +696,7 @@ declare module ng {
|
||||
constant(name: string, value: any): void;
|
||||
|
||||
decorator(name: string, decorator: Function): void;
|
||||
decorator(name: string, decoratorInline: any[]): void;
|
||||
factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider;
|
||||
provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider;
|
||||
provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider;
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
|
||||
interface TimeickerOptions {
|
||||
defaultTime?: string;
|
||||
disableFocus?: boolean;
|
||||
isOpen?: boolean;
|
||||
minuteStep?: number;
|
||||
modalBackdrop?: boolean;
|
||||
secondStep?: number;
|
||||
showSeconds?: boolean;
|
||||
showInputs?: boolean;
|
||||
showMeridian?: boolean;
|
||||
template?: string;
|
||||
appendWidgetTo?: string;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
timepicker(): JQuery;
|
||||
timepicker(methodName: string): JQuery;
|
||||
timepicker(methodName: string, params: any): JQuery;
|
||||
timepicker(options: TimeickerOptions): JQuery;
|
||||
}
|
||||
@@ -35,6 +35,11 @@ $('#myCollapsible').collapse({ toggle: false });
|
||||
$('.carousel').carousel();
|
||||
$('.carousel').carousel({ interval: 2000 });
|
||||
|
||||
$('.typeahead').typeahead();
|
||||
$('.typeahead').typeahead({
|
||||
matcher: item => true,
|
||||
sorter: (items: any[]) => items,
|
||||
updater: item => item,
|
||||
highlighter: item => ""
|
||||
});
|
||||
|
||||
$('#navbar').affix();
|
||||
Vendored
+7
-4
@@ -32,6 +32,7 @@ interface TooltipOptions {
|
||||
title?: any;
|
||||
trigger?: string;
|
||||
delay?: any;
|
||||
container?: any;
|
||||
}
|
||||
|
||||
interface PopoverOptions {
|
||||
@@ -42,7 +43,8 @@ interface PopoverOptions {
|
||||
trigger?: string;
|
||||
title?: any;
|
||||
content?: any;
|
||||
delay?: any;
|
||||
delay?: any;
|
||||
container?: any;
|
||||
}
|
||||
|
||||
interface CollapseOptions {
|
||||
@@ -59,9 +61,10 @@ interface TypeaheadOptions {
|
||||
source?: any;
|
||||
items?: number;
|
||||
minLength?: number;
|
||||
matcher?: () => any;
|
||||
sorter?: () => any;
|
||||
highlighter?: () => any;
|
||||
matcher?: (item: any) => boolean;
|
||||
sorter?: (items: any[]) => any[];
|
||||
updater?: (item: any) => any;
|
||||
highlighter?: (item: any) => string;
|
||||
}
|
||||
|
||||
interface AffixOptions {
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/// <reference path="./browser-harness.d.ts" />
|
||||
|
||||
import harness = module('browser-harness');
|
||||
|
||||
harness.listen(4500);
|
||||
harness.listen(4500, function(){});
|
||||
harness.config.retryMS = 50;
|
||||
harness.config.timeoutMS = 1500;
|
||||
|
||||
var browser = new harness.Browser({ type: 'chrome' });
|
||||
browser.open('http://localhost:8000/harness.html');
|
||||
browser.close();
|
||||
|
||||
harness.events.on('ready', function(driver){
|
||||
driver.events.on('console.log', function(text){
|
||||
console.log(text);
|
||||
});
|
||||
|
||||
driver.events.on('console.warn', function(text){
|
||||
console.log(text);
|
||||
});
|
||||
|
||||
driver.events.on('console.error', function(text){
|
||||
console.log(text);
|
||||
});
|
||||
|
||||
driver.events.on('window.onerror', function(text){
|
||||
console.log(text);
|
||||
});
|
||||
|
||||
driver.setUrl('http://localhost:8000');
|
||||
driver.setUrl('http://localhost:8000', function(){});
|
||||
|
||||
var element = driver.findElement('body');
|
||||
var html = element.html();
|
||||
element.addClass('test').click();
|
||||
|
||||
driver.findElements('div').removeClass('test');
|
||||
|
||||
driver.findVisible('html').findVisible('body').toggleClass('test');
|
||||
driver.findVisibles('div').hide().show();
|
||||
|
||||
driver.find('div').css('color', 'red', function(err, element){
|
||||
element.hide().show();
|
||||
});
|
||||
|
||||
driver.waitFor(function(){
|
||||
return false;
|
||||
});
|
||||
|
||||
driver.waitFor(function(){
|
||||
return false;
|
||||
}, function(){
|
||||
|
||||
});
|
||||
|
||||
driver.waitFor({
|
||||
condition: function(){
|
||||
|
||||
},
|
||||
|
||||
exec: function(){
|
||||
|
||||
},
|
||||
|
||||
timeoutMS: 1000
|
||||
});
|
||||
|
||||
driver.exec(function(){
|
||||
|
||||
});
|
||||
|
||||
driver.exec(function(){}, function(){});
|
||||
|
||||
driver.exec({ func: function(){}, args: [] });
|
||||
driver.exec({ func: function(){}, args: [] }, function(){});
|
||||
});
|
||||
|
||||
harness.events.once('ready', function(driver){
|
||||
driver.events.once('console.log', function(text){
|
||||
console.log(text);
|
||||
});
|
||||
|
||||
driver.events.once('console.warn', function(text){
|
||||
console.log(text);
|
||||
});
|
||||
|
||||
driver.events.once('console.error', function(text){
|
||||
console.log(text);
|
||||
});
|
||||
|
||||
driver.events.once('window.onerror', function(text){
|
||||
console.log(text);
|
||||
});
|
||||
});
|
||||
Vendored
+133
@@ -0,0 +1,133 @@
|
||||
// Type definitions for Browser Harness
|
||||
// Project: https://github.com/scriby/browser-harness
|
||||
// Definitions by: Chris Scribner <https://github.com/scriby>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module "browser-harness" {
|
||||
import events = module("events");
|
||||
|
||||
interface HarnessEvents extends events.NodeEventEmitter {
|
||||
once(event: string, listener: (driver: Driver) => void);
|
||||
once(event: 'ready', listener: (driver: Driver) => void);
|
||||
|
||||
on(event: string, listener: (driver: Driver) => void);
|
||||
on(event: 'ready', listener: (driver: Driver) => void);
|
||||
}
|
||||
|
||||
interface DriverEvents extends events.NodeEventEmitter {
|
||||
once(event: string, listener: (text: string) => void);
|
||||
once(event: 'console.log', listener: (text: string) => void);
|
||||
once(event: 'console.warn', listener: (text: string) => void);
|
||||
once(event: 'console.error', listener: (text: string) => void);
|
||||
once(event: 'window.onerror', listener: (text: string) => void);
|
||||
|
||||
on(event: string, listener: (text: string) => void);
|
||||
on(event: 'console.log', listener: (text: string) => void);
|
||||
on(event: 'console.warn', listener: (text: string) => void);
|
||||
on(event: 'console.error', listener: (text: string) => void);
|
||||
on(event: 'window.onerror', listener: (text: string) => void);
|
||||
}
|
||||
|
||||
export interface Driver {
|
||||
exec(args: { func: Function; args?: any[]}, callback?: Function) : any;
|
||||
exec(func: Function, callback?: Function) : any;
|
||||
|
||||
setUrl(url: string, callback?: Function);
|
||||
|
||||
waitFor(args: { condition: Function; exec?: Function; timeoutMS?: number }, callback?: Function);
|
||||
waitFor(condition: Function, callback?: Function);
|
||||
|
||||
findElement(selector: string, callback?: (err: Error, element: ElementProxy) => void): ElementProxy;
|
||||
findElements(selector: string, callback?: (err: Error, elements: ElementProxy) => void): ElementProxy;
|
||||
|
||||
findVisible(selector: string, callback?: (err: Error, element: ElementProxy) => void): ElementProxy;
|
||||
findVisibles(selector: string, callback?: (err: Error, elements: ElementProxy) => void): ElementProxy;
|
||||
find(selector: string, callback?: (err: Error, elements: ElementProxy) => void): ElementProxy;
|
||||
|
||||
events: DriverEvents;
|
||||
}
|
||||
|
||||
export interface ElementProxy {
|
||||
click(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
focus(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
blur(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
val(value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
attr(name: string, value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
removeAttr(name: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
prop(name: string, value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
removeProp(name: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
html(value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
text(value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
hasClass(className: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
addClass(className: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
removeClass(className: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
toggleClass(className: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
|
||||
trigger(event: string, extraParameters?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
triggerHandler(event: string, extraParameters?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
|
||||
css(name: string, value?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
height(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
innerHeight(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
outerHeight(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
width(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
innerWidth(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
outerWidth(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
offset(value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
position(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
scrollLeft(value?: number, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
scrollTop(value?: number, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
|
||||
hide(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
show(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
toggle(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
|
||||
children(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
closest(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
contents(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
find(selector: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
findElements(selector: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
findElement(selector: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
findVisible(selector: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
findVisibles(selector: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
isActionable(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
first(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
has(arg: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
is(arg: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
last(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
next(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
nextAll(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
nextUntil(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
offsetParent(callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
parent(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
parents(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
parentsUntil(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
prev(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
prevAll(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
prevUntil(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
siblings(selector?: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
|
||||
|
||||
data(name: string, value?: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
removeData(name: string, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
|
||||
filter(selector: any, callback?: (err: Error, element: ElementProxy) => void) : ElementProxy
|
||||
}
|
||||
|
||||
export class Browser {
|
||||
//constructor(args: { type: string; location?: string; args?: string[] });
|
||||
constructor(args: { type: string; location?: string; args?: any; });
|
||||
|
||||
open(harnessUrl: string, serverUrl?: string);
|
||||
close();
|
||||
}
|
||||
|
||||
export function listen(port: number, callback?: Function)
|
||||
export var events: HarnessEvents;
|
||||
export var config: {
|
||||
timeoutMS: number;
|
||||
retryMS: number;
|
||||
};
|
||||
}
|
||||
Vendored
+125
-115
@@ -1,139 +1,160 @@
|
||||
// GreenSock Animation Platform (GSAP) - http://www.greensock.com/get-started-js/
|
||||
// JavaScript Docs http://api.greensock.com/js/
|
||||
// Version 1.0
|
||||
// Version 1.1 (TypeScript 0.9)
|
||||
|
||||
interface IDispatcher {
|
||||
addEventListener(type:string, callback:Function, scope:Object, useParam:boolean, priority:number):void;
|
||||
removeEventListener(type:string, callback:Function):void;
|
||||
}
|
||||
|
||||
//com.greensock.core
|
||||
interface Animation {
|
||||
declare class Animation {
|
||||
data:any;
|
||||
ticker:any;
|
||||
static ticker:IDispatcher;
|
||||
timeline:SimpleTimeline;
|
||||
vars:Object;
|
||||
|
||||
Animation(duration:number, vars?:Object);
|
||||
constructor(duration?:number, vars?:Object);
|
||||
|
||||
delay(value:number):any;
|
||||
duration(value:number):any;
|
||||
eventCallback(type:string, callback?:Function, params?:any[], scope?:any):any;
|
||||
invalidate():any;
|
||||
kill(vars?:Object, target?:Object):any;
|
||||
pause(atTime?:any, suppressEvents?:bool):any;
|
||||
paused(value?:bool):any;
|
||||
play(from?:any, suppressEvents?:bool):any;
|
||||
restart(includeDelay?:bool, suppressEvents?:bool):any;
|
||||
resume(from?:any, suppressEvents?:bool):any;
|
||||
reverse(from?:any, suppressEvents?:bool):any;
|
||||
reversed(value?:bool):any;
|
||||
seek(time:any, suppressEvents?:bool):any;
|
||||
pause(atTime?:any, suppressEvents?:boolean):any;
|
||||
paused(value?:boolean):any;
|
||||
play(from?:any, suppressEvents?:boolean):any;
|
||||
restart(includeDelay?:boolean, suppressEvents?:boolean):any;
|
||||
resume(from?:any, suppressEvents?:boolean):any;
|
||||
reverse(from?:any, suppressEvents?:boolean):any;
|
||||
reversed(value?:boolean):any;
|
||||
seek(time:any, suppressEvents?:boolean):any;
|
||||
startTime(value:number):any;
|
||||
time(value:number, suppressEvents?:bool):any;
|
||||
time(value:number, suppressEvents?:boolean):any;
|
||||
timeScale(value:number):any;
|
||||
totalDuration(value:number):any;
|
||||
totalTime(time:number, suppressEvents?:bool):any;
|
||||
totalTime(time:number, suppressEvents?:boolean):any;
|
||||
}
|
||||
|
||||
interface SimpleTimeline extends Animation {
|
||||
autoRemoveChildren:bool;
|
||||
smoothChildTiming:bool;
|
||||
declare class SimpleTimeline extends Animation {
|
||||
autoRemoveChildren:boolean;
|
||||
smoothChildTiming:boolean;
|
||||
|
||||
constructor(vars?:Object);
|
||||
|
||||
add(value:any, position?:any, align?:string, stagger?:number):any;
|
||||
insert(tween:any, time:any):any;
|
||||
render(time:number, suppressEvents?:bool, force?:bool):void;
|
||||
render(time:number, suppressEvents?:boolean, force?:boolean):void;
|
||||
}
|
||||
|
||||
//com.greensock
|
||||
interface TimelineLite {
|
||||
addLabel(label:string, time:number):any;
|
||||
append(value:any, offset:number):any;
|
||||
appendMultiple(tweens:any[], offset:number, align:string, stagger:number):any;
|
||||
call(callback:Function, params?:any[], scope?:any, offset?:number, baseTimeOrLabel?:any):any;
|
||||
clear(labels?:bool):any;
|
||||
duration(value:number):any;
|
||||
exportRoot(vars?:Object, omitDelayedCalls?:bool):TimelineLite;
|
||||
from(target:Object, duration:number, vars:Object, offset:number, baseTimeOrLabel?:any):any;
|
||||
fromTo(target:Object, duration:number, fromVars:Object, toVars:Object, offset:number, baseTimeOrLabel?:any):any;
|
||||
getChildren(nested?:bool, tweens?:bool, timelines?:bool, ignoreBeforeTime?:number):any[];
|
||||
getLabelTime(label:string):number;
|
||||
getTweensOf(target:Object, nested?:bool):any[];
|
||||
insert(value:any, timeOrLabel:any):any;
|
||||
insertMultiple(tweens:any[], timeOrLabel:any, align:string, stagger:number):any;
|
||||
declare class TweenLite extends Animation {
|
||||
static defaultEase:Ease;
|
||||
static defaultOverwrite:string;
|
||||
static selector:any;
|
||||
target:Object;
|
||||
static ticker:IDispatcher;
|
||||
timeline:SimpleTimeline;
|
||||
vars:Object;
|
||||
|
||||
constructor(target:Object, duration:number, vars:Object);
|
||||
|
||||
static delayedCall(delay:number, callback:Function, params?:any[], scope?:any, useFrames?:boolean):TweenLite;
|
||||
static from(target:Object, duration:number, vars:Object):TweenLite;
|
||||
static fromTo(target:Object, duration:number, fromVars:Object, toVars:Object):TweenLite;
|
||||
static getTweensOf(target:Object):any[];
|
||||
invalidate():any;
|
||||
static killDelayedCallsTo(func:Function):void;
|
||||
static killTweensOf(target:Object, vars?:Object):void;
|
||||
static set(target:Object, vars:Object):TweenLite;
|
||||
static to(target:Object, duration:number, vars:Object):TweenLite;
|
||||
}
|
||||
|
||||
declare class TweenMax extends TweenLite {
|
||||
static ticker:IDispatcher;
|
||||
|
||||
constructor(target:Object, duration:number, vars:Object);
|
||||
|
||||
static delayedCall(delay:number, callback:Function, params?:any[], scope?:any, useFrames?:boolean):TweenMax;
|
||||
static from(target:Object, duration:number, vars:Object):TweenMax;
|
||||
static fromTo(target:Object, duration:number, fromVars:Object, toVars:Object):TweenMax;
|
||||
static getAllTweens(includeTimelines?:boolean):any[];
|
||||
static getTweensOf(target:Object):any[];
|
||||
invalidate():any;
|
||||
static isTweening(target:Object):boolean;
|
||||
static killAll(complete?:boolean, tweens?:boolean, delayedCalls?:boolean, timelines?:boolean):void;
|
||||
static killChildTweensOf(parent:any, complete?:boolean):void;
|
||||
static killDelayedCallsTo(func:Function):void;
|
||||
static killTweensOf(target:Object, vars?:Object):void;
|
||||
static pauseAll(tweens?:boolean, delayedCalls?:boolean, timelines?:boolean):void;
|
||||
progress(value:number):any;
|
||||
repeat(value:number):any;
|
||||
repeatDelay(value:number):any;
|
||||
static resumeAll(tweens?:boolean, delayedCalls?:boolean, timelines?:boolean):void;
|
||||
static set(target:Object, vars:Object):TweenMax;
|
||||
static staggerFrom(targets:Object[], duration:number, vars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[];
|
||||
static staggerFromTo(targets:Object[], duration:number, fromVars:Object, toVars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[];
|
||||
static staggerTo(targets:Object[], duration:number, vars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[];
|
||||
time(value:number, suppressEvents?:boolean):any;
|
||||
static to(target:Object, duration:number, vars:Object):TweenMax;
|
||||
totalDuration(value:number):any;
|
||||
totalProgress(value:number):any;
|
||||
updateTo(vars:Object, resetDuration?:boolean):any;
|
||||
yoyo(value?:boolean):any;
|
||||
}
|
||||
|
||||
declare class TimelineLite extends SimpleTimeline {
|
||||
constructor(vars?:Object);
|
||||
|
||||
add(value:any, position?:any, align?:string, stagger?:number):any
|
||||
addLabel(label:string, position:any):any
|
||||
addPause(position?:any, callback?:Function, params?:any[], scope?:any):any
|
||||
append(value:any, offsetOrLabel?:any):any
|
||||
appendMultiple(tweens:any[], offsetOrLabel?:any, align?:string, stagger?:number):any
|
||||
call(callback:Function, params?:any[], scope?:any, position?:any):any
|
||||
clear(labels?:boolean):any
|
||||
duration(value:number):any
|
||||
exportRoot(vars?:Object, omitDelayedCalls?:boolean):TimelineLite
|
||||
fromTo(target:Object, duration:number, fromVars:Object, toVars:Object, position?:any):any
|
||||
getChildren(nested?:boolean, tweens?:boolean, timelines?:boolean, ignoreBeforeTime?:number):any[];
|
||||
getLabelTime(label:string):number
|
||||
getTweensOf(target:Object, nested?:boolean):any[];
|
||||
insert(value:any, timeOrLabel?:any):any
|
||||
insertMultiple(tweens:any[], timeOrLabel?:any, align?:string, stagger?:number):any
|
||||
invalidate():any
|
||||
progress(value:number):any;
|
||||
remove(value:any):any;
|
||||
removeLabel(label:string):any;
|
||||
seek(timeOrLabel:any, suppressEvents?:bool):any;
|
||||
set(target:Object, vars:Object, offset:number, baseTimeOrLabel?:any):any;
|
||||
shiftChildren(amount:number, adjustLabels?:bool, ignoreBeforeTime?:number):any;
|
||||
staggerFrom(targets:Object[], duration:number, vars:Object, stagger:number, offset:number, baseTimeOrLabel?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any;
|
||||
staggerFromTo(targets:Object[], duration:number, fromVars:Object, toVars:Object, stagger:number, offset:number, baseTimeOrLabel?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any;
|
||||
staggerTo(targets:Object[], duration:number, vars:Object, stagger:number, offset:number, baseTimeOrLabel?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any;
|
||||
seek(position:any, suppressEvents?:boolean):any;
|
||||
shiftChildren(amount:number, adjustLabels?:boolean, ignoreBeforeTime?:number):any;
|
||||
staggerFrom(targets:any[], duration:number, vars:Object, stagger?:number, position?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteScope?:any):any;
|
||||
staggerFromTo(targets:any[], duration:number, fromVars:Object, toVars:Object, stagger?:number, position?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any;
|
||||
staggerTo(targets:any[], duration:number, vars:Object, stagger:number, position?:any, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any;
|
||||
stop():any;
|
||||
to(target:Object, duration:number, vars:Object, offset:number, baseTimeOrLabel?:any):any;
|
||||
totalDuration(value:number):any;
|
||||
usesFrames():bool;
|
||||
to(target:Object, duration:number, vars:Object, position?:any):any;
|
||||
usesFrames():Boolean
|
||||
}
|
||||
|
||||
interface TimelineMax {
|
||||
addCallback(callback:Function, timeOrLabel:any, params?:any[], scope?:any):TimelineMax;
|
||||
declare class TimelineMax extends TimelineLite {
|
||||
constructor(vars?:Object);
|
||||
|
||||
addCallback(callback:Function, position:any, params?:any[], scope?:any):TimelineMax;
|
||||
currentLabel(value?:string):any;
|
||||
getActive(nested?:bool, tweens?:bool, timelines?:bool):any[];
|
||||
getLabelAfter(time:number):string;
|
||||
getLabelBefore(time:number):string;
|
||||
getActive(nested?:boolean, tweens?:boolean, timelines?:boolean):any[];
|
||||
getLabelAfter(time:number):string
|
||||
getLabelBefore(time:number):string
|
||||
getLabelsArray():any[];
|
||||
invalidate():any;
|
||||
progress(value:number):any;
|
||||
removeCallback(callback:Function, timeOrLabel?:any):TimelineMax;
|
||||
repeat(value:number):any;
|
||||
repeatDelay(value:number):any;
|
||||
time(value:number, suppressEvents?:bool):any;
|
||||
removeCallback(callback:Function, timeOrLabel?:any):TimelineMax
|
||||
repeat(value?:number):any;
|
||||
repeatDelay(value?:number):any;
|
||||
time(value:number, suppressEvents?:boolean):any;
|
||||
totalDuration(value:number):any;
|
||||
totalProgress(value:number):any;
|
||||
tweenFromTo(fromTimeOrLabel:any, toTimeOrLabel:any, vars?:Object):TweenLite;
|
||||
tweenTo(timeOrLabel:any, vars?:Object):TweenLite;
|
||||
yoyo(value?:bool):any;
|
||||
}
|
||||
|
||||
interface TweenLite extends Animation {
|
||||
defaultEase:Ease;
|
||||
defaultOverwrite:string;
|
||||
target:Object;
|
||||
ticker:any;
|
||||
|
||||
delayedCall(delay:number, callback:Function, params?:any[], scope?:any, useFrames?:bool):TweenLite;
|
||||
from(target:Object, duration:number, vars:Object):TweenLite;
|
||||
fromTo(target:Object, duration:number, fromVars:Object, toVars:Object):TweenLite;
|
||||
getTweensOf(target:Object):any[];
|
||||
invalidate():any;
|
||||
killDelayedCallsTo(func:Function):void;
|
||||
killTweensOf(target:Object, vars?:Object):void;
|
||||
set(target:Object, vars:Object):TweenLite;
|
||||
to(target:Object, duration:number, vars:Object):TweenLite;
|
||||
}
|
||||
|
||||
interface TweenMax extends TweenLite {
|
||||
delayedCall(delay:number, callback:Function, params?:any[], scope?:any, useFrames?:bool):TweenMax;
|
||||
from(target:Object, duration:number, vars:Object):TweenMax;
|
||||
fromTo(target:Object, duration:number, fromVars:Object, toVars:Object):TweenMax;
|
||||
getAllTweens(includeTimelines?:bool):any[];
|
||||
getTweensOf(target:Object):any[];
|
||||
invalidate():any;
|
||||
isTweening(target:Object):bool;
|
||||
killAll(complete?:bool, tweens?:bool, delayedCalls?:bool, timelines?:bool):void;
|
||||
killChildTweensOf(parent:any, complete?:bool):void;
|
||||
killDelayedCallsTo(func:Function):void;
|
||||
killTweensOf(target:Object, vars?:Object):void;
|
||||
pauseAll(tweens?:bool, delayedCalls?:bool, timelines?:bool):void;
|
||||
progress(value:number):any;
|
||||
repeat(value:number):any;
|
||||
repeatDelay(value:number):any;
|
||||
resumeAll(tweens?:bool, delayedCalls?:bool, timelines?:bool):void;
|
||||
set(target:Object, vars:Object):TweenMax;
|
||||
staggerFrom(targets:Object[], duration:number, vars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[];
|
||||
staggerFromTo(targets:Object[], duration:number, fromVars:Object, toVars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[];
|
||||
staggerTo(targets:Object[], duration:number, vars:Object, stagger:number, onCompleteAll?:Function, onCompleteAllParams?:any[], onCompleteAllScope?:any):any[];
|
||||
time(value:number, suppressEvents?:bool):any;
|
||||
to(target:Object, duration:number, vars:Object):TweenMax;
|
||||
totalDuration(value:number):any;
|
||||
totalProgress(value:number):any;
|
||||
updateTo(vars:Object, resetDuration?:bool):any;
|
||||
yoyo(value?:bool):any;
|
||||
tweenFromTo(fromPosition:any, toPosition:any, vars?:Object):TweenLite
|
||||
tweenTo(position:any, vars?:Object):TweenLite
|
||||
yoyo(value?:boolean):any;
|
||||
}
|
||||
|
||||
//com.greensock.easing
|
||||
@@ -228,8 +249,8 @@ interface Sine {
|
||||
interface SlowMo {
|
||||
ease:SlowMo;
|
||||
|
||||
SlowMo(linearRatio:number, power:number, yoyoMode:bool);
|
||||
config(linearRatio:number, power:number, yoyoMode:bool):SlowMo;
|
||||
SlowMo(linearRatio:number, power:number, yoyoMode:boolean);
|
||||
config(linearRatio:number, power:number, yoyoMode:boolean):SlowMo;
|
||||
getRatio(p:number):number;
|
||||
}
|
||||
interface SteppedEase {
|
||||
@@ -244,7 +265,7 @@ interface Strong {
|
||||
|
||||
//com.greensock.plugins
|
||||
interface BezierPlugin extends TweenPlugin {
|
||||
bezierThrough(values:any[], curviness?:number, quadratic?:bool, correlate?:string, prepend?:Object, calcDifs?:bool):Object;
|
||||
bezierThrough(values:any[], curviness?:number, quadratic?:boolean, correlate?:string, prepend?:Object, calcDifs?:boolean):Object;
|
||||
cubicToQuadratic(a:number, b:number, c:number, d:number):any[];
|
||||
quadraticToCubic(a:number, b:number, c:number):Object;
|
||||
}
|
||||
@@ -270,20 +291,9 @@ interface ScrollToPlugin extends TweenPlugin {
|
||||
|
||||
}
|
||||
interface TweenPlugin {
|
||||
activate(plugins:any[]):bool;
|
||||
activate(plugins:any[]):boolean;
|
||||
}
|
||||
|
||||
|
||||
//com.greensock.core
|
||||
declare var Animation:Animation;
|
||||
declare var SimpleTimeline:SimpleTimeline;
|
||||
|
||||
//com.greensock
|
||||
declare var TimelineLite:TimelineLite;
|
||||
declare var TimelineMax:TimelineMax;
|
||||
declare var TweenLite:TweenLite;
|
||||
declare var TweenMax:TweenMax;
|
||||
|
||||
//com.greensock.easing
|
||||
declare var Back:Back;
|
||||
declare var Bounce:Bounce;
|
||||
|
||||
Vendored
+1
-1
@@ -411,7 +411,7 @@ interface JQuery {
|
||||
html(): string;
|
||||
html(htmlString: string): JQuery;
|
||||
html(htmlContent: (index: number, oldhtml: string) => string): JQuery;
|
||||
html(JQuery): JQuery;
|
||||
html(obj: JQuery): JQuery;
|
||||
|
||||
prop(propertyName: string): any;
|
||||
prop(propertyName: string, value: any): JQuery;
|
||||
|
||||
Vendored
+2
-2
@@ -1538,7 +1538,7 @@ declare module L {
|
||||
/**
|
||||
* Function that will be used to decide whether to show a feature or not.
|
||||
*/
|
||||
filter?: (featureData: any, layer: ILayer) => bool;
|
||||
filter?: (featureData: any, layer: ILayer) => boolean;
|
||||
|
||||
}
|
||||
|
||||
@@ -2440,7 +2440,7 @@ declare module L {
|
||||
/**
|
||||
* Returns a function which always returns false.
|
||||
*/
|
||||
static falseFn(): () => bool;
|
||||
static falseFn(): () => boolean;
|
||||
|
||||
/**
|
||||
* Returns the number num rounded to digits decimals.
|
||||
|
||||
Vendored
+6
-6
@@ -68,8 +68,9 @@ interface Moment {
|
||||
subtract(soort: string, aantal: number): Moment;
|
||||
|
||||
calendar(): string;
|
||||
clone(): Moment;
|
||||
|
||||
valueOf(): string;
|
||||
valueOf(): number;
|
||||
|
||||
local(): Moment; // current date/time in local mode
|
||||
|
||||
@@ -95,13 +96,13 @@ interface Moment {
|
||||
seconds(): number;
|
||||
milliseconds(ms: number): Moment;
|
||||
milliseconds(): number;
|
||||
weekday(): Moment;
|
||||
weekday(): number;
|
||||
weekday(d: number): Moment;
|
||||
isoWeekday(): Moment;
|
||||
isoWeekday(): number;
|
||||
isoWeekday(d: number): Moment;
|
||||
weekYear(): Moment;
|
||||
weekYear(): number;
|
||||
weekYear(d: number): Moment;
|
||||
isoWeekYear(): Moment;
|
||||
isoWeekYear(): number;
|
||||
isoWeekYear(d: number): Moment;
|
||||
|
||||
from(f: Moment): string;
|
||||
@@ -232,7 +233,6 @@ interface MomentStatic {
|
||||
(date: number[]): Moment;
|
||||
(clone: Moment): Moment;
|
||||
|
||||
clone(): Moment;
|
||||
unix(timestamp: number): Moment;
|
||||
|
||||
utc(): Moment; // current date/time in UTC mode
|
||||
|
||||
Vendored
+5
-4
@@ -72,7 +72,7 @@ interface EventEmitter {
|
||||
on(event: string, listener: Function);
|
||||
once(event: string, listener: Function): void;
|
||||
removeListener(event: string, listener: Function): void;
|
||||
removeAllListener(event: string): void;
|
||||
removeAllListeners(event?: string): void;
|
||||
setMaxListeners(n: number): void;
|
||||
listeners(event: string): { Function; }[];
|
||||
emit(event: string, arg1?: any, arg2?: any): void;
|
||||
@@ -213,7 +213,7 @@ declare module "events" {
|
||||
on(event: string, listener: Function): any;
|
||||
once(event: string, listener: Function): void;
|
||||
removeListener(event: string, listener: Function): void;
|
||||
removeAllListener(event: string): void;
|
||||
removeAllListeners(event?: string): void;
|
||||
setMaxListeners(n: number): void;
|
||||
listeners(event: string): { Function; }[];
|
||||
emit(event: string, arg1?: any, arg2?: any): void;
|
||||
@@ -224,7 +224,7 @@ declare module "events" {
|
||||
on(event: string, listener: Function): any;
|
||||
once(event: string, listener: Function): void;
|
||||
removeListener(event: string, listener: Function): void;
|
||||
removeAllListener(event: string): void;
|
||||
removeAllListener(sevent?: string): void;
|
||||
setMaxListeners(n: number): void;
|
||||
listeners(event: string): { Function; }[];
|
||||
emit(event: string, arg1?: any, arg2?: any): void;
|
||||
@@ -333,7 +333,7 @@ declare module "cluster" {
|
||||
export function on(event: string, listener: Function): any;
|
||||
export function once(event: string, listener: Function): void;
|
||||
export function removeListener(event: string, listener: Function): void;
|
||||
export function removeAllListener(event: string): void;
|
||||
export function removeAllListeners(event?: string): void;
|
||||
export function setMaxListeners(n: number): void;
|
||||
export function listeners(event: string): { Function; }[];
|
||||
export function emit(event: string, arg1?: any, arg2?: any): void;
|
||||
@@ -808,6 +808,7 @@ declare module "fs" {
|
||||
declare module "path" {
|
||||
export function normalize(p: string): string;
|
||||
export function join(...paths: any[]): string;
|
||||
export function resolve(to: string);
|
||||
export function resolve(from: string, to: string): string;
|
||||
export function resolve(from: string, from2: string, to: string): string;
|
||||
export function resolve(from: string, from2: string, from3: string, to: string): string;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/// <reference path="persona.d.ts" />
|
||||
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.watch
|
||||
navigator.id.watch({
|
||||
loggedInUser: 'bob@example.org',
|
||||
onlogin: function(assertion: String) {},
|
||||
onlogout: function() {}
|
||||
});
|
||||
navigator.id.watch({
|
||||
loggedInUser: 'bob@example.org',
|
||||
onlogin: function(assertion: String) {},
|
||||
onlogout: function() {},
|
||||
onready: function() {}
|
||||
});
|
||||
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.request
|
||||
navigator.id.request();
|
||||
navigator.id.request({siteName: 'Example Site', siteLogo: '/logo.png'});
|
||||
navigator.id.request({termsOfService: '/tos.html', privacyPolicy: '/privacy.html'});
|
||||
navigator.id.request({
|
||||
backgroundColor: '#rrggbb',
|
||||
siteName: 'My Example Site',
|
||||
siteLogo: '/logo.png',
|
||||
termsOfService: '/tos.html',
|
||||
privacyPolicy: '/privacy.html',
|
||||
returnTo: '/welcome.html',
|
||||
oncancel: function() {}
|
||||
});
|
||||
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.logout
|
||||
navigator.id.logout();
|
||||
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/navigator.id.get
|
||||
var gotAssertion = function ( assertion: String ) {}
|
||||
navigator.id.get(gotAssertion);
|
||||
navigator.id.get(gotAssertion, {privacyPolicy: "/privacy.html", termsOfService: "/tos.html"});
|
||||
navigator.id.get(gotAssertion, {
|
||||
backgroundColor: '#rrggbb',
|
||||
siteName: 'My Example Site',
|
||||
siteLogo: '/logo.png',
|
||||
termsOfService: '/tos.html',
|
||||
privacyPolicy: '/privacy.html'
|
||||
});
|
||||
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Type definitions for Persona
|
||||
// Project: http://www.mozilla.org/en-US/persona
|
||||
// Definitions by: James Frasca <https://github.com/Nycto>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module Persona {
|
||||
|
||||
export interface WatchOptions {
|
||||
loggedInUser: String
|
||||
onlogin: (String) => void
|
||||
onlogout: () => void
|
||||
onready?: () => void
|
||||
}
|
||||
|
||||
export interface RequestOptions {
|
||||
backgroundColor?: String
|
||||
siteName?: String
|
||||
siteLogo?: String
|
||||
termsOfService?: String
|
||||
privacyPolicy?: String
|
||||
returnTo?: String
|
||||
oncancel?: () => void
|
||||
}
|
||||
|
||||
export interface GetOptions {
|
||||
backgroundColor?: String
|
||||
siteName?: String
|
||||
siteLogo?: String
|
||||
termsOfService?: String
|
||||
privacyPolicy?: String
|
||||
}
|
||||
|
||||
export interface Persona {
|
||||
watch( options: WatchOptions ): void
|
||||
request( options: RequestOptions ): void
|
||||
request(): void
|
||||
logout(): void
|
||||
get( gotAssertion: (String) => void ): void
|
||||
get( gotAssertion: (String) => void, options: GetOptions ): void
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface Navigator {
|
||||
id: Persona.Persona
|
||||
}
|
||||
|
||||
Vendored
+4
-4
@@ -81,11 +81,11 @@ interface RequireConfig {
|
||||
// If set to true, an error will be thrown if a script loads
|
||||
// that does not call define() or have shim exports string
|
||||
// value that can be checked.
|
||||
enforceDefine?: bool;
|
||||
enforceDefine?: boolean;
|
||||
|
||||
// If set to true, document.createElementNS() will be used
|
||||
// to create script elements.
|
||||
xhtml?: bool;
|
||||
xhtml?: boolean;
|
||||
|
||||
/**
|
||||
* Extra query string arguments appended to URLs that RequireJS
|
||||
@@ -204,7 +204,7 @@ interface RequireDefine {
|
||||
* Defines whether require js supports multiple versions of jQuery being loaded
|
||||
**/
|
||||
amd: {
|
||||
jQuery: bool;
|
||||
jQuery: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -212,4 +212,4 @@ interface RequireDefine {
|
||||
declare var require: Require;
|
||||
declare var requirejs: Require;
|
||||
declare var req: Require;
|
||||
declare var define: RequireDefine;
|
||||
declare var define: RequireDefine;
|
||||
|
||||
Vendored
+5
-2
@@ -8,9 +8,10 @@
|
||||
|
||||
interface Restangular extends RestangularCustom {
|
||||
one(route: string, id?: number): RestangularElement;
|
||||
one(route: string, id?: string): RestangularElement;
|
||||
all(route: string): RestangularCollection;
|
||||
copy(fromElement: any): RestangularElement;
|
||||
withConfig(configurer: any): RestangularElement;
|
||||
withConfig(configurer: any): Restangular;
|
||||
}
|
||||
|
||||
interface RestangularElement extends Restangular {
|
||||
@@ -31,6 +32,7 @@ interface RestangularElement extends Restangular {
|
||||
trace(queryParams?, headers?): ng.IPromise;
|
||||
options(queryParams?, headers?): ng.IPromise;
|
||||
patch(queryParams?, headers?): ng.IPromise;
|
||||
getRestangularUrl(): string;
|
||||
}
|
||||
|
||||
interface RestangularCollection extends Restangular {
|
||||
@@ -41,6 +43,7 @@ interface RestangularCollection extends Restangular {
|
||||
options(queryParams?, headers?): ng.IPromise;
|
||||
patch(queryParams?, headers?): ng.IPromise;
|
||||
putElement(idx, params, headers): ng.IPromise;
|
||||
getRestangularUrl(): string;
|
||||
}
|
||||
|
||||
interface RestangularCustom {
|
||||
@@ -67,4 +70,4 @@ interface RestangularProvider {
|
||||
}
|
||||
|
||||
declare var Restangular: Restangular;
|
||||
declare var RestangularProvider: RestangularProvider;
|
||||
declare var RestangularProvider: RestangularProvider;
|
||||
|
||||
Vendored
+921
-697
File diff suppressed because it is too large
Load Diff
Vendored
+2
-2
@@ -168,7 +168,7 @@ declare module createjs {
|
||||
static getCapabilities(): Object;
|
||||
static getCapability(key: string): any; //HERE can return string | number | bool
|
||||
static getInstanceById(uniqueId: string): SoundInstance;
|
||||
static getMute(): number;
|
||||
static getMute(): bool;
|
||||
static getMasterVolume(): number;
|
||||
static getSrcFromId(value: string): string;
|
||||
static getVolume(): number;
|
||||
@@ -181,7 +181,7 @@ declare module createjs {
|
||||
static registerManifest(manifest: Array);
|
||||
static resume(id: string): void;
|
||||
static setMasterVolume(value: number): bool;
|
||||
static setMute(isMuted: bool, id: string): bool;
|
||||
static setMute(isMuted: bool): bool;
|
||||
static setVolume(value: number, id?: string): bool;
|
||||
static stop(): bool;
|
||||
|
||||
|
||||
+237
-5
@@ -1,4 +1,4 @@
|
||||
/// <reference path="sugar.d.ts" />
|
||||
/// <reference path="sugar.d.ts" />
|
||||
|
||||
'schfifty'.add(' five'); // - > schfifty five
|
||||
'dopamine'.insert('e', 3); // - > dopeamine
|
||||
@@ -90,7 +90,7 @@
|
||||
'?????'.hasCyrillic(); // - > true
|
||||
'? ?????!'.hasHangul(); // - > true
|
||||
'??????'.hasKatakana(); // - > true
|
||||
"l'année".hasLatin(); // - > true
|
||||
"l'année".hasLatin(); // - > true
|
||||
|
||||
// visual studio is not liking these characters very much.
|
||||
'????'.hiragana(); // - > '????'
|
||||
@@ -110,7 +110,7 @@
|
||||
'?????'.isCyrillic(); // - > true
|
||||
'? ?????!'.isHangul(); // - > true
|
||||
'??????'.isKatakana(); // - > false
|
||||
"l'année".isLatin(); // - > true
|
||||
"l'année".isLatin(); // - > true
|
||||
|
||||
// visual studio is not liking these characters very much.
|
||||
'????'.katakana(); // - > '????'
|
||||
@@ -124,8 +124,8 @@
|
||||
// Called three times: "broken wear", "and", "jumpy jump"
|
||||
});
|
||||
|
||||
'á'.normalize(); // - > 'a'
|
||||
'Ménage à trois'.normalize(); // - > 'Menage a trois'
|
||||
'á'.normalize(); // - > 'a'
|
||||
'Ménage à trois'.normalize(); // - > 'Menage a trois'
|
||||
'Volkswagen'.normalize(); // - > 'Volkswagen'
|
||||
'FULLWIDTH'.normalize(); // - > 'FULLWIDTH'
|
||||
|
||||
@@ -345,3 +345,235 @@
|
||||
// This function is called 5 times receiving n as the value.
|
||||
});
|
||||
(2).upto(8, null, 2); // - > [2, 4, 6, 8]
|
||||
|
||||
|
||||
//#region Arrays
|
||||
|
||||
[1, 2, 3, 4].add(5);
|
||||
[1, 2, 3, 4].add([5, 6, 7]);
|
||||
[1, 2, 3, 4].insert(8, 1);
|
||||
|
||||
[1, 2, 3].at(0);
|
||||
[1, 2, 3].at(2);
|
||||
[1, 2, 3].at(4);
|
||||
[1, 2, 3].at(4, false);
|
||||
[1, 2, 3].at(-1);
|
||||
[1, 2, 3].at(0, 1);
|
||||
|
||||
[1, 2, 3].average();
|
||||
[{age:35},{age:11},{age:11}].average(function(n) {
|
||||
return n.age;
|
||||
});
|
||||
[{ age: 35 }, { age: 11 }, { age: 11 }].average('age');
|
||||
|
||||
[1, 2, 3].clone();
|
||||
|
||||
[1, null, 2, undefined, 3].compact();
|
||||
[1, '', 2, false, 3].compact();
|
||||
[1, '', 2, false, 3].compact(true);
|
||||
|
||||
[1, 2, 3, 1].count(1);
|
||||
['a', 'b', 'c'].count(/b/);
|
||||
[{a:1},{b:2}].count(function(n) {
|
||||
return n['a'] > 1;
|
||||
});
|
||||
|
||||
[1,2,3,4].each(function(n) {
|
||||
// Called 4 times: 1, 2, 3, 4
|
||||
});
|
||||
[1,2,3,4].each(function(n) {
|
||||
// Called 4 times: 3, 4, 1, 2
|
||||
}, 2, true);
|
||||
[1,2,3,4].each(n => false);
|
||||
|
||||
['a','a','a'].every(function(n) {
|
||||
return n == 'a';
|
||||
});
|
||||
['a', 'a', 'a'].every('a');
|
||||
[{ a: 2 }, { a: 2 }].every({ a: 2 });
|
||||
|
||||
[1, 2, 3].exclude(3);
|
||||
['a', 'b', 'c'].exclude(/b/);
|
||||
[{a:1},{b:2}].exclude(function(n) {
|
||||
return n['a'] == 1;
|
||||
});
|
||||
["a", "bbb", "ccc"].exclude((e,i,a) => e.length > 2, (e,i,a) => e.length < 0);
|
||||
|
||||
[1,2,3].filter(function(n) {
|
||||
return n > 1;
|
||||
});
|
||||
[1, 2, 2, 4].filter(2);
|
||||
|
||||
[{a:1,b:2},{a:1,b:3},{a:1,b:4}].find(function(n) {
|
||||
return n['a'] == 1;
|
||||
});
|
||||
['cuba', 'japan', 'canada'].find(/^c/, 2);
|
||||
|
||||
[{a:1,b:2},{a:1,b:3},{a:2,b:4}].findAll(function(n) {
|
||||
return n['a'] == 1;
|
||||
});
|
||||
['cuba', 'japan', 'canada'].findAll(/^c/);
|
||||
['cuba', 'japan', 'canada'].findAll(/^c/, 2);
|
||||
|
||||
[1,2,3,4].findIndex(3);
|
||||
[1,2,3,4].findIndex(function(n) {
|
||||
return n % 2 == 0;
|
||||
});
|
||||
['one','two','three'].findIndex(/th/);
|
||||
|
||||
[1, 2, 3].first();
|
||||
[1, 2, 3].first(2);
|
||||
|
||||
[[1], 2, [3]].flatten();
|
||||
[['a'], [], 'b', 'c'].flatten();
|
||||
|
||||
['a','b','c'].forEach(function(a) {
|
||||
// Called 3 times: 'a','b','c'
|
||||
});
|
||||
|
||||
[1, 2, 3].from(1);
|
||||
[1, 2, 3].from(2);
|
||||
|
||||
['fee', 'fi', 'fum'].groupBy('length');
|
||||
[{age:35,name:'ken'},{age:15,name:'bob'}].groupBy(function(n) {
|
||||
return n.age;
|
||||
});
|
||||
|
||||
[1, 2, 3, 4, 5, 6, 7].inGroups(3);
|
||||
[1, 2, 3, 4, 5, 6, 7].inGroups(3, 'none');
|
||||
|
||||
[1, 2, 3, 4, 5, 6, 7].inGroupsOf(4);
|
||||
[1, 2, 3, 4, 5, 6, 7].inGroupsOf(4, 'none');
|
||||
|
||||
[1, 2, 3, 4].include(5);
|
||||
[1, 2, 3, 4].include(8, 1);
|
||||
[1, 2, 3, 4].include([5, 6, 7]);
|
||||
|
||||
[1, 2, 3].indexOf(3);
|
||||
[1, 2, 3].indexOf(7);
|
||||
|
||||
[1, 3, 5].intersect([5, 7, 9]);
|
||||
['a', 'b'].intersect('b', 'c');
|
||||
|
||||
[1, 2, 3].last();
|
||||
[1, 2, 3].last(2);
|
||||
|
||||
[1, 2, 1].lastIndexOf(1);
|
||||
[1, 2, 1].lastIndexOf(7);
|
||||
|
||||
[3, 2, 2].least();
|
||||
['fe', 'fo', 'fum'].least('length');
|
||||
[{age:35,name:'ken'},{age:12,name:'bob'},{age:12,name:'ted'}].least(function(n) {
|
||||
return n.age;
|
||||
});
|
||||
|
||||
[1,2,3].map(function(n) {
|
||||
return n * 3;
|
||||
});
|
||||
['one','two','three'].map(function(n) {
|
||||
return n.length;
|
||||
});
|
||||
['one', 'two', 'three'].map('length');
|
||||
|
||||
[1, 2, 3].max();
|
||||
['fee', 'fo', 'fum'].max('length');
|
||||
['fee', 'fo', 'fum'].max('length', true);
|
||||
[{a:3,a:2}].max(function(n) {
|
||||
return n['a'];
|
||||
});
|
||||
|
||||
[1, 2, 3].min();
|
||||
['fee', 'fo', 'fum'].min('length');
|
||||
['fee', 'fo', 'fum'].min('length', true);
|
||||
['fee','fo','fum'].min(function(n) {
|
||||
return n.length;
|
||||
});
|
||||
[{a:3,a:2}].min(function(n) {
|
||||
return n['a'];
|
||||
});
|
||||
|
||||
[3, 2, 2].most();
|
||||
['fe', 'fo', 'fum'].most('length');
|
||||
[{age:35,name:'ken'},{age:12,name:'bob'},{age:12,name:'ted'}].most(function(n) {
|
||||
return n.age;
|
||||
});
|
||||
|
||||
[1, 2, 3].none(5);
|
||||
['a', 'b', 'c'].none(/b/);
|
||||
[{a:1},{b:2}].none(function(n) {
|
||||
return n['a'] > 1;
|
||||
});
|
||||
|
||||
[1, 2, 3, 4].randomize();
|
||||
|
||||
[1,2,3,4].reduce(function(a, b) {
|
||||
return a - b;
|
||||
});
|
||||
[1,2,3,4].reduce(function(a, b) {
|
||||
return a - b;
|
||||
}, 100);
|
||||
|
||||
[1,2,3,4].reduceRight(function(a, b) {
|
||||
return a - b;
|
||||
});
|
||||
|
||||
[1, 2, 3].remove(3);
|
||||
['a', 'b', 'c'].remove(/b/);
|
||||
[{a:1},{b:2}].remove(function(n) {
|
||||
return n['a'] == 1;
|
||||
});
|
||||
|
||||
[1, 2, 3].remove(3);
|
||||
['a', 'b', 'c'].remove(/b/);
|
||||
[{a:1},{b:2}].remove(function(n) {
|
||||
return n['a'] == 1;
|
||||
});
|
||||
|
||||
['a', 'b', 'c'].removeAt(0);
|
||||
[1, 2, 3, 4].removeAt(1, 3);
|
||||
|
||||
[1, 2, 3, 4, 5].sample();
|
||||
[1, 2, 3, 4, 5].sample(3);
|
||||
|
||||
['a','b','c'].some(function(n) {
|
||||
return n == 'a';
|
||||
});
|
||||
['a','b','c'].some(function(n) {
|
||||
return n == 'd';
|
||||
});
|
||||
['a', 'b', 'c'].some('a');
|
||||
[{ a: 2 }, { b: 5 }].some({ a: 2 });
|
||||
|
||||
['world', 'a', 'new'].sortBy('length');
|
||||
['world', 'a', 'new'].sortBy('length', true);
|
||||
[{age:72},{age:13},{age:18}].sortBy(function(n) {
|
||||
return n.age;
|
||||
});
|
||||
|
||||
[1, 3, 5].subtract([5, 7, 9]);
|
||||
[1, 3, 5].subtract([3], [5]);
|
||||
['a', 'b'].subtract('b', 'c');
|
||||
|
||||
[1, 2, 2].sum();
|
||||
[{age:35},{age:12},{age:12}].sum(function(n) {
|
||||
return n.age;
|
||||
});
|
||||
[{ age: 35 }, { age: 12 }, { age: 12 }].sum('age');
|
||||
|
||||
[1, 2, 3].to(1);
|
||||
[1, 2, 3].to(2);
|
||||
|
||||
[1, 3, 5].union([5, 7, 9]);
|
||||
['a', 'b'].union(['b', 'c']);
|
||||
|
||||
[1, 2, 2, 3].unique();
|
||||
[{ foo: 'bar' }, { foo: 'bar' }].unique();
|
||||
[{foo:'bar'},{foo:'bar'}].unique(function(obj){
|
||||
return obj.foo;
|
||||
});
|
||||
[{ foo: 'bar' }, { foo: 'bar' }].unique('foo');
|
||||
|
||||
[1, 2, 3].zip([4, 5, 6]);
|
||||
['Martin', 'John'].zip(['Luther', 'F.'], ['King', 'Kennedy']);
|
||||
|
||||
//#endregion
|
||||
Vendored
+89
-159
@@ -24,10 +24,6 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
interface SuggarExcludeFunction {
|
||||
(el: any, i?: number, array?: any[]): bool;
|
||||
}
|
||||
|
||||
interface String {
|
||||
|
||||
/**
|
||||
@@ -1984,7 +1980,7 @@ interface Number {
|
||||
upto(num: number, fn?: Function, step?: number): number[];
|
||||
}
|
||||
|
||||
interface Array {
|
||||
interface Array<T> {
|
||||
|
||||
/***
|
||||
* Alternate array constructor.
|
||||
@@ -2039,10 +2035,10 @@ interface Array {
|
||||
* [1,2,3,4].insert(8, 1) -> [1,8,2,3,4]
|
||||
*
|
||||
***/
|
||||
add(el: any, index?: number): any[];
|
||||
add(el: any[], index?: number): any[];
|
||||
insert(el: any, index?: number): any[];
|
||||
insert(el: any[], index?: number): any[];
|
||||
add(el: T, index?: number): T[];
|
||||
add(el: T[], index?: number): T[];
|
||||
insert(el: any, index?: number): T[];
|
||||
insert(el: any[], index?: number): T[];
|
||||
|
||||
/***
|
||||
* Gets the element(s) at a given index.
|
||||
@@ -2059,8 +2055,8 @@ interface Array {
|
||||
* [1,2,3].at(0,1) -> [1,2]
|
||||
*
|
||||
***/
|
||||
at(index: number, loop?: bool): any;
|
||||
at(start: number, stop: number): any[];
|
||||
at(index: number, loop?: bool): T;
|
||||
at(start: number, stop: number): T[];
|
||||
|
||||
/***
|
||||
* Averages all values in the array.
|
||||
@@ -2077,7 +2073,8 @@ interface Array {
|
||||
* [{age:35},{age:11},{age:11}].average('age') -> 19
|
||||
*
|
||||
***/
|
||||
average(map?: (n: number) => number): number;
|
||||
average(map?: (n: T) => number): number;
|
||||
average(mapShortcut: string): number;
|
||||
|
||||
/***
|
||||
* Clones the array.
|
||||
@@ -2088,7 +2085,7 @@ interface Array {
|
||||
* [1,2,3].clone() -> [1,2,3]
|
||||
*
|
||||
***/
|
||||
clone(): any[];
|
||||
clone(): T[];
|
||||
|
||||
/***
|
||||
* Removes all instances of %undefined%, %null%, and %NaN% from the array.
|
||||
@@ -2102,7 +2099,7 @@ interface Array {
|
||||
* [1,'',2,false,3].compact(true) -> [1,2,3]
|
||||
*
|
||||
***/
|
||||
compact(all?: bool): any[];
|
||||
compact(all?: bool): T[];
|
||||
|
||||
/***
|
||||
* Counts all elements in the array that match <f>.
|
||||
@@ -2122,7 +2119,7 @@ interface Array {
|
||||
count(f: string): number;
|
||||
count(f: any[]): number;
|
||||
count(f: Object): number;
|
||||
count(f: (n: any) => any): number;
|
||||
count(f: (n: T) => boolean): number;
|
||||
count(f: RegExp): number;
|
||||
|
||||
/***
|
||||
@@ -2148,9 +2145,9 @@ interface Array {
|
||||
* }, 2, true);
|
||||
*
|
||||
***/
|
||||
each(fn: (el: any, i?: number, array?: any[]) => bool,
|
||||
each(fn: (el: T, i?: number, array?: T[]) => any,
|
||||
index?: number,
|
||||
loop?: bool): any[];
|
||||
loop?: bool): T[];
|
||||
|
||||
/***
|
||||
* Returns true if all elements in the array match <f>.
|
||||
@@ -2170,11 +2167,11 @@ interface Array {
|
||||
every(f: number, scope?: any): bool;
|
||||
every(f: string, scope?: any): bool;
|
||||
every(f: Object, scope?: any): bool;
|
||||
every(f: (el: any, i?: number, array?: any[]) => bool, scope?: any): bool;
|
||||
every(f: (el: T, i?: number, array?: T[]) => bool, scope?: any): bool;
|
||||
all(f: number, scope?: any): bool;
|
||||
all(f: string, scope?: any): bool;
|
||||
all(f: Object, scope?: any): bool;
|
||||
all(f: (el: any, i?: number, array?: any[]) => bool, scope?: any): bool;
|
||||
all(f: (el: T, i?: number, array?: T[]) => bool, scope?: any): bool;
|
||||
|
||||
/***
|
||||
* Removes any element in the array that matches [f1], [f2], etc.
|
||||
@@ -2190,11 +2187,11 @@ interface Array {
|
||||
* }); -> [{b:2}]
|
||||
*
|
||||
***/
|
||||
exclude(...f: number[]): number[];
|
||||
exclude(...f: string[]): string[];
|
||||
exclude(...f: RegExp[]): string[];
|
||||
exclude(...f: Object[]): Object[];
|
||||
exclude(...f: SuggarExcludeFunction[]): any[];
|
||||
exclude(...f: number[]): T[];
|
||||
exclude(...f: string[]): T[];
|
||||
exclude(...f: RegExp[]): T[];
|
||||
exclude(...f: Object[]): T[];
|
||||
exclude(fn: (n: T) => bool): T[];
|
||||
|
||||
/***
|
||||
* Returns any elements in the array that match <f>.
|
||||
@@ -2211,11 +2208,11 @@ interface Array {
|
||||
* [1,2,2,4].filter(2) -> 2
|
||||
*
|
||||
***/
|
||||
filter(f: number, scope?: any): number[];
|
||||
filter(f: string, scope?: any): string[];
|
||||
filter(f: RegExp, scope?: any): String[];
|
||||
filter(f: Object, scope?: any): Object[];
|
||||
filter(f: (el: any, i?: number, array?: any[]) => bool, scope?: any): any[];
|
||||
filter(f: number, scope?: any): T[];
|
||||
filter(f: string, scope?: any): T[];
|
||||
filter(f: RegExp, scope?: any): T[];
|
||||
filter(f: Object, scope?: any): T[];
|
||||
filter(f: (el: T, i?: number, array?: T[]) => bool, scope?: any): T[];
|
||||
|
||||
/***
|
||||
* Returns the first element that matches <f>.
|
||||
@@ -2233,11 +2230,11 @@ interface Array {
|
||||
* ['cuba','japan','canada'].find(/^c/, 2) -> 'canada'
|
||||
*
|
||||
***/
|
||||
find(f: number, index?: number, loop?: bool): number;
|
||||
find(f: string, index?: number, loop?: bool): string;
|
||||
find(f: RegExp, index?: number, loop?: bool): string;
|
||||
find(f: Object, index?: number, loop?: bool): Object;
|
||||
find(f: (el: any, i?: number, array?: any[]) => bool, index?: number, loop?: bool): any;
|
||||
find(f: number, index?: number, loop?: bool): T;
|
||||
find(f: string, index?: number, loop?: bool): T;
|
||||
find(f: RegExp, index?: number, loop?: bool): T;
|
||||
find(f: Object, index?: number, loop?: bool): T;
|
||||
find(f: (el: T, i?: number, array?: T[]) => bool, index?: number, loop?: bool): T;
|
||||
|
||||
/***
|
||||
* Returns all elements that match <f>.
|
||||
@@ -2256,11 +2253,11 @@ interface Array {
|
||||
* ['cuba','japan','canada'].findAll(/^c/, 2) -> 'canada'
|
||||
*
|
||||
***/
|
||||
findAll(f: number, index?: number, loop?: bool): number[];
|
||||
findAll(f: string, index?: number, loop?: bool): string[];
|
||||
findAll(f: RegExp, index?: number, loop?: bool): string[];
|
||||
findAll(f: Object, index?: number, loop?: bool): Object[];
|
||||
findAll(f: (el: any, i?: number, array?: any[]) => bool, index?: number, loop?: bool): any[];
|
||||
findAll(f: number, index?: number, loop?: bool): T[];
|
||||
findAll(f: string, index?: number, loop?: bool): T[];
|
||||
findAll(f: RegExp, index?: number, loop?: bool): T[];
|
||||
findAll(f: Object, index?: number, loop?: bool): T[];
|
||||
findAll(f: (el: T, i?: number, array?: T[]) => bool, index?: number, loop?: bool): T[];
|
||||
|
||||
/***
|
||||
* Returns the index of the first element that matches <f>
|
||||
@@ -2288,7 +2285,7 @@ interface Array {
|
||||
findIndex(f: number, startIndex?: number, loop?: bool): number;
|
||||
findIndex(f: any, startIndex?: number, loop?: bool): number;
|
||||
findIndex(f: RegExp, startIndex?: number, loop?: bool): number;
|
||||
findIndex(f: (el: any, i?: number, array?: any[]) => bool, startIndex?: number, loop?: bool): number;
|
||||
findIndex(f: (el: T, i?: number, array?: T[]) => bool, startIndex?: number, loop?: bool): number;
|
||||
|
||||
/***
|
||||
* Returns the first element(s) in the array.
|
||||
@@ -2301,7 +2298,7 @@ interface Array {
|
||||
* [1,2,3].first(2) -> [1,2]
|
||||
*
|
||||
***/
|
||||
first(num?: number): any[];
|
||||
first(num?: number): T[];
|
||||
|
||||
/***
|
||||
* Returns a flattened, one-dimensional copy of the array.
|
||||
@@ -2315,7 +2312,7 @@ interface Array {
|
||||
* [['a'],[],'b','c'].flatten() -> ['a','b','c']
|
||||
*
|
||||
***/
|
||||
flatten(limit?: number): any[];
|
||||
flatten(limit?: number): T[];
|
||||
|
||||
/***
|
||||
* Iterates over the array, calling [fn] on each loop.
|
||||
@@ -2330,7 +2327,7 @@ interface Array {
|
||||
* });
|
||||
*
|
||||
***/
|
||||
forEach(fn: (el: any, i?: number, array?: any[]) => any, scope?: any): void;
|
||||
forEach(fn: (el: T, i?: number, array?: T[]) => void, scope?: any): void;
|
||||
|
||||
/***
|
||||
* Returns a slice of the array from <index>.
|
||||
@@ -2342,7 +2339,7 @@ interface Array {
|
||||
* [1,2,3].from(2) -> [3]
|
||||
*
|
||||
***/
|
||||
from(index: number): any[];
|
||||
from(index: number): T[];
|
||||
|
||||
/***
|
||||
* Groups the array by <map>.
|
||||
@@ -2359,8 +2356,8 @@ interface Array {
|
||||
* }); -> { 35: [{age:35,name:'ken'}], 15: [{age:15,name:'bob'}] }
|
||||
*
|
||||
***/
|
||||
groupBy(map: string, fn?: (n: any) => void ): Object;
|
||||
groupBy(fn: (n: any) => void ): Object;
|
||||
groupBy(map: string, fn?: (n: any) => void ): any;
|
||||
groupBy(fn: (n: T) => any ): any;
|
||||
|
||||
/***
|
||||
* Groups the array into <num> arrays.
|
||||
@@ -2402,24 +2399,8 @@ interface Array {
|
||||
* [1,2,3,4].include([5,6,7]) -> [1,2,3,4,5,6,7]
|
||||
*
|
||||
***/
|
||||
include(el: any, index?: number): any[];
|
||||
|
||||
/***
|
||||
* Searches the array and returns the first index where <search> occurs, or -1 if the element is not found.
|
||||
* @method indexOf(<search>, [fromIndex])
|
||||
* @returns Number
|
||||
* @extra [fromIndex] is the index from which to begin the search.
|
||||
* This method performs a simple strict equality comparison on <search>.
|
||||
* It does not support enhanced functionality such as searching
|
||||
* the contents against a regex, callback, or deep comparison of objects.
|
||||
* For such functionality, use the %findIndex% method instead.
|
||||
* @example
|
||||
*
|
||||
* [1,2,3].indexOf(3) -> 1
|
||||
* [1,2,3].indexOf(7) -> -1
|
||||
*
|
||||
***/
|
||||
indexOf(search: any, fromIndex?: number): number;
|
||||
include(el: T, index?: number): T[];
|
||||
include(els: T[], index?: number): T[];
|
||||
|
||||
/***
|
||||
* Returns an array containing the elements all arrays have in common.
|
||||
@@ -2432,10 +2413,10 @@ interface Array {
|
||||
* ['a','b'].intersect('b','c') -> ['b']
|
||||
*
|
||||
***/
|
||||
intersect(...args: number[]): number[];
|
||||
intersect(...args: string[]): string[];
|
||||
intersect(...args: Object[]): Object[];
|
||||
intersect(...args: T[]): T[];
|
||||
intersect(args: T[]): T[];
|
||||
intersect(...args: any[]): any[];
|
||||
intersect(args: any[]): any[];
|
||||
|
||||
/***
|
||||
* Returns true if the array is empty.
|
||||
@@ -2462,23 +2443,8 @@ interface Array {
|
||||
* [1,2,3].last(2) -> [2,3]
|
||||
*
|
||||
***/
|
||||
last(): any;
|
||||
last(num: number): any[];
|
||||
|
||||
/***
|
||||
* Searches the array and returns the last index where <search> occurs,
|
||||
* or -1 if the element is not found.
|
||||
* @method lastIndexOf(<search>, [fromIndex])
|
||||
* @returns Number
|
||||
* @extra [fromIndex] is the index from which to begin the search.
|
||||
* This method performs a simple strict equality comparison on <search>.
|
||||
* @example
|
||||
*
|
||||
* [1,2,1].lastIndexOf(1) -> 2
|
||||
* [1,2,1].lastIndexOf(7) -> -1
|
||||
*
|
||||
***/
|
||||
lastIndexOf(search: any, fromIndex?: number): number;
|
||||
last(): T;
|
||||
last(num: number): T[];
|
||||
|
||||
/***
|
||||
* Returns the elements in the array with the least
|
||||
@@ -2496,8 +2462,9 @@ interface Array {
|
||||
* }); -> [{age:35,name:'ken'}]
|
||||
*
|
||||
***/
|
||||
least(map: string): any[];
|
||||
least(map: (n: any) => any): any[];
|
||||
least(): T[];
|
||||
least(map: string): T[];
|
||||
least(map: (n: T) => any): any[];
|
||||
|
||||
/***
|
||||
* Maps the array to another array containing the values that
|
||||
@@ -2518,8 +2485,8 @@ interface Array {
|
||||
* }); -> [3,3,5]
|
||||
* ['one','two','three'].map('length') -> [3,3,5]
|
||||
***/
|
||||
map(map: string, scope?: any): any[];
|
||||
map(map: (n: any) => any, scope?: any): any[];
|
||||
map<U>(map: string, scope?: any): U[];
|
||||
map<U>(map: (n: T) => U, scope?: any): U[];
|
||||
|
||||
/***
|
||||
* Returns the element in the array with the greatest value.
|
||||
@@ -2538,8 +2505,11 @@ interface Array {
|
||||
* }); -> {a:3}
|
||||
*
|
||||
***/
|
||||
max(map: string): any;
|
||||
max(map: (n: any) => any): any;
|
||||
max(): T;
|
||||
max(map: string): T;
|
||||
max(map: string, all: boolean): any;
|
||||
max(map: (n: T) => any): T;
|
||||
max(map: (n: T) => any, all: boolean): any;
|
||||
|
||||
/***
|
||||
* Returns the element in the array with the lowest value.
|
||||
@@ -2559,8 +2529,11 @@ interface Array {
|
||||
* }); -> [{a:2}]
|
||||
*
|
||||
***/
|
||||
min(map: string): any;
|
||||
min(map: (n: any) => any): any;
|
||||
min(): T;
|
||||
min(map: string): T;
|
||||
min(map: string, all: boolean): any;
|
||||
min(map: (n: T) => any): T;
|
||||
min(map: (n: T) => any, all: boolean): any;
|
||||
|
||||
/***
|
||||
* Returns the elements in the array with the most
|
||||
@@ -2578,8 +2551,9 @@ interface Array {
|
||||
* }); -> [{age:12,name:'bob'},{age:12,name:'ted'}]
|
||||
*
|
||||
***/
|
||||
most(map: string): any[];
|
||||
most(map: (n: any) => any): any[];
|
||||
most(): T[];
|
||||
most(map: string): T[];
|
||||
most(map: (T: any) => any): T[];
|
||||
|
||||
/***
|
||||
* Returns true if none of the elements in the array match <f>.
|
||||
@@ -2601,7 +2575,7 @@ interface Array {
|
||||
none(f: RegExp): bool;
|
||||
none(f: Object): bool;
|
||||
none(f: any[]): bool;
|
||||
none(f: (n: any) => bool): bool;
|
||||
none(f: (n: T) => bool): bool;
|
||||
|
||||
/***
|
||||
* Returns a copy of the array with the elements randomized.
|
||||
@@ -2613,53 +2587,8 @@ interface Array {
|
||||
* [1,2,3,4].randomize() -> [?,?,?,?]
|
||||
*
|
||||
***/
|
||||
randomize(): any[];
|
||||
|
||||
/***
|
||||
* Reduces the array to a single result.
|
||||
* @method reduce(<fn>, [init])
|
||||
* @returns Mixed
|
||||
* @extra If [init] is passed as a starting value, that value will be passed
|
||||
* as the first argument to the callback. The second argument will be
|
||||
* the first element in the array. From that point, the result of the
|
||||
* callback will then be used as the first argument of the next
|
||||
* iteration. This is often refered to as "accumulation", and [init]
|
||||
* is often called an "accumulator". If [init] is not passed, then
|
||||
* <fn> will be called n - 1 times, where n is the length of the array.
|
||||
* In this case, on the first iteration only, the first argument will
|
||||
* be the first element of the array, and the second argument will be
|
||||
* the second. After that callbacks work as normal, using the result
|
||||
* of the previous callback as the first argument of the next. This
|
||||
* method is only provided for those browsers that do not support it
|
||||
* natively.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* [1,2,3,4].reduce(function(a, b) {
|
||||
* return a - b;
|
||||
* });
|
||||
* [1,2,3,4].reduce(function(a, b) {
|
||||
* return a - b;
|
||||
* }, 100);
|
||||
*
|
||||
***/
|
||||
reduce(fn: (a: any, b: any) => any, init: any): any;
|
||||
|
||||
/***
|
||||
* Identical to %Array#reduce%,
|
||||
* but operates on the elements in reverse order.
|
||||
* @method reduceRight([fn], [init])
|
||||
* @returns Mixed
|
||||
* @extra This method is only provided for those browsers that do not support
|
||||
* it natively.
|
||||
* @example
|
||||
*
|
||||
* [1,2,3,4].reduceRight(function(a, b) {
|
||||
* return a - b;
|
||||
* });
|
||||
*
|
||||
***/
|
||||
reduceRight(fn: (a: any, b: any) => any, init: any): any;
|
||||
randomize(): T[];
|
||||
|
||||
|
||||
/***
|
||||
* Removes any element in the array that matches [f1], [f2], etc.
|
||||
@@ -2678,11 +2607,11 @@ interface Array {
|
||||
* }); -> [{b:2}]
|
||||
*
|
||||
***/
|
||||
remove(...args: number[]): number[];
|
||||
remove(...args: string[]): string[];
|
||||
remove(...args: Object[]): Object[];
|
||||
remove(...args: number[]): T[];
|
||||
remove(...args: string[]): T[];
|
||||
remove(...args: Object[]): T[];
|
||||
remove(...args: any[]): any[];
|
||||
remove(fn: (n: any) => bool): any[];
|
||||
remove(...args: {(n: T): bool}[]): T[];
|
||||
|
||||
/***
|
||||
* Removes element at <start>. If [end] is specified, removes the range
|
||||
@@ -2696,7 +2625,7 @@ interface Array {
|
||||
* [1,2,3,4].removeAt(1, 3) -> [1]
|
||||
*
|
||||
***/
|
||||
removeAt(start: number, end?: number): any[];
|
||||
removeAt(start: number, end?: number): T[];
|
||||
|
||||
/***
|
||||
* Returns a random element from the array.
|
||||
@@ -2709,8 +2638,8 @@ interface Array {
|
||||
* [1,2,3,4,5].sample(3) -> // Array of 3 random elements
|
||||
*
|
||||
***/
|
||||
sample(): any;
|
||||
sample(num: number): any[];
|
||||
sample(): T;
|
||||
sample(num: number): T[];
|
||||
|
||||
/***
|
||||
* Returns true if any element in the array matches <f>.
|
||||
@@ -2733,7 +2662,7 @@ interface Array {
|
||||
some(f: number, scope?: any): bool;
|
||||
some(f: string, scope?: any): bool;
|
||||
some(f: any, scope?: any): bool;
|
||||
some(f: (n: any) => bool, scope?: any): bool;
|
||||
some(f: (n: T) => bool, scope?: any): bool;
|
||||
|
||||
/***
|
||||
* Sorts the array by <map>.
|
||||
@@ -2754,8 +2683,8 @@ interface Array {
|
||||
* }); -> [{age:13},{age:18},{age:72}]
|
||||
*
|
||||
***/
|
||||
sortBy(map: string, desc?: bool): any[];
|
||||
sortBy(fn: (n: any) => any, desc?: bool): any[];
|
||||
sortBy(map: string, desc?: bool): T[];
|
||||
sortBy(fn: (n: T) => any, desc?: bool): T[];
|
||||
|
||||
/***
|
||||
* Subtracts from the array all elements in [a1], [a2], etc.
|
||||
@@ -2768,8 +2697,8 @@ interface Array {
|
||||
* [1,3,5].subtract([3],[5]) -> [1]
|
||||
* ['a','b'].subtract('b','c') -> ['a']
|
||||
*
|
||||
***/
|
||||
subtract(...args: any[]): any[];
|
||||
***/
|
||||
subtract(...args: any[]): T[];
|
||||
|
||||
/***
|
||||
* @method sum([map])
|
||||
@@ -2786,8 +2715,9 @@ interface Array {
|
||||
* [{age:35},{age:12},{age:12}].sum('age') -> 59
|
||||
*
|
||||
***/
|
||||
sum(): number;
|
||||
sum(map: string): number;
|
||||
sum(fn: (n: any) => number): number;
|
||||
sum(fn: (n: T) => number): number;
|
||||
|
||||
/***
|
||||
* Returns a slice of the array up to <index>.
|
||||
@@ -2799,7 +2729,7 @@ interface Array {
|
||||
* [1,2,3].to(2) -> [1,2]
|
||||
*
|
||||
***/
|
||||
to(index: number): any[];
|
||||
to(index: number): T[];
|
||||
|
||||
/***
|
||||
* Returns an array containing all elements in all arrays with
|
||||
@@ -2834,9 +2764,9 @@ interface Array {
|
||||
* }); -> [{foo:'bar'}]
|
||||
* [{foo:'bar'},{foo:'bar'}].unique('foo') -> [{foo:'bar'}]
|
||||
*
|
||||
***/
|
||||
unique(map?: string): any[];
|
||||
unique(fn?: (obj: any) => any): any[];
|
||||
***/
|
||||
unique(map?: string): T[];
|
||||
unique(fn?: (obj: T) => any): T[];
|
||||
|
||||
/***
|
||||
* Merges multiple arrays together.
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import _ = require("underscore")
|
||||
/// <reference path="underscore.d.ts" />
|
||||
|
||||
declare var $;
|
||||
declare function alert(any);
|
||||
|
||||
_.each([1, 2, 3], (num) => alert(num));
|
||||
_.each({ one: 1, two: 2, three: 3 }, (num, key) => alert(num));
|
||||
_.each([1, 2, 3], (num) => alert(num.toString()));
|
||||
_.each({ one: 1, two: 2, three: 3 }, (value) => alert(value.toString()));
|
||||
|
||||
_.map([1, 2, 3], (num) => num * 3);
|
||||
_.map({ one: 1, two: 2, three: 3 }, (num, key) => num * 3);
|
||||
_.map({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => value * 3);
|
||||
|
||||
var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0);
|
||||
|
||||
var list = [[0, 1], [2, 3], [4, 5]];
|
||||
|
||||
var flat = _.reduceRight(list, (a, b) => a.concat(b), []);
|
||||
|
||||
var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0);
|
||||
@@ -37,19 +35,23 @@ _.pluck(stooges, 'name');
|
||||
|
||||
_.max(stooges, (stooge) => stooge.age);
|
||||
|
||||
_.max([1, 2, 3, 4, 5]);
|
||||
|
||||
var numbers = [10, 5, 100, 2, 1000];
|
||||
_.min(numbers);
|
||||
|
||||
_.sortBy([1, 2, 3, 4, 5, 6], (num) => Math.sin(num));
|
||||
|
||||
_.groupBy([1.3, 2.1, 2.4], (num) => Math.floor(num));
|
||||
|
||||
_([1.3, 2.1, 2.4]).groupBy((e) => Math.floor(e));
|
||||
_.groupBy([1.3, 2.1, 2.4], (num: number) => Math.floor(num).toString());
|
||||
_.groupBy(['one', 'two', 'three'], 'length');
|
||||
|
||||
_.countBy([1, 2, 3, 4, 5], (num) => num % 2 == 0 ? 'even' : 'odd');
|
||||
_.countBy<number>([1, 2, 3, 4, 5], (num) => (num % 2 == 0) ? 'even' : 'odd');
|
||||
|
||||
_.shuffle([1, 2, 3, 4, 5, 6]);
|
||||
|
||||
// (function(){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
||||
(function(a, b, c, d){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
||||
|
||||
_.size({ one: 1, two: 2, three: 3 });
|
||||
|
||||
@@ -60,16 +62,21 @@ _.initial([5, 4, 3, 2, 1]);
|
||||
_.last([5, 4, 3, 2, 1]);
|
||||
_.rest([5, 4, 3, 2, 1]);
|
||||
_.compact([0, 1, false, 2, '', 3]);
|
||||
_.flatten([1, [2], [3, <any>[[4]]]]);
|
||||
_.flatten([1, [2], [3, <any>[[4]]]], true);
|
||||
|
||||
_.flatten([1, 2, 3, 4]);
|
||||
_.flatten([1, <any>[2]]);
|
||||
|
||||
// typescript doesn't like the elements being different
|
||||
_.flatten([1, [2], <any>[3, <any>[[4]]]]);
|
||||
_.flatten([1, [2], <any>[3, <any>[[4]]]], true);
|
||||
_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
||||
_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
|
||||
_.uniq([1, 2, 1, 3, 1, 4]);
|
||||
_.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
|
||||
_.object(['moe', 'larry', 'curly'], [30, 40, 50]);
|
||||
_.object([['moe', <any>30], ['larry', <any>40], ['curly', <any>50]]);
|
||||
var r = _.object<{ [key: string]: number }>(['moe', 'larry', 'curly'], [30, 40, 50]);
|
||||
_.object([[<any>'moe', 30], [<any>'larry', 40], [<any>'curly', 50]]);
|
||||
_.indexOf([1, 2, 3], 2);
|
||||
_.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
|
||||
_.sortedIndex([10, 20, 30, 40, 50], 35);
|
||||
@@ -81,20 +88,22 @@ _.range(0);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var func = function (greeting?) { return greeting + ': ' + this.name };
|
||||
func = _.bind(func, { name: 'moe' }, 'hi');
|
||||
func();
|
||||
var func = function (greeting) { return greeting + ': ' + this.name };
|
||||
// need a second var otherwise typescript thinks func signature is the above func type,
|
||||
// instead of the newly returned _bind => func type.
|
||||
var func2 = _.bind(func, { name: 'moe' }, 'hi');
|
||||
func2();
|
||||
|
||||
var buttonView = {
|
||||
label: 'underscore',
|
||||
onClick: function () { alert('clicked: ' + this.label); },
|
||||
onHover: function () { console.log('hovering: ' + this.label); }
|
||||
label: 'underscore',
|
||||
onClick: function () { alert('clicked: ' + this.label); },
|
||||
onHover: function () { console.log('hovering: ' + this.label); }
|
||||
};
|
||||
_.bindAll(buttonView);
|
||||
$('#underscore_button').bind('click', buttonView.onClick);
|
||||
|
||||
var fibonacci = _.memoize(function (n) {
|
||||
return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
|
||||
return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
|
||||
});
|
||||
|
||||
var log = _.bind(console.log, console);
|
||||
@@ -120,9 +129,10 @@ var render = () => alert("rendering...");
|
||||
var renderNotes = _.after(notes.length, render);
|
||||
_.each(notes, (note) => note.asyncSave({ success: renderNotes }));
|
||||
|
||||
var hello = function (name?) { return "hello: " + name; };
|
||||
hello = _.wrap(hello, (func) => { return "before, " + func("moe") + ", after"; });
|
||||
hello();
|
||||
var hello = function (name) { return "hello: " + name; };
|
||||
// can't use the same "hello" var otherwise typescript fails
|
||||
var hello2 = _.wrap(hello, (func) => { return "before, " + func("moe") + ", after"; });
|
||||
hello2();
|
||||
|
||||
var greet = function (name) { return "hi: " + name; };
|
||||
var exclaim = function (statement) { return statement + "!"; };
|
||||
@@ -144,12 +154,23 @@ var iceCream = { flavor: "chocolate" };
|
||||
_.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" });
|
||||
|
||||
_.clone({ name: 'moe' });
|
||||
_.clone(['i', 'am', 'an', 'object!']);
|
||||
|
||||
_([1, 2, 3, 4])
|
||||
.chain()
|
||||
.filter((num: number) => {
|
||||
return num % 2 == 0;
|
||||
}).tap(alert)
|
||||
.map((num: number) => {
|
||||
return num * num;
|
||||
})
|
||||
.value();
|
||||
|
||||
_.chain([1, 2, 3, 200])
|
||||
.filter(function (num) { return num % 2 == 0; })
|
||||
.tap(alert)
|
||||
.map(function (num) { return num * num })
|
||||
.value();
|
||||
.filter(function (num: number) { return num % 2 == 0; })
|
||||
.tap(alert)
|
||||
.map(function (num: number) { return num * num })
|
||||
.value();
|
||||
|
||||
_.has({ a: 1, b: 2, c: 3 }, "b");
|
||||
|
||||
@@ -206,15 +227,17 @@ var moe2 = { name: 'moe' };
|
||||
moe2 === _.identity(moe);
|
||||
|
||||
var genie;
|
||||
var r2 = _.times<number>(3, (n) => { return n * n });
|
||||
_(3).times(function (n) { genie.grantWishNumber(n); });
|
||||
|
||||
_.random(0, 100);
|
||||
|
||||
_.mixin({
|
||||
capitalize: function (string) {
|
||||
return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
|
||||
}
|
||||
capitalize: function (string) {
|
||||
return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
|
||||
}
|
||||
});
|
||||
(<any>_("fabio")).capitalize();
|
||||
|
||||
_.uniqueId('contact_');
|
||||
|
||||
@@ -234,14 +257,11 @@ template({ value: '<script>' });
|
||||
var compiled2 = _.template("<% print('Hello ' + epithet); %>");
|
||||
compiled2({ epithet: "stooge" });
|
||||
_.templateSettings = {
|
||||
interpolate: /\{\{(.+?)\}\}/g
|
||||
interpolate: /\{\{(.+?)\}\}/g
|
||||
};
|
||||
var template2 = _.template("Hello {{ name }}!");
|
||||
template2({ name: "Mustache" });
|
||||
_.template("Using 'with': <%= data.answer %>", { answer: 'no' }, { variable: 'data' });
|
||||
|
||||
|
||||
|
||||
_.countBy([1, 2, 3], function (item) {
|
||||
return item % 2;
|
||||
});
|
||||
_(['test', 'test']).pick(['test2', 'test2']);
|
||||
@@ -1,261 +0,0 @@
|
||||
/// <reference path="underscore-typed.d.ts" />
|
||||
|
||||
declare var $;
|
||||
|
||||
_.each([1, 2, 3], (num) => alert(num.toString()));
|
||||
_.each({ one: 1, two: 2, three: 3 }, (value) => alert(value.toString()));
|
||||
|
||||
_.map([1, 2, 3], (num) => num * 3);
|
||||
_.map({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => value * 3);
|
||||
|
||||
var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0);
|
||||
|
||||
var list = [[0, 1], [2, 3], [4, 5]];
|
||||
var flat = _.reduceRight(list, (a, b) => a.concat(b), []);
|
||||
|
||||
var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0);
|
||||
|
||||
var evens = _.filter([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0);
|
||||
|
||||
var listOfPlays = [{ title: "Cymbeline", author: "Shakespeare", year: 1611 }, { title: "The Tempest", author: "Shakespeare", year: 1611 }, { title: "Other", author: "Not Shakespeare", year: 2012 }];
|
||||
_.where(listOfPlays, { author: "Shakespeare", year: 1611 });
|
||||
|
||||
var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0);
|
||||
|
||||
_.all([true, 1, null, 'yes'], _.identity);
|
||||
|
||||
_.any([null, 0, 'yes', false]);
|
||||
|
||||
_.contains([1, 2, 3], 3);
|
||||
|
||||
_.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
|
||||
|
||||
var stooges = [{ name: 'moe', age: 40 }, { name: 'larry', age: 50 }, { name: 'curly', age: 60 }];
|
||||
_.pluck(stooges, 'name');
|
||||
|
||||
_.max(stooges, (stooge) => stooge.age);
|
||||
|
||||
var numbers = [10, 5, 100, 2, 1000];
|
||||
_.min(numbers);
|
||||
|
||||
_.sortBy([1, 2, 3, 4, 5, 6], (num) => Math.sin(num));
|
||||
|
||||
|
||||
_([1.3, 2.1, 2.4]).groupBy((e, i?: number, list?: any[]) => Math.floor(e));
|
||||
_.groupBy([1.3, 2.1, 2.4], (num: number) => Math.floor(num).toString());
|
||||
_.groupBy(['one', 'two', 'three'], 'length');
|
||||
|
||||
_.countBy([1, 2, 3, 4, 5], (num) => num % 2 == 0 ? 'even' : 'odd');
|
||||
|
||||
_.shuffle([1, 2, 3, 4, 5, 6]);
|
||||
|
||||
(function(a, b, c, d){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
||||
|
||||
_.size({ one: 1, two: 2, three: 3 });
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
_.first([5, 4, 3, 2, 1]);
|
||||
_.initial([5, 4, 3, 2, 1]);
|
||||
_.last([5, 4, 3, 2, 1]);
|
||||
_.rest([5, 4, 3, 2, 1]);
|
||||
_.compact([0, 1, false, 2, '', 3]);
|
||||
|
||||
_.flatten([1, 2, 3, 4]);
|
||||
_.flatten([1, <any>[2]]);
|
||||
|
||||
// typescript doesn't like the elements being different
|
||||
_.flatten([1, [2], <any>[3, <any>[[4]]]]);
|
||||
_.flatten([1, [2], <any>[3, <any>[[4]]]], true);
|
||||
_.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
||||
_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
|
||||
_.difference([1, 2, 3, 4, 5], [5, 2, 10]);
|
||||
_.uniq([1, 2, 1, 3, 1, 4]);
|
||||
_.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]);
|
||||
var r = _.object<{ [key: string]: number }>(['moe', 'larry', 'curly'], [30, 40, 50]);
|
||||
_.object([[<any>'moe', 30], [<any>'larry', 40], [<any>'curly', 50]]);
|
||||
_.indexOf([1, 2, 3], 2);
|
||||
_.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
|
||||
_.sortedIndex([10, 20, 30, 40, 50], 35);
|
||||
_.range(10);
|
||||
_.range(1, 11);
|
||||
_.range(0, 30, 5);
|
||||
_.range(0, 30, 5);
|
||||
_.range(0);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var func = function (greeting) { return greeting + ': ' + this.name };
|
||||
// need a second var otherwise typescript thinks func signature is the above func type,
|
||||
// instead of the newly returned _bind => func type.
|
||||
var func2 = _.bind(func, { name: 'moe' }, 'hi');
|
||||
func2();
|
||||
|
||||
var buttonView = {
|
||||
label: 'underscore',
|
||||
onClick: function () { alert('clicked: ' + this.label); },
|
||||
onHover: function () { console.log('hovering: ' + this.label); }
|
||||
};
|
||||
_.bindAll(buttonView);
|
||||
$('#underscore_button').bind('click', buttonView.onClick);
|
||||
|
||||
var fibonacci = _.memoize(function (n) {
|
||||
return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
|
||||
});
|
||||
|
||||
var log = _.bind(console.log, console);
|
||||
_.delay(log, 1000, 'logged later');
|
||||
|
||||
_.defer(function () { alert('deferred'); });
|
||||
|
||||
var updatePosition = () => alert('updating position...');
|
||||
var throttled = _.throttle(updatePosition, 100);
|
||||
$(window).scroll(throttled);
|
||||
|
||||
var calculateLayout = () => alert('calculating layout...');
|
||||
var lazyLayout = _.debounce(calculateLayout, 300);
|
||||
$(window).resize(lazyLayout);
|
||||
|
||||
var createApplication = () => alert('creating application...');
|
||||
var initialize = _.once(createApplication);
|
||||
initialize();
|
||||
initialize();
|
||||
|
||||
var notes: any[];
|
||||
var render = () => alert("rendering...");
|
||||
var renderNotes = _.after(notes.length, render);
|
||||
_.each(notes, (note) => note.asyncSave({ success: renderNotes }));
|
||||
|
||||
var hello = function (name) { return "hello: " + name; };
|
||||
// can't use the same "hello" var otherwise typescript fails
|
||||
var hello2 = _.wrap(hello, (func) => { return "before, " + func("moe") + ", after"; });
|
||||
hello2();
|
||||
|
||||
var greet = function (name) { return "hi: " + name; };
|
||||
var exclaim = function (statement) { return statement + "!"; };
|
||||
var welcome = _.compose(exclaim, greet);
|
||||
welcome('moe');
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
_.keys({ one: 1, two: 2, three: 3 });
|
||||
_.values({ one: 1, two: 2, three: 3 });
|
||||
_.pairs({ one: 1, two: 2, three: 3 });
|
||||
_.invert({ Moe: "Moses", Larry: "Louis", Curly: "Jerome" });
|
||||
_.functions(_);
|
||||
_.extend({ name: 'moe' }, { age: 50 });
|
||||
_.pick({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age');
|
||||
_.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'userid');
|
||||
|
||||
var iceCream = { flavor: "chocolate" };
|
||||
_.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" });
|
||||
|
||||
_.clone({ name: 'moe' });
|
||||
|
||||
_([1, 2, 3, 4])
|
||||
.chain()
|
||||
.filter((num: number) => {
|
||||
return num % 2 == 0;
|
||||
}).tap(alert)
|
||||
.map((num: number) => {
|
||||
return num * num;
|
||||
})
|
||||
.value();
|
||||
|
||||
_.chain([1, 2, 3, 200])
|
||||
.filter(function (num: number) { return num % 2 == 0; })
|
||||
.tap(alert)
|
||||
.map(function (num: number) { return num * num })
|
||||
.value();
|
||||
|
||||
_.has({ a: 1, b: 2, c: 3 }, "b");
|
||||
|
||||
var moe = { name: 'moe', luckyNumbers: [13, 27, 34] };
|
||||
var clone = { name: 'moe', luckyNumbers: [13, 27, 34] };
|
||||
moe == clone;
|
||||
_.isEqual(moe, clone);
|
||||
|
||||
_.isEmpty([1, 2, 3]);
|
||||
_.isEmpty({});
|
||||
|
||||
_.isElement($('body')[0]);
|
||||
|
||||
(function () { return _.isArray(arguments); })();
|
||||
_.isArray([1, 2, 3]);
|
||||
|
||||
_.isObject({});
|
||||
_.isObject(1);
|
||||
|
||||
|
||||
// (() => { return _.isArguments(arguments); })(1, 2, 3);
|
||||
_.isArguments([1, 2, 3]);
|
||||
|
||||
_.isFunction(alert);
|
||||
|
||||
_.isString("moe");
|
||||
|
||||
_.isNumber(8.4 * 5);
|
||||
|
||||
_.isFinite(-101);
|
||||
|
||||
_.isFinite(-Infinity);
|
||||
|
||||
_.isBoolean(null);
|
||||
|
||||
_.isDate(new Date());
|
||||
|
||||
_.isRegExp(/moe/);
|
||||
|
||||
_.isNaN(NaN);
|
||||
isNaN(undefined);
|
||||
_.isNaN(undefined);
|
||||
|
||||
_.isNull(null);
|
||||
_.isNull(undefined);
|
||||
|
||||
_.isUndefined((<any>window).missingVariable);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var underscore = _.noConflict();
|
||||
|
||||
var moe2 = { name: 'moe' };
|
||||
moe2 === _.identity(moe);
|
||||
|
||||
var genie;
|
||||
var r2 = _.times<number>(3, (n) => { return n * n });
|
||||
_(3).times(function (n) { genie.grantWishNumber(n); });
|
||||
|
||||
_.random(0, 100);
|
||||
|
||||
_.mixin({
|
||||
capitalize: function (string) {
|
||||
return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
|
||||
}
|
||||
});
|
||||
(<any>_("fabio")).capitalize();
|
||||
|
||||
_.uniqueId('contact_');
|
||||
|
||||
_.escape('Curly, Larry & Moe');
|
||||
|
||||
var object = { cheese: 'crumpets', stuff: function () { return 'nonsense'; } };
|
||||
_.result(object, 'cheese');
|
||||
|
||||
_.result(object, 'stuff');
|
||||
|
||||
var compiled = _.template("hello: <%= name %>");
|
||||
compiled({ name: 'moe' });
|
||||
var list2 = "<% _.each(people, function(name) { %> <li><%= name %></li> <% }); %>";
|
||||
_.template(list2, { people: ['moe', 'curly', 'larry'] });
|
||||
var template = _.template("<b><%- value %></b>");
|
||||
template({ value: '<script>' });
|
||||
var compiled2 = _.template("<% print('Hello ' + epithet); %>");
|
||||
compiled2({ epithet: "stooge" });
|
||||
_.templateSettings = {
|
||||
interpolate: /\{\{(.+?)\}\}/g
|
||||
};
|
||||
var template2 = _.template("Hello {{ name }}!");
|
||||
template2({ name: "Mustache" });
|
||||
_.template("Using 'with': <%= data.answer %>", { answer: 'no' }, { variable: 'data' });
|
||||
Vendored
-2814
File diff suppressed because it is too large
Load Diff
Vendored
+2757
-289
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user