Merge remote-tracking branch 'upstream/master'

This commit is contained in:
bgrieder
2015-10-22 10:08:09 +02:00
87 changed files with 9312 additions and 22156 deletions
+1
View File
@@ -1119,6 +1119,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](simple-cw-node/simple-cw-node.d.ts) [simple-cw-node](https://github.com/astronaughts/simple-cw-node) by [vvakame](https://github.com/vvakame)
* [:link:](simplebar/simplebar.d.ts) [simplebar.js](https://github.com/Grsmto/simplebar) by [Gregor Woiwode](https://github.com/gregonnet)
* [:link:](jquery.simplemodal/jquery.simplemodal.d.ts) [SimpleModal](http://www.ericmmartin.com/projects/simplemodal) by [Friedrich von Never](https://github.com/ForNeVeR)
* [:link:](simpleStorage/simplestorage.js.d.ts) [simpleStorage](https://github.com/andris9/simpleStorage) by [Áxel Costas Pena](https://github.com/axelcostaspena)
* [:link:](sinon/sinon.d.ts) [Sinon](http://sinonjs.org) by [William Sears](https://github.com/mrbigdog2u)
* [:link:](sinon-chai/sinon-chai.d.ts) [sinon-chai](https://github.com/domenic/sinon-chai) by [Kazi Manzur Rashid](https://github.com/kazimanzurrashid), [Jed Mao](https://github.com/jedmao)
* [:link:](sinon-chrome/sinon-chrome.d.ts) [Sinon-Chrome](https://github.com/vitalets/sinon-chrome) by [Tim Perry](https://github.com/pimterry)
+3 -2
View File
@@ -6,6 +6,7 @@
function testSaveAs() {
var data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
var filename: string = 'hello world.txt';
saveAs(data, filename);
var disableAutoBOM = true;
saveAs(data, filename, disableAutoBOM);
}
+8 -2
View File
@@ -20,8 +20,14 @@ interface FileSaver {
* @summary File name.
* @type {DOMString}
*/
filename: string
filename: string,
/**
* @summary Disable Unicode text encoding hints or not.
* @type {boolean}
*/
disableAutoBOM?: boolean
): void
}
declare var saveAs: FileSaver;
declare var saveAs: FileSaver;
+1 -1
View File
@@ -34,7 +34,7 @@ Please see the [contribution guide](http://definitelytyped.org/guides/contributi
Here is are the [currently requested definitions](https://github.com/borisyankov/DefinitelyTyped/labels/Definition%3ARequest).
## Licence
## License
This project is licensed under the MIT license.
+32
View File
@@ -1,5 +1,6 @@
/// <reference path="amqplib.d.ts" />
// promise api tests
import amqp = require("amqplib");
var msg = "Hello World";
@@ -19,3 +20,34 @@ amqp.connect("amqp://localhost")
.then(channel => channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())))
.ensure(() => connection.close());
});
// callback api tests
import amqpcb = require("amqplib/callback_api");
amqpcb.connect("amqp://localhost", (err, connection) => {
if(!err) {
connection.createChannel((err, channel) => {
if (!err) {
channel.assertQueue("myQueue", {}, (err, ok) => {
if(!err) {
channel.sendToQueue("myQueue", new Buffer(msg));
}
});
}
});
}
});
amqpcb.connect("amqp://localhost", (err, connection) => {
if(!err) {
connection.createChannel((err, channel) => {
if (!err) {
channel.assertQueue("myQueue", {}, (err, ok) => {
if(!err) {
channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString()));
}
});
}
});
}
});
+87 -13
View File
@@ -1,22 +1,12 @@
// Type definitions for amqplib 0.3.x
// Project: https://github.com/squaremo/amqp.node
// Definitions by: Michael Nahkies <https://github.com/mnahkies>
// Definitions by: Michael Nahkies <https://github.com/mnahkies>, Ab Reitsma <https://github.com/abreits>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../when/when.d.ts" />
/// <reference path="../node/node.d.ts" />
declare module "amqplib" {
import events = require("events");
import when = require("when");
interface Connection extends events.EventEmitter {
close(): when.Promise<void>;
createChannel(): when.Promise<Channel>;
createConfirmChannel(): when.Promise<Channel>;
}
declare module "amqplib/properties" {
module Replies {
interface Empty {
}
@@ -25,6 +15,9 @@ declare module "amqplib" {
messageCount: number;
consumerCount: number;
}
interface PurgeQueue {
messageCount: number;
}
interface DeleteQueue {
messageCount: number;
}
@@ -100,6 +93,22 @@ declare module "amqplib" {
fields: Object;
properties: Object;
}
}
declare module "amqplib" {
import events = require("events");
import when = require("when");
import shared = require("amqplib/properties")
import Replies = shared.Replies;
import Options = shared.Options;
import Message = shared.Message;
interface Connection extends events.EventEmitter {
close(): when.Promise<void>;
createChannel(): when.Promise<Channel>;
createConfirmChannel(): when.Promise<Channel>;
}
interface Channel extends events.EventEmitter {
close(): when.Promise<void>;
@@ -108,7 +117,7 @@ declare module "amqplib" {
checkQueue(queue: string): when.Promise<Replies.AssertQueue>;
deleteQueue(queue: string, options?: Options.DeleteQueue): when.Promise<Replies.DeleteQueue>;
purgeQueue(queue: string): when.Promise<Replies.DeleteQueue>;
purgeQueue(queue: string): when.Promise<Replies.PurgeQueue>;
bindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
unbindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
@@ -142,3 +151,68 @@ declare module "amqplib" {
function connect(url: string, socketOptions?: any): when.Promise<Connection>;
}
declare module "amqplib/callback_api" {
import events = require("events");
import shared = require("amqplib/properties")
import Replies = shared.Replies;
import Options = shared.Options;
import Message = shared.Message;
interface Connection extends events.EventEmitter {
close(callback?: (err: any) => void): void;
createChannel(callback: (err: any, channel: Channel) => void): void;
createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void;
}
interface Channel extends events.EventEmitter {
close(callback: (err: any) => void): void;
assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void): void;
checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void): void;
purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void): void;
bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void): void;
checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void): void;
deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void): void;
bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void;
cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void;
get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void): void;
ack(message: Message, allUpTo?: boolean): void;
ackAll(): void;
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
nackAll(requeue?: boolean): void;
reject(message: Message, requeue?: boolean): void;
prefetch(count: number, global?: boolean): void;
recover(callback?: (err: any, ok: Replies.Empty) => void): void;
}
interface ConfirmChannel extends Channel {
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
waitForConfirms(callback?: (err: any) => void): void;
}
function connect(callback: (err: any, connection: Connection) => void): void;
function connect(url: string, callback: (err: any, connection: Connection) => void): void;
function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void): void;
}
+9
View File
@@ -80,3 +80,12 @@ function testIntegrations(): void {
}
});
}
function testFlush(): void {
analytics.flush();
analytics.flush(function(err, batch) {
if (err) { alert("Oh nos!"); }
else { console.log(batch.batch[0].type); }
});
}
+10
View File
@@ -65,6 +65,16 @@ declare module AnalyticsNode {
anonymous_id?: string | number;
integrations?: Integrations;
}): Analytics;
/* Flush batched calls to make sure nothing is left in the queue */
flush(fn?: (err: Error, batch: {
batch: Array<{
type: string;
}>;
messageId: string;
sentAt: Date;
timestamp: Date;
}) => void): Analytics;
}
}
+11 -5
View File
@@ -71,10 +71,16 @@ declare module angular.ui {
* Arbitrary data object, useful for custom configuration.
*/
data?: any;
/**
* Boolean (default true). If false will not re-trigger the same state just because a search/query parameter has changed. Useful for when you'd like to modify $location.search() without triggering a reload.
*/
reloadOnSearch?: boolean;
/**
* Boolean (default true). If false will reload state on everytransitions. Useful for when you'd like to restore all data to its initial state.
*/
cache?: boolean;
}
interface IStateProvider extends angular.IServiceProvider {
@@ -229,10 +235,10 @@ declare module angular.ui {
*/
go(to: string, params?: {}, options?: IStateOptions): angular.IPromise<any>;
go(to: IState, params?: {}, options?: IStateOptions): angular.IPromise<any>;
transitionTo(state: string, params?: {}, updateLocation?: boolean): void;
transitionTo(state: IState, params?: {}, updateLocation?: boolean): void;
transitionTo(state: string, params?: {}, options?: IStateOptions): void;
transitionTo(state: IState, params?: {}, options?: IStateOptions): void;
transitionTo(state: string, params?: {}, updateLocation?: boolean): ng.IPromise<any>;
transitionTo(state: IState, params?: {}, updateLocation?: boolean): ng.IPromise<any>;
transitionTo(state: string, params?: {}, options?: IStateOptions): ng.IPromise<any>;
transitionTo(state: IState, params?: {}, options?: IStateOptions): ng.IPromise<any>;
includes(state: string, params?: {}): boolean;
is(state:string, params?: {}): boolean;
is(state: IState, params?: {}): boolean;
@@ -244,7 +250,7 @@ declare module angular.ui {
current: IState;
/** A param object, e.g. {sectionId: section.id)}, that you'd like to test against the current active state. */
params: IStateParamsService;
reload(): void;
reload(): ng.IPromise<any>;
/** Currently pending transition. A promise that'll resolve or reject. */
transition: ng.IPromise<{}>;
+1 -41
View File
@@ -1,43 +1,3 @@
/// <reference path="angular2.d.ts"/>
/// <reference path="router.d.ts"/>
import {Component, View, Directive, bootstrap, bind, NgFor, NgIf} from "angular2/angular2";
class Service {
}
class Service2 {
}
class Cmp {
static annotations: any[];
}
Cmp.annotations = [
Component({
selector: 'cmp',
bindings: [Service, bind(Service2).toValue(null)]
}),
View({
template: '{{greeting}} world!',
directives: [NgFor, NgIf]
}),
Directive({
selector: '[tooltip]',
inputs: [
'text: tooltip'
],
outputs: [
'(mouseenter):onMouseEnter()',
'(mouseleave):onMouseLeave()'
]
})
];
@Component({selector: 'cmp2'})
@View({templateUrl: '/index.html'})
class Cmp2 {
}
bootstrap(Cmp);
// No tests, because angular 2 typings are not in DefinitelyTyped.
-1
View File
@@ -1 +0,0 @@
--experimentalDecorators --noImplicitAny --target ES5
+9 -17101
View File
File diff suppressed because it is too large Load Diff
-1310
View File
File diff suppressed because it is too large Load Diff
-1330
View File
File diff suppressed because it is too large Load Diff
-408
View File
@@ -1,408 +0,0 @@
// Type definitions for Angular v2.0.0-local_sha.7d5c3eb
// Project: http://angular.io/
// Definitions by: angular team <https://github.com/angular/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// ***********************************************************
// This file is generated by the Angular build process.
// Please do not create manual edits or send pull requests
// modifying this file.
// ***********************************************************
// angular2/test_lib depends transitively on these libraries.
// If you don't have them installed you can install them using TSD
// https://github.com/DefinitelyTyped/tsd
///<reference path="./angular2.d.ts"/>
///<reference path="../jasmine/jasmine.d.ts"/>
declare module ngTestLib {
/**
* Allows injecting dependencies in `beforeEach()` and `it()`.
*
* Example:
*
* ```
* beforeEach(inject([Dependency, AClass], (dep, object) => {
* // some code that uses `dep` and `object`
* // ...
* }));
*
* it('...', inject([AClass, AsyncTestCompleter], (object, async) => {
* object.doSomething().then(() => {
* expect(...);
* async.done();
* });
* })
* ```
*
* Notes:
* - injecting an `AsyncTestCompleter` allow completing async tests - this is the equivalent of
* adding a `done` parameter in Jasmine,
* - inject is currently a function because of some Traceur limitation the syntax should eventually
* becomes `it('...', @Inject (object: AClass, async: AsyncTestCompleter) => { ... });`
*
* @param {Array} tokens
* @param {Function} fn
* @return {FunctionWithParamTokens}
*/
function inject(tokens: any[], fn: Function): FunctionWithParamTokens;
var proxy: ClassDecorator;
var afterEach: Function;
type SyncTestFn = () => void
interface NgMatchers extends jasmine.Matchers {
toBe(expected: any): boolean;
toEqual(expected: any): boolean;
toBePromise(): boolean;
toBeAnInstanceOf(expected: any): boolean;
toHaveText(expected: any): boolean;
toHaveCssClass(expected: any): boolean;
toImplement(expected: any): boolean;
toContainError(expected: any): boolean;
toThrowErrorWith(expectedMessage: any): boolean;
not: NgMatchers;
}
var expect: (actual: any) => NgMatchers;
class AsyncTestCompleter {
constructor(_done: Function);
done(): void;
}
function describe(...args: any[]): void;
function ddescribe(...args: any[]): void;
function xdescribe(...args: any[]): void;
function beforeEach(fn: FunctionWithParamTokens | SyncTestFn): void;
/**
* Allows overriding default bindings defined in test_injector.js.
*
* The given function must return a list of DI bindings.
*
* Example:
*
* beforeEachBindings(() => [
* bind(Compiler).toClass(MockCompiler),
* bind(SomeToken).toValue(myValue),
* ]);
*/
function beforeEachBindings(fn: any): void;
function it(name: any, fn: any, timeOut?: any): void;
function xit(name: any, fn: any, timeOut?: any): void;
function iit(name: any, fn: any, timeOut?: any): void;
interface GuinessCompatibleSpy extends jasmine.Spy {
/**
* By chaining the spy with and.returnValue, all calls to the function will return a specific
* value.
*/
andReturn(val: any): void;
/**
* By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied
* function.
*/
andCallFake(fn: Function): GuinessCompatibleSpy;
/**
* removes all recorded calls
*/
reset(): void;
}
class SpyObject {
constructor(type?: any);
static stub(object?: any, config?: any, overrides?: any): void;
noSuchMethod(args: any): void;
spy(name: any): void;
prop(name: any, value: any): void;
}
function isInInnerZone(): boolean;
interface RootTestComponent {
debugElement: ng.DebugElement;
detectChanges(): void;
destroy(): void;
}
/**
* Builds a RootTestComponent for use in component level tests.
*/
class TestComponentBuilder {
constructor(_injector: ng.Injector);
/**
* Overrides only the html of a {@link ComponentMetadata}.
* All the other properties of the component's {@link ng.ViewMetadata} are preserved.
*
* @param {ng.Type} component
* @param {string} html
*
* @return {TestComponentBuilder}
*/
overrideTemplate(componentType: ng.Type, template: string): TestComponentBuilder;
/**
* Overrides a component's {@link ng.ViewMetadata}.
*
* @param {ng.Type} component
* @param {view} View
*
* @return {TestComponentBuilder}
*/
overrideView(componentType: ng.Type, view: ng.ViewMetadata): TestComponentBuilder;
/**
* Overrides the directives from the component {@link ng.ViewMetadata}.
*
* @param {ng.Type} component
* @param {ng.Type} from
* @param {ng.Type} to
*
* @return {TestComponentBuilder}
*/
overrideDirective(componentType: ng.Type, from: ng.Type, to: ng.Type): TestComponentBuilder;
/**
* Overrides one or more injectables configured via `bindings` metadata property of a directive or
* component.
* Very useful when certain bindings need to be mocked out.
*
* The bindings specified via this method are appended to the existing `bindings` causing the
* duplicated bindings to
* be overridden.
*
* @param {ng.Type} component
* @param {any[]} bindings
*
* @return {TestComponentBuilder}
*/
overrideBindings(type: ng.Type, bindings: any[]): TestComponentBuilder;
/**
* Overrides one or more injectables configured via `bindings` metadata property of a directive or
* component.
* Very useful when certain bindings need to be mocked out.
*
* The bindings specified via this method are appended to the existing `bindings` causing the
* duplicated bindings to
* be overridden.
*
* @param {ng.Type} component
* @param {any[]} bindings
*
* @return {TestComponentBuilder}
*/
overrideViewBindings(type: ng.Type, bindings: any[]): TestComponentBuilder;
/**
* Builds and returns a RootTestComponent.
*
* @return {Promise<RootTestComponent>}
*/
createAsync(rootComponentType: ng.Type): Promise<RootTestComponent>;
}
function createTestInjector(bindings: Array<ng.Type | ng.Binding | any[]>): ng.Injector;
class FunctionWithParamTokens {
constructor(_tokens: any[], _fn: Function);
/**
* Returns the value of the executed function.
*/
execute(injector: ng.Injector): any;
hasToken(token: any): boolean;
}
/**
* Wraps a function to be executed in the fakeAsync zone:
* - microtasks are manually executed by calling `flushMicrotasks()`,
* - timers are synchronous, `tick()` simulates the asynchronous passage of time.
*
* If there are any pending timers at the end of the function, an exception will be thrown.
*
* @param fn
* @returns {Function} The function wrapped to be executed in the fakeAsync zone
*/
function fakeAsync(fn: Function): Function;
function clearPendingTimers(): void;
/**
* Simulates the asynchronous passage of time for the timers in the fakeAsync zone.
*
* The microtasks queue is drained at the very start of this function and after any timer callback
* has been executed.
*
* @param {number} millis Number of millisecond, defaults to 0
*/
function tick(millis?: number): void;
/**
* Flush any pending microtasks.
*/
function flushMicrotasks(): void;
class Log {
constructor();
add(value: any): void;
fn(value: any): void;
clear(): void;
result(): string;
}
class BrowserDetection {
constructor(ua: string);
isFirefox: boolean;
isAndroid: boolean;
isEdge: boolean;
isIE: boolean;
isWebkit: boolean;
isIOS7: boolean;
isSlow: boolean;
supportsIntlApi: boolean;
}
var browserDetection: BrowserDetection;
function dispatchEvent(element: any, eventType: any): void;
function el(html: string): HTMLElement;
function containsRegexp(input: string): RegExp;
function normalizeCSS(css: string): string;
function stringifyElement(el: any): string;
var RootTestComponent: ng.InjectableReference;
}
declare module "angular2/test_lib" {
export = ngTestLib;
}
+3 -3
View File
@@ -76,11 +76,11 @@ interface Async {
each<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
eachSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
eachLimit<T>(arr: T[], limit: number, iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
forEachOf(obj: any, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void;
forEachOf(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void;
forEachOf<T>(obj: T[], iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
forEachOfSeries(obj: any, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void;
forEachOfSeries(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void;
forEachOfSeries<T>(obj: T[], iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
forEachOfLimit(obj: any, limit: number, iterator: (item: any, key: [string|number], callback?: ErrorCallback) => void, callback: ErrorCallback): void;
forEachOfLimit(obj: any, limit: number, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void;
forEachOfLimit<T>(obj: T[], limit: number, iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
map<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
mapSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
+237
View File
@@ -0,0 +1,237 @@
/// <reference path="./benchmark.d.ts"/>
import Benchmark = require("benchmark");
var suite = new Benchmark.Suite;
// add tests
suite.add('RegExp#test', function() {
/o/.test('Hello World!');
})
.add('String#indexOf', function() {
'Hello World!'.indexOf('o') > -1;
})
.add('String#match', function() {
!!'Hello World!'.match(/o/);
})
// add listeners
.on('cycle', function(event: {target: any}) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
})
// run async
.run({ 'async': true });
var fn: Function;
var onStart: Function;
var onCycle: Function;
var onAbort: Function;
var onError: Function;
var onReset: Function;
var onComplete: Function;
var setup: Function;
var teardown: Function;
var benches: Benchmark[];
var listener: Function;
var count: number;
// basic usage (the `new` operator is optional)
var bench = new Benchmark(fn);
// or using a name first
var bench = new Benchmark('foo', fn);
// or with options
var bench = new Benchmark('foo', fn, {
// displayed by Benchmark#toString if `name` is not available
'id': 'xyz',
// called when the benchmark starts running
'onStart': onStart,
// called after each run cycle
'onCycle': onCycle,
// called when aborted
'onAbort': onAbort,
// called when a test errors
'onError': onError,
// called when reset
'onReset': onReset,
// called when the benchmark completes running
'onComplete': onComplete,
// compiled/called before the test loop
'setup': setup,
// compiled/called after the test loop
'teardown': teardown
});
// or name and options
var bench = new Benchmark('foo', {
// a flag to indicate the benchmark is deferred
'defer': true,
// benchmark test function
'fn': function(deferred: {resolve(): void}) {
// call resolve() when the deferred test is finished
deferred.resolve();
}
});
// or options only
var bench = new Benchmark({
// benchmark name
'name': 'foo',
// benchmark test as a string
'fn': '[1,2,3,4].sort()'
});
// a tests `this` binding is set to the benchmark instance
var bench = new Benchmark('foo', function() {
'My name is '.concat(this.name); // My name is foo
});
// get odd numbers
Benchmark.filter([1, 2, 3, 4, 5], function(n) {
return n % 2;
}); // -> [1, 3, 5];
// get fastest benchmarks
Benchmark.filter(benches, 'fastest');
// get slowest benchmarks
Benchmark.filter(benches, 'slowest');
// get benchmarks that completed without erroring
Benchmark.filter(benches, 'successful');
// invoke `reset` on all benchmarks
Benchmark.invoke(benches, 'reset');
// invoke `emit` with arguments
Benchmark.invoke(benches, 'emit', 'complete', listener);
// invoke `run(true)`, treat benchmarks as a queue, and register invoke callbacks
Benchmark.invoke(benches, {
// invoke the `run` method
'name': 'run',
// pass a single argument
'args': true,
// treat as queue, removing benchmarks from front of `benches` until empty
'queued': true,
// called before any benchmarks have been invoked.
'onStart': onStart,
// called between invoking benchmarks
'onCycle': onCycle,
// called after all benchmarks have been invoked.
'onComplete': onComplete
});
var element: HTMLElement;
// basic usage
var bench = new Benchmark({
'setup': function() {
var c = this.count,
element = document.getElementById('container');
while (c--) {
element.appendChild(document.createElement('div'));
}
},
'fn': function() {
element.removeChild(element.lastChild);
}
});
// or using strings
var bench = new Benchmark({
'setup': '\
var a = 0;\n\
(function() {\n\
(function() {\n\
(function() {',
'fn': 'a += 1;',
'teardown': '\
}())\n\
}())\n\
}())'
});
var bizarro = bench.clone({
'name': 'doppelganger'
});
// unregister a listener for an event type
bench.off('cycle', listener);
// unregister a listener for multiple event types
bench.off('start cycle', listener);
// unregister all listeners for an event type
bench.off('cycle');
// unregister all listeners for multiple event types
bench.off('start cycle complete');
// unregister all listeners for all event types
bench.off();
// register a listener for an event type
bench.on('cycle', listener);
// register a listener for multiple event types
bench.on('start cycle', listener);
// basic usage
bench.run();
// or with options
bench.run({ 'async': true });
// basic usage
suite.add(fn);
// or using a name first
suite.add('foo', fn);
// or with options
suite.add('foo', fn, {
'onCycle': onCycle,
'onComplete': onComplete
});
// or name and options
suite.add('foo', {
'fn': fn,
'onCycle': onCycle,
'onComplete': onComplete
});
// or options only
suite.add({
'name': 'foo',
'fn': fn,
'onCycle': onCycle,
'onComplete': onComplete
});
// basic usage
suite.run();
// or with options
suite.run({ 'async': true, 'queued': true });
+192
View File
@@ -0,0 +1,192 @@
// Type definitions for Benchmark v1.0.0
// Project: http://benchmarkjs.com
// Definitions by: Asana <https://asana.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "benchmark" {
class Benchmark {
static deepClone<T>(value: T): T;
static each(obj: Object | any[], callback: Function, thisArg?: any): void;
static extend(destination: Object, ...sources: Object[]): Object;
static filter<T>(arr: T[], callback: (value: T) => any, thisArg?: any): T[];
static filter<T>(arr: T[], filter: string, thisArg?: any): T[];
static forEach<T>(arr: T[], callback: (value: T) => any, thisArg?: any): void;
static formatNumber(num: number): string;
static forOwn(obj: Object, callback: Function, thisArg?: any): void;
static hasKey(obj: Object, key: string): boolean;
static indexOf<T>(arr: T[], value: T, fromIndex?: number): number;
static interpolate(template: string, values: Object): string;
static invoke(benches: Benchmark[], name: string | Object, ...args: any[]): any[];
static join(obj: Object, separator1?: string, separator2?: string): string;
static map<T, K>(arr: T[], callback: (value: T) => K, thisArg?: any): K[];
static pluck<T, K>(arr: T[], key: string): K[];
static reduce<T, K>(arr: T[], callback: (accumulator: K, value: T) => K, thisArg?: any): K;
static options: Benchmark.Options;
static platform: Benchmark.Platform;
static support: Benchmark.Support;
static version: string;
constructor(fn: Function | string, options?: Benchmark.Options);
constructor(name: string, fn: Function | string, options?: Benchmark.Options);
constructor(name: string, options?: Benchmark.Options);
constructor(options: Benchmark.Options);
aborted: boolean;
compiled: Function | string;
count: number;
cycles: number;
error: Error;
fn: Function | string;
hz: number;
running: boolean;
setup: Function | string;
teardown: Function | string;
stats: Benchmark.Stats;
times: Benchmark.Times;
abort(): Benchmark;
clone(options: Benchmark.Options): Benchmark;
compare(benchmark: Benchmark): number;
emit(type: string | Object): any;
listeners(type: string): Function[];
off(type?: string, listener?: Function): Benchmark;
off(types: string[]): Benchmark;
on(type?: string, listener?: Function): Benchmark;
on(types: string[]): Benchmark;
reset(): Benchmark;
run(options?: Benchmark.Options): Benchmark;
toString(): string;
}
module Benchmark {
export interface Options {
async?: boolean;
defer?: boolean;
delay?: number;
id?: string;
initCount?: number;
maxTime?: number;
minSamples?: number;
minTime?: number;
name?: string;
onAbort?: Function;
onComplete?: Function;
onCycle?: Function;
onError?: Function;
onReset?: Function;
onStart?: Function;
setup?: Function | string;
teardown?: Function | string;
fn?: Function | string;
queued?: boolean;
}
export interface Platform {
description: string;
layout: string;
manufacturer: string;
name: string;
os: string;
prerelease: string;
product: string;
version: string;
toString(): string;
}
export interface Support {
air: boolean;
argumentsClass: boolean;
browser: boolean;
charByIndex: boolean;
charByOwnIndex: boolean;
decompilation: boolean;
descriptors: boolean;
getAllKeys: boolean;
iteratesOwnFirst: boolean;
java: boolean;
nodeClass: boolean;
timeout: boolean;
}
export interface Stats {
deviation: number;
mean: number;
moe: number;
rme: number;
sample: any[];
sem: number;
variance: number;
}
export interface Times {
cycle: number;
elapsed: number;
period: number;
timeStamp: number;
}
export class Deferred {
constructor(clone: Benchmark);
benchmark: Benchmark;
cycles: number;
elapsed: number;
timeStamp: number;
}
export class Event {
constructor(type: string | Object);
aborted: boolean;
cancelled: boolean;
currentTarget: Object;
result: any;
target: Object;
timeStamp: number;
type: string;
}
export class Suite {
static options: { name: string };
constructor(name?: string, options?: Options);
aborted: boolean;
length: number;
running: boolean;
abort(): Suite;
add(name: string, fn: Function | string, options?: Options): Suite;
add(fn: Function | string, options?: Options): Suite;
add(name: string, options?: Options): Suite;
add(options: Options): Suite;
clone(options: Options): Suite;
emit(type: string | Object): any;
filter(callback: Function | string): Suite;
forEach(callback: Function): Suite;
indexOf(value: any): number;
invoke(name: string, ...args: any[]): any[];
join(separator?: string): string;
listeners(type: string): Function[];
map(callback: Function): any[];
off(type?: string, callback?: Function): Benchmark;
off(types: string[]): Benchmark;
on(type?: string, callback?: Function): Benchmark;
on(types: string[]): Benchmark;
pluck(property: string): any[];
pop(): Function;
push(benchmark: Benchmark): number;
reduce<T>(callback: Function, accumulator: T): T;
reset(): Suite;
reverse(): any[];
run(options?: Options): Suite;
shift(): Benchmark;
slice(start: number, end: number): any[];
slice(start: number, deleteCount: number, ...values: any[]): any[];
unshift(benchmark: Benchmark): number;
}
}
export = Benchmark;
}
+77
View File
@@ -0,0 +1,77 @@
/// <reference path="./bounce.d.ts" />
/// <reference path="./../jquery/jquery.d.ts" />
import Bounce from 'bounce.js';
import * as $ from 'jquery';
function test_chaining_transformations() {
var bounce = new Bounce();
bounce
.scale({
from: { x: 0, y: 0 },
to: { x: 2, y: 2 },
duration: 1000
})
.rotate({
from: 0,
to: 360,
delay: 500
})
.translate({
from: { x: 0, y: -100 },
to: { x: 0, y: 0 },
stiffness: 1,
bounces: 4
})
.skew({
from: { x: 1, y: 0.8 },
to: { x: 0.8, y: 1 },
easing: 'bounce'
});
}
function test_serialization() {
var b1 = new Bounce();
var serialized = b1.serialize();
var b2 = new Bounce();
b2.deserialize(serialized);
}
function test_apply () {
var bounce = new Bounce();
var element = document.createElement('div');
bounce.applyTo(element);
bounce.applyTo([element]);
bounce.applyTo($('div'));
var options = {
loop: true,
remove: true,
onComplete: () => {}
};
bounce.applyTo(element, options);
bounce.applyTo([element], options);
bounce.applyTo($('div'), options);
}
function test_apply_promise () {
var bounce = new Bounce();
var element = document.createElement('div');
bounce.applyTo($('div')).then(() => {});
var options = {
loop: true,
remove: true
};
bounce.applyTo($('div')).then(() => {});
}
function test_define() {
var bounce = new Bounce();
bounce.define('named-animation');
}
function test_remove() {
var bounce = new Bounce();
bounce.remove();
}
+66
View File
@@ -0,0 +1,66 @@
// Type definitions for Bounce.js v0.8.2
// Project: http://github.com/tictail/bounce.js
// Definitions by: Cherry <http://github.com/cherrry>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts"/>
declare module 'bounce.js' {
export default Bounce
interface Point2D {
x: number
y: number
}
interface BounceOptions<T> {
from: T
to: T
duration?: number
delay?: number
easing?: string
bounces?: number
stiffness?: number
}
interface AnimationOptions {
loop?: boolean
remove?: boolean
onComplete?: () => void
}
interface SerailizedComponent<T> {
type: string
from: T
to: T
duration: number
delay: number
easing: string
bounces: number
stiffness: number
}
class Bounce {
static FPS: number
static counter: number
static isSupported(): boolean
constructor();
scale(options: BounceOptions<Point2D>): Bounce
rotate(options: BounceOptions<number>): Bounce
translate(options: BounceOptions<Point2D>): Bounce
skew(options: BounceOptions<Point2D>): Bounce
serialize(): SerailizedComponent<number|Point2D>[]
deserialize(serailized: SerailizedComponent<number|Point2D>[]): Bounce
applyTo(element: Element, options?: AnimationOptions): void
applyTo(elements: Element[], options?: AnimationOptions): void
applyTo(elements: JQuery, options?: AnimationOptions): JQueryPromise<void>
define(name: string): Bounce
remove(): void
}
}
+3
View File
@@ -64,6 +64,7 @@ declare module CKEDITOR {
var status: string;
var timestamp: string;
var version: string;
var config: config;
// Methods
@@ -556,6 +557,7 @@ declare module CKEDITOR {
}
interface config {
contentsCss?: string | string[];
startupMode?: string;
removeButtons?: string;
removePlugins?: string;
@@ -576,6 +578,7 @@ declare module CKEDITOR {
height?: string | number;
toolbarLocation?: string;
readOnly?: boolean;
customConfig?: string;
}
@@ -0,0 +1,17 @@
/// <reference path="closure-compiler.d.ts"/>
import {compile} from 'closure-compiler';
compile('some.source()', {'check-only': null},
(err: Error, stdout: string, stderr: string): void => {
console.log('Got', err, 'stdout', stdout, 'stderr', stderr);
});
// No options, Callback wins.
compile('some.source()', (err: Error, stdout: string, stderr: string): void => {
console.log('Got', err, 'stdout', stdout, 'stderr', stderr);
});
compile(null, {'js': ['a/f.js', 'a/f2.js'], 'check-only': null},
(err: Error, stdout: string, stderr: string): void => {
console.log('Got', err, 'stdout', stdout, 'stderr', stderr);
});
+11
View File
@@ -0,0 +1,11 @@
// Type definitions for closure-compiler
// Project: https://github.com/tim-smart/node-closure/
// Definitions by: Martin Probst <https://github.com/mprobst>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'closure-compiler' {
type Callback = (err: Error, stdout: string, stderr: string) => any;
function compile(src: string, callback: Callback): void;
function compile(src: string, options: {[k: string]: string | string[]},
callback: Callback): void;
}
+32
View File
@@ -0,0 +1,32 @@
/// <reference path="./connect.d.ts" />
import * as http from "http";
import * as connect from "connect";
const app = connect();
// log all requests
app.use((req: http.IncomingMessage, res: http.ServerResponse, next: Function) => {
console.log(req, res);
next();
});
// Stop on errors
app.use((err: Error, req: http.IncomingMessage, res: http.ServerResponse, next: Function) => {
if (err) {
return res.end(`Error: ${err}`);
}
next();
});
// respond to all requests
app.use((req: http.IncomingMessage, res: http.ServerResponse) => {
res.end("Hello from Connect!\n");
});
//create node.js http server and listen on port
http.createServer(app).listen(3000);
//create node.js http server and listen on port using connect shortcut
app.listen(3000);
+92
View File
@@ -0,0 +1,92 @@
// Type definitions for connect v3.4.0
// Project: https://github.com/senchalabs/connect
// Definitions by: Maxime LUCE <https://github.com/SomaticIT/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "connect" {
import * as http from "http";
/**
* Create a new connect server.
* @public
*/
function createServer(): createServer.Server;
module createServer {
export type ServerHandle = HandleFunction | http.Server;
export type SimpleHandleFunction = (req: http.IncomingMessage, res: http.ServerResponse) => void;
export type NextHandleFunction = (req: http.IncomingMessage, res: http.ServerResponse, next: Function) => void;
export type ErrorHandleFunction = (err: Error, req: http.IncomingMessage, res: http.ServerResponse, next: Function) => void;
export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
export interface ServerStackItem {
route: string;
handle: ServerHandle;
}
export interface Server extends NodeJS.EventEmitter {
(req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void;
route: string;
stack: ServerStackItem[];
/**
* Utilize the given middleware `handle` to the given `route`,
* defaulting to _/_. This "route" is the mount-point for the
* middleware, when given a value other than _/_ the middleware
* is only effective when that segment is present in the request's
* pathname.
*
* For example if we were to mount a function at _/admin_, it would
* be invoked on _/admin_, and _/admin/settings_, however it would
* not be invoked for _/_, or _/posts_.
*
* @public
*/
use(fn: HandleFunction): Server;
use(route: string, fn: HandleFunction): Server;
/**
* Handle server requests, punting them down
* the middleware stack.
*
* @private
*/
handle(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void;
/**
* Listen for connections.
*
* This method takes the same arguments
* as node's `http.Server#listen()`.
*
* HTTP and HTTPS:
*
* If you run your application both as HTTP
* and HTTPS you may wrap them individually,
* since your Connect "server" is really just
* a JavaScript `Function`.
*
* var connect = require('connect')
* , http = require('http')
* , https = require('https');
*
* var app = connect();
*
* http.createServer(app).listen(80);
* https.createServer(options, app).listen(443);
*
* @api public
*/
listen(port: number, hostname?: string, backlog?: number, callback?: Function): http.Server;
listen(port: number, hostname?: string, callback?: Function): http.Server;
listen(path: string, callback?: Function): http.Server;
listen(handle: any, listeningListener?: Function): http.Server;
}
}
export = createServer;
}
+10
View File
@@ -0,0 +1,10 @@
/// <reference path="denodeify.d.ts" />
/// <reference path="../es6-promise/es6-promise.d.ts" />
/// <reference path="../node/node.d.ts" />
import denodeify = require("denodeify");
import fs = require('fs');
import cp = require('child_process');
const readFile = denodeify<string,string,string>(fs.readFile);
const exec = denodeify<string,string>(cp.exec, (err, stdout, stderr) => [err, stdout]);
+36
View File
@@ -0,0 +1,36 @@
// Type definitions for denodeify 1.2.1
// Project: https://github.com/matthew-andrews/denodeify
// Definitions by: joaomoreno <https://github.com/joaomoreno/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../es6-promise/es6-promise.d.ts" />
declare module "denodeify" {
function _<R>(fn: _.F0<R>, transformer?: _.M): () => Promise<R>;
function _<A,R>(fn: _.F1<A,R>, transformer?: _.M): (a:A) => Promise<R>;
function _<A,B,R>(fn: _.F2<A,B,R>, transformer?: _.M): (a:A, b:B) => Promise<R>;
function _<A,B,C,R>(fn: _.F3<A,B,C,R>, transformer?: _.M): (a:A, b:B, c:C) => Promise<R>;
function _<A,B,C,D,R>(fn: _.F4<A,B,C,D,R>, transformer?: _.M): (a:A, b:B, c:C, d:D) => Promise<R>;
function _<A,B,C,D,E,R>(fn: _.F5<A,B,C,D,E,R>, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E) => Promise<R>;
function _<A,B,C,D,E,F,R>(fn: _.F6<A,B,C,D,E,F,R>, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E, f:F) => Promise<R>;
function _<A,B,C,D,E,F,G,R>(fn: _.F7<A,B,C,D,E,F,G,R>, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E, f:F, g:G) => Promise<R>;
function _<A,B,C,D,E,F,G,H,R>(fn: _.F8<A,B,C,D,E,F,G,H,R>, transformer?: _.M): (a:A, b:B, c:C, d:D, e:E, f:F, g:G, h:H) => Promise<R>;
function _(fn: _.F, transformer?: _.M): (...args: any[]) => Promise<any>;
module _ {
type Callback<R> = (err: Error, result: R) => any;
type F0<R> = (cb: Callback<R>) => any;
type F1<A,R> = (a:A, cb: Callback<R>) => any;
type F2<A,B,R> = (a:A, b:B, cb: Callback<R>) => any;
type F3<A,B,C,R> = (a:A, b:B, c:C, cb: Callback<R>) => any;
type F4<A,B,C,D,R> = (a:A, b:B, c:C, d:D, cb: Callback<R>) => any;
type F5<A,B,C,D,E,R> = (a:A, b:B, c:C, d:D, e:E, cb: Callback<R>) => any;
type F6<A,B,C,D,E,F,R> = (a:A, b:B, c:C, d:D, e:E, f:F, cb: Callback<R>) => any;
type F7<A,B,C,D,E,F,G,R> = (a:A, b:B, c:C, d:D, e:E, f:F, g:G, cb: Callback<R>) => any;
type F8<A,B,C,D,E,F,G,H,R> = (a:A, b:B, c:C, d:D, e:E, f:F, g:G, h:H, cb: Callback<R>) => any;
type F = (...args: any[]) => any;
type M = (err: Error, ...args: any[]) => any[];
}
export = _;
}
+11
View File
@@ -0,0 +1,11 @@
/// <reference path="docopt.d.ts" />
/// <reference path="../node/node.d.ts" />
var doc = `
Usage:
quick_example.coffee tcp <host> <port> [--timeout=<seconds>]
quick_example.coffee serial <port> [--baud=9600] [--timeout=<seconds>]
quick_example.coffee -h | --help | --version
`;
var {docopt} = require('docopt');
console.log(docopt(doc, { version: '0.1.1rc' }));
+23
View File
@@ -0,0 +1,23 @@
// Type definitions for Docopt v0.6.2
// Project: http://docopt.org/
// Definitions by: Giovanni Bassi <https://github.com/giggio/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface DocoptOption {
/** is an optional argument vector. It defaults to the arguments passed to your program (process.argv[2..]). You can also supply it with an array of strings, as with process.argv. For example: ['--verbose', '-o', 'hai.txt'] */
argv?: Array<string>,
/** (default:true) specifies whether the parser should automatically print the help message (supplied as doc) in case -h or --help options are encountered. After showing the usage-message, the program will terminate. If you want to handle -h or --help options manually (the same as other options), set help=false. */
help?: boolean,
/** (default:null) is an optional argument that specifies the version of your program. If supplied, then, if the parser encounters --version option, it will print the supplied version and terminate. version could be any printable object, but most likely a string, e.g. '2.1.0rc1'. */
version?: any,
/** (default false) If set to true will disallow mixing options and positional argument. I.e. after first positional argument, all arguments will be interpreted as positional even if the look like options. This can be used for strict compatibility with POSIX, or if you want to dispatch your arguments to other programs. */
options_first?: boolean,
/** (default true) If set to false will cause docopt to throw exceptions instead of printing the error to console and terminating the application. This flag is mainly for testing purposes. */
exit?: boolean
}
declare module "docopt" {
/**
* @param doc should be a string with the help message, written according to rules of the docopt language.
*/
export function docopt(doc: string, options: DocoptOption): any;
}
+2
View File
@@ -171,6 +171,8 @@ declare module Faker {
uuid(): string;
boolean(): boolean;
};
seed(value: number): void;
}
interface Card {
+17
View File
@@ -0,0 +1,17 @@
/// <reference path="./finalhandler.d.ts" />
import {ServerRequest, ServerResponse} from "http";
import finalHandler from "finalhandler";
let req: ServerRequest;
let res: ServerResponse;
let options: {
onerror: (err: any, req: ServerRequest, res: ServerResponse) => void;
message: boolean|((err: any, status: number) => string);
stacktrace: boolean;
};
let result: (err: any) => void;
result = finalHandler(req, res);
result = finalHandler(req, res, options);
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for finalhandler
// Project: https://github.com/pillarjs/finalhandler
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "finalhandler" {
import {ServerRequest, ServerResponse} from "http";
export interface Options {
message?: boolean|((err: any, status: number) => string);
onerror?: (err: any, req: ServerRequest, res: ServerResponse) => void;
stacktrace?: boolean;
}
function finalHandler(req: ServerRequest, res: ServerResponse, options?: Options): (err: any) => void;
export default finalHandler;
}
+57
View File
@@ -0,0 +1,57 @@
/// <reference path="./flat.d.ts" />
import {flatten, unflatten} from "flat";
module TestFlatten {
let options: {
delimiter?: string;
safe?: boolean;
maxDepth?: number;
};
type Target = {
a: {
b: number;
},
c: boolean[][];
};
let target: Target;
type Result = {
'a.b': number;
'c.0.0': boolean;
};
let result: Result;
result = flatten<Target, Result>(target);
result = flatten<Target, Result>(target, options);
}
module TestUnflatten {
let options: {
delimiter?: string;
object?: boolean;
overwrite?: boolean;
};
type Target = {
'a.b': number;
'c.0.0': boolean;
};
let target: Target;
type Result = {
a: {
b: number;
},
c: boolean[][];
};
let result: Result;
result = unflatten<Target, Result>(target);
result = unflatten<Target, Result>(target, options);
}
+41
View File
@@ -0,0 +1,41 @@
// Type definitions for flat
// Project: https://github.com/hughsk/flat
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module FlatTypes {
interface FlattenOptions {
delimiter?: string;
safe?: boolean;
maxDepth?: number;
}
interface Flatten {
<TTarget, TResult>(
target: TTarget,
options?: FlattenOptions
): TResult;
flatten: Flatten;
unflatten: Unflatten;
}
interface UnflattenOptions {
delimiter?: string;
object?: boolean;
overwrite?: boolean;
}
interface Unflatten {
<TTarget, TResult>(
target: TTarget,
options?: UnflattenOptions
): TResult;
}
}
declare module "flat" {
var flatten: FlatTypes.Flatten;
export = flatten;
}
+7
View File
@@ -406,6 +406,12 @@ declare module freedom.PgpProvider {
interface PublicKey {
key: string;
fingerprint: string;
words: string[];
}
interface KeyFingerprint {
fingerprint: string;
words: string[];
}
interface VerifyDecryptResult {
@@ -418,6 +424,7 @@ declare module freedom.PgpProvider {
setup(passphrase: string, userid: string): Promise<void>;
clear(): Promise<void>;
exportKey(): Promise<PublicKey>;
getFingerprint(publicKey: string): Promise<KeyFingerprint>;
signEncrypt(data: ArrayBuffer, encryptKey?: string,
sign?: boolean): Promise<ArrayBuffer>;
verifyDecrypt(data: ArrayBuffer,
+6
View File
@@ -192,6 +192,12 @@ declare module grunt {
*/
requires(prop: string, ...andProps: string[]): void
requires(prop: string[], ...andProps: string[][]): void
/**
* Recursively merges properties of the specified configObject into the current project configuration.
* You can use this method to append configuration options, targets, etc., to already defined tasks.
*/
merge<T>(configObject: T): void;
}
}
+3
View File
@@ -22,8 +22,11 @@ declare module "gulp-inject" {
ignorePath?: string | string[];
relative?: boolean;
addPrefix?: string;
addSuffix?: string;
addRootSlash?: boolean;
name?: string;
removeTags?: boolean;
empty?: boolean;
starttag?: string | ITagFunction;
endtag?: string | ITagFunction;
transform?: ITransformFunction;
-2
View File
@@ -3,8 +3,6 @@
// Definitions by: Philip Bulley <https://github.com/milkisevil/>, Han Lin Yap <https://github.com/codler>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../touch-events/touch-events.d.ts" />
declare var Hammer:HammerStatic;
declare module "hammerjs" {
+21
View File
@@ -0,0 +1,21 @@
/// <reference path="iniparser.d.ts" />
import * as iniparser from 'iniparser';
type Result = {section: {param: string}};
let file: string;
{
let callback: (err: any, data: Result) => void;
let result: void;
iniparser.parse(file, callback);
}
{
let result: Result;
result = iniparser.parseSync<Result>(file);
result = iniparser.parseString<Result>('');
}
+15
View File
@@ -0,0 +1,15 @@
// Type definitions for iniparser
// Project: https://github.com/shockie/node-iniparser
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "iniparser" {
export function parse<T>(
file: string,
callback: (err: any, data: T) => void
): void;
export function parseSync<T>(file: string): T;
export function parseString<T>(data: string): T;
}
+1
View File
@@ -40,6 +40,7 @@ declare module jest {
toBeFalsy(): boolean;
toBeTruthy(): boolean;
toBeNull(): boolean;
toBeDefined(): boolean;
toBeUndefined(): boolean;
toMatch(expected: RegExp): boolean;
toContain(expected: string): boolean;
+2
View File
@@ -11,6 +11,8 @@ interface PNotifyStack {
push?: string;
spacing1?: number;
spacing2?: number;
firstpos1?: number;
firstpos2?: number;
context?: JQuery
}
+8 -1
View File
@@ -12,6 +12,7 @@ var knex = Knex({
});
var knex = Knex({
debug: true,
client: 'mysql',
connection: {
socketPath : '/path/to/socket.sock',
@@ -32,7 +33,13 @@ var knex = Knex({
},
pool: {
min: 0,
max: 7
max: 7,
afterCreate: (connection: any, callback: Function) => {
return callback(null, connection);
},
beforeDestroy: (connection: any, callback: Function) => {
return callback(null, connection);
}
}
});
+5
View File
@@ -135,6 +135,8 @@ declare module "knex" {
transacting(trx: Transaction): QueryBuilder;
connection(connection: any): QueryBuilder;
clone(): QueryBuilder;
}
interface As {
@@ -394,6 +396,7 @@ declare module "knex" {
}
interface Config {
debug?: boolean;
client?: string;
dialect?: string;
connection: string|ConnectionConfig|
@@ -427,7 +430,9 @@ declare module "knex" {
interface PoolConfig {
name?: string;
create?: Function;
afterCreate?: Function;
destroy?: Function;
beforeDestroy?: Function;
min?: number;
max?: number;
refreshIdle?: boolean;
+10 -2
View File
@@ -11,6 +11,9 @@
Version 1.1 - added test for makeEditable
Version 1.2 - amended callback on commmand.fail() method - accepts response,
status and message values
Note: Typescript version 1.4 or higher is required for union types
and type declarations
*/
@@ -29,8 +32,13 @@ function CommandTests() {
.done((data: any) => {
alert("success");
})
.fail((error: string) => {
alert(error);
.fail((response) => {
// dummy
return false;
})
.fail((response, status, message) => {
// fail has response, error and text
alert(status + message);
});
// initialize command with options (action only)
+6 -2
View File
@@ -1,8 +1,9 @@
// Type definitions for ko.plus v0.0.21
// Type definitions for ko.plus v0.0.24
// Project: https://github.com/stevegreatrex/ko.plus
// Definitions by: Howard Richards <https://github.com/conficient>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="../knockout/knockout.d.ts" />
/**
@@ -16,6 +17,9 @@
*
* Version 1.1 - fixed bug - makeEditable is now a function on .editable
* also refactored how the Editable classes inherit to simplify
*
* Version 1.2 - amended callback on commmand.fail() method - accepts response,
* status and message values
*/
//
@@ -87,7 +91,7 @@ declare module KoPlus {
//
done: (callback: (data: any) => void) => Command;
fail: (callback: (error: string) => void) => Command;
fail: (callback: (response: any, status?: string, statusText?:string) => void) => Command;
always: (callback: Function) => Command;
+596 -166
View File
@@ -104,46 +104,43 @@ result = <(key: string) => any>testMapCache.get;
result = <(key: string) => boolean>testMapCache.has;
result = <(key: string, value: any) => _.Dictionary<any>>testMapCache.set;
/*************
* Chaining *
*************/
result = <_.LoDashWrapper<string>>_('test');
result = <_.LoDashWrapper<number>>_(1);
result = <_.LoDashWrapper<boolean>>_(true);
result = <_.LoDashArrayWrapper<string>>_(['test1', 'test2']);
// Appears to be a change in the compiler, if the type explicity implements the object indexer.
// Looking at: https://typescript.codeplex.com/wikipage?title=Known%20breaking%20changes%20between%200.8%20and%200.9&referringTitle=Documentation
// "The noimplicitany option now warns on the use of the hidden default indexer"
result = <_.LoDashObjectWrapper<_.Dictionary<string>>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' });
// _
module TestWrapper {
{
let result: _.LoDashImplicitWrapper<string>;
result = _('');
}
result = <_.LoDashWrapper<string>>_.chain('test');
result = <_.LoDashWrapper<string>>_('test').chain();
result = <_.LoDashWrapper<number>>_.chain(1);
result = <_.LoDashWrapper<number>>_(1).chain();
result = <_.LoDashWrapper<boolean>>_.chain(true);
result = <_.LoDashWrapper<boolean>>_(true).chain();
result = <_.LoDashArrayWrapper<string>>_.chain(['test1', 'test2']);
result = <_.LoDashArrayWrapper<string>>_(['test1', 'test2']).chain();
result = <_.LoDashObjectWrapper<_.Dictionary<string>>>_.chain(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' });
result = <_.LoDashObjectWrapper<_.Dictionary<string>>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).chain();
{
let result: _.LoDashImplicitWrapper<number>;
result = _(42);
}
{
let result: _.LoDashImplicitWrapper<boolean>;
result = _(true);
}
{
let result: _.LoDashImplicitArrayWrapper<string>;
result = _<string>(['']);
}
{
let result: _.LoDashImplicitObjectWrapper<{a: string}>;
result = _<{a: string}>({a: ''});
}
}
//Wrapped array shortcut methods
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).concat(5, 6);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).concat([5, 6]);
result = <string>_([1, 2, 3, 4]).join(',');
result = <number>_([1, 2, 3, 4]).pop();
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).push(5, 6, 7);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).reverse();
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).push(5, 6, 7);
result = <number>_([1, 2, 3, 4]).shift();
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).sort((a, b) => 1);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).splice(1);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).splice(1, 2, 5, 6);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).unshift(5, 6);
result = <number[]>_.tap([1, 2, 3, 4], function (array) { console.log(array); });
result = <_.LoDashWrapper<string>>_('test').tap(function (value) { console.log(value); });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).tap(function (array) { console.log(array); });
result = <_.LoDashObjectWrapper<_.Dictionary<string>>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).tap(function (array) { console.log(array); });
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).sort((a, b) => 1);
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).splice(1);
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).splice(1, 2, 5, 6);
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).unshift(5, 6);
result = <string>_('test').toString();
result = <string>_([1, 2, 3]).toString();
@@ -412,10 +409,10 @@ result = <Array<number>>_.flatten([1, [2], [[3]]], true);
result = <Array<number>>_.flatten<number>([1, [2], [3, [[4]]]], true);
result = <Array<number|boolean>>_.flatten<number|boolean>([1, [2], [3, [[false]]]], true);
result = <_.LoDashArrayWrapper<number>>_([[1, 2], [3, 4], 5, 6]).flatten();
result = <_.LoDashArrayWrapper<number|Array<Array<number>>>>_([1, [2], [3, [[4]]]]).flatten();
result = <_.LoDashImplicitArrayWrapper<number>>_([[1, 2], [3, 4], 5, 6]).flatten();
result = <_.LoDashImplicitArrayWrapper<number|Array<Array<number>>>>_([1, [2], [3, [[4]]]]).flatten();
result = <_.LoDashArrayWrapper<number>>_([1, [2], [3, [[4]]]]).flatten(true);
result = <_.LoDashImplicitArrayWrapper<number>>_([1, [2], [3, [[4]]]]).flatten(true);
// _.flattenDeep
module TestFlattenDeep {
@@ -1053,76 +1050,417 @@ result = <number[]>_([1, 2]).zipWith<number>([1, 2], [1, 2], [1, 2], [1, 2], [1,
* Chain *
*********/
// _.chain
module TestChain {
{
let result: _.LoDashExplicitWrapper<string>;
result = _.chain('');
result = _('').chain();
result = _.chain('').chain();
result = _('').chain().chain();
}
{
let result: _.LoDashExplicitWrapper<number>;
result = _.chain(42);
result = _(42).chain();
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _.chain(true);
result = _(true).chain();
}
{
let result: _.LoDashExplicitArrayWrapper<string>;
result = _.chain(['']);
result = _(['']).chain();
}
{
let result: _.LoDashExplicitObjectWrapper<{a: string}>;
result = _.chain<{a: string}>({a: ''});
result = _<{a: string}>({a: ''}).chain();
}
}
// _.tap
module TestTap {
{
let interceptor: (value: string) => void;
let result: string;
_.tap('', interceptor);
_.tap('', interceptor, any);
}
{
let interceptor: (value: string[]) => void;
let result: _.LoDashImplicitArrayWrapper<string>;
_.tap([''], interceptor);
_.tap([''], interceptor, any);
}
{
let interceptor: (value: {a: string}) => void;
let result: _.LoDashImplicitObjectWrapper<{a: string}>;
_.tap({a: ''}, interceptor);
_.tap({a: ''}, interceptor, any);
}
{
let interceptor: (value: string) => void;
let result: _.LoDashImplicitWrapper<string>;
_.chain('').tap(interceptor, any);
_.chain('').tap(interceptor, any);
_('').tap(interceptor);
_('').tap(interceptor, any);
}
{
let interceptor: (value: string[]) => void;
let result: _.LoDashImplicitArrayWrapper<string>;
_.chain(['']).tap(interceptor);
_.chain(['']).tap(interceptor, any);
_(['']).tap(interceptor);
_(['']).tap(interceptor, any);
}
{
let interceptor: (value: {a: string}) => void;
let result: _.LoDashImplicitObjectWrapper<{a: string}>;
_.chain({a: ''}).tap(interceptor);
_.chain({a: ''}).tap(interceptor, any);
_({a: ''}).tap(interceptor);
_({a: ''}).tap(interceptor, any);
}
{
let interceptor: (value: string) => void;
let result: _.LoDashExplicitWrapper<string>;
_.chain('').tap(interceptor, any);
_.chain('').tap(interceptor, any);
_('').chain().tap(interceptor);
_('').chain().tap(interceptor, any);
}
{
let interceptor: (value: string[]) => void;
let result: _.LoDashExplicitArrayWrapper<string>;
_.chain(['']).tap(interceptor);
_.chain(['']).tap(interceptor, any);
_(['']).chain().tap(interceptor);
_(['']).chain().tap(interceptor, any);
}
{
let interceptor: (value: {a: string}) => void;
let result: _.LoDashExplicitObjectWrapper<{a: string}>;
_.chain({a: ''}).tap(interceptor);
_.chain({a: ''}).tap(interceptor, any);
_({a: ''}).chain().tap(interceptor);
_({a: ''}).chain().tap(interceptor, any);
}
}
// _.thru
{
let result: number;
result = _.thru<number, number>(1, (value: number) => value);
result = _.thru<number, number>(1, (value: number) => value, any);
}
{
let result: _.LoDashWrapper<number>;
result = _(1).thru<number>((value: number) => value);
result = _(1).thru<number>((value: number) => value, any);
}
{
let result: _.LoDashWrapper<string>;
result = _('').thru<string>((value: string) => value);
result = _('').thru<string>((value: string) => value, any);
}
{
let result: _.LoDashWrapper<boolean>;
result = _(true).thru<boolean>((value: boolean) => value);
result = _(true).thru<boolean>((value: boolean) => value, any);
}
{
let result: _.LoDashObjectWrapper<any>;
result = _({}).thru<Object>((value: Object) => value);
result = _({}).thru<Object>((value: Object) => value, any);
}
{
let result: _.LoDashArrayWrapper<number>;
result = _([1, 2, 3]).thru<number>((value: number[]) => value);
result = _([1, 2, 3]).thru<number>((value: number[]) => value, any);
module TestThru {
interface Interceptor<T> {
(value: T): T;
}
{
let interceptor: Interceptor<number>;
let result: number;
result = _.thru<number, number>(1, interceptor);
result = _.thru<number, number>(1, interceptor, any);
}
{
let interceptor: Interceptor<number>;
let result: _.LoDashImplicitWrapper<number>;
result = _(1).thru<number>(interceptor);
result = _(1).thru<number>(interceptor, any);
}
{
let interceptor: Interceptor<string>;
let result: _.LoDashImplicitWrapper<string>;
result = _('').thru<string>(interceptor);
result = _('').thru<string>(interceptor, any);
}
{
let interceptor: Interceptor<boolean>;
let result: _.LoDashImplicitWrapper<boolean>;
result = _(true).thru<boolean>(interceptor);
result = _(true).thru<boolean>(interceptor, any);
}
{
let interceptor: Interceptor<{a: string}>;
let result: _.LoDashImplicitObjectWrapper<{a: string}>;
result = _({a: ''}).thru<{a: string}>(interceptor);
result = _({a: ''}).thru<{a: string}>(interceptor, any);
}
{
let interceptor: Interceptor<number[]>;
let result: _.LoDashImplicitArrayWrapper<number>;
result = _([1, 2, 3]).thru<number>(interceptor);
result = _([1, 2, 3]).thru<number>(interceptor, any);
}
{
let interceptor: Interceptor<number>;
let result: _.LoDashExplicitWrapper<number>;
result = _(1).chain().thru<number>(interceptor);
result = _(1).chain().thru<number>(interceptor, any);
}
{
let interceptor: Interceptor<string>;
let result: _.LoDashExplicitWrapper<string>;
result = _('').chain().thru<string>(interceptor);
result = _('').chain().thru<string>(interceptor, any);
}
{
let interceptor: Interceptor<boolean>;
let result: _.LoDashExplicitWrapper<boolean>;
result = _(true).chain().thru<boolean>(interceptor);
result = _(true).chain().thru<boolean>(interceptor, any);
}
{
let interceptor: Interceptor<{a: string}>;
let result: _.LoDashExplicitObjectWrapper<{a: string}>;
result = _({a: ''}).chain().thru<{a: string}>(interceptor);
result = _({a: ''}).chain().thru<{a: string}>(interceptor, any);
}
{
let interceptor: Interceptor<number[]>;
let result: _.LoDashExplicitArrayWrapper<number>;
result = _([1, 2, 3]).chain().thru<number>(interceptor);
result = _([1, 2, 3]).chain().thru<number>(interceptor, any);
}
}
// _.prototype.commit
{
let result: _.LoDashWrapper<number>;
result = _(42).commit();
module TestCommit {
{
let result: _.LoDashImplicitWrapper<number>;
result = _(42).commit();
}
{
let result: _.LoDashImplicitArrayWrapper<any>;
result = _<any>([]).commit();
}
{
let result: _.LoDashImplicitObjectWrapper<any>;
result = _({}).commit();
}
{
let result: _.LoDashExplicitWrapper<number>;
result = _(42).chain().commit();
}
{
let result: _.LoDashExplicitArrayWrapper<any>;
result = _<any>([]).chain().commit();
}
{
let result: _.LoDashExplicitObjectWrapper<any>;
result = _({}).chain().commit();
}
}
{
let result: _.LoDashArrayWrapper<any>;
result = _<any>([]).commit();
}
{
let result: _.LoDashObjectWrapper<any>;
result = _({}).commit();
// _.prototype.concat
module TestConcat {
{
let result: _.LoDashImplicitArrayWrapper<number>;
result = _(1).concat<number>(2);
result = _(1).concat<number>(2, 3);
result = _(1).concat<number>(2, 3, 4);
result = _(1).concat(2);
result = _(1).concat(2, 3);
result = _(1).concat(2, 3, 4);
}
{
let result: _.LoDashImplicitArrayWrapper<string>;
result = _<string>(['']).concat<string>(['']);
result = _<string>(['']).concat<string>([''], ['']);
result = _<string>(['']).concat<string>([''], [''], ['']);
result = _<string>(['']).concat(['']);
result = _<string>(['']).concat([''], ['']);
result = _<string>(['']).concat([''], [''], ['']);
}
{
let result: _.LoDashImplicitArrayWrapper<{a: string}>;
result = _({a: ''}).concat<{a: string}>({a: ''});
result = _({a: ''}).concat<{a: string}>({a: ''}, {a: ''});
result = _({a: ''}).concat<{a: string}>({a: ''}, {a: ''}, {a: ''});
result = _({a: ''}).concat({a: ''});
result = _({a: ''}).concat({a: ''}, {a: ''});
result = _({a: ''}).concat({a: ''}, {a: ''}, {a: ''});
}
{
let result: _.LoDashExplicitArrayWrapper<number>;
result = _(1).chain().concat<number>(2);
result = _(1).chain().concat<number>(2, 3);
result = _(1).chain().concat<number>(2, 3, 4);
result = _(1).chain().concat(2);
result = _(1).chain().concat(2, 3);
result = _(1).chain().concat(2, 3, 4);
}
{
let result: _.LoDashExplicitArrayWrapper<string>;
result = _<string>(['']).chain().concat<string>(['']);
result = _<string>(['']).chain().concat<string>([''], ['']);
result = _<string>(['']).chain().concat<string>([''], [''], ['']);
result = _<string>(['']).chain().concat(['']);
result = _<string>(['']).chain().concat([''], ['']);
result = _<string>(['']).chain().concat([''], [''], ['']);
}
{
let result: _.LoDashExplicitArrayWrapper<{a: string}>;
result = _({a: ''}).chain().concat<{a: string}>({a: ''});
result = _({a: ''}).chain().concat<{a: string}>({a: ''}, {a: ''});
result = _({a: ''}).chain().concat<{a: string}>({a: ''}, {a: ''}, {a: ''});
result = _({a: ''}).chain().concat({a: ''});
result = _({a: ''}).chain().concat({a: ''}, {a: ''});
result = _({a: ''}).chain().concat({a: ''}, {a: ''}, {a: ''});
}
}
// _.prototype.plant
{
let result: _.LoDashWrapper<number>;
result = _(any).plant(42);
module TestPlant {
{
let result: _.LoDashImplicitWrapper<number>;
result = _(any).plant(42);
}
{
let result: _.LoDashImplicitStringWrapper;
result = _(any).plant('');
}
{
let result: _.LoDashImplicitWrapper<boolean>;
result = _(any).plant(true);
}
{
let result: _.LoDashImplicitNumberArrayWrapper;
result = _(any).plant([42]);
}
{
let result: _.LoDashImplicitArrayWrapper<any>;
result = _(any).plant<any>([]);
}
{
let result: _.LoDashImplicitObjectWrapper<{}>;
result = _(any).plant<{}>({});
}
{
let result: _.LoDashExplicitWrapper<number>;
result = _(any).chain().plant(42);
}
{
let result: _.LoDashExplicitStringWrapper;
result = _(any).chain().plant('');
}
{
let result: _.LoDashExplicitWrapper<boolean>;
result = _(any).chain().plant(true);
}
{
let result: _.LoDashExplicitNumberArrayWrapper;
result = _(any).chain().plant([42]);
}
{
let result: _.LoDashExplicitArrayWrapper<any>;
result = _(any).chain().plant<any>([]);
}
{
let result: _.LoDashExplicitObjectWrapper<{}>;
result = _(any).chain().plant<{}>({});
}
}
{
let result: _.LoDashStringWrapper;
result = _(any).plant('');
}
{
let result: _.LoDashWrapper<boolean>;
result = _(any).plant(true);
}
{
let result: _.LoDashNumberArrayWrapper;
result = _(any).plant([42]);
}
{
let result: _.LoDashArrayWrapper<any>;
result = _(any).plant<any>([]);
}
{
let result: _.LoDashObjectWrapper<{}>;
result = _(any).plant<{}>({});
// _.prototype.reverse
module TestReverse {
{
let result: _.LoDashImplicitArrayWrapper<number>;
result: _([42]).reverse();
}
{
let result: _.LoDashExplicitArrayWrapper<number>;
result: _([42]).chain().reverse();
}
}
/**************
@@ -1318,9 +1656,9 @@ result = <_.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function (num) { retur
result = <_.Dictionary<number>>_.countBy([4.3, 6.1, 6.4], function (num) { return this.floor(num); }, Math);
result = <_.Dictionary<number>>_.countBy(['one', 'two', 'three'], 'length');
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_([4.3, 6.1, 6.4]).countBy(function (num) { return Math.floor(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_([4.3, 6.1, 6.4]).countBy(function (num) { return this.floor(num); }, Math);
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_(['one', 'two', 'three']).countBy('length');
result = <_.LoDashImplicitObjectWrapper<_.Dictionary<number>>>_([4.3, 6.1, 6.4]).countBy(function (num) { return Math.floor(num); });
result = <_.LoDashImplicitObjectWrapper<_.Dictionary<number>>>_([4.3, 6.1, 6.4]).countBy(function (num) { return this.floor(num); }, Math);
result = <_.LoDashImplicitObjectWrapper<_.Dictionary<number>>>_(['one', 'two', 'three']).countBy('length');
// _.detect
module TestDetect {
@@ -1509,11 +1847,11 @@ result = <number[]>_.each([1, 2, 3], function (num) { console.log(num); });
result = <_.Dictionary<number>>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); });
result = <IFoodType>_.each<IFoodType, string>({ name: 'apple', type: 'fruit' }, function (value, key) { console.log(value, key) });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).forEach(function (num) { console.log(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEach(function (num) { console.log(num); });
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3]).forEach(function (num) { console.log(num); });
result = <_.LoDashImplicitObjectWrapper<_.Dictionary<number>>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEach(function (num) { console.log(num); });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).each(function (num) { console.log(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).each(function (num) { console.log(num); });
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3]).each(function (num) { console.log(num); });
result = <_.LoDashImplicitObjectWrapper<_.Dictionary<number>>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).each(function (num) { console.log(num); });
result = <number[]>_.forEachRight([1, 2, 3], function (num) { console.log(num); });
result = <_.Dictionary<number>>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); });
@@ -1521,11 +1859,11 @@ result = <_.Dictionary<number>>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }
result = <number[]>_.eachRight([1, 2, 3], function (num) { console.log(num); });
result = <_.Dictionary<number>>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).forEachRight(function (num) { console.log(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function (num) { console.log(num); });
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3]).forEachRight(function (num) { console.log(num); });
result = <_.LoDashImplicitObjectWrapper<_.Dictionary<number>>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function (num) { console.log(num); });
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).eachRight(function (num) { console.log(num); });
result = <_.LoDashObjectWrapper<_.Dictionary<number>>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function (num) { console.log(num); });
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3]).eachRight(function (num) { console.log(num); });
result = <_.LoDashImplicitObjectWrapper<_.Dictionary<number>>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function (num) { console.log(num); });
result = <_.Dictionary<number[]>>_.groupBy([4.2, 6.1, 6.4], function (num) { return Math.floor(num); });
result = <_.Dictionary<number[]>>_.groupBy([4.2, 6.1, 6.4], function (num) { return this.floor(num); }, Math);
@@ -1764,14 +2102,14 @@ result = <IFoodCombined[]>_(foodsCombined).reject({ 'type': 'fruit' }).value();
result = <number>_.sample([1, 2, 3, 4]);
result = <number[]>_.sample([1, 2, 3, 4], 2);
result = <_.LoDashWrapper<number>>_([1, 2, 3, 4]).sample();
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3, 4]).sample(2);
result = <_.LoDashImplicitWrapper<number>>_([1, 2, 3, 4]).sample();
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).sample(2);
result = <number>_([1, 2, 3, 4]).sample().value();
result = <number[]>_([1, 2, 3, 4]).sample(2).value();
result = <number[]>_.shuffle([1, 2, 3, 4, 5, 6]);
result = <_.LoDashArrayWrapper<number>>_([1, 2, 3]).shuffle();
result = <_.LoDashArrayWrapper<_.Dictionary<string>>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).shuffle();
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3]).shuffle();
result = <_.LoDashImplicitArrayWrapper<_.Dictionary<string>>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).shuffle();
result = <number>_.size([1, 2]);
result = <number>_([1, 2]).size();
@@ -1850,12 +2188,6 @@ result = <number[]>_([1, 2, 3]).sortBy(function (num) { return this.sin(num); },
result = <string[]>_(['banana', 'strawberry', 'apple']).sortBy('length').value();
result = <IFoodOrganic[]>_(foodsOrganic).sortByAll('organic', (food) => food.name, { organic: true }).value();
(function (a: number, b: number, c: number, d: number): Array<number> { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
result = <number[]>_.toArray([1, 2, 3, 4]);
(function (a: number, b: number, c: number, d: number): Array<number> { return _(arguments).toArray<number>().slice(1).value(); })(1, 2, 3, 4);
result = <number[]>_([1,2,3,4]).toArray().value();
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'age': 40 });
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'quotes': ['Poifect!'] });
@@ -1866,7 +2198,24 @@ result = <IStoogesCombined[]>_(stoogesCombined).where({ 'quotes': ['Poifect!'] }
* Date *
********/
result = <number>_.now();
module TestNow {
{
let result: number;
result = _.now();
result = _(42).now();
result = _<any>([]).now();
result = _({}).now();
}
{
let result: _.LoDashExplicitWrapper<number>;
result = _(42).chain().now();
result = _<any>([]).chain().now();
result = _({}).chain().now();
}
}
/*************
* Functions *
@@ -1969,8 +2318,8 @@ result = <number>_(testComposeSquareFn).compose<(n: number, m: number) => number
var createCallbackObj: { [index: string]: string; } = { name: 'Joe' };
result = <() => any>_.createCallback('name');
result = <() => boolean>_.createCallback(createCallbackObj);
result = <_.LoDashObjectWrapper<() => any>>_('name').createCallback();
result = <_.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallback();
result = <_.LoDashImplicitObjectWrapper<() => any>>_('name').createCallback();
result = <_.LoDashImplicitObjectWrapper<() => boolean>>_(createCallbackObj).createCallback();
// _.curry
var testCurryFn = (a: number, b: number, c: number) => [a, b, c];
@@ -2034,14 +2383,14 @@ source.addEventListener('message', <Function>_.debounce(function () { }, 250, {
'maxWait': 1000
}), false);
result = <_.LoDashObjectWrapper<Function>>_(function () { }).debounce(150);
result = <_.LoDashImplicitObjectWrapper<Function>>_(function () { }).debounce(150);
jQuery('#postbox').on('click', <_.LoDashObjectWrapper<Function>>_(function () { }).debounce(300, {
jQuery('#postbox').on('click', <_.LoDashImplicitObjectWrapper<Function>>_(function () { }).debounce(300, {
'leading': true,
'trailing': false
}));
source.addEventListener('message', <_.LoDashObjectWrapper<Function>>_(function () { }).debounce(250, {
source.addEventListener('message', <_.LoDashImplicitObjectWrapper<Function>>_(function () { }).debounce(250, {
'maxWait': 1000
}), false);
@@ -2049,11 +2398,11 @@ var returnedDebounce = _.throttle(function (a: any) { return a * 5; }, 5);
returnedThrottled(4);
result = <number>_.defer(function () { console.log('deferred'); });
result = <_.LoDashWrapper<number>>_(function () { console.log('deferred'); }).defer();
result = <_.LoDashImplicitWrapper<number>>_(function () { console.log('deferred'); }).defer();
var log = _.bind(console.log, console);
result = <number>_.delay(log, 1000, 'logged later');
result = <_.LoDashWrapper<number>>_(log).delay(1000, 'logged later');
result = <_.LoDashImplicitWrapper<number>>_(log).delay(1000, 'logged later');
// _.flow
var testFlowSquareFn = (n: number) => n * n;
@@ -2271,6 +2620,20 @@ var testCloneDeepCustomizerFn: TestCloneDeepCustomizerFn;
result = _({a: {b: 2}}).cloneDeep(testCloneDeepCustomizerFn, any);
}
// _.eq
module TestEq {
let customizer: (value: any, other: any, indexOrKey?: number|string) => boolean;
let result: boolean;
result = _.eq(any, any);
result = _.eq(any, any, customizer);
result = _.eq(any, any, customizer, any);
result = _(any).eq(any);
result = _(any).eq(any, customizer);
result = _(any).eq(any, customizer, any)
}
// _.gt
result = <boolean>_.gt(1, 2);
result = <boolean>_(1).gt(2);
@@ -2321,6 +2684,20 @@ result = <boolean>_([1, 2, 3]).isEmpty();
result = <boolean>_({}).isEmpty();
result = <boolean>_('').isEmpty();
// _.isEqual
module TestIsEqual {
let customizer: (value: any, other: any, indexOrKey?: number|string) => boolean;
let result: boolean;
result = _.isEqual(any, any);
result = _.isEqual(any, any, customizer);
result = _.isEqual(any, any, customizer, any);
result = _(any).isEqual(any);
result = _(any).isEqual(any, customizer);
result = _(any).isEqual(any, customizer, any)
}
// _.isError
result = <boolean>_.isError(any);
result = <boolean>_(1).isError();
@@ -2418,6 +2795,47 @@ result = <boolean>_(1).lte(2);
result = <boolean>_([]).lte(2);
result = <boolean>_({}).lte(2);
// _.toArray
module TestToArray {
let array: TResult[];
let list: _.List<TResult>;
let dictionary: _.Dictionary<TResult>;
{
let result: string[];
result = _.toArray('');
result = (function (a: string) {return _.toArray<IArguments, string>(arguments);})('');
result = _((function (a: string) {return arguments;})('')).toArray<string>().value();
}
{
let result: TResult[];
result = _.toArray<TResult>(array);
result = _.toArray<TResult>(list);
result = _.toArray<TResult>(dictionary);
result = _(array).toArray().value();
result = _(list).toArray<TResult>().value();
result = _(dictionary).toArray<TResult>().value();
}
{
let result: any[];
result = _.toArray();
result = _.toArray<number>(42);
result = _.toArray<boolean>(true);
result = _('').toArray<string>().value();
result = _(42).toArray<any>().value();
result = _(true).toArray<any>().value();
}
}
// _.toPlainObject
module TestToPlainObject {
let result: TResult;
@@ -2581,8 +2999,8 @@ result = <NameAge>_.assign({ 'name': 'moe' }, { 'age': 40 }, function (a, b) {
return typeof a == 'undefined' ? b : a;
});
result = <_.LoDashObjectWrapper<NameAge>>_({ 'name': 'moe' }).assign({ 'age': 40 });
result = <_.LoDashObjectWrapper<NameAge>>_({ 'name': 'moe' }).assign({ 'age': 40 }, function (a, b) {
result = <_.LoDashImplicitObjectWrapper<NameAge>>_({ 'name': 'moe' }).assign({ 'age': 40 });
result = <_.LoDashImplicitObjectWrapper<NameAge>>_({ 'name': 'moe' }).assign({ 'age': 40 }, function (a, b) {
return typeof a == 'undefined' ? b : a;
});
@@ -2591,8 +3009,8 @@ result = <NameAge>_.extend({ 'name': 'moe' }, { 'age': 40 }, function (a, b) {
return typeof a == 'undefined' ? b : a;
});
result = <_.LoDashObjectWrapper<NameAge>>_({ 'name': 'moe' }).extend({ 'age': 40 });
result = <_.LoDashObjectWrapper<NameAge>>_({ 'name': 'moe' }).extend({ 'age': 40 }, function (a, b) {
result = <_.LoDashImplicitObjectWrapper<NameAge>>_({ 'name': 'moe' }).extend({ 'age': 40 });
result = <_.LoDashImplicitObjectWrapper<NameAge>>_({ 'name': 'moe' }).extend({ 'age': 40 }, function (a, b) {
return typeof a == 'undefined' ? b : a;
});
@@ -2621,7 +3039,7 @@ interface Food {
}
var foodDefaults = { 'name': 'apple' };
result = <Food>_.defaults(foodDefaults, { 'name': 'banana', 'type': 'fruit' });
result = <_.LoDashObjectWrapper<Food>>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' });
result = <_.LoDashImplicitObjectWrapper<Food>>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' });
//_.defaultsDeep
interface DefaultsDeepResult {
@@ -2676,15 +3094,52 @@ module TestFindKey {
}
}
result = <string>_.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) {
return num % 2 == 1;
});
// _.findLastKey
module TestFindLastKey {
let result: string;
{
let predicateFn: (value: any, key?: string, object?: {}) => boolean;
result = _.findLastKey<{a: string;}>({a: ''});
result = _.findLastKey<{a: string;}>({a: ''}, predicateFn);
result = _.findLastKey<{a: string;}>({a: ''}, predicateFn, any);
result = _.findLastKey<{a: string;}>({a: ''}, '');
result = _.findLastKey<{a: string;}>({a: ''}, '', any);
result = _.findLastKey<{a: number;}, {a: string;}>({a: ''}, {a: 42});
result = _<{a: string;}>({a: ''}).findLastKey();
result = _<{a: string;}>({a: ''}).findLastKey(predicateFn);
result = _<{a: string;}>({a: ''}).findLastKey(predicateFn, any);
result = _<{a: string;}>({a: ''}).findLastKey('');
result = _<{a: string;}>({a: ''}).findLastKey('', any);
result = _<{a: string;}>({a: ''}).findLastKey<{a: number;}>({a: 42});
}
{
let predicateFn: (value: string, key?: string, collection?: _.Dictionary<string>) => boolean;
result = _.findLastKey<string, {a: string;}>({a: ''}, predicateFn);
result = _.findLastKey<string, {a: string;}>({a: ''}, predicateFn, any);
result = _<{a: string;}>({a: ''}).findLastKey<string>(predicateFn);
result = _<{a: string;}>({a: ''}).findLastKey<string>(predicateFn, any);
}
}
result = <Dog>_.forIn(new Dog('Dagny'), function (value, key) {
console.log(key);
});
result = <_.LoDashObjectWrapper<Dog>>_(new Dog('Dagny')).forIn(function (value, key) {
result = <_.LoDashImplicitObjectWrapper<Dog>>_(new Dog('Dagny')).forIn(function (value, key) {
console.log(key);
});
@@ -2692,7 +3147,7 @@ result = <Dog>_.forInRight(new Dog('Dagny'), function (value, key) {
console.log(key);
});
result = <_.LoDashObjectWrapper<Dog>>_(new Dog('Dagny')).forInRight(function (value, key) {
result = <_.LoDashImplicitObjectWrapper<Dog>>_(new Dog('Dagny')).forInRight(function (value, key) {
console.log(key);
});
@@ -2706,7 +3161,7 @@ result = <ZeroOne>_.forOwn(<ZeroOne>{ '0': 'zero', '1': 'one', 'one': '2' }, fun
console.log(key);
});
result = <_.LoDashObjectWrapper<ZeroOne>>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function (num, key) {
result = <_.LoDashImplicitObjectWrapper<ZeroOne>>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function (num, key) {
console.log(key);
});
@@ -2714,15 +3169,15 @@ result = <any>_.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function (
console.log(key);
});
result = <_.LoDashObjectWrapper<ZeroOne>>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function (num, key) {
result = <_.LoDashImplicitObjectWrapper<ZeroOne>>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function (num, key) {
console.log(key);
});
result = <string[]>_.functions(_);
result = <string[]>_.methods(_);
result = <_.LoDashArrayWrapper<string>>_(_).functions();
result = <_.LoDashArrayWrapper<string>>_(_).methods();
result = <_.LoDashImplicitArrayWrapper<string>>_(_).functions();
result = <_.LoDashImplicitArrayWrapper<string>>_(_).methods();
// _.get
result = <number>_.get<number>({ 'a': [{ 'b': { 'c': 3 } }] }, 'a[0].b.c');
@@ -2758,31 +3213,6 @@ result = <boolean>_({}).has(['', 42, true]);
result = _({}).invert<TResult>(true).value();
}
// _.isEqual (alias: _.eq)
result = <boolean>_.isEqual(1, 1);
result = <boolean>_(1).isEqual(1);
result = <boolean>_.eq(1, 1);
result = <boolean>_(1).eq(1);
var testEqObject = { 'user': 'fred' };
var testEqOtherObject = { 'user': 'fred' };
result = <boolean>_.isEqual(testEqObject, testEqOtherObject);
result = <boolean>_(testEqObject).isEqual(testEqOtherObject);
result = <boolean>_.eq(testEqObject, testEqOtherObject);
result = <boolean>_(testEqObject).eq(testEqOtherObject);
var testEqArray = ['hello', 'goodbye'];
var testEqOtherArray = ['hi', 'goodbye'];
var testEqCustomizerFn = (value: any, other: any): boolean => {
if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) {
return true;
}
};
result = <boolean>_.isEqual(testEqArray, testEqOtherArray, testEqCustomizerFn);
result = <boolean>_(testEqArray).isEqual(testEqOtherArray, testEqCustomizerFn);
result = <boolean>_.eq(testEqArray, testEqOtherArray, testEqCustomizerFn);
result = <boolean>_(testEqArray).eq(testEqOtherArray, testEqCustomizerFn);
class Stooge {
constructor(
public name: string,
+1038 -762
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -10,7 +10,7 @@ declare module "mobservable-react" {
* Turns a React component or stateless render function into a reactive component.
*/
export function reactiveComponent<P>(clazz: React.ClassicComponentClass<P>): React.ClassicComponentClass<P>;
export function reactiveComponent<TFunction extends React.ComponentClass<any>>(target: TFunction): void; // decorator signature
export function reactiveComponent<P>(clazz: React.ComponentClass<P>): React.ComponentClass<P>;
export function reactiveComponent<TFunction extends React.ComponentClass<any>>(target: TFunction): TFunction | void; // decorator signature
export function reactiveComponent<P>(renderFunction: (props: P) => React.ReactElement<any>): React.ClassicComponentClass<P>;
}
+4
View File
@@ -249,3 +249,7 @@ function test_run_withOnComplete() {
console.log(failures);
});
}
function test_throwError() {
mocha.throwError(new Error("I'm an error!"));
}
+6
View File
@@ -100,6 +100,12 @@ declare class Mocha {
invert(): Mocha;
ignoreLeaks(value: boolean): Mocha;
checkLeaks(): Mocha;
/**
* Function to allow assertion libraries to throw errors directly into mocha.
* This is useful when running tests in a browser because window.onerror will
* only receive the 'message' attribute of the Error.
*/
throwError(error: Error): void;
/** Enables growl support. */
growl(): Mocha;
globals(value: string): Mocha;
+3
View File
@@ -255,6 +255,7 @@ moment.locale('en', {
weekdaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
weekdaysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
longDateFormat: {
LTS: "h:mm:ss A",
LT: "h:mm A",
L: "MM/DD/YYYY",
LL: "MMMM D YYYY",
@@ -376,6 +377,7 @@ moment.locale('en', {
moment.locale('en', {
longDateFormat : {
LTS: "h:mm:ss A",
LT: "h:mm A",
L: "MM/DD/YYYY",
l: "M/D/YYYY",
@@ -390,6 +392,7 @@ moment.locale('en', {
moment.locale('en', {
longDateFormat : {
LTS: "h:mm:ss A",
LT: "h:mm A",
L: "MM/DD/YYYY",
LL: "MMMM Do YYYY",
+3 -1
View File
@@ -19,7 +19,7 @@ declare module moment {
month?: number;
/** Month */
M?: number;
/** Week */
weeks?: number;
/** Week */
@@ -346,11 +346,13 @@ declare module moment {
LLL: string;
LLLL: string;
LT: string;
LTS: string;
l?: string;
ll?: string;
lll?: string;
llll?: string;
lt?: string;
lts?: string;
}
interface MomentRelativeTime {
+12
View File
@@ -127,6 +127,15 @@ moment().isoWeeks(45);
moment().dayOfYear();
moment().dayOfYear(45);
moment().set('year', 2013);
moment().set('month', 3); // April
moment().set('date', 1);
moment().set('hour', 13);
moment().set('minute', 20);
moment().set('second', 30);
moment().set('millisecond', 123);
moment().set({'year': 2013, 'month': 3});
var getMilliseconds: number = moment().milliseconds();
var getSeconds: number = moment().seconds();
var getMinutes: number = moment().minutes();
@@ -257,6 +266,7 @@ moment.locale('en', {
weekdaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
weekdaysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
longDateFormat: {
LTS: "h:mm:ss A",
LT: "h:mm A",
L: "MM/DD/YYYY",
LL: "MMMM D YYYY",
@@ -378,6 +388,7 @@ moment.locale('en', {
moment.locale('en', {
longDateFormat : {
LTS: "h:mm:ss A",
LT: "h:mm A",
L: "MM/DD/YYYY",
l: "M/D/YYYY",
@@ -392,6 +403,7 @@ moment.locale('en', {
moment.locale('en', {
longDateFormat : {
LTS: "h:mm A",
LT: "h:mm A",
L: "MM/DD/YYYY",
LL: "MMMM Do YYYY",
+8
View File
@@ -127,6 +127,14 @@ declare module "mongodb" {
// Creates an ObjectID from a hex string representation of an ObjectID.
// hexString create a ObjectID from a passed in 24 byte hexstring.
public static createFromHexString(hexString: string): ObjectID;
// Checks if a value is a valid bson ObjectId
// id - Value to be checked
public static isValid(id: string): Boolean;
// Generate a 12 byte id string used in ObjectID's
// time - optional parameter allowing to pass in a second based timestamp
public generate(time?: number): string;
}
// Class documentation : http://mongodb.github.io/node-mongodb-native/api-bson-generated/binary.html
+2 -2
View File
@@ -63,7 +63,7 @@ var el2 = document.createElement('my-element');
class MyElement2 {
is: string;
registered() {
beforeRegister() {
this.is = "my-element2";
}
}
@@ -74,7 +74,7 @@ Polymer(MyElement2);
class MyElement3 implements polymer.Base {
is: string;
registered() {
beforeRegister() {
this.is = "my-element3";
}
}
+8 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for polymer v1.1.2
// Type definitions for polymer v1.1.5
// Project: https://github.com/Polymer/polymer
// Definitions by: Louis Grignon <https://github.com/lgrignon>, Suguru Inatomi <https://github.com/laco0416>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -161,7 +161,7 @@ declare module polymer {
getContentChildren?(selector: string): HTMLElement[];
fire?(type: string, detail?: Object, options?: Object): CustomEvent;
fire?(type: string, detail?: any, options?: Object): CustomEvent;
async?(callback: ()=>void, waitTime?: number): number;
@@ -177,6 +177,10 @@ declare module polymer {
create?(tag: string, props: Object): Element;
isLightDescendant?(node: HTMLElement): boolean;
isLocalDescendant?(node: HTMLElement): boolean
// XStyling
updateStyles?(): void;
@@ -201,6 +205,8 @@ declare module polymer {
observers?: string[];
beforeRegister?(): void;
registered?(): void;
created?(): void;
+42 -8
View File
@@ -4,7 +4,7 @@
/// <reference path="../react-router/react-router.d.ts" />
/// <reference path="../object-assign/object-assign.d.ts" />
import { Component } from 'react';
import { Component, ReactElement } from 'react';
import * as React from 'react';
import * as Router from 'react-router';
import { Route, RouterState } from 'react-router';
@@ -23,13 +23,13 @@ interface CounterState {
declare var increment: Function;
class Counter extends Component<any, any> {
render() {
return (
<button onClick={this.props.onIncrement}>
{this.props.value}
</button>
);
}
render() {
return (
<button onClick={this.props.onIncrement}>
{this.props.value}
</button>
);
}
}
function mapStateToProps(state: CounterState) {
@@ -242,3 +242,37 @@ connect(mapStateToProps2, actionCreators, mergeProps)(TodoApp);
interface TestProp {
property1: number;
someOtherProperty?: string;
}
interface TestState {
isLoaded: boolean;
state1: number;
}
class TestComponent extends Component<TestProp, TestState> { }
const WrappedTestComponent = connect()(TestComponent);
// return value of the connect()(TestComponent) is of the type TestComponent
let ATestComponent: typeof TestComponent = null;
ATestComponent = TestComponent;
ATestComponent = WrappedTestComponent;
let anElement: ReactElement<TestProp>;
<TestComponent property1={42} />;
<WrappedTestComponent property1={42} />;
<ATestComponent property1={42} />;
class NonComponent {}
// this doesn't compile
//connect()(NonComponent);
// connect()(SomeClass) has the same constructor as SomeClass itself
class SomeClass extends Component<any, any> {
constructor(public foo: string) { super() }
public bar: number;
}
let bar: number = new (connect()(SomeClass))("foo").bar;
+2 -1
View File
@@ -10,8 +10,9 @@ declare module "react-redux" {
import { Component } from 'react';
import { Store, Dispatch, ActionCreator } from 'redux';
export class ElementClass extends Component<any, any> { }
export interface ClassDecorator {
<TFunction extends Function>(target: TFunction): TFunction|void;
<T extends (typeof ElementClass)>(component: T): T
}
/**
+1 -1
View File
@@ -427,7 +427,7 @@ declare namespace __React {
allowTransparency?: boolean;
alt?: string;
async?: boolean;
autoComplete?: boolean;
autoComplete?: string;
autoFocus?: boolean;
autoPlay?: boolean;
cellPadding?: number | string;
+1 -1
View File
@@ -43,7 +43,7 @@ declare module Redux {
function createStore(reducer: Reducer, initialState?: any): Store;
function bindActionCreators<T>(actionCreators: T, dispatch: Dispatch): T;
function combineReducers(reducers: any): Reducer;
function applyMiddleware(...middleware: Middleware[]): Function;
function applyMiddleware(...middlewares: Middleware[]): Function;
function compose<T extends Function>(...functions: Function[]): T;
}
+59
View File
@@ -0,0 +1,59 @@
/// <reference path="reflux.d.ts" />
/// <reference path="../react/react.d.ts" />
import Reflux = require("reflux");
import React = require("react");
var syncActions = Reflux.createActions([
"statusUpdate",
"statusEdited",
"statusAdded"
]);
var asyncActions = Reflux.createActions({
fireBall: {asyncResult: true}
});
asyncActions.fireBall.listen(function () {
// Trigger async action
setTimeout(() => this.completed(true), 1000);
});
// Creates a DataStore
var statusStore = Reflux.createStore({
// Initial setup
init: function () {
// Register statusUpdate action
this.listenTo(asyncActions.fireBall, this.onFireBall);
},
// Callback
onFireBall: function (flag: boolean) {
var status = flag ? 'ONLINE' : 'OFFLINE';
// Pass on to listeners
this.trigger(status);
}
});
Reflux.createAction({
children: ["progressed", "completed", "failed"]
});
var actions = Reflux.createActions(["fireBall", "magicMissile"]);
var Store = Reflux.createStore({
init: function () {
this.listenToMany(actions);
},
onFireBall: function () {
// whoooosh!
},
onMagicMissile: function () {
// bzzzzapp!
}
});
+62
View File
@@ -0,0 +1,62 @@
// Type definitions for RefluxJS
// Project: https://github.com/reflux/refluxjs
// Definitions by: Maurice de Beijer <https://github.com/mauricedb>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module RefluxCore {
interface StoreDefinition {
listenables?: any[],
init?: Function,
getInitialState?: Function,
[propertyName: string]: any;
}
interface ListenFn {
(...params: any[]):any,
completed: Function,
failed: Function
}
interface Listenable {
listen: ListenFn
}
interface Subscription {
stop: Function,
listenable: Listenable
}
interface Store {
hasListener(listenable: Listenable): boolean,
listenToMany(listenables: Listenable[]): void,
validateListening(listenable: Listenable): string,
listenTo(listenable: Listenable, callback: Function, defaultCallback?: Function): Subscription,
stopListeningTo(listenable: Listenable): boolean,
stopListeningToAll(): void,
fetchInitialState(listenable: Listenable, defaultCallback: Function): void,
trigger(state: any):void;
}
interface ActionsDefinition {
[index: string]:any
}
interface Actions {
[index: string]: Listenable
}
function createStore(definition: StoreDefinition): Store;
function createAction(definition: ActionsDefinition): any;
function createActions(definition: ActionsDefinition): any;
function createActions(definitions: string[]): any;
function listenTo(store: Store, handler: string):void;
function setState(state: any):void;
}
declare module "reflux" {
export = RefluxCore;
}
+1 -1
View File
@@ -79,7 +79,7 @@ declare module 'request' {
method?: string;
headers?: Headers;
body?: any;
followRedirect?: boolean;
followRedirect?: boolean|((response: http.IncomingMessage) => boolean);
followAllRedirects?: boolean;
maxRedirects?: number;
encoding?: string;
+19 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for RequireJS 2.1.8
// Type definitions for RequireJS 2.1.20
// Project: http://requirejs.org/
// Definitions by: Josh Baldwin <https://github.com/jbaldwin/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -88,6 +88,10 @@ interface RequireConfig {
// baseUrl.
paths?: { [key: string]: any; };
// Allows configuring multiple module IDs to be found in
// another script.
bundles?: { [key: string]: any; };
// Dictionary of Shim's.
// does not cover case of key->string[]
shim?: { [key: string]: RequireShim; };
@@ -195,6 +199,20 @@ interface RequireConfig {
**/
scriptType?: string;
/**
* If set to true, skips the data-main attribute scanning done
* to start module loading. Useful if RequireJS is embedded in
* a utility library that may interact with other RequireJS
* library on the page, and the embedded version should not do
* data-main loading.
**/
skipDataMain?: boolean;
/**
* Allow extending requirejs to support Subresource Integrity
* (SRI).
**/
onNodeCreated?: (node: HTMLScriptElement, config: RequireConfig, moduleName: string, url: string) => void;
}
// todo: not sure what to do with this guy
+21 -3
View File
@@ -7,9 +7,9 @@ r.connect({host:"localhost", port: 28015}, function(err, conn) {
var testDb = r.db('test')
testDb.tableCreate('users').run(conn, function(err, stuff) {
var users = testDb.table('users')
users.insert({name: "bob"}).run(conn, function() {})
users.filter(function(doc?) {
return doc("henry").eq("bob")
})
@@ -19,6 +19,24 @@ r.connect({host:"localhost", port: 28015}, function(err, conn) {
})
})
})
// use promises instead of callbacks
r.connect({host:"localhost", port: 28015}).then(function(conn) {
console.log("HI", conn)
var testDb = r.db('test')
testDb.tableCreate('users').run(conn).then(function(stuff) {
var users = testDb.table('users')
users.insert({name: "bob"}).run(conn, function() {})
users.filter(function(doc?) {
return doc("henry").eq("bob")
})
.between("james", "beth")
.limit(4)
.run(conn);
})
})
})
+8 -7
View File
@@ -4,10 +4,11 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// Reference: http://www.rethinkdb.com/api/#js
// TODO: Document manipulation and below
///<reference path="../bluebird/bluebird.d.ts"/>
declare module "rethinkdb" {
export function connect(host:ConnectionOptions, cb:(err:Error, conn:Connection)=>void);
export function connect(host:ConnectionOptions, cb?:(err:Error, conn:Connection)=>void):Promise<Connection>;
export function dbCreate(name:string):Operation<CreateResult>;
export function dbDrop(name:string):Operation<DropResult>;
@@ -50,7 +51,7 @@ declare module "rethinkdb" {
interface Connection {
close();
reconnect(cb:(err:Error, conn:Connection)=>void);
reconnect(cb?:(err:Error, conn:Connection)=>void):Promise<Connection>;
use(dbName:string);
addListener(event:string, cb:Function);
on(event:string, cb:Function);
@@ -139,11 +140,11 @@ declare module "rethinkdb" {
}
interface ExpressionFunction<U> {
(doc:Expression<any>):Expression<U>;
(doc:Expression<any>):Expression<U>;
}
interface JoinFunction<U> {
(left:Expression<any>, right:Expression<any>):Expression<U>;
(left:Expression<any>, right:Expression<any>):Expression<U>;
}
interface ReduceFunction<U> {
@@ -159,7 +160,7 @@ declare module "rethinkdb" {
interface UpdateOptions {
non_atomic: boolean;
durability: string; // 'soft'
return_vals: boolean; // false
return_vals: boolean; // false
}
interface WriteResult {
@@ -193,7 +194,7 @@ declare module "rethinkdb" {
}
interface Expression<T> extends Writeable, Operation<T> {
(prop:string):Expression<any>;
(prop:string):Expression<any>;
merge(query:Expression<Object>):Expression<Object>;
append(prop:string):Expression<Object>;
contains(prop:string):Expression<boolean>;
@@ -221,7 +222,7 @@ declare module "rethinkdb" {
}
interface Operation<T> {
run(conn:Connection, cb:(err:Error, result:T)=>void);
run(conn:Connection, cb?:(err:Error, result:T)=>void):Promise<T>;
}
interface Aggregator {}
+356 -5
View File
@@ -3,22 +3,373 @@
// Definitions by: Stefan Profanter <https://github.com/Pro/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/* ----------------------------------
NOTE: This typescript definition is not yet complete. I should be extended if definitions are missing.
---------------------------------- */
declare module ROSLIB {
export class Ros {
constructor(data: {
url: string
/**
* Manages connection to the server and all interactions with ROS.
*
* Emits the following events:
* * 'error' - there was an error with ROS
* * 'connection' - connected to the WebSocket server
* * 'close' - disconnected to the WebSocket server
* * <topicName> - a message came from rosbridge with the given topic name
* * <serviceID> - a service response came from rosbridge with the given ID
*
* @constructor
* @param options - possible keys include:
* * url (optional) - the WebSocket URL for rosbridge (can be specified later with `connect`)
*/
constructor(options:{
url?: string
});
on(eventName: string, callback: (event: any) => void) : void;
connect(url: string) : void;
on(eventName:string, callback:(event:any) => void):void;
/**
* Connect to the specified WebSocket.
*
* @param url - WebSocket URL for Rosbridge
*/
connect(url:string):void;
/**
* Disconnect from the WebSocket server.
*/
close():void;
/**
* Sends an authorization request to the server.
*
* @param mac - MAC (hash) string given by the trusted source.
* @param client - IP of the client.
* @param dest - IP of the destination.
* @param rand - Random string given by the trusted source.
* @param t - Time of the authorization request.
* @param level - User level as a string given by the client.
* @param end - End time of the client's session.
*/
authenticate(mac:string, client:string, dest:string, rand:string, t:number, level:string, end:string): void;
/**
* Sends the message over the WebSocket, but queues the message up if not yet
* connected.
*/
callOnConnection(message:any): void;
/**
* Retrieves list of topics in ROS as an array.
*
* @param callback function with params:
* * topics - Array of topic names
*/
getTopics(callback:(topics:string[]) => void, failedCallback:(error:any)=>void): void;
/**
* Retrieves Topics in ROS as an array as specific type
*
* @param topicType topic type to find:
* @param callback function with params:
* * topics - Array of topic names
*/
getTopicsForType(topicType:string, callback:(topics:string[]) => void, failedCallback:(error:any)=>void): void;
/**
* Retrieves list of active service names in ROS.
*
* @param callback - function with the following params:
* * services - array of service names
*/
getServices(callback:(services:string[]) => void, failedCallback:(error:any)=>void): void;
/**
* Retrieves list of services in ROS as an array as specific type
*
* @param serviceType service type to find:
* @param callback function with params:
* * topics - Array of service names
*/
getServicesForType(serviceType: string, callback:(services:string[]) => void, failedCallback:(error:any)=>void): void;
/**
* Retrieves list of active node names in ROS.
*
* @param callback - function with the following params:
* * nodes - array of node names
*/
getNodes(callback:(nodes:string[]) => void, failedCallback:(error:any)=>void): void;
/**
* Retrieves list of param names from the ROS Parameter Server.
*
* @param callback function with params:
* * params - array of param names.
*/
getParams(callback:(params:string[]) => void, failedCallback:(error:any)=>void): void;
/**
* Retrieves a type of ROS topic.
*
* @param topic name of the topic:
* @param callback - function with params:
* * type - String of the topic type
*/
getTopicType(topic: string, callback:(type:string) => void, failedCallback:(error:any)=>void): void;
/**
* Retrieves a type of ROS service.
*
* @param service name of service:
* @param callback - function with params:
* * type - String of the service type
*/
getServiceType(service: string, callback:(type:string) => void, failedCallback:(error:any)=>void): void;
/**
* Retrieves a detail of ROS message.
*
* @param callback - function with params:
* * details - Array of the message detail
* @param message - String of a topic type
*/
getMessageDetails(message: Message, callback:(detail:any) => void, failedCallback:(error:any)=>void): void;
/**
* Decode a typedefs into a dictionary like `rosmsg show foo/bar`
*
* @param defs - array of type_def dictionary
*/
decodeTypeDefs(defs: any): void;
}
export class Message {
/**
* Message objects are used for publishing and subscribing to and from topics.
*
* @constructor
* @param values - object matching the fields defined in the .msg definition file
*/
constructor(values:any);
}
export class Param {
/**
* A ROS parameter.
*
* @constructor
* @param options - possible keys include:
* * ros - the ROSLIB.Ros connection handle
* * name - the param name, like max_vel_x
*/
constructor(options:{
ros: Ros,
name: string
});
/**
* Fetches the value of the param.
*
* @param callback - function with the following params:
* * value - the value of the param from ROS.
*/
get(callback:(response:any) => void): void;
/**
* Sets the value of the param in ROS.
*
* @param value - value to set param to.
*/
set(value:any, callback:(response:any) => void): void;
/**
* Delete this parameter on the ROS server.
*/
delete(callback:(response:any) => void): void;
}
export class Service {
constructor(data: {
/**
* A ROS service client.
*
* @constructor
* @params options - possible keys include:
* * ros - the ROSLIB.Ros connection handle
* * name - the service name, like /add_two_ints
* * serviceType - the service type, like 'rospy_tutorials/AddTwoInts'
*/
constructor(data:{
ros: Ros,
name: string,
serviceType: string
});
/**
* Calls the service. Returns the service response in the callback.
*
* @param request - the ROSLIB.ServiceRequest to send
* @param callback - function with params:
* * response - the response from the service request
* @param failedCallback - the callback function when the service call failed (optional). Params:
* * error - the error message reported by ROS
*/
callService(request:ServiceRequest, callback:(response:any) => void, failedCallback?:(error:any) => void): void;
}
export class ServiceRequest {
/**
* A ServiceRequest is passed into the service call.
*
* @constructor
* @param values - object matching the fields defined in the .srv definition file
*/
constructor(values?: any);
}
export class ServiceResponse {
/**
* A ServiceResponse is returned from the service call.
*
* @constructor
* @param values - object matching the fields defined in the .srv definition file
*/
constructor(values?: any);
}
export class Topic {
/**
* Publish and/or subscribe to a topic in ROS.
*
* Emits the following events:
* * 'warning' - if there are any warning during the Topic creation
* * 'message' - the message data from rosbridge
*
* @constructor
* @param options - object with following keys:
* * ros - the ROSLIB.Ros connection handle
* * name - the topic name, like /cmd_vel
* * messageType - the message type, like 'std_msgs/String'
* * compression - the type of compression to use, like 'png'
* * throttle_rate - the rate (in ms in between messages) at which to throttle the topics
* * queue_size - the queue created at bridge side for re-publishing webtopics (defaults to 100)
* * latch - latch the topic when publishing
* * queue_length - the queue length at bridge side used when subscribing (defaults to 0, no queueing).
*/
constructor(options: {
ros: Ros,
name: string,
messageType: string,
compression: string,
throttle_rate: number,
queue_size: number,
latch: number,
queue_length: number
});
/**
* Every time a message is published for the given topic, the callback
* will be called with the message object.
*
* @param callback - function with the following params:
* * message - the published message
*/
subscribe(callback: (message: Message) => void): void;
/**
* Unregisters as a subscriber for the topic. Unsubscribing stop remove
* all subscribe callbacks. To remove a call back, you must explicitly
* pass the callback function in.
*
* @param callback - the optional callback to unregister, if
* * provided and other listeners are registered the topic won't
* * unsubscribe, just stop emitting to the passed listener
*/
unsubscribe(callback?: () => void): void;
/**
* Registers as a publisher for the topic.
*/
advertise(): void;
/**
* Unregisters as a publisher for the topic.
*/
unadvertise(): void;
/**
* Publish the message.
*
* @param message - A ROSLIB.Message object.
*/
publish(message: Message): void;
}
class ActionClient {
/**
* An actionlib action client.
*
* Emits the following events:
* * 'timeout' - if a timeout occurred while sending a goal
* * 'status' - the status messages received from the action server
* * 'feedback' - the feedback messages received from the action server
* * 'result' - the result returned from the action server
*
* @constructor
* @param options - object with following keys:
* * ros - the ROSLIB.Ros connection handle
* * serverName - the action server name, like /fibonacci
* * actionName - the action message name, like 'actionlib_tutorials/FibonacciAction'
* * timeout - the timeout length when connecting to the action server
*/
constructor(options: {
ros: Ros,
serverName: string,
actionName: string,
timeout: number
});
/**
* Cancel all goals associated with this ActionClient.
*/
cancel(): void;
}
class Goal {
/**
* An actionlib goal goal is associated with an action server.
*
* Emits the following events:
* * 'timeout' - if a timeout occurred while sending a goal
*
* @constructor
* @param object with following keys:
* * actionClient - the ROSLIB.ActionClient to use with this goal
* * goalMessage - The JSON object containing the goal for the action server
*/
constructor(options: {
actionClient: ActionClient,
goalMessage: any
});
/**
* Send the goal to the action server.
*
* @param timeout (optional) - a timeout length for the goal's result
*/
send(timeout?: number): void;
/**
* Cancel the current goal.
*/
cancel(): void;
}
}
@@ -0,0 +1,17 @@
///<reference path="simplestorage.js.d.ts"/>
var versionTest: string = simpleStorage.version;
var canUseTest: boolean = simpleStorage.canUse();
var simpleStorageTest1: boolean|Error = simpleStorage.set("string", 7);
var simpleStorageTest2: boolean|Error = simpleStorage.set("string", 7, {});
var simpleStorageTest3: boolean|Error = simpleStorage.set("string", 7, { TTL: 7 });
var simpleStorageTest4: boolean|Error = simpleStorage.set("string", undefined);
var simpleStorageTest5: boolean|Error = simpleStorage.set("string", undefined, {});
var simpleStorageTest6: boolean|Error = simpleStorage.set("string", undefined, { TTL: 7 });
var getTest: any = simpleStorage.get("string");
var deleteKeyTest: boolean|Error = simpleStorage.deleteKey("string");
var setTTLTest: boolean|Error = simpleStorage.setTTL("string", 7);
var getTTLTest: number|boolean = simpleStorage.getTTL("string");
var flushTest: boolean|Error = simpleStorage.flush();
var indexTest: [string]|boolean = simpleStorage.index();
var storageSizeTest: number = simpleStorage.storageSize();
+110
View File
@@ -0,0 +1,110 @@
// Type definitions for simpleStorage v0.1.3
// Project: https://github.com/andris9/simpleStorage
// Definitions by: Áxel Costas Pena <https://github.com/axelcostaspena>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module simplestoragejs {
/**
* {@link simpleStorage} API is a subset of {@link http://www.jstorage.info/|jStorage} with slight modifications, so for most cases it should work out of the box if you are converting from {@link http://www.jstorage.info/|jStorage}. Main difference is between return values - if an action failed because of an error (storage full, storage not available, invalid data used etc.), you get the error object as the return value. {@link http://www.jstorage.info/|jStorage} never indicated anything if an error occurred.
* @see https://github.com/andris9/simpleStorage#usage
*/
export interface SimpleStorage {
version: string;
/**
* Check if local storage can be used.
* Returns <code>true</code> if storage is available.
* @see https://github.com/andris9/simpleStorage#canuse
*/
canUse(): boolean;
/**
* Store or update a value in local storage.
* Returns <code>true</code> if value was stored, <code>false</code> if value was not stored or <code>{@link Error}</code> object if value was not stored because of an error.
* @param key The key for the value.
* @param value Value to be stored (can be any JSONeable value).
* @param [options] Optional options object.
* @see https://github.com/andris9/simpleStorage#setkey-value-options
*/
set(key: string, value: any, options?: SetOptions): boolean|Error;
/**
* Retrieve a value from local storage.
* Returns the value for a key or undefined if the key was not found.
* @param key The key to be retrieved.
* @see https://github.com/andris9/simpleStorage#getkey
*/
get(key: string): any;
/**
* Removes a value from local storage.
* Returns <code>true</code> if the value was deleted, <code>false</code> if the value was not found or <code>{@link Error}</code> object if value was not deleted because of an error.
* @param key The key to be deleted.
* @see https://github.com/andris9/simpleStorage#deletekeykey
*/
deleteKey(key: string): boolean|Error;
/**
* Set a millisecond timeout. When the timeout is reached, the key is removed automatically from local storage.
* Returns <code>true</code> if ttl was set, <code>false</code> if value was not found or <code>{@link Error}</code> object if ttl was not set because of an error.
* @param key The key to be updated.
* @param ttl Timeout in milliseconds. If the value is 0, timeout is cleared from the key.
* @see https://github.com/andris9/simpleStorage#setttlkey-ttl
*/
setTTL(key: string, ttl: number): boolean|Error;
/**
* Retrieve remaining milliseconds for a key with TTL.
* Returns the finite number of remaining milliseconds, <code>Infinity</code> if TTL is not set for the selected key or <code>false</code> if the selected key does not exist or is expired.
* @param key The key to be checked.
* @see https://github.com/andris9/simpleStorage#getttlkey
*/
getTTL(key: string): number|boolean;
/**
* Clear all values.
* Returns <code>true</code> if storage was flushed or <code>{@link Error}</code> object if storage was not flushed because of an error.
* @see https://github.com/andris9/simpleStorage#flush
*/
flush(): boolean|Error;
/**
* Retrieve all used keys as an array.
* Returns an array of keys.
* @see https://github.com/andris9/simpleStorage#index
*/
index(): [string]|boolean;
/**
* Get used storage in symbol count.
* @see https://github.com/andris9/simpleStorage#storagesize
*/
storageSize(): number;
}
/**
* @see https://github.com/andris9/simpleStorage#setkey-value-options
*/
export interface SetOptions {
/**
* Sets the time-to-live (TTL) value in milliseconds for the given key/value.
*/
TTL?: number;
}
}
declare module "simpleStorage" {
export = simpleStorage;
}
/**
* Cross-browser key-value store database to store data locally in the browser.
* {@link simpleStorage} is a fork of {@link http://www.jstorage.info/|jStorage} that only includes the minimal set of features. Basically it is a wrapper for native <code>{@link JSON}</code> + <code>{@link WindowLocalStorage.localStorage|localStorage}</code> with some TTL magic mixed in.
* The module has no dependencies, you can use it as a standalone script (introduces {@link simpleStorage} global) or as an AMD module. All modern browsers (including mobile) are supported, older browsers (IE7, Firefox 3) are not.
* {@link simpleStorage} is very small - about 1kB in size when minimized and gzipped.
* @see https://github.com/andris9/simpleStorage#simplestorage
*/
declare var simpleStorage:simplestoragejs.SimpleStorage;
+14
View File
@@ -152,6 +152,20 @@ declare module Twitter.Typeahead {
* If it's a precompiled template, the passed in context will contain query and isEmpty.
*/
header?: any;
/**
* Rendered when 0 suggestions are available for the given query.
* Can be either a HTML string or a precompiled template.
* If it's a precompiled template, the passed in context will contain query.
*/
notFound?: (query: string) => string;
/**
* Rendered when 0 synchronous suggestions are available but asynchronous suggestions are expected.
* Can be either a HTML string or a precompiled template.
* If it's a precompiled template, the passed in context will contain query.
*/
pending?: (query: string) => string;
/**
* Used to render a single suggestion.
+17 -2
View File
@@ -734,13 +734,13 @@ declare module uiGrid {
* to load when scrolling up
* @default false
*/
infiniteScrollUp?: boolean,
infiniteScrollUp?: boolean;
/**
* Inform the grid of whether there are rows
* to load scrolling down
* @default true
*/
infiniteScrollDown?: boolean,
infiniteScrollDown?: boolean;
/**
* Defaults to 200
* @default 200
@@ -1038,6 +1038,12 @@ declare module uiGrid {
* @param {scrollEndHandler} handler callback
*/
scrollEnd: (scope: ng.IScope, handler: scrollEndHandler) => void;
/**
* is raised after the sort criteria on one or more columns have changed
* @param {ng.IScope} scope Grid scope
* @param {sortChangedHandler} handler callback
*/
sortChanged: (scope: ng.IScope, handler: sortChangedHandler<TEntity>) => void;
}
}
export interface columnVisibilityChangedHandler<TEntity> {
@@ -1096,6 +1102,15 @@ declare module uiGrid {
(scrollEvent: JQueryMouseEventObject): void;
}
export interface sortChangedHandler<TEntity> {
/**
* Sort change event callback
* @param {IGridInstance} grid instance
* @param {IGridColumn} array of gridColumns that have sorting on them, sorted in priority order
*/
(grid: IGridInstanceOf<TEntity>, columns: Array<IGridColumnOf<TEntity>>): void;
}
export module cellNav {
/**
* Column Definitions for cellNav feature, these are available to be set using the ui-grid
+2
View File
@@ -0,0 +1,2 @@
tsconfig.json
.idea/
+88
View File
@@ -0,0 +1,88 @@
# UIkit
UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.
* [Homepage](http://getuikit.com) - Learn more about UIkit
* [@getuikit](https://twitter.com/getuikit) - Get the latest buzz on Twitter
* [Google+ Community](https://plus.google.com/communities/114238665434626719878) - Share news and latest work
Join our developer chat. We are online every work day between 8:00 and 18:00 UTC
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/uikit/uikit)
## Getting started
You have following options to get UIkit:
- Download the [latest release](https://github.com/uikit/uikit/releases/latest)
- Clone the repo, `git clone git://github.com/uikit/uikit.git`.
- Install with [Bower](http://bower.io): ```bower install uikit```
You find the compiled UIkit distribution in its own [repo](https://github.com/uikit/bower-uikit).
## Developers
First of all, install [Node](http://nodejs.org/). We use [Gulp](http://gulpjs.com) to build UIkit. If you haven't used Gulp before, you need to install the `gulp` package as a global install.
```
npm install --global gulp
```
If you haven't done so already, clone the UIkit git repo.
```
git clone git://github.com/uikit/uikit.git
```
Install the Node dependencies.
```
cd uikit
npm install
```
Run `gulp` to lint, build and minify the release.
```
gulp [-t themename]
```
The built version of UIkit will be put in the `/dist` subdirectory. Pass a theme name parameter to only build the specified theme.
### Browsersync
```
gulp sync
```
After running `gulp sync` a new browser instance will open, pointing to the uikit folder - `http://localhost:3000/`. The browser window will reload anytime you modify a source file.
### Custom prefix
Run gulp with your own prefix parameter ```-p``` to have all classes and JavaScript files custom prefixed.
```
gulp -p myprefix
```
## Contributing
UIkit follows the [GitFlow branching model](http://nvie.com/posts/a-successful-git-branching-model). The ```master``` branch always reflects a production-ready state while the latest development is taking place in the ```develop``` branch.
Each time you want to work on a fix or a new feature, create a new branch based on the ```develop``` branch: ```git checkout -b BRANCH_NAME develop```. Only pull requests to the ```develop``` branch will be merged.
## Versioning
UIkit is maintained by using the [Semantic Versioning Specification (SemVer)](http://semver.org).
## Browser Support
![Chrome](https://raw.github.com/alrra/browser-logos/master/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/firefox/firefox_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/internet-explorer/internet-explorer_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/opera/opera_48x48.png)
--- | --- | --- | --- | --- |
Latest ✔ | Latest ✔ | 9+ ✔ | 7.1+ ✔ | Latest ✔ |
Tested with [BrowserStack](https://www.browserstack.com) (thanks for sponsoring!).
## Copyright and License
Copyright [YOOtheme](http://www.yootheme.com) GmbH under the [MIT license](LICENSE.md).
+186
View File
@@ -0,0 +1,186 @@
/// <reference path="uikit.d.ts" />
function testModal() {
UIkit.modal.alert("Attention!");
UIkit.modal.confirm("Are you sure?", function () {
// will be executed on confirm.
});
UIkit.modal.prompt("Name:", 'value', function (newvalue:string) {
// will be executed on submit.
});
var modal = UIkit.modal.blockUI("Any content...");
modal.hide();
modal.show();
var modal = UIkit.modal(".modalSelector");
if (modal.isActive()) {
modal.hide();
} else {
modal.show();
}
}
function testOffCanvas() {
UIkit.offcanvas.show("#id");
UIkit.offcanvas.hide();
UIkit.offcanvas.hide(true);
}
function testLightBox() {
var element = "#group";
var lightbox = UIkit.lightbox(element, {/* options */});
var lightbox2 = UIkit.lightbox.create([
{source: 'http://url/to/video.mp4', 'type': 'video'},
{'source': 'http://url/to/image.jpg', 'type': 'image'}
]);
lightbox2.show();
var lightbox3 = UIkit.lightbox(element)
}
function testAutoComplete() {
UIkit.autocomplete("#group", {});
UIkit.autocomplete("#group");
}
function testDatepicker() {
var datepicker = UIkit.datepicker("#element", {});
}
function testHtmlEditor() {
var htmleditor = UIkit.htmleditor("textarea", {/* options */});
}
function testSlider() {
var slider = UIkit.slider("element", {})
}
function testSlideSet() {
var slideset = UIkit.slideset("element", {})
}
function testSlideShow() {
var slideshow = UIkit.slideshow("element", {})
}
function testParallax() {
var parallax = UIkit.parallax("element", {})
}
function testAccordion() {
var accordion = UIkit.accordion("element", {})
}
function testNotify() {
UIkit.notify({
message: 'Bazinga!',
status: 'info',
timeout: 5000,
pos: 'top-center'
});
// Shortcuts
UIkit.notify('My message');
UIkit.notify('My message', status);
UIkit.notify('My message', {/* options */});
UIkit.notify("Message...", {timeout: 0});
UIkit.notify("...", {pos: 'top-center'});
UIkit.notify("...", {status: 'info'});
}
function testSearch() {
var search = UIkit.search("element", {})
}
function testNestable() {
var nestable = UIkit.nestable('element', {});
}
function testSortable() {
var sortable = UIkit.sortable('element', {});
}
function testStick() {
var sticky = UIkit.sticky('element', {});
}
function testTimePicker() {
var timepicker = UIkit.timepicker('element', {})
}
function testTooltip() {
var tooltip = UIkit.tooltip('element', {})
}
function testUpload() {
$(function(){
var progressbar = $("#progressbar"),
bar = progressbar.find('.uk-progress-bar'),
settings = {
action: '/', // upload url
allow : '*.(jpg|jpeg|gif|png)', // allow only images
loadstart: function() {
bar.css("width", "0%").text("0%");
progressbar.removeClass("uk-hidden");
},
progress: function(percent: number) {
percent = Math.ceil(percent);
bar.css("width", percent+"%").text(percent+"%");
},
allcomplete: function(response: any) {
bar.css("width", "100%").text("100%");
setTimeout(function(){
progressbar.addClass("uk-hidden");
}, 250);
alert("Upload Completed")
}
};
var select = UIkit.uploadSelect($("#upload-select"), settings),
drop = UIkit.uploadDrop($("#upload-drop"), settings);
});
// Test with object literal
var select2 = UIkit.uploadSelect($("#upload-select"), {
action: '/', // upload url
allow: '*.(jpg|jpeg|gif|png)', // allow only images
loadstart: function () {
},
progress: function (percent:number) {
},
allcomplete: function (response:any) {
}
});
var drop2 = UIkit.uploadDrop($("#upload-drop"), {
action: '/', // upload url
allow: '*.(jpg|jpeg|gif|png)', // allow only images
loadstart: function () {
},
progress: function (percent:number) {
},
allcomplete: function (response:any) {
}
});
}
+1443
View File
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
/// <reference path="./utils-merge.d.ts" />
import merge from "utils-merge";
type Result = {a: string, b: number};
let result: Result;
result = merge<{a: string}, {b: number}, Result>({a: ''}, {b: 42});
+10
View File
@@ -0,0 +1,10 @@
// Type definitions for utils-merge
// Project: https://github.com/jaredhanson/utils-merge
// Definitions by: Ilya Mochalov <https://github.com/chrootsu>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "utils-merge" {
function merge<TA, TB, TResult>(a: TA, b: TB): TResult;
export default merge;
}
@@ -0,0 +1,85 @@
/// <reference path="./voximplant-websdk.d.ts"/>
var vox: VoxImplant.Client = VoxImplant.getInstance(),
call: VoxImplant.Call;
vox.init({
micRequired: true
});
vox.addEventListener("SDKReady", function(event: VoxImplant.Events.SDKReady) {
console.log("VoxImplant SDK ver. " + event.version + " initialized");
vox.connect();
});
vox.addEventListener("ConnectionEstablished", function(event: VoxImplant.Events.ConnectionEstablished) {
console.log("Connection established");
vox.login("username", "password");
});
vox.addEventListener("ConnectionClosed", function(event: VoxImplant.Events.ConnectionClosed) {
console.log("Connection closed");
});
vox.addEventListener("ConnectionFailed", function(event: VoxImplant.Events.ConnectionFailed) {
console.log("Connection failed. Reason: " + event.message);
});
vox.addEventListener("AuthEvent", function(event: VoxImplant.Events.AuthEvent) {
if (event.result === true) {
// Authorized successfully
console.log("Logged in as " + event.displayName);
call = vox.call("some_number", false);
call.addEventListener("Connected", function(callevent: VoxImplant.CallEvents.Connected) {
console.log("Call connected");
});
call.addEventListener("Failed", function(callevent: VoxImplant.CallEvents.Failed) {
console.log("Call failed, reason: " + callevent.reason);
});
call.addEventListener("Disconnected", function(callevent: VoxImplant.CallEvents.Disconnected) {
console.log("Call disconnected");
});
var msg_id:String = vox.sendInstantMessage("other_user", "Hello World!");
} else {
console.log("Authorization failed. Code: " + event.code);
}
});
vox.addEventListener("MicAccessResult", function(event: VoxImplant.Events.MicAccessResult) {
console.log("Microphone access allowed: " + event.result);
});
vox.addEventListener("IncomingCall", function(event: VoxImplant.Events.IncomingCall) {
call = event.call;
call.addEventListener("Connected", function(callevent: VoxImplant.CallEvents.Connected) {
console.log("Inbound Call Connected");
setTimeout(function() {
vox.disconnect();
}, 5000);
});
call.answer();
});
vox.addEventListener("MessageReceived", function(event: VoxImplant.IMEvents.MessageReceived) {
console.log("Message received: " + event.content + " from " + event.id + " id " + event.message_id);
});
vox.addEventListener("SourcesInfoUpdated", function(event: VoxImplant.Events.SourcesInfoUpdated) {
var audioSources: VoxImplant.AudioSourceInfo[] = vox.audioSources(),
videoSources: VoxImplant.VideoSourceInfo[] = vox.videoSources();
console.log("Received recording sources data:");
console.log("Audio: " + audioSources);
console.log("Video: " + videoSources);
vox.useAudioSource(audioSources[0].id, function() { console.log('OK'); }, function() { console.log('Failed'); });
vox.useVideoSource(videoSources[0].id, function() { console.log('OK'); }, function() { console.log('Failed'); });
});
vox.addEventListener("RosterReceived", function(event: VoxImplant.IMEvents.RosterReceived) {
var roster: VoxImplant.RosterItem[] = event.roster;
console.log("Roster received: " + roster);
});
File diff suppressed because it is too large Load Diff
+15
View File
@@ -0,0 +1,15 @@
/// <reference path="./webpack-env.d.ts" />
interface SomeModule {
someMethod(): void;
}
let someModule = require<SomeModule>('./someModule');
someModule.someMethod();
let context = require.context('./somePath', true);
let contextModule = context<SomeModule>('./someModule');
require(['./someModule', './otherModule'], (someModule: SomeModule, otherModule: any) => {
});
+103
View File
@@ -0,0 +1,103 @@
// Type definitions for webpack 1.12.2 (module API)
// Project: https://github.com/webpack/webpack
// Definitions by: use-strict <https://github.com/use-strict>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/**
* Webpack module API - variables and global functions available inside modules
*/
declare namespace __WebpackModuleApi {
interface RequireContext {
keys(): string[];
<T>(id: string): T;
resolve(id: string): string;
}
interface RequireFunction {
/**
* Returns the exports from a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available.
*/
<T>(path: string): T;
/**
* Behaves similar to require.ensure, but the callback is called with the exports of each dependency in the paths array. There is no option to provide a chunk name.
*/
(paths: string[], callback: (...modules: any[]) => void): void;
/**
* Download additional dependencies on demand. The paths array lists modules that should be available. When they are, callback is called. If the callback is a function expression, dependencies in that source part are extracted and also loaded on demand. A single request is fired to the server, except if all modules are already available.
*
* This creates a chunk. The chunk can be named. If a chunk with this name already exists, the dependencies are merged into that chunk and that chunk is used.
*/
ensure: (paths: string[], callback: (require: <T>(path: string) => T) => void) => void;
context: (path: string, deep?: boolean, filter?: RegExp) => RequireContext;
/**
* Returns the module id of a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available.
*
* The module id is a number in webpack (in contrast to node.js where it is a string, the filename).
*/
resolve(path: string): number;
/**
* Like require.resolve, but doesnt include the module into the bundle. Its a weak dependency.
*/
resolveWeak(path: string): number;
/**
* Ensures that the dependency is available, but dont execute it. This can be use for optimizing the position of a module in the chunks.
*/
include(path: string): void;
/**
* Multiple requires to the same module result in only one module execution and only one export. Therefore a cache in the runtime exists. Removing values from this cache cause new module execution and a new export. This is only needed in rare cases (for compatibility!).
*/
cache: {
[id: string]: any;
}
}
}
declare var require: __WebpackModuleApi.RequireFunction;
/**
* The resource query of the current module.
*
* e.g. __resourceQuery === "?test" // Inside "file.js?test"
*/
declare var __resourceQuery: string;
/**
* Equals the config options output.publicPath.
*/
declare var __webpack_public_path__: string;
/**
* The raw require function. This expression isnt parsed by the Parser for dependencies.
*/
declare var __webpack_require__: any;
/**
* The internal chunk loading function
*
* @param chunkId The id for the chunk to load.
* @param callback A callback function called once the chunk is loaded.
*/
declare var __webpack_chunk_load__: (chunkId: any, callback: (require: (id: string) => any) => void) => void;
/**
* Access to the internal object of all modules.
*/
declare var __webpack_modules__: any[];
/**
* Access to the hash of the compilation.
*
* Only available with the HotModuleReplacementPlugin or the ExtendedAPIPlugin
*/
declare var __webpack_hash__: any;
/**
* Generates a require function that is not parsed by webpack. Can be used to do cool stuff with a global require function if available.
*/
declare var __non_webpack_require__: any;
/**
* Equals the config option debug
*/
declare var DEBUG: boolean;
-19
View File
@@ -386,22 +386,3 @@ plugin = new webpack.ExtendedAPIPlugin();
plugin = new webpack.NoErrorsPlugin();
plugin = new webpack.WatchIgnorePlugin(paths);
//
// http://webpack.github.io/docs/api-in-modules.html
//
interface SomeModule {
someMethod(): void;
}
let someModule: SomeModule = require('./someModule');
someModule.someMethod();
let context2 = require.context('./somePath', true);
let contextModule: SomeModule = context2('./someModule');
require(['./someModule', './otherModule'], (someModule: SomeModule, otherModule: any) => {
});
-98
View File
@@ -259,101 +259,3 @@ declare module "webpack" {
export = webpack;
}
/**
* Webpack module API - variables and global functions available inside modules
*/
declare namespace __WebpackModuleApi {
interface RequireContext {
keys(): string[];
<T>(id: string): T;
resolve(id: string): string;
}
interface RequireFunction {
/**
* Returns the exports from a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available.
*/
<T>(path: string): T;
/**
* Behaves similar to require.ensure, but the callback is called with the exports of each dependency in the paths array. There is no option to provide a chunk name.
*/
(paths: string[], callback: (...modules: any[]) => void): void;
/**
* Download additional dependencies on demand. The paths array lists modules that should be available. When they are, callback is called. If the callback is a function expression, dependencies in that source part are extracted and also loaded on demand. A single request is fired to the server, except if all modules are already available.
*
* This creates a chunk. The chunk can be named. If a chunk with this name already exists, the dependencies are merged into that chunk and that chunk is used.
*/
ensure: (paths: string[], callback: (require: <T>(path: string) => T) => void) => void;
context: (path: string, deep?: boolean, filter?: RegExp) => RequireContext;
/**
* Returns the module id of a dependency. The call is sync. No request to the server is fired. The compiler ensures that the dependency is available.
*
* The module id is a number in webpack (in contrast to node.js where it is a string, the filename).
*/
resolve(path: string): number;
/**
* Like require.resolve, but doesnt include the module into the bundle. Its a weak dependency.
*/
resolveWeak(path: string): number;
/**
* Ensures that the dependency is available, but dont execute it. This can be use for optimizing the position of a module in the chunks.
*/
include(path: string): void;
/**
* Multiple requires to the same module result in only one module execution and only one export. Therefore a cache in the runtime exists. Removing values from this cache cause new module execution and a new export. This is only needed in rare cases (for compatibility!).
*/
cache: {
[id: string]: any;
}
}
}
declare var require: __WebpackModuleApi.RequireFunction;
/**
* The resource query of the current module.
*
* e.g. __resourceQuery === "?test" // Inside "file.js?test"
*/
declare var __resourceQuery: string;
/**
* Equals the config options output.publicPath.
*/
declare var __webpack_public_path__: string;
/**
* The raw require function. This expression isnt parsed by the Parser for dependencies.
*/
declare var __webpack_require__: any;
/**
* The internal chunk loading function
*
* @param chunkId The id for the chunk to load.
* @param callback A callback function called once the chunk is loaded.
*/
declare var __webpack_chunk_load__: (chunkId: any, callback: (require: (id: string) => any) => void) => void;
/**
* Access to the internal object of all modules.
*/
declare var __webpack_modules__: any[];
/**
* Access to the hash of the compilation.
*
* Only available with the HotModuleReplacementPlugin or the ExtendedAPIPlugin
*/
declare var __webpack_hash__: any;
/**
* Generates a require function that is not parsed by webpack. Can be used to do cool stuff with a global require function if available.
*/
declare var __non_webpack_require__: any;
/**
* Equals the config option debug
*/
declare var DEBUG: boolean;
+2473 -820
View File
File diff suppressed because it is too large Load Diff
+20 -8
View File
@@ -8,6 +8,7 @@ import TokenOpts = X.TokenOpts;
var exp: RegExp;
var expArr: RegExp[];
var expArrArr: RegExp[][];
var chain: RegExp[];
var groupChain: { regex: RegExp; backref: string }[];
var groupChain1: { regex: RegExp; backref: number }[];
@@ -19,6 +20,7 @@ var search: string;
var searchEx: RegExp;
var bool: boolean;
var strArr: string[];
var strArrArr: string[][];
var pattern: string;
var flags: string;
var right: string;
@@ -42,6 +44,14 @@ str = XRegExp.version;
// -- -- -- -- -- -- -- -- -- -- -- -- --
regex = X(str);
regex = X(str, flags);
regex = X(regex);
str = X.version;
// -- -- -- -- -- -- -- -- -- -- -- -- --
XRegExp.addToken(regex, (arr, scope) => {
matchArr = arr;
str = scope;
@@ -69,13 +79,6 @@ matchArr = XRegExp.exec(str, regex);
// -- -- -- -- -- -- -- -- -- -- -- -- --
matchArr = XRegExp.forEach(str, regex, (match, index, input, regexp) => {
exp = regexp;
str = input;
num = index;
matchArr = match;
}, obj);
matchArr = XRegExp.forEach(str, regex, (match, index, input, regexp) => {
exp = regexp;
str = input;
@@ -92,6 +95,11 @@ XRegExp.install(obj);
bool = XRegExp.isInstalled(str);
bool = XRegExp.isRegExp(value);
strArr = XRegExp.match(str, regex);
strArr = XRegExp.match(str, regex, scope);
str = XRegExp.match(str, regex, "one");
strArr = XRegExp.matchChain(str, chain);
strArr = XRegExp.matchChain(str, groupChain);
strArr = XRegExp.matchChain(str, groupChain1);
@@ -113,6 +121,11 @@ str = XRegExp.replace(str, searchEx, str);
str = XRegExp.replace(str, searchEx, replacer, scope);
str = XRegExp.replace(str, searchEx, replacer);
// -- -- -- -- -- -- -- -- -- -- -- -- --
str = XRegExp.replaceEach(str, expArrArr);
str = XRegExp.replaceEach(str, strArrArr);
str = XRegExp.replaceEach(str, [[str, exp], [str, exp]]);
// -- -- -- -- -- -- -- -- -- -- -- -- --
strArr = XRegExp.split(str, search, limit);
@@ -135,4 +148,3 @@ regex = XRegExp.union(strArr, flags);
regex = XRegExp.union(strArr);
// -- -- -- -- -- -- -- -- -- -- -- -- --
+95 -23
View File
@@ -1,38 +1,58 @@
// Type definitions for XRegExp 2.0.0
// Type definitions for XRegExp 3.0.0
// Project: http://xregexp.com
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>,
// Johannes Fahrenkrug <https://github.com/jfahrenkrug>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'xregexp' {
// scopes: 'default', 'class', or 'all'
/*
Native flags:
g - global
i - ignore case
m - multiline anchors
y - sticky (Firefox 3+)
Additional XRegExp flags:
n - explicit capture
s - dot matches all (aka singleline)
x - free-spacing and line comments (aka extended)
*/
export interface TokenOpts {
scope?: string;
trigger?: () => boolean;
customFlags?: string;
}
export function XRegExp(pattern: string, flags?: string): RegExp;
export function XRegExp(pattern: RegExp): RegExp;
function OuterXRegExp(pattern: string, flags?: string): RegExp;
function OuterXRegExp(pattern: RegExp): RegExp;
export module XRegExp {
module OuterXRegExp {
// scopes: 'default', 'class', or 'all'
/*
Native flags:
g - global
i - ignore case
m - multiline anchors
y - sticky (Firefox 3+)
Additional XRegExp flags:
n - explicit capture
s - dot matches all (aka singleline)
x - free-spacing and line comments (aka extended)
*/
interface TokenOpts {
scope?: string;
trigger?: () => boolean;
customFlags?: string;
}
function XRegExp(pattern: string, flags?: string): RegExp;
function XRegExp(pattern: RegExp): RegExp;
/* Since xregexp 3.0.0 can be used either via
import X = require('xregexp');
X();
or via
import XRegExp = X.XRegExp;
XRegExp()
I had to duplicate the function declarations. I could simply not
find another way to accomplish this with TypeScript.
*/
// begin API definitions
function addToken(regex: RegExp, handler: (matchArr: RegExpExecArray, scope: string) => string, options?: TokenOpts): void;
function build(pattern: string, subs: string[], flags?: string): RegExp;
function cache(pattern: string, flags?: string): RegExp;
function escape(str: string): string;
function exec(str: string, regex: RegExp, pos?: number, sticky?: boolean): RegExpExecArray;
function forEach(str: string, regex: RegExp, callback: (matchArr: RegExpExecArray, index: number, input: string, regexp: RegExp) => void, context?: Object): any;
function forEach(str: string, regex: RegExp, callback: (matchArr: RegExpExecArray, index: number, input: string, regexp: RegExp) => void): any;
function globalize(regex: RegExp): RegExp;
function install(options: string): void;
@@ -40,6 +60,10 @@ declare module 'xregexp' {
function isInstalled(feature: string): boolean;
function isRegExp(value: any): boolean;
function match(str: string, regex: RegExp, scope: string): any;
function match(str: string, regex: RegExp, scope: "one"): string;
function match(str: string, regex: RegExp, scope: "all"): string[];
function match(str: string, regex: RegExp): string[];
function matchChain(str: string, chain: RegExp[]): string[];
function matchChain(str: string, chain: { regex: RegExp; backref: string }[]): string[];
function matchChain(str: string, chain: { regex: RegExp; backref: number }[]): string[];
@@ -49,6 +73,7 @@ declare module 'xregexp' {
function replace(str: string, search: string, replacement: Function, scope?: string): string;
function replace(str: string, search: RegExp, replacement: string, scope?: string): string;
function replace(str: string, search: RegExp, replacement: Function, scope?: string): string;
function replaceEach(str: string, replacements: Array<RegExp|string>[]): string;
function split(str: string, separator: string, limit?: number): string[];
function split(str: string, separator: RegExp, limit?: number): string[];
@@ -60,5 +85,52 @@ declare module 'xregexp' {
function union(patterns: string[], flags?: string): RegExp;
var version: string;
// end API definitions
module XRegExp {
// begin API definitions
function addToken(regex: RegExp, handler: (matchArr: RegExpExecArray, scope: string) => string, options?: TokenOpts): void;
function build(pattern: string, subs: string[], flags?: string): RegExp;
function cache(pattern: string, flags?: string): RegExp;
function escape(str: string): string;
function exec(str: string, regex: RegExp, pos?: number, sticky?: boolean): RegExpExecArray;
function forEach(str: string, regex: RegExp, callback: (matchArr: RegExpExecArray, index: number, input: string, regexp: RegExp) => void): any;
function globalize(regex: RegExp): RegExp;
function install(options: string): void;
function install(options: Object): void;
function isInstalled(feature: string): boolean;
function isRegExp(value: any): boolean;
function match(str: string, regex: RegExp, scope: string): any;
function match(str: string, regex: RegExp, scope: "one"): string;
function match(str: string, regex: RegExp, scope: "all"): string[];
function match(str: string, regex: RegExp): string[];
function matchChain(str: string, chain: RegExp[]): string[];
function matchChain(str: string, chain: { regex: RegExp; backref: string }[]): string[];
function matchChain(str: string, chain: { regex: RegExp; backref: number }[]): string[];
function matchRecursive(str: string, left: string, right: string, flags?: string, options?: Object): string[];
function replace(str: string, search: string, replacement: string, scope?: string): string;
function replace(str: string, search: string, replacement: Function, scope?: string): string;
function replace(str: string, search: RegExp, replacement: string, scope?: string): string;
function replace(str: string, search: RegExp, replacement: Function, scope?: string): string;
function replaceEach(str: string, replacements: Array<RegExp|string>[]): string;
function split(str: string, separator: string, limit?: number): string[];
function split(str: string, separator: RegExp, limit?: number): string[];
function test(str: string, regex: RegExp, pos?: number, sticky?: boolean): boolean;
function uninstall(options: Object): void;
function uninstall(options: string): void;
function union(patterns: string[], flags?: string): RegExp;
var version: string;
// end API definitions
}
}
export = OuterXRegExp;
}