mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge branch 'master' of https://github.com/ekosystem/DefinitelyTyped
This commit is contained in:
@@ -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 test’s `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 });
|
||||
Vendored
+192
@@ -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;
|
||||
}
|
||||
Vendored
+3
@@ -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,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]);
|
||||
Vendored
+36
@@ -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 = _;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Vendored
+8
-7
@@ -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 {}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
+1165
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user