mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 09:01:45 +08:00
Merge branch 'upstream-master' into request-fix-defaults
This commit is contained in:
16
assertsharp/assertsharp-tests.ts
Normal file
16
assertsharp/assertsharp-tests.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/// <reference path="./assertsharp.d.ts" />
|
||||
|
||||
import Assert from "assertsharp";
|
||||
|
||||
Assert.AreEqual(0, 0, "Pass");
|
||||
Assert.AreNotEqual(0, 1, "Pass");
|
||||
Assert.AreNotSame(new Date(), new Date(), "Pass");
|
||||
Assert.AreSequenceEqual([0], [0], (x, y) => x === y, "Pass");
|
||||
Assert.Fail("Should fail");
|
||||
Assert.IsFalse(false, "Pass");
|
||||
Assert.IsInstanceOfType(new Date(), Date, "Pass");
|
||||
Assert.IsNotInstanceOfType(true, Date, "Pass");
|
||||
Assert.IsNotNull(new Date(), "Pass");
|
||||
Assert.IsNull(null, "Pass");
|
||||
Assert.IsTrue(true, "Pass");
|
||||
Assert.Throws(() => { throw ""; }, "Pass");
|
||||
21
assertsharp/assertsharp.d.ts
vendored
Normal file
21
assertsharp/assertsharp.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// Type definitions for assertsharp
|
||||
// Project: https://www.npmjs.com/package/assertsharp
|
||||
// Definitions by: Bruno Leonardo Michels <https://github.com/brunolm>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "assertsharp" {
|
||||
export default class Assert {
|
||||
static AreEqual<T>(expected: T, actual: T, message?: string): void;
|
||||
static AreNotEqual<T>(notExpected: T, actual: T, message?: string): void;
|
||||
static AreNotSame<T>(notExpected: T, actual: T, message?: string): void;
|
||||
static AreSequenceEqual<T>(expected: T[], actual: T[], equals?: (x: any, y: any) => boolean, message?: string): void;
|
||||
static Fail(message?: string): void;
|
||||
static IsFalse(actual: boolean, message?: string): void;
|
||||
static IsInstanceOfType(actual: any, expectedType: Function, message?: string): void;
|
||||
static IsNotInstanceOfType(actual: any, wrongType: Function, message?: string): void;
|
||||
static IsNotNull(actual: any, message?: string): void;
|
||||
static IsNull(actual: any, message?: string): void;
|
||||
static IsTrue(actual: boolean, message?: string): void;
|
||||
static Throws(fn: () => void, message?: string): void;
|
||||
}
|
||||
}
|
||||
16
bytes/bytes-tests.ts
Normal file
16
bytes/bytes-tests.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/// <reference path="./bytes.d.ts"/>
|
||||
|
||||
import bytes = require('bytes');
|
||||
|
||||
// 1024*1024 = 1048576
|
||||
console.log(bytes(104857));
|
||||
console.log(bytes(104857, { thousandsSeparator: ' ' }));
|
||||
|
||||
console.log(bytes.format(104857));
|
||||
console.log(bytes.format(104857, { thousandsSeparator: ' ' }));
|
||||
|
||||
console.log(bytes('1024kb'));
|
||||
console.log(bytes(1024));
|
||||
|
||||
console.log(bytes.parse('1024kb'));
|
||||
console.log(bytes.parse(1024));
|
||||
62
bytes/bytes.d.ts
vendored
Normal file
62
bytes/bytes.d.ts
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
// Type definitions for bytes v2.1.0
|
||||
// Project: https://github.com/visionmedia/bytes.js
|
||||
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module 'bytes' {
|
||||
|
||||
/**
|
||||
*Convert the given value in bytes into a string.
|
||||
*
|
||||
* @param {number} value
|
||||
* @param {{
|
||||
* thousandsSeparator: [string]
|
||||
* }} [options] bytes options.
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
function bytes(value: number, options?: { thousandsSeparator: string }): string;
|
||||
|
||||
/**
|
||||
*Parse string to an integer in bytes.
|
||||
*
|
||||
* @param {string} value
|
||||
* @returns {number}
|
||||
*/
|
||||
function bytes(value: string): number;
|
||||
|
||||
module bytes {
|
||||
|
||||
/**
|
||||
* Format the given value in bytes into a string.
|
||||
*
|
||||
* If the value is negative, take Math.abs(). If it is a float,
|
||||
* it is rounded.
|
||||
*
|
||||
* @param {number} value
|
||||
* @param {BytesFormatOptions} [options]
|
||||
*/
|
||||
|
||||
function format(value: number, options?: { thousandsSeparator: string }): string;
|
||||
|
||||
/**
|
||||
* Just return the input number value.
|
||||
*
|
||||
* @param {number} value
|
||||
* @return {number}
|
||||
*/
|
||||
function parse(value: number): number;
|
||||
|
||||
/**
|
||||
* Parse the string value into an integer in bytes.
|
||||
*
|
||||
* If no unit is given, it is assumed the value is in bytes.
|
||||
*
|
||||
* @param {string} value
|
||||
* @return {number}
|
||||
*/
|
||||
function parse(value: string): number;
|
||||
}
|
||||
|
||||
export = bytes;
|
||||
}
|
||||
54
depd/depd-tests.ts
Normal file
54
depd/depd-tests.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
/// <reference path="./depd.d.ts"/>
|
||||
|
||||
import depd = require('depd');
|
||||
|
||||
var deprecate = depd("depd-tests");
|
||||
|
||||
function assert(condition: boolean, message: string): void {
|
||||
if (!condition) {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
|
||||
function testDepdMessage(...args: string[]): boolean {
|
||||
if (arguments.length < 1) {
|
||||
deprecate('testDepdMessage argument.lenth<1');
|
||||
return true;
|
||||
} else {
|
||||
console.log('normal logic');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
assert(testDepdMessage() === true, "Deprecated code must be triggered!");
|
||||
assert(testDepdMessage('a') === false, "Deprecated code must be triggered!");
|
||||
|
||||
interface ITestObject {
|
||||
p1: string;
|
||||
p2: string;
|
||||
}
|
||||
|
||||
var obj = <ITestObject>{ p1: 'deprecated property', p2: 'normal property' };
|
||||
deprecate.property(obj, 'p1', 'property [p1] is deprecated!');
|
||||
|
||||
console.log(obj.p1);
|
||||
|
||||
interface ITestDeprecatedFunction {
|
||||
func1?: Function;
|
||||
func2?: Function;
|
||||
}
|
||||
|
||||
var obj2 = <ITestDeprecatedFunction>{};
|
||||
|
||||
// message automatically derived from function name
|
||||
obj2.func1 = deprecate.function(function func1() {
|
||||
console.log('all calls to [func1] are deprecated ');
|
||||
});
|
||||
|
||||
// specific message
|
||||
obj2.func2 = deprecate.function(function () {
|
||||
console.log('all calls to [func2] are deprecated ');
|
||||
}, 'func2');
|
||||
|
||||
obj2.func1();
|
||||
obj2.func2();
|
||||
17
depd/depd.d.ts
vendored
Normal file
17
depd/depd.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Type definitions for depd 1.1.0
|
||||
// Project: https://github.com/dougwilson/nodejs-depd
|
||||
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
declare module 'depd' {
|
||||
function depd(namespace: string): Deprecate;
|
||||
|
||||
interface Deprecate {
|
||||
(message: string): void;
|
||||
function(fn: Function, message?: string): Function;
|
||||
property(obj: Object, prop: string, message: string): void;
|
||||
}
|
||||
|
||||
export = depd;
|
||||
}
|
||||
2
dexie/dexie.d.ts
vendored
2
dexie/dexie.d.ts
vendored
@@ -38,7 +38,7 @@ declare class Dexie {
|
||||
|
||||
static deepClone(obj: Object): Object;
|
||||
|
||||
version(versionNumber: Number): Dexie.Version
|
||||
version(versionNumber: number): Dexie.Version
|
||||
|
||||
on: {
|
||||
(eventName: string, subscriber: () => any): void;
|
||||
|
||||
File diff suppressed because one or more lines are too long
11692
fhir/fhir.d.ts
vendored
11692
fhir/fhir.d.ts
vendored
File diff suppressed because it is too large
Load Diff
23
firebase/firebase.d.ts
vendored
23
firebase/firebase.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Firebase API 2.0.2
|
||||
// Project: https://www.firebase.com/docs/javascript/firebase
|
||||
// Definitions by: Vincent Botone <https://github.com/vbortone/>, Shin1 Kashimura <https://github.com/in-async/>
|
||||
// Definitions by: Vincent Botone <https://github.com/vbortone/>, Shin1 Kashimura <https://github.com/in-async/>, Sebastien Dubois <https://github.com/dsebastien/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface FirebaseAuthResult {
|
||||
@@ -317,6 +317,27 @@ interface FirebaseAuthData {
|
||||
token: string;
|
||||
expires: number;
|
||||
auth: Object;
|
||||
google?: FirebaseAuthDataGoogle;
|
||||
}
|
||||
|
||||
interface FirebaseAuthDataGoogle {
|
||||
accessToken: string;
|
||||
cachedUserProfile: FirebaseAuthDataGoogleCachedUserProfile;
|
||||
displayName: string;
|
||||
email?: string;
|
||||
id: string;
|
||||
profileImageURL: string;
|
||||
}
|
||||
|
||||
interface FirebaseAuthDataGoogleCachedUserProfile {
|
||||
"family name"?: string;
|
||||
gender?: string;
|
||||
"given name"?: string;
|
||||
id?: string;
|
||||
link?: string;
|
||||
locale?: string;
|
||||
name?: string;
|
||||
picture?: string;
|
||||
}
|
||||
|
||||
interface FirebaseCredentials {
|
||||
|
||||
2
gridfs-stream/gridfs-stream.d.ts
vendored
2
gridfs-stream/gridfs-stream.d.ts
vendored
@@ -52,6 +52,7 @@ declare module "gridfs-stream" {
|
||||
|
||||
files: mongo.Collection;
|
||||
collection(name?: string): mongo.Collection;
|
||||
curCol: string;
|
||||
|
||||
createWriteStream(options?: GridFSStream.Options): GridFSStream.WriteStream;
|
||||
createReadStream(options?: GridFSStream.Options): GridFSStream.ReadStream;
|
||||
@@ -60,6 +61,7 @@ declare module "gridfs-stream" {
|
||||
|
||||
remove(options: GridFSStream.Options, callback: (err: Error) => void): void;
|
||||
exist(options: GridFSStream.Options, callback: (err: Error, found: boolean) => void): void;
|
||||
findOne(options: GridFSStream.Options, callback: (err: Error, record: any)=>void):void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
highcharts/highcharts.d.ts
vendored
1
highcharts/highcharts.d.ts
vendored
@@ -1715,6 +1715,7 @@ interface HighchartsCSSObject {
|
||||
color?: string;
|
||||
cursor?: string;
|
||||
font?: string;
|
||||
fontFamily?: string;
|
||||
fontSize?: string;
|
||||
fontWeight?: string;
|
||||
left?: string;
|
||||
|
||||
2
html2canvas/html2canvas.d.ts
vendored
2
html2canvas/html2canvas.d.ts
vendored
@@ -37,6 +37,8 @@ declare module Html2Canvas {
|
||||
/** Whether to attempt to load cross-origin images as CORS served, before reverting back to proxy. */
|
||||
useCORS?: boolean;
|
||||
|
||||
/** Callback providing the rendered canvas element after rendering */
|
||||
onrendered?(canvas: HTMLCanvasElement): void;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -260,17 +260,37 @@ module TestDifference {
|
||||
|
||||
// _.drop
|
||||
{
|
||||
let testDropArray: TResult[];
|
||||
let testDropList: _.List<TResult>;
|
||||
let result: TResult[];
|
||||
result = _.drop<TResult>(testDropArray);
|
||||
result = _.drop<TResult>(testDropArray, 42);
|
||||
result = _.drop<TResult>(testDropList);
|
||||
result = _.drop<TResult>(testDropList, 42);
|
||||
result = _(testDropArray).drop().value();
|
||||
result = _(testDropArray).drop(42).value();
|
||||
result = _(testDropList).drop<TResult>().value();
|
||||
result = _(testDropList).drop<TResult>(42).value();
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
|
||||
{
|
||||
let result: TResult[];
|
||||
result = _.drop<TResult>(array);
|
||||
result = _.drop<TResult>(array, 42);
|
||||
|
||||
result = _.drop<TResult>(list);
|
||||
result = _.drop<TResult>(list, 42);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).drop();
|
||||
result = _(array).drop(42);
|
||||
|
||||
result = _(list).drop<TResult>();
|
||||
result = _(list).drop<TResult>(42);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().drop();
|
||||
result = _(array).chain().drop(42);
|
||||
|
||||
result = _(list).chain().drop<TResult>();
|
||||
result = _(list).chain().drop<TResult>(42);
|
||||
}
|
||||
}
|
||||
|
||||
// _.dropRight
|
||||
@@ -315,35 +335,60 @@ module TestDropRightWhile {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let predicateFn: (value: TResult, index: number, collection: _.List<TResult>) => boolean;
|
||||
let result: TResult[];
|
||||
|
||||
result = _.dropRightWhile<TResult>(array);
|
||||
result = _.dropRightWhile<TResult>(array, predicateFn);
|
||||
result = _.dropRightWhile<TResult>(array, predicateFn, any);
|
||||
result = _.dropRightWhile<TResult>(array, '');
|
||||
result = _.dropRightWhile<TResult>(array, '', any);
|
||||
result = _.dropRightWhile<{a: number;}, TResult>(array, {a: 42});
|
||||
{
|
||||
let result: TResult[];
|
||||
|
||||
result = _.dropRightWhile<TResult>(list);
|
||||
result = _.dropRightWhile<TResult>(list, predicateFn);
|
||||
result = _.dropRightWhile<TResult>(list, predicateFn, any);
|
||||
result = _.dropRightWhile<TResult>(list, '');
|
||||
result = _.dropRightWhile<TResult>(list, '', any);
|
||||
result = _.dropRightWhile<{a: number;}, TResult>(list, {a: 42});
|
||||
result = _.dropRightWhile<TResult>(array);
|
||||
result = _.dropRightWhile<TResult>(array, predicateFn);
|
||||
result = _.dropRightWhile<TResult>(array, predicateFn, any);
|
||||
result = _.dropRightWhile<TResult>(array, '');
|
||||
result = _.dropRightWhile<TResult>(array, '', any);
|
||||
result = _.dropRightWhile<{a: number;}, TResult>(array, {a: 42});
|
||||
|
||||
result = _(array).dropRightWhile().value();
|
||||
result = _(array).dropRightWhile(predicateFn).value();
|
||||
result = _(array).dropRightWhile(predicateFn, any).value();
|
||||
result = _(array).dropRightWhile('').value();
|
||||
result = _(array).dropRightWhile('', any).value();
|
||||
result = _(array).dropRightWhile<{a: number;}>({a: 42}).value();
|
||||
result = _.dropRightWhile<TResult>(list);
|
||||
result = _.dropRightWhile<TResult>(list, predicateFn);
|
||||
result = _.dropRightWhile<TResult>(list, predicateFn, any);
|
||||
result = _.dropRightWhile<TResult>(list, '');
|
||||
result = _.dropRightWhile<TResult>(list, '', any);
|
||||
result = _.dropRightWhile<{a: number;}, TResult>(list, {a: 42});
|
||||
}
|
||||
|
||||
result = _(list).dropRightWhile<TResult>().value();
|
||||
result = _(list).dropRightWhile<TResult>(predicateFn).value();
|
||||
result = _(list).dropRightWhile<TResult>(predicateFn, any).value();
|
||||
result = _(list).dropRightWhile<TResult>('').value();
|
||||
result = _(list).dropRightWhile<TResult>('', any).value();
|
||||
result = _(list).dropRightWhile<{a: number;}, TResult>({a: 42}).value();
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).dropRightWhile();
|
||||
result = _(array).dropRightWhile(predicateFn);
|
||||
result = _(array).dropRightWhile(predicateFn, any);
|
||||
result = _(array).dropRightWhile('');
|
||||
result = _(array).dropRightWhile('', any);
|
||||
result = _(array).dropRightWhile<{a: number;}>({a: 42});
|
||||
|
||||
result = _(list).dropRightWhile<TResult>();
|
||||
result = _(list).dropRightWhile<TResult>(predicateFn);
|
||||
result = _(list).dropRightWhile<TResult>(predicateFn, any);
|
||||
result = _(list).dropRightWhile<TResult>('');
|
||||
result = _(list).dropRightWhile<TResult>('', any);
|
||||
result = _(list).dropRightWhile<{a: number;}, TResult>({a: 42});
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().dropRightWhile();
|
||||
result = _(array).chain().dropRightWhile(predicateFn);
|
||||
result = _(array).chain().dropRightWhile(predicateFn, any);
|
||||
result = _(array).chain().dropRightWhile('');
|
||||
result = _(array).chain().dropRightWhile('', any);
|
||||
result = _(array).chain().dropRightWhile<{a: number;}>({a: 42});
|
||||
|
||||
result = _(list).chain().dropRightWhile<TResult>();
|
||||
result = _(list).chain().dropRightWhile<TResult>(predicateFn);
|
||||
result = _(list).chain().dropRightWhile<TResult>(predicateFn, any);
|
||||
result = _(list).chain().dropRightWhile<TResult>('');
|
||||
result = _(list).chain().dropRightWhile<TResult>('', any);
|
||||
result = _(list).chain().dropRightWhile<{a: number;}, TResult>({a: 42});
|
||||
}
|
||||
}
|
||||
|
||||
// _.dropWhile
|
||||
@@ -477,36 +522,58 @@ module TestFindIndex {
|
||||
module TestFindLastIndex {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
|
||||
let predicateFn: (value: TResult, index?: number, collection?: _.List<TResult>) => boolean;
|
||||
let result: number;
|
||||
|
||||
result = _.findLastIndex<TResult>(array);
|
||||
result = _.findLastIndex<TResult>(array, predicateFn);
|
||||
result = _.findLastIndex<TResult>(array, predicateFn, any);
|
||||
result = _.findLastIndex<TResult>(array, '');
|
||||
result = _.findLastIndex<TResult>(array, '', any);
|
||||
result = _.findLastIndex<{a: number}, TResult>(array, {a: 42});
|
||||
{
|
||||
let result: number;
|
||||
|
||||
result = _.findLastIndex<TResult>(list);
|
||||
result = _.findLastIndex<TResult>(list, predicateFn);
|
||||
result = _.findLastIndex<TResult>(list, predicateFn, any);
|
||||
result = _.findLastIndex<TResult>(list, '');
|
||||
result = _.findLastIndex<TResult>(list, '', any);
|
||||
result = _.findLastIndex<{a: number}, TResult>(list, {a: 42});
|
||||
result = _.findLastIndex<TResult>(array);
|
||||
result = _.findLastIndex<TResult>(array, predicateFn);
|
||||
result = _.findLastIndex<TResult>(array, predicateFn, any);
|
||||
result = _.findLastIndex<TResult>(array, '');
|
||||
result = _.findLastIndex<TResult>(array, '', any);
|
||||
result = _.findLastIndex<{a: number}, TResult>(array, {a: 42});
|
||||
|
||||
result = _<TResult>(array).findLastIndex();
|
||||
result = _<TResult>(array).findLastIndex(predicateFn);
|
||||
result = _<TResult>(array).findLastIndex(predicateFn, any);
|
||||
result = _<TResult>(array).findLastIndex('');
|
||||
result = _<TResult>(array).findLastIndex('', any);
|
||||
result = _<TResult>(array).findLastIndex<{a: number}>({a: 42});
|
||||
result = _.findLastIndex<TResult>(list);
|
||||
result = _.findLastIndex<TResult>(list, predicateFn);
|
||||
result = _.findLastIndex<TResult>(list, predicateFn, any);
|
||||
result = _.findLastIndex<TResult>(list, '');
|
||||
result = _.findLastIndex<TResult>(list, '', any);
|
||||
result = _.findLastIndex<{a: number}, TResult>(list, {a: 42});
|
||||
|
||||
result = _(list).findLastIndex();
|
||||
result = _(list).findLastIndex<TResult>(predicateFn);
|
||||
result = _(list).findLastIndex<TResult>(predicateFn, any);
|
||||
result = _(list).findLastIndex('');
|
||||
result = _(list).findLastIndex('', any);
|
||||
result = _(list).findLastIndex<{a: number}>({a: 42});
|
||||
result = _<TResult>(array).findLastIndex();
|
||||
result = _<TResult>(array).findLastIndex(predicateFn);
|
||||
result = _<TResult>(array).findLastIndex(predicateFn, any);
|
||||
result = _<TResult>(array).findLastIndex('');
|
||||
result = _<TResult>(array).findLastIndex('', any);
|
||||
result = _<TResult>(array).findLastIndex<{a: number}>({a: 42});
|
||||
|
||||
result = _(list).findLastIndex();
|
||||
result = _(list).findLastIndex<TResult>(predicateFn);
|
||||
result = _(list).findLastIndex<TResult>(predicateFn, any);
|
||||
result = _(list).findLastIndex('');
|
||||
result = _(list).findLastIndex('', any);
|
||||
result = _(list).findLastIndex<{a: number}>({a: 42});
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitWrapper<number>;
|
||||
|
||||
result = _<TResult>(array).chain().findLastIndex();
|
||||
result = _<TResult>(array).chain().findLastIndex(predicateFn);
|
||||
result = _<TResult>(array).chain().findLastIndex(predicateFn, any);
|
||||
result = _<TResult>(array).chain().findLastIndex('');
|
||||
result = _<TResult>(array).chain().findLastIndex('', any);
|
||||
result = _<TResult>(array).chain().findLastIndex<{a: number}>({a: 42});
|
||||
|
||||
result = _(list).chain().findLastIndex();
|
||||
result = _(list).chain().findLastIndex<TResult>(predicateFn);
|
||||
result = _(list).chain().findLastIndex<TResult>(predicateFn, any);
|
||||
result = _(list).chain().findLastIndex('');
|
||||
result = _(list).chain().findLastIndex('', any);
|
||||
result = _(list).chain().findLastIndex<{a: number}>({a: 42});
|
||||
}
|
||||
}
|
||||
|
||||
// _.first
|
||||
@@ -614,14 +681,30 @@ module TestIndexOf {
|
||||
}
|
||||
|
||||
//_.initial
|
||||
{
|
||||
let testInitalArray: TResult[];
|
||||
let testInitalList: _.List<TResult>;
|
||||
let result: TResult[];
|
||||
result = _.initial<TResult>(testInitalArray);
|
||||
result = _.initial<TResult>(testInitalList);
|
||||
result = _(testInitalArray).initial().value();
|
||||
result = _(testInitalList).initial<TResult>().value();
|
||||
module TestInitial {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
|
||||
{
|
||||
let result: TResult[];
|
||||
|
||||
result = _.initial<TResult>(array);
|
||||
result = _.initial<TResult>(list);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).initial();
|
||||
result = _(list).initial<TResult>();
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().initial();
|
||||
result = _(list).chain().initial<TResult>();
|
||||
}
|
||||
}
|
||||
|
||||
// _.intersection
|
||||
@@ -920,12 +1003,28 @@ module TestRemove {
|
||||
module TestRest {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let result: TResult[];
|
||||
|
||||
result = _.rest<TResult>(array);
|
||||
result = _.rest<TResult>(list);
|
||||
result = _(array).rest().value();
|
||||
result = _(list).rest<TResult>().value();
|
||||
{
|
||||
let result: TResult[];
|
||||
|
||||
result = _.rest<TResult>(array);
|
||||
result = _.rest<TResult>(list);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).rest();
|
||||
result = _(list).rest<TResult>();
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().rest();
|
||||
result = _(list).chain().rest<TResult>();
|
||||
}
|
||||
}
|
||||
|
||||
// _.slice
|
||||
@@ -991,12 +1090,28 @@ module TestSortedLastIndex {
|
||||
module TestTail {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let result: TResult[];
|
||||
|
||||
result = _.tail<TResult>(array);
|
||||
result = _.tail<TResult>(list);
|
||||
result = _(array).tail().value();
|
||||
result = _(list).tail<TResult>().value();
|
||||
{
|
||||
let result: TResult[];
|
||||
|
||||
result = _.tail<TResult>(array);
|
||||
result = _.tail<TResult>(list);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).tail();
|
||||
result = _(list).tail<TResult>();
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().tail();
|
||||
result = _(list).chain().tail<TResult>();
|
||||
}
|
||||
}
|
||||
|
||||
// _.take
|
||||
@@ -2777,10 +2892,6 @@ module TestMap {
|
||||
}
|
||||
}
|
||||
|
||||
result = <string[]>_.pluck(stoogesAges, 'name');
|
||||
result = <string[]>_(stoogesAges).pluck('name').value();
|
||||
result = <string[]>_.pluck(stoogesAges, ['name']);
|
||||
|
||||
// _.partition
|
||||
result = <string[][]>_.partition<string>('abcd', (n) => n < 'c');
|
||||
result = <string[][]>_.partition<string>(['a', 'b', 'c', 'd'], (n) => n < 'c');
|
||||
@@ -2809,6 +2920,69 @@ result = <{a: number}[][]>_([{a: 1}, {a: 2}]).partition('a', 2).value();
|
||||
result = <{a: number}[][]>_({0: {a: 1}, 1: {a: 2}}).partition<{a: number}>('a').value();
|
||||
result = <{a: number}[][]>_({0: {a: 1}, 1: {a: 2}}).partition<{a: number}>('a', 2).value();
|
||||
|
||||
// _.pluck
|
||||
module TestPluck {
|
||||
interface SampleObject {
|
||||
d: {b: TResult}[];
|
||||
}
|
||||
|
||||
let array: SampleObject[];
|
||||
let list: _.List<SampleObject>;
|
||||
let dictionary: _.Dictionary<SampleObject>;
|
||||
|
||||
{
|
||||
let result: any[];
|
||||
|
||||
result = _.pluck<SampleObject>(array, 'd.0.b');
|
||||
result = _.pluck<SampleObject>(array, ['d', 0, 'b']);
|
||||
|
||||
result = _.pluck<SampleObject>(list, 'd.0.b');
|
||||
result = _.pluck<SampleObject>(list, ['d', 0, 'b']);
|
||||
|
||||
result = _.pluck<SampleObject>(dictionary, 'd.0.b');
|
||||
result = _.pluck<SampleObject>(dictionary, ['d', 0, 'b']);
|
||||
}
|
||||
|
||||
{
|
||||
let result: TResult[];
|
||||
|
||||
result = _.pluck<SampleObject, TResult>(array, 'd.0.b');
|
||||
result = _.pluck<SampleObject, TResult>(array, ['d', 0, 'b']);
|
||||
|
||||
result = _.pluck<SampleObject, TResult>(list, 'd.0.b');
|
||||
result = _.pluck<SampleObject, TResult>(list, ['d', 0, 'b']);
|
||||
|
||||
result = _.pluck<SampleObject, TResult>(dictionary, 'd.0.b');
|
||||
result = _.pluck<SampleObject, TResult>(dictionary, ['d', 0, 'b']);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).pluck<TResult>('d.0.b');
|
||||
result = _(array).pluck<TResult>(['d', 0, 'b']);
|
||||
|
||||
result = _(list).pluck<TResult>('d.0.b');
|
||||
result = _(list).pluck<TResult>(['d', 0, 'b']);
|
||||
|
||||
result = _(dictionary).pluck<TResult>('d.0.b');
|
||||
result = _(dictionary).pluck<TResult>(['d', 0, 'b']);
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().pluck<TResult>('d.0.b');
|
||||
result = _(array).chain().pluck<TResult>(['d', 0, 'b']);
|
||||
|
||||
result = _(list).chain().pluck<TResult>('d.0.b');
|
||||
result = _(list).chain().pluck<TResult>(['d', 0, 'b']);
|
||||
|
||||
result = _(dictionary).chain().pluck<TResult>('d.0.b');
|
||||
result = _(dictionary).chain().pluck<TResult>(['d', 0, 'b']);
|
||||
}
|
||||
}
|
||||
|
||||
interface ABC {
|
||||
[index: string]: number;
|
||||
a: number;
|
||||
@@ -2964,9 +3138,81 @@ module TestSome {
|
||||
}
|
||||
}
|
||||
|
||||
result = <number[]>_.sortBy([1, 2, 3], function (num) { return Math.sin(num); });
|
||||
result = <number[]>_.sortBy([1, 2, 3], function (num) { return this.sin(num); }, Math);
|
||||
result = <string[]>_.sortBy(['banana', 'strawberry', 'apple'], 'length');
|
||||
// _.sortBy
|
||||
module TestSortBy {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let dictionary: _.Dictionary<TResult>;
|
||||
|
||||
let listIterator: (value: TResult, index: number, collection: _.List<TResult>) => number;
|
||||
let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary<TResult>) => number;
|
||||
|
||||
{
|
||||
let result: TResult[];
|
||||
|
||||
result = _.sortBy<TResult>(array);
|
||||
result = _.sortBy<TResult, number>(array, listIterator);
|
||||
result = _.sortBy<TResult, number>(array, listIterator, any);
|
||||
result = _.sortBy<TResult>(array, '');
|
||||
result = _.sortBy<{a: number}, TResult>(array, {a: 42});
|
||||
|
||||
result = _.sortBy<TResult>(list);
|
||||
result = _.sortBy<TResult, number>(list, listIterator);
|
||||
result = _.sortBy<TResult, number>(list, listIterator, any);
|
||||
result = _.sortBy<TResult>(list, '');
|
||||
result = _.sortBy<{a: number}, TResult>(list, {a: 42});
|
||||
|
||||
result = _.sortBy<TResult>(dictionary);
|
||||
result = _.sortBy<TResult, number>(dictionary, dictionaryIterator);
|
||||
result = _.sortBy<TResult, number>(dictionary, dictionaryIterator, any);
|
||||
result = _.sortBy<TResult>(dictionary, '');
|
||||
result = _.sortBy<{a: number}, TResult>(dictionary, {a: 42});
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).sortBy();
|
||||
result = _(array).sortBy<number>(listIterator);
|
||||
result = _(array).sortBy<number>(listIterator, any);
|
||||
result = _(array).sortBy('');
|
||||
result = _(array).sortBy<{a: number}>({a: 42});
|
||||
|
||||
result = _(list).sortBy<TResult>();
|
||||
result = _(list).sortBy<TResult, number>(listIterator);
|
||||
result = _(list).sortBy<TResult, number>(listIterator, any);
|
||||
result = _(list).sortBy<TResult>('');
|
||||
result = _(list).sortBy<{a: number}, TResult>({a: 42});
|
||||
|
||||
result = _(dictionary).sortBy<TResult>();
|
||||
result = _(dictionary).sortBy<TResult, number>(dictionaryIterator);
|
||||
result = _(dictionary).sortBy<TResult, number>(dictionaryIterator, any);
|
||||
result = _(dictionary).sortBy<TResult>('');
|
||||
result = _(dictionary).sortBy<{a: number}, TResult>({a: 42});
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitArrayWrapper<TResult>;
|
||||
|
||||
result = _(array).chain().sortBy();
|
||||
result = _(array).chain().sortBy<number>(listIterator);
|
||||
result = _(array).chain().sortBy<number>(listIterator, any);
|
||||
result = _(array).chain().sortBy('');
|
||||
result = _(array).chain().sortBy<{a: number}>({a: 42});
|
||||
|
||||
result = _(list).chain().sortBy<TResult>();
|
||||
result = _(list).chain().sortBy<TResult, number>(listIterator);
|
||||
result = _(list).chain().sortBy<TResult, number>(listIterator, any);
|
||||
result = _(list).chain().sortBy<TResult>('');
|
||||
result = _(list).chain().sortBy<{a: number}, TResult>({a: 42});
|
||||
|
||||
result = _(dictionary).chain().sortBy<TResult>();
|
||||
result = _(dictionary).chain().sortBy<TResult, number>(dictionaryIterator);
|
||||
result = _(dictionary).chain().sortBy<TResult, number>(dictionaryIterator, any);
|
||||
result = _(dictionary).chain().sortBy<TResult>('');
|
||||
result = _(dictionary).chain().sortBy<{a: number}, TResult>({a: 42});
|
||||
}
|
||||
}
|
||||
|
||||
result = <IStoogesAge[]>_.sortByAll(stoogesAges, function(stooge) { return Math.sin(stooge.age); }, function(stooge) { return stooge.name.slice(1); });
|
||||
result = <IStoogesAge[]>_.sortByAll(stoogesAges, ['name', 'age']);
|
||||
@@ -2982,9 +3228,6 @@ result = <IStoogesAge[]>_.sortByOrder(stoogesAges, [function(stooge) { return Ma
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, ['name', 'age'], [true, false]);
|
||||
result = <IStoogesAge[]>_.sortByOrder(stoogesAges, ['name', function(stooge) { return Math.sin(stooge.age); }], [true, false]);
|
||||
|
||||
result = <number[]>_([1, 2, 3]).sortBy(function (num) { return Math.sin(num); }).value();
|
||||
result = <number[]>_([1, 2, 3]).sortBy(function (num) { return this.sin(num); }, Math).value();
|
||||
result = <string[]>_(['banana', 'strawberry', 'apple']).sortBy('length').value();
|
||||
result = <IFoodOrganic[]>_(foodsOrganic).sortByAll('organic', (food) => food.name, { organic: true }).value();
|
||||
|
||||
result = <IStoogesCombined[]>_.where(stoogesCombined, { 'age': 40 });
|
||||
@@ -4899,11 +5142,25 @@ module TestTemplate {
|
||||
}
|
||||
|
||||
// _.trim
|
||||
result = <string>_.trim();
|
||||
result = <string>_.trim(' abc ');
|
||||
result = <string>_.trim('-_-abc-_-', '_-');
|
||||
result = <string>_('-_-abc-_-').trim();
|
||||
result = <string>_('-_-abc-_-').trim('_-');
|
||||
module TestTrim {
|
||||
{
|
||||
let result: string;
|
||||
|
||||
result = _.trim();
|
||||
result = _.trim(' abc ');
|
||||
result = _.trim('-_-abc-_-', '_-');
|
||||
|
||||
result = _('-_-abc-_-').trim();
|
||||
result = _('-_-abc-_-').trim('_-');
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitWrapper<string>;
|
||||
|
||||
result = _('-_-abc-_-').chain().trim();
|
||||
result = _('-_-abc-_-').chain().trim('_-');
|
||||
}
|
||||
}
|
||||
|
||||
// _.trimLeft
|
||||
module TestTrimLeft {
|
||||
@@ -4927,11 +5184,26 @@ module TestTrimLeft {
|
||||
}
|
||||
|
||||
// _.trimRight
|
||||
result = <string>_.trimRight();
|
||||
result = <string>_.trimRight(' abc ');
|
||||
result = <string>_.trimRight('-_-abc-_-', '_-');
|
||||
result = <string>_('-_-abc-_-').trimRight();
|
||||
result = <string>_('-_-abc-_-').trimRight('_-');
|
||||
|
||||
module TestTrimRight {
|
||||
{
|
||||
let result: string;
|
||||
|
||||
result = _.trimRight();
|
||||
result = _.trimRight(' abc ');
|
||||
result = _.trimRight('-_-abc-_-', '_-');
|
||||
|
||||
result = _('-_-abc-_-').trimRight();
|
||||
result = _('-_-abc-_-').trimRight('_-');
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitWrapper<string>;
|
||||
|
||||
result = _('-_-abc-_-').chain().trimRight();
|
||||
result = _('-_-abc-_-').chain().trimRight('_-');
|
||||
}
|
||||
}
|
||||
|
||||
// _.trunc
|
||||
module TestTrunc {
|
||||
@@ -4963,8 +5235,20 @@ module TestTrunc {
|
||||
}
|
||||
|
||||
// _.unescape
|
||||
result = <string>_.unescape('fred, barney, & pebbles');
|
||||
result = <string>_('fred, barney, & pebbles').unescape();
|
||||
module TestUnescape {
|
||||
{
|
||||
let result: string;
|
||||
|
||||
result = _.unescape('fred, barney, & pebbles');
|
||||
result = _('fred, barney, & pebbles').unescape();
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitWrapper<string>;
|
||||
|
||||
result = _('fred, barney, & pebbles').chain().unescape();
|
||||
}
|
||||
}
|
||||
|
||||
// _.words
|
||||
module TestWords {
|
||||
|
||||
541
lodash/lodash.d.ts
vendored
541
lodash/lodash.d.ts
vendored
@@ -401,7 +401,21 @@ declare module _ {
|
||||
/**
|
||||
* @see _.drop
|
||||
*/
|
||||
drop<TResult>(n?: number): LoDashImplicitArrayWrapper<TResult>;
|
||||
drop<T>(n?: number): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.drop
|
||||
*/
|
||||
drop(n?: number): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.drop
|
||||
*/
|
||||
drop<T>(n?: number): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.dropRight
|
||||
@@ -541,6 +555,56 @@ declare module _ {
|
||||
): LoDashImplicitArrayWrapper<TValue>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.dropRightWhile
|
||||
*/
|
||||
dropRightWhile(
|
||||
predicate?: ListIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.dropRightWhile
|
||||
*/
|
||||
dropRightWhile(
|
||||
predicate?: string,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.dropRightWhile
|
||||
*/
|
||||
dropRightWhile<TWhere>(
|
||||
predicate?: TWhere
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.dropRightWhile
|
||||
*/
|
||||
dropRightWhile<TValue>(
|
||||
predicate?: ListIterator<TValue, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<TValue>;
|
||||
|
||||
/**
|
||||
* @see _.dropRightWhile
|
||||
*/
|
||||
dropRightWhile<TValue>(
|
||||
predicate?: string,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<TValue>;
|
||||
|
||||
/**
|
||||
* @see _.dropRightWhile
|
||||
*/
|
||||
dropRightWhile<TWhere, TValue>(
|
||||
predicate?: TWhere
|
||||
): LoDashExplicitArrayWrapper<TValue>;
|
||||
}
|
||||
|
||||
//_.dropWhile
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -922,6 +986,56 @@ declare module _ {
|
||||
): number;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.findLastIndex
|
||||
*/
|
||||
findLastIndex(
|
||||
predicate?: ListIterator<T, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitWrapper<number>;
|
||||
|
||||
/**
|
||||
* @see _.findLastIndex
|
||||
*/
|
||||
findLastIndex(
|
||||
predicate?: string,
|
||||
thisArg?: any
|
||||
): LoDashExplicitWrapper<number>;
|
||||
|
||||
/**
|
||||
* @see _.findLastIndex
|
||||
*/
|
||||
findLastIndex<W>(
|
||||
predicate?: W
|
||||
): LoDashExplicitWrapper<number>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.findLastIndex
|
||||
*/
|
||||
findLastIndex<TResult>(
|
||||
predicate?: ListIterator<TResult, boolean>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitWrapper<number>;
|
||||
|
||||
/**
|
||||
* @see _.findLastIndex
|
||||
*/
|
||||
findLastIndex(
|
||||
predicate?: string,
|
||||
thisArg?: any
|
||||
): LoDashExplicitWrapper<number>;
|
||||
|
||||
/**
|
||||
* @see _.findLastIndex
|
||||
*/
|
||||
findLastIndex<W>(
|
||||
predicate?: W
|
||||
): LoDashExplicitWrapper<number>;
|
||||
}
|
||||
|
||||
//_.first
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -1116,7 +1230,7 @@ declare module _ {
|
||||
* @param array The array to query.
|
||||
* @return Returns the slice of array.
|
||||
*/
|
||||
initial<T>(array: T[]|List<T>): T[];
|
||||
initial<T>(array: List<T>): T[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
@@ -1130,7 +1244,21 @@ declare module _ {
|
||||
/**
|
||||
* @see _.initial
|
||||
*/
|
||||
initial<TResult>(): LoDashImplicitArrayWrapper<TResult>;
|
||||
initial<T>(): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.initial
|
||||
*/
|
||||
initial(): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.initial
|
||||
*/
|
||||
initial<T>(): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.intersection
|
||||
@@ -1583,7 +1711,21 @@ declare module _ {
|
||||
/**
|
||||
* @see _.rest
|
||||
*/
|
||||
rest<TResult>(): LoDashImplicitArrayWrapper<TResult>;
|
||||
rest<T>(): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.rest
|
||||
*/
|
||||
rest(): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.rest
|
||||
*/
|
||||
rest<T>(): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.slice
|
||||
@@ -1782,7 +1924,21 @@ declare module _ {
|
||||
/**
|
||||
* @see _.rest
|
||||
*/
|
||||
tail<TResult>(): LoDashImplicitArrayWrapper<TResult>;
|
||||
tail<T>(): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.rest
|
||||
*/
|
||||
tail(): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.rest
|
||||
*/
|
||||
tail<T>(): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.take
|
||||
@@ -5291,49 +5447,6 @@ declare module _ {
|
||||
): LoDashExplicitArrayWrapper<boolean>;
|
||||
}
|
||||
|
||||
//_.pluck
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Retrieves the value of a specified property from all elements in the collection.
|
||||
* @param collection The collection to iterate over.
|
||||
* @param property The property to pluck.
|
||||
* @return A new array of property values.
|
||||
**/
|
||||
pluck<T extends {}>(
|
||||
collection: Array<T>,
|
||||
property: string|string[]): any[];
|
||||
|
||||
/**
|
||||
* @see _.pluck
|
||||
**/
|
||||
pluck<T extends {}>(
|
||||
collection: List<T>,
|
||||
property: string|string[]): any[];
|
||||
|
||||
/**
|
||||
* @see _.pluck
|
||||
**/
|
||||
pluck<T extends {}>(
|
||||
collection: Dictionary<T>,
|
||||
property: string|string[]): any[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
**/
|
||||
pluck<TResult>(
|
||||
property: string): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
**/
|
||||
pluck<TResult>(
|
||||
property: string): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.partition
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -5482,6 +5595,57 @@ declare module _ {
|
||||
pluckValue: string): LoDashImplicitArrayWrapper<TResult[]>;
|
||||
}
|
||||
|
||||
//_.pluck
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Gets the property value of path from all elements in collection.
|
||||
*
|
||||
* @param collection The collection to iterate over.
|
||||
* @param path The path of the property to pluck.
|
||||
* @return A new array of property values.
|
||||
*/
|
||||
pluck<T extends {}>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
path: StringRepresentable|StringRepresentable[]
|
||||
): any[];
|
||||
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck<T extends {}, TResult>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
path: StringRepresentable|StringRepresentable[]
|
||||
): TResult[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck<TResult>(path: StringRepresentable|StringRepresentable[]): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck<TResult>(path: StringRepresentable|StringRepresentable[]): LoDashImplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck<TResult>(path: StringRepresentable|StringRepresentable[]): LoDashExplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.pluck
|
||||
*/
|
||||
pluck<TResult>(path: StringRepresentable|StringRepresentable[]): LoDashExplicitArrayWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.reduce
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -6247,104 +6411,162 @@ declare module _ {
|
||||
//_.sortBy
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Creates an array of elements, sorted in ascending order by the results of running each
|
||||
* element in a collection through the callback. This method performs a stable sort, that
|
||||
* is, it will preserve the original sort order of equal elements. The callback is bound
|
||||
* to thisArg and invoked with three arguments; (value, index|key, collection).
|
||||
*
|
||||
* If a property name is provided for callback the created "_.pluck" style callback will
|
||||
* return the property value of the given element.
|
||||
*
|
||||
* If a value is also provided for thisArg the created "_.matchesProperty" style callback
|
||||
* returns true for elements that have a matching property value, else false.
|
||||
*
|
||||
* If an object is provided for an iteratee the created "_.matches" style callback returns
|
||||
* true for elements that have the properties of the given object, else false.
|
||||
* @param collection The collection to iterate over.
|
||||
* @param callback The function called per iteration.
|
||||
* @param thisArg The this binding of callback.
|
||||
* @return A new array of sorted elements.
|
||||
**/
|
||||
sortBy<T, TSort>(
|
||||
collection: Array<T>,
|
||||
iteratee?: ListIterator<T, TSort>,
|
||||
thisArg?: any): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
**/
|
||||
sortBy<T, TSort>(
|
||||
collection: List<T>,
|
||||
iteratee?: ListIterator<T, TSort>,
|
||||
thisArg?: any): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
sortBy<T>(
|
||||
collection: Array<T>,
|
||||
pluckValue: string): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
sortBy<T>(
|
||||
collection: List<T>,
|
||||
pluckValue: string): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
sortBy<W, T>(
|
||||
collection: Array<T>,
|
||||
whereValue: W): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
sortBy<W, T>(
|
||||
collection: List<T>,
|
||||
whereValue: W): T[];
|
||||
|
||||
/**
|
||||
* Sorts by all the given arguments, using either ListIterator, pluckValue, or whereValue foramts
|
||||
* @param args The rules by which to sort
|
||||
* Creates an array of elements, sorted in ascending order by the results of running each element in a
|
||||
* collection through iteratee. This method performs a stable sort, that is, it preserves the original sort
|
||||
* order of equal elements. The iteratee is bound to thisArg and invoked with three arguments:
|
||||
* (value, index|key, collection).
|
||||
*
|
||||
* If a property name is provided for iteratee the created _.property style callback returns the property
|
||||
* valueof the given element.
|
||||
*
|
||||
* If a value is also provided for thisArg the created _.matchesProperty style callback returns true for
|
||||
* elements that have a matching property value, else false.
|
||||
*
|
||||
* If an object is provided for iteratee the created _.matches style callback returns true for elements that
|
||||
* have the properties of the given object, else false.
|
||||
*
|
||||
* @param collection The collection to iterate over.
|
||||
* @param iteratee The function invoked per iteration.
|
||||
* @param thisArg The this binding of iteratee.
|
||||
* @return Returns the new sorted array.
|
||||
*/
|
||||
sortByAll<T>(
|
||||
collection: (Array<T>|List<T>),
|
||||
...args: (ListIterator<T, boolean>|Object|string)[]
|
||||
sortBy<T, TSort>(
|
||||
collection: List<T>,
|
||||
iteratee?: ListIterator<T, TSort>,
|
||||
thisArg?: any
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<T, TSort>(
|
||||
collection: Dictionary<T>,
|
||||
iteratee?: DictionaryIterator<T, TSort>,
|
||||
thisArg?: any
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
iteratee: string
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<W extends {}, T>(
|
||||
collection: List<T>|Dictionary<T>,
|
||||
whereValue: W
|
||||
): T[];
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<T>(
|
||||
collection: List<T>|Dictionary<T>
|
||||
): T[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.sortBy
|
||||
**/
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<TSort>(
|
||||
iteratee?: ListIterator<T, TSort>,
|
||||
thisArg?: any): LoDashImplicitArrayWrapper<T>;
|
||||
thisArg?: any
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
* @param pluckValue _.pluck style callback
|
||||
**/
|
||||
sortBy(pluckValue: string): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
* @param whereValue _.where style callback
|
||||
**/
|
||||
sortBy<W>(whereValue: W): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* Sorts by all the given arguments, using either ListIterator, pluckValue, or whereValue foramts
|
||||
* @param args The rules by which to sort
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortByAll(...args: (ListIterator<T, boolean>|Object|string)[]): LoDashImplicitArrayWrapper<T>;
|
||||
sortBy(iteratee: string): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<W extends {}>(whereValue: W): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy(): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<T, TSort>(
|
||||
iteratee?: ListIterator<T, TSort>|DictionaryIterator<T, TSort>,
|
||||
thisArg?: any
|
||||
): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<T>(iteratee: string): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<W extends {}, T>(whereValue: W): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<T>(): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<TSort>(
|
||||
iteratee?: ListIterator<T, TSort>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy(iteratee: string): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<W extends {}>(whereValue: W): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy(): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<T, TSort>(
|
||||
iteratee?: ListIterator<T, TSort>|DictionaryIterator<T, TSort>,
|
||||
thisArg?: any
|
||||
): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<T>(iteratee: string): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<W extends {}, T>(whereValue: W): LoDashExplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortBy
|
||||
*/
|
||||
sortBy<T>(): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
//_.sortByAll
|
||||
@@ -6391,9 +6613,24 @@ declare module _ {
|
||||
sortByAll<T>(
|
||||
collection: List<T>,
|
||||
...iteratees: (ListIterator<T, any>|string|Object)[]): T[];
|
||||
|
||||
/**
|
||||
* Sorts by all the given arguments, using either ListIterator, pluckValue, or whereValue foramts
|
||||
* @param args The rules by which to sort
|
||||
*/
|
||||
sortByAll<T>(
|
||||
collection: (Array<T>|List<T>),
|
||||
...args: (ListIterator<T, boolean>|Object|string)[]
|
||||
): T[];
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* Sorts by all the given arguments, using either ListIterator, pluckValue, or whereValue foramts
|
||||
* @param args The rules by which to sort
|
||||
*/
|
||||
sortByAll(...args: (ListIterator<T, boolean>|Object|string)[]): LoDashImplicitArrayWrapper<T>;
|
||||
|
||||
/**
|
||||
* @see _.sortByAll
|
||||
**/
|
||||
@@ -10459,11 +10696,15 @@ declare module _ {
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Removes leading and trailing whitespace or specified characters from string.
|
||||
*
|
||||
* @param string The string to trim.
|
||||
* @param chars The characters to trim.
|
||||
* @return Returns the trimmed string.
|
||||
*/
|
||||
trim(string?: string, chars?: string): string;
|
||||
trim(
|
||||
string?: string,
|
||||
chars?: string
|
||||
): string;
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
@@ -10473,6 +10714,13 @@ declare module _ {
|
||||
trim(chars?: string): string;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.trim
|
||||
*/
|
||||
trim(chars?: string): LoDashExplicitWrapper<string>;
|
||||
}
|
||||
|
||||
//_.trimLeft
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
@@ -10506,11 +10754,15 @@ declare module _ {
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Removes trailing whitespace or specified characters from string.
|
||||
*
|
||||
* @param string The string to trim.
|
||||
* @param chars The characters to trim.
|
||||
* @return Returns the trimmed string.
|
||||
*/
|
||||
trimRight(string?: string, chars?: string): string;
|
||||
trimRight(
|
||||
string?: string,
|
||||
chars?: string
|
||||
): string;
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
@@ -10520,6 +10772,13 @@ declare module _ {
|
||||
trimRight(chars?: string): string;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.trimRight
|
||||
*/
|
||||
trimRight(chars?: string): LoDashExplicitWrapper<string>;
|
||||
}
|
||||
|
||||
//_.trunc
|
||||
interface TruncOptions {
|
||||
/** The maximum string length. */
|
||||
@@ -10564,6 +10823,7 @@ declare module _ {
|
||||
/**
|
||||
* The inverse of _.escape; this method converts the HTML entities &, <, >, ", ', and `
|
||||
* in string to their corresponding characters.
|
||||
*
|
||||
* @param string The string to unescape.
|
||||
* @return Returns the unescaped string.
|
||||
*/
|
||||
@@ -10577,6 +10837,13 @@ declare module _ {
|
||||
unescape(): string;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.unescape
|
||||
*/
|
||||
unescape(): LoDashExplicitWrapper<string>;
|
||||
}
|
||||
|
||||
//_.words
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@ function main(): void {
|
||||
addColumn('description', lf.Type.STRING).
|
||||
addColumn('deadline', lf.Type.DATE_TIME).
|
||||
addColumn('done', lf.Type.BOOLEAN).
|
||||
addPrimaryKey(['id']).
|
||||
addPrimaryKey(['id'], false).
|
||||
addIndex('idxDeadline', ['deadline'], false, lf.Order.DESC);
|
||||
|
||||
var todoDb: lf.Database = null;
|
||||
|
||||
4
lovefield/lovefield.d.ts
vendored
4
lovefield/lovefield.d.ts
vendored
@@ -200,7 +200,9 @@ declare module lf {
|
||||
name: string, columns: Array<string>|Array<IndexedColumn>,
|
||||
unique?: boolean, order?: Order): TableBuilder
|
||||
addNullable(columns: Array<Column>): TableBuilder
|
||||
addPrimaryKey(columns: Array<string>|Array<IndexedColumn>): TableBuilder
|
||||
addPrimaryKey(
|
||||
columns: Array<string>|Array<IndexedColumn>,
|
||||
autoInc?: boolean): TableBuilder
|
||||
addUnique(name: string, columns: Array<Column>): TableBuilder
|
||||
}
|
||||
|
||||
|
||||
35
merge-descriptors/merge-descriptors-tests.ts
Normal file
35
merge-descriptors/merge-descriptors-tests.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/// <reference path="merge-descriptors.d.ts"/>
|
||||
import mixin = require('merge-descriptors');
|
||||
|
||||
function testAssertion(condition: boolean, errorMessage: string) {
|
||||
if (!condition) {
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
interface IMergedObject {
|
||||
InSrc?: string;
|
||||
name: string;
|
||||
InTarget: string;
|
||||
}
|
||||
|
||||
var src = {
|
||||
InSrc: 'src',
|
||||
get name(): string {
|
||||
return 'from src name';
|
||||
}
|
||||
}
|
||||
|
||||
var target: IMergedObject = { name: 'my target name', InTarget: 'target' };
|
||||
|
||||
var target2 = mixin(target, src, true);
|
||||
|
||||
console.log(JSON.stringify(target));
|
||||
|
||||
testAssertion(target2 === target, "Returned object should refer to input [destination] object");
|
||||
testAssertion(target.name === 'from src name', "[redfine]=true, source member will overwrite destination member");
|
||||
testAssertion(target.InTarget === 'target', "overwrite do not affect members only in [destination]");
|
||||
testAssertion(target['InSrc'] === 'src', "members from [source] must be copied to [destination]");
|
||||
|
||||
var nameProperty:PropertyDescriptor = Object.getOwnPropertyDescriptor(target, "name");
|
||||
testAssertion(nameProperty.set === undefined, "member descriptor must be overwritten");
|
||||
1
merge-descriptors/merge-descriptors-tests.ts.tscparams
Normal file
1
merge-descriptors/merge-descriptors-tests.ts.tscparams
Normal file
@@ -0,0 +1 @@
|
||||
--noImplicitAny --module commonjs --target es5
|
||||
13
merge-descriptors/merge-descriptors.d.ts
vendored
Normal file
13
merge-descriptors/merge-descriptors.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Type definitions for merge-descriptors
|
||||
// Project: https://github.com/component/merge-descriptors
|
||||
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module 'merge-descriptors' {
|
||||
|
||||
function merge(destination: Object, source: Object): Object;
|
||||
|
||||
function merge(destination: Object, source: Object, redefine: boolean): Object;
|
||||
|
||||
export = merge;
|
||||
}
|
||||
14
ms/ms-tests.ts
Normal file
14
ms/ms-tests.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/// <reference path="./ms.d.ts"/>
|
||||
|
||||
import ms = require('ms');
|
||||
|
||||
ms('2 days') // 172800000
|
||||
ms('1d') // 86400000
|
||||
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(ms('10 hours'), { long: true }) // "10 hours"
|
||||
26
ms/ms.d.ts
vendored
Normal file
26
ms/ms.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Type definitions for ms v0.7.1
|
||||
// Project: https://github.com/guille/ms.js
|
||||
// Definitions by: Zhiyuan Wang <https://github.com/danny8002/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module 'ms' {
|
||||
|
||||
/**
|
||||
* Short/Long format for `value`.
|
||||
*
|
||||
* @param {Number} value
|
||||
* @param {{long: boolean}} options
|
||||
* @return {String}
|
||||
*/
|
||||
function ms(value: number, options?: { long: boolean }): string;
|
||||
|
||||
/**
|
||||
* Parse the given `value` and return milliseconds.
|
||||
*
|
||||
* @param {String} value
|
||||
* @return {Number}
|
||||
*/
|
||||
function ms(value: string): number;
|
||||
|
||||
export = ms;
|
||||
}
|
||||
2
node/node.d.ts
vendored
2
node/node.d.ts
vendored
@@ -758,7 +758,7 @@ declare module "punycode" {
|
||||
export function toASCII(domain: string): string;
|
||||
export var ucs2: ucs2;
|
||||
interface ucs2 {
|
||||
decode(string: string): string;
|
||||
decode(string: string): number[];
|
||||
encode(codePoints: number[]): string;
|
||||
}
|
||||
export var version: any;
|
||||
|
||||
99
react-intl/react-intl-1.2.0.d.ts
vendored
Normal file
99
react-intl/react-intl-1.2.0.d.ts
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
// Type definitions for react-intl 1.2.0
|
||||
// Project: http://formatjs.io/react/
|
||||
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path='../react/react.d.ts' />
|
||||
|
||||
declare module "react-intl" {
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
module ReactIntl {
|
||||
|
||||
|
||||
interface IIntlMixin extends React.Mixin<any,any> {
|
||||
getIntlMessage(key: string): string
|
||||
}
|
||||
|
||||
var IntlMixin: IIntlMixin
|
||||
|
||||
module IntlComponent {
|
||||
interface Props {
|
||||
locales?: string[]
|
||||
messages?: {[key: string]: any}
|
||||
formats?: string[]
|
||||
}
|
||||
}
|
||||
interface IntlComponent {
|
||||
getIntlMessage(key: string): string;
|
||||
}
|
||||
|
||||
|
||||
module FormattedDate {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
value: Date
|
||||
day?: string
|
||||
month?: string
|
||||
year?: string
|
||||
}
|
||||
}
|
||||
class FormattedDate extends React.Component<FormattedDate.Props,any> {}
|
||||
|
||||
|
||||
module FormattedTime {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
value: Date
|
||||
day?: string
|
||||
month?: string
|
||||
year?: string
|
||||
format?: string
|
||||
}
|
||||
}
|
||||
class FormattedTime extends React.Component<FormattedTime.Props,any> {}
|
||||
|
||||
|
||||
module FormattedRelative {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
value: number
|
||||
units?: string //"second", "minute", "hour", "day", "month" or "year"
|
||||
style?: string //"best fit" (default) or "numeric"
|
||||
format?: string
|
||||
}
|
||||
}
|
||||
class FormattedRelative extends React.Component<FormattedRelative.Props,any> {}
|
||||
|
||||
|
||||
module FormattedMessage {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
message: string;
|
||||
[prop: string]: any
|
||||
}
|
||||
}
|
||||
class FormattedMessage extends React.Component<FormattedMessage.Props,any> {}
|
||||
|
||||
|
||||
module FormattedHTMLMessage {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
message: string;
|
||||
[prop: string]: any
|
||||
}
|
||||
}
|
||||
class FormattedHTMLMessage extends React.Component<FormattedHTMLMessage.Props,any> {}
|
||||
|
||||
|
||||
module FormattedNumber {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
value: number
|
||||
style?: string
|
||||
currency?: string
|
||||
format?: string
|
||||
}
|
||||
}
|
||||
class FormattedNumber extends React.Component<FormattedNumber.Props,any> {}
|
||||
|
||||
}
|
||||
|
||||
export = ReactIntl
|
||||
|
||||
}
|
||||
138
react-intl/react-intl-tests-1.2.0.tsx
Normal file
138
react-intl/react-intl-tests-1.2.0.tsx
Normal file
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* Created by Bruno Grieder
|
||||
*/
|
||||
|
||||
///<reference path='../react/react.d.ts' />
|
||||
///<reference path='../react-mixin/react-mixin.d.ts' />
|
||||
///<reference path='../react-intl/react-intl-1.2.0.d.ts' />
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
import * as reactMixin from 'react-mixin'
|
||||
import {IntlMixin, IntlComponent, FormattedNumber, FormattedMessage, FormattedDate} from 'react-intl'
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This class does not use the mixin and react-mixin is not required
|
||||
// The MESSAGES are maintained in the file
|
||||
// To use it call <I18nDirect locales={['en-US']}/>
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
const MESSAGES: {[key: string] : { [lang: string]: string }} = {
|
||||
|
||||
Sorry: {
|
||||
'en-US': 'Sorry {name}',
|
||||
'fr-FR': 'Désolé {name}'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module I18nDirect {
|
||||
|
||||
export interface Props extends IntlComponent.Props {}
|
||||
}
|
||||
|
||||
class I18nDirect extends React.Component<I18nDirect.Props, any> {
|
||||
|
||||
private _currentLocale: string
|
||||
private _messages: {[key: string]: string}
|
||||
|
||||
constructor( props: I18nDirect.Props ) {
|
||||
super( props )
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
|
||||
<ul>
|
||||
<li>FormattedNumber:
|
||||
<FormattedNumber value={99.95} style="currency" currency="USD"/>
|
||||
</li>
|
||||
<li>FormattedMessage:
|
||||
<FormattedMessage message={this._messages['Sorry']} name='Dave'/>
|
||||
</li>
|
||||
<li>FormattedDate:
|
||||
<FormattedDate value={new Date()}/>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
componentWillReceiveProps( nextProps: I18nDirect.Props ) {
|
||||
this.compileMessages(nextProps)
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.compileMessages(this.props)
|
||||
}
|
||||
|
||||
|
||||
private compileMessages = (props: I18nDirect.Props): void => {
|
||||
|
||||
let locale: string = ( props.locales && props.locales[ 0 ] ) || 'en-US'
|
||||
|
||||
if (this._currentLocale !== locale) {
|
||||
|
||||
this._messages = Object.keys( MESSAGES ).reduce(
|
||||
( dic , key ) => {
|
||||
dic[ key ] = MESSAGES[ key ][ locale ]
|
||||
return dic
|
||||
},
|
||||
{} as { [key: string]: string; }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This class uses the mixin and react-mixin is
|
||||
// The MESSAGES are passed from messages property of the props
|
||||
// To use it call <I18nMixin {...props}/>
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
module I18nMixin {
|
||||
|
||||
export interface Props extends IntlComponent.Props {}
|
||||
}
|
||||
|
||||
@reactMixin.decorate( IntlMixin )
|
||||
class I18nMixin extends React.Component<I18nMixin.Props, any> implements IntlComponent {
|
||||
|
||||
private _currentLocale: string
|
||||
|
||||
constructor( props: I18nMixin.Props ) {
|
||||
super( props )
|
||||
}
|
||||
|
||||
//Expose the method provided by the Mixin
|
||||
getIntlMessage: (key: string) => string = this['getIntlMessage']
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
|
||||
<ul>
|
||||
<li>FormattedNumber:
|
||||
<FormattedNumber value={99.95} style="currency" currency="USD"/>
|
||||
</li>
|
||||
<li>FormattedMessage:
|
||||
<FormattedMessage message={this.getIntlMessage('Sorry')} name='Dave'/> {/* this uses the mixin */}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export { I18nDirect, I18nMixin }
|
||||
1
react-intl/react-intl-tests-1.2.0.tsx.tscparams
Normal file
1
react-intl/react-intl-tests-1.2.0.tsx.tscparams
Normal file
@@ -0,0 +1 @@
|
||||
--target es5 --noImplicitAny --experimentalDecorators --jsx react --module commonjs
|
||||
@@ -1,138 +1,168 @@
|
||||
/**
|
||||
* Created by Bruno Grieder
|
||||
* Created by Bruno Grieder and Christian Droulers
|
||||
*/
|
||||
|
||||
///<reference path='../react/react.d.ts' />
|
||||
///<reference path='../react-mixin/react-mixin.d.ts' />
|
||||
///<reference path='../react-intl/react-intl.d.ts' />
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
import * as reactMixin from 'react-mixin'
|
||||
import {IntlMixin, IntlComponent, FormattedNumber, FormattedMessage, FormattedDate} from 'react-intl'
|
||||
///<reference path="../react/react.d.ts" />
|
||||
///<reference path="../react-mixin/react-mixin.d.ts" />
|
||||
///<reference path="./react-intl.d.ts" />
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This class does not use the mixin and react-mixin is not required
|
||||
// The MESSAGES are maintained in the file
|
||||
// To use it call <I18nDirect locales={['en-US']}/>
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
import * as React from "react"
|
||||
|
||||
import * as reactMixin from "react-mixin"
|
||||
import {
|
||||
IntlProvider,
|
||||
InjectedIntlProps,
|
||||
addLocaleData,
|
||||
hasLocaleData,
|
||||
injectIntl,
|
||||
intlShape,
|
||||
defineMessages,
|
||||
FormattedRelative,
|
||||
FormattedMessage,
|
||||
FormattedHTMLMessage,
|
||||
FormattedNumber,
|
||||
FormattedPlural,
|
||||
FormattedDate,
|
||||
FormattedTime
|
||||
} from "react-intl"
|
||||
import reactIntlEn = require("react-intl/lib/locale-data/en");
|
||||
|
||||
const MESSAGES: {[key: string] : { [lang: string]: string }} = {
|
||||
addLocaleData(reactIntlEn);
|
||||
console.log(hasLocaleData("en"));
|
||||
|
||||
Sorry: {
|
||||
'en-US': 'Sorry {name}',
|
||||
'fr-FR': 'Désolé {name}'
|
||||
interface SomeComponentProps extends InjectedIntlProps {
|
||||
|
||||
}
|
||||
|
||||
class SomeComponent extends React.Component<SomeComponentProps, {}> {
|
||||
static propTypes: React.ValidationMap<any> = {
|
||||
intl: intlShape.isRequired
|
||||
};
|
||||
public render(): React.ReactElement<{}> {
|
||||
const formattedDate = this.props.formatDate(new Date(), { format: "short" });
|
||||
const formattedTime = this.props.formatTime(new Date(), { format: "short" });
|
||||
const formattedRelative = this.props.formatRelative(new Date().getTime(), { format: "short" });
|
||||
const formattedNumber = this.props.formatNumber(123, { format: "short" });
|
||||
const formattedPlural = this.props.formatPlural(1, { one: "hai!" });
|
||||
const formattedMessage = this.props.formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" });
|
||||
const formattedHTMLMessage = this.props.formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{name}</strong>!" }, { name: "Roger" });
|
||||
return <div>
|
||||
<FormattedRelative
|
||||
value={new Date().getTime() }
|
||||
units="hour"
|
||||
style="numeric"
|
||||
format="yyyy-MM-dd"
|
||||
updateInterval={123}
|
||||
initialNow={new Date() } />
|
||||
|
||||
<FormattedMessage
|
||||
id="test"
|
||||
description="Test"
|
||||
defaultMessage="Hi, {name}!"
|
||||
values={{ name: "bob" }}
|
||||
tagName="div" />
|
||||
|
||||
<FormattedHTMLMessage
|
||||
id="test"
|
||||
description="Test"
|
||||
defaultMessage="Hi, {name}!"
|
||||
values={{ name: "bob" }}
|
||||
tagName="div" />
|
||||
|
||||
<FormattedHTMLMessage
|
||||
id="test"
|
||||
description="Test"
|
||||
defaultMessage="Hi, {name}!"
|
||||
values={{ name: "bob" }}
|
||||
tagName="div" />
|
||||
|
||||
<FormattedNumber
|
||||
value={123456.78}
|
||||
format="N"
|
||||
localeMatcher="lookup"
|
||||
style="currency"
|
||||
currency="USD"
|
||||
currencyDisplay="name"
|
||||
useGrouping={false}
|
||||
minimumIntegerDigits={1}
|
||||
minimumFractionDigits={1}
|
||||
minimumSignificantDigits={2}
|
||||
maximumFractionDigits={3}
|
||||
maximumSignificantDigits={3} />
|
||||
|
||||
<FormattedPlural
|
||||
style="cardinal"
|
||||
value={3}
|
||||
other="hai?"
|
||||
zero="no hai"
|
||||
one="hai"
|
||||
two="hai2"
|
||||
few="haifew"
|
||||
many="haiku" />
|
||||
|
||||
<FormattedDate
|
||||
value={new Date() }
|
||||
format="short"
|
||||
localeMatcher="best fit"
|
||||
formatMatcher="basic"
|
||||
timeZone="EDT"
|
||||
hour12={false}
|
||||
weekday="short"
|
||||
era="short"
|
||||
year="2-digit"
|
||||
month="2-digit"
|
||||
day="2-digit"
|
||||
hour="2-digit"
|
||||
minute="2-digit"
|
||||
second="2-digit"
|
||||
timeZoneName="short" />
|
||||
|
||||
<FormattedTime
|
||||
value={new Date() }
|
||||
format="short"
|
||||
localeMatcher="best fit"
|
||||
formatMatcher="basic"
|
||||
timeZone="EDT"
|
||||
hour12={false}
|
||||
weekday="short"
|
||||
era="short"
|
||||
year="2-digit"
|
||||
month="2-digit"
|
||||
day="2-digit"
|
||||
hour="2-digit"
|
||||
minute="2-digit"
|
||||
second="2-digit"
|
||||
timeZoneName="short" />
|
||||
|
||||
<FormattedNumber value={123}>
|
||||
{(formattedNum: string) => (
|
||||
<span className="number">{formattedNum}</span>
|
||||
) }
|
||||
</FormattedNumber>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
class TestApp extends React.Component<{}, {}> {
|
||||
public render(): React.ReactElement<{}> {
|
||||
const definedMessages = defineMessages({
|
||||
"sup": {
|
||||
id: "sup",
|
||||
defaultMessage: "Hai mom"
|
||||
}
|
||||
});
|
||||
|
||||
module I18nDirect {
|
||||
|
||||
export interface Props extends IntlComponent.Props {}
|
||||
}
|
||||
|
||||
class I18nDirect extends React.Component<I18nDirect.Props, any> {
|
||||
|
||||
private _currentLocale: string
|
||||
private _messages: {[key: string]: string}
|
||||
|
||||
constructor( props: I18nDirect.Props ) {
|
||||
super( props )
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
|
||||
<ul>
|
||||
<li>FormattedNumber:
|
||||
<FormattedNumber value={99.95} style="currency" currency="USD"/>
|
||||
</li>
|
||||
<li>FormattedMessage:
|
||||
<FormattedMessage message={this._messages['Sorry']} name='Dave'/>
|
||||
</li>
|
||||
<li>FormattedDate:
|
||||
<FormattedDate value={new Date()}/>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
componentWillReceiveProps( nextProps: I18nDirect.Props ) {
|
||||
this.compileMessages(nextProps)
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.compileMessages(this.props)
|
||||
}
|
||||
|
||||
|
||||
private compileMessages = (props: I18nDirect.Props): void => {
|
||||
|
||||
let locale: string = ( props.locales && props.locales[ 0 ] ) || 'en-US'
|
||||
|
||||
if (this._currentLocale !== locale) {
|
||||
|
||||
this._messages = Object.keys( MESSAGES ).reduce(
|
||||
( dic , key ) => {
|
||||
dic[ key ] = MESSAGES[ key ][ locale ]
|
||||
return dic
|
||||
},
|
||||
{} as { [key: string]: string; }
|
||||
)
|
||||
const messages = {
|
||||
"hello": "Hello, {name}!"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// This class uses the mixin and react-mixin is
|
||||
// The MESSAGES are passed from messages property of the props
|
||||
// To use it call <I18nMixin {...props}/>
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
module I18nMixin {
|
||||
|
||||
export interface Props extends IntlComponent.Props {}
|
||||
}
|
||||
|
||||
@reactMixin.decorate( IntlMixin )
|
||||
class I18nMixin extends React.Component<I18nMixin.Props, any> implements IntlComponent {
|
||||
|
||||
private _currentLocale: string
|
||||
|
||||
constructor( props: I18nMixin.Props ) {
|
||||
super( props )
|
||||
}
|
||||
|
||||
//Expose the method provided by the Mixin
|
||||
getIntlMessage: (key: string) => string = this['getIntlMessage']
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
|
||||
<ul>
|
||||
<li>FormattedNumber:
|
||||
<FormattedNumber value={99.95} style="currency" currency="USD"/>
|
||||
</li>
|
||||
<li>FormattedMessage:
|
||||
<FormattedMessage message={this.getIntlMessage('Sorry')} name='Dave'/> {/* this uses the mixin */}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
)
|
||||
return (<IntlProvider locale="en" formats={{}} messages={messages} defaultLocale="en" defaultFormats={messages}>
|
||||
<SomeComponent />
|
||||
</IntlProvider>)
|
||||
}
|
||||
}
|
||||
|
||||
export { I18nDirect, I18nMixin }
|
||||
export default {
|
||||
TestApp,
|
||||
SomeComponent: injectIntl(SomeComponent)
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
--target es5 --noImplicitAny --experimentalDecorators --jsx react
|
||||
--target es5 --noImplicitAny --experimentalDecorators --jsx react --module commonjs
|
||||
|
||||
318
react-intl/react-intl.d.ts
vendored
318
react-intl/react-intl.d.ts
vendored
@@ -1,99 +1,239 @@
|
||||
// Type definitions for react-intl 1.2.0
|
||||
// Type definitions for react-intl 2.0.0-beta1
|
||||
// Project: http://formatjs.io/react/
|
||||
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
|
||||
// Definitions by: Bruno Grieder <https://github.com/bgrieder>, Christian Droulers <https://github.com/cdroulers>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path='../react/react.d.ts' />
|
||||
|
||||
declare module "react-intl" {
|
||||
|
||||
import * as React from 'react'
|
||||
|
||||
module ReactIntl {
|
||||
|
||||
|
||||
interface IIntlMixin extends React.Mixin<any,any> {
|
||||
getIntlMessage(key: string): string
|
||||
}
|
||||
|
||||
var IntlMixin: IIntlMixin
|
||||
|
||||
module IntlComponent {
|
||||
interface Props {
|
||||
locales?: string[]
|
||||
messages?: {[key: string]: any}
|
||||
formats?: string[]
|
||||
}
|
||||
}
|
||||
interface IntlComponent {
|
||||
getIntlMessage(key: string): string;
|
||||
}
|
||||
|
||||
|
||||
module FormattedDate {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
value: Date
|
||||
day?: string
|
||||
month?: string
|
||||
year?: string
|
||||
}
|
||||
}
|
||||
class FormattedDate extends React.Component<FormattedDate.Props,any> {}
|
||||
|
||||
|
||||
module FormattedTime {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
value: Date
|
||||
day?: string
|
||||
month?: string
|
||||
year?: string
|
||||
format?: string
|
||||
}
|
||||
}
|
||||
class FormattedTime extends React.Component<FormattedTime.Props,any> {}
|
||||
|
||||
|
||||
module FormattedRelative {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
value: number
|
||||
units?: string //"second", "minute", "hour", "day", "month" or "year"
|
||||
style?: string //"best fit" (default) or "numeric"
|
||||
format?: string
|
||||
}
|
||||
}
|
||||
class FormattedRelative extends React.Component<FormattedRelative.Props,any> {}
|
||||
|
||||
|
||||
module FormattedMessage {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
message: string;
|
||||
[prop: string]: any
|
||||
}
|
||||
}
|
||||
class FormattedMessage extends React.Component<FormattedMessage.Props,any> {}
|
||||
|
||||
|
||||
module FormattedHTMLMessage {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
message: string;
|
||||
[prop: string]: any
|
||||
}
|
||||
}
|
||||
class FormattedHTMLMessage extends React.Component<FormattedHTMLMessage.Props,any> {}
|
||||
|
||||
|
||||
module FormattedNumber {
|
||||
export interface Props extends IntlComponent.Props {
|
||||
value: number
|
||||
style?: string
|
||||
currency?: string
|
||||
format?: string
|
||||
}
|
||||
}
|
||||
class FormattedNumber extends React.Component<FormattedNumber.Props,any> {}
|
||||
declare module ReactIntl {
|
||||
import React = __React;
|
||||
|
||||
interface Locale {
|
||||
locale: string;
|
||||
fields?: { [key: string]: string },
|
||||
pluralRuleFunction?: (n: number, ord: boolean) => string;
|
||||
}
|
||||
|
||||
export = ReactIntl
|
||||
function injectIntl<T>(clazz: T): T;
|
||||
|
||||
function addLocaleData(data: Locale[] | Locale): void;
|
||||
|
||||
function hasLocaleData(localeName: string): boolean;
|
||||
|
||||
interface Messages {
|
||||
[key: string]: FormattedMessage.MessageDescriptor
|
||||
}
|
||||
|
||||
function defineMessages<T extends Messages>(messages: Messages): T;
|
||||
|
||||
interface IntlShape extends React.Requireable<any> {
|
||||
}
|
||||
|
||||
var intlShape: IntlShape;
|
||||
|
||||
interface FormatConfig {
|
||||
locale?: string;
|
||||
formats?: any;
|
||||
}
|
||||
|
||||
interface InjectedIntlProps {
|
||||
formatDate?: (date: Date, options?: FormattedDate.PropsBase) => string;
|
||||
formatTime?: (date: Date, options?: FormattedTime.PropsBase) => string;
|
||||
formatRelative?: (value: number, options?: FormattedRelative.PropsBase) => string;
|
||||
formatNumber?: (value: number, options?: FormattedNumber.PropsBase) => string;
|
||||
formatPlural?: (value: number, options?: FormattedPlural.PropsBase) => string;
|
||||
formatMessage?: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: Object) => string;
|
||||
formatHTMLMessage?: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: Object) => string;
|
||||
}
|
||||
|
||||
module IntlComponent {
|
||||
interface DateTimeFormatProps {
|
||||
/*
|
||||
* one of "best fit" (default) | "lookup"
|
||||
*/
|
||||
localeMatcher?: string;
|
||||
/*
|
||||
* one of "basic" (default) | "best fit"
|
||||
*/
|
||||
formatMatcher?: string;
|
||||
timeZone?: string,
|
||||
hour12?: boolean;
|
||||
/*
|
||||
* one of "narrow" (default) | "short" | "long"
|
||||
*/
|
||||
weekday?: string;
|
||||
/*
|
||||
* one of "narrow" (default) | "short" | "long"
|
||||
*/
|
||||
era?: string;
|
||||
/*
|
||||
* one of "numeric" (default) | "2-digit"
|
||||
*/
|
||||
year?: string;
|
||||
/*
|
||||
* one of "numeric" (default) | "2-digit" | "narrow" | "short" | "long"
|
||||
*/
|
||||
month?: string;
|
||||
/*
|
||||
* one of "numeric" (default) | "2-digit"
|
||||
*/
|
||||
day?: string;
|
||||
/*
|
||||
* one of "numeric" (default) | "2-digit"
|
||||
*/
|
||||
hour?: string;
|
||||
/*
|
||||
* one of "numeric" (default) | "2-digit"
|
||||
*/
|
||||
minute?: string;
|
||||
/*
|
||||
* one of "numeric" (default) | "2-digit"
|
||||
*/
|
||||
second?: string;
|
||||
/*
|
||||
* one of "short" (default) | "long"
|
||||
*/
|
||||
timeZoneName?: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module FormattedDate {
|
||||
export interface PropsBase extends IntlComponent.DateTimeFormatProps {
|
||||
format?: string;
|
||||
}
|
||||
|
||||
export interface Props extends PropsBase {
|
||||
value: Date;
|
||||
}
|
||||
}
|
||||
class FormattedDate extends React.Component<FormattedDate.Props, any> { }
|
||||
|
||||
|
||||
module FormattedTime {
|
||||
export interface PropsBase extends IntlComponent.DateTimeFormatProps {
|
||||
format?: string;
|
||||
}
|
||||
|
||||
export interface Props extends PropsBase {
|
||||
value: Date;
|
||||
}
|
||||
}
|
||||
class FormattedTime extends React.Component<FormattedTime.Props, any> { }
|
||||
|
||||
|
||||
module FormattedRelative {
|
||||
export interface PropsBase {
|
||||
/*
|
||||
* one of "second", "minute", "hour", "day", "month" or "year"
|
||||
*/
|
||||
units?: string;
|
||||
/*
|
||||
* one of "best fit" (default) | "numeric"
|
||||
*/
|
||||
style?: string;
|
||||
format?: string;
|
||||
updateInterval?: number;
|
||||
initialNow?: any;
|
||||
}
|
||||
|
||||
export interface Props extends PropsBase {
|
||||
value: number;
|
||||
}
|
||||
}
|
||||
class FormattedRelative extends React.Component<FormattedRelative.Props, any> { }
|
||||
|
||||
|
||||
module FormattedMessage {
|
||||
export interface MessageDescriptor {
|
||||
id: string;
|
||||
description?: string;
|
||||
defaultMessage?: string;
|
||||
}
|
||||
|
||||
export interface Props extends MessageDescriptor {
|
||||
values?: Object;
|
||||
tagName?: string;
|
||||
}
|
||||
}
|
||||
class FormattedMessage extends React.Component<FormattedMessage.Props, any> { }
|
||||
|
||||
|
||||
class FormattedHTMLMessage extends React.Component<FormattedMessage.Props, any> { }
|
||||
|
||||
|
||||
module FormattedNumber {
|
||||
export interface PropsBase {
|
||||
format?: string;
|
||||
/*
|
||||
* one of "best fit" (default) | "lookup"
|
||||
*/
|
||||
localeMatcher?: string;
|
||||
/*
|
||||
* one of "decimal" (default) | "currency" | "percent"
|
||||
*/
|
||||
style?: string;
|
||||
currency?: string,
|
||||
/*
|
||||
* one of "symbol" (default) | "code" | "name"
|
||||
*/
|
||||
currencyDisplay?: string;
|
||||
useGrouping?: boolean;
|
||||
minimumIntegerDigits?: number;
|
||||
minimumFractionDigits?: number;
|
||||
maximumFractionDigits?: number;
|
||||
minimumSignificantDigits?: number;
|
||||
maximumSignificantDigits?: number;
|
||||
}
|
||||
|
||||
export interface Props extends PropsBase {
|
||||
value: number;
|
||||
}
|
||||
}
|
||||
class FormattedNumber extends React.Component<FormattedNumber.Props, any> { }
|
||||
|
||||
|
||||
module FormattedPlural {
|
||||
export interface PropsBase {
|
||||
/*
|
||||
* one of "cardinal" (default) | "ordinal"
|
||||
*/
|
||||
style?: string;
|
||||
other?: any;
|
||||
zero?: any;
|
||||
one?: any;
|
||||
two?: any;
|
||||
few?: any;
|
||||
many?: any;
|
||||
}
|
||||
|
||||
export interface Props extends PropsBase {
|
||||
value: number;
|
||||
}
|
||||
}
|
||||
class FormattedPlural extends React.Component<FormattedPlural.Props, any> { }
|
||||
|
||||
|
||||
module IntlProvider {
|
||||
export interface Props {
|
||||
locale?: string;
|
||||
formats?: Object;
|
||||
messages?: Object;
|
||||
defaultLocale?: string;
|
||||
defaultFormats?: Object;
|
||||
}
|
||||
}
|
||||
class IntlProvider extends React.Component<IntlProvider.Props, any> { }
|
||||
|
||||
class LocaleData extends Array<Locale> {
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react-intl" {
|
||||
export = ReactIntl
|
||||
}
|
||||
|
||||
declare module "react-intl/lib/locale-data/en" {
|
||||
var data: ReactIntl.LocaleData;
|
||||
export = data;
|
||||
}
|
||||
4
react/react.d.ts
vendored
4
react/react.d.ts
vendored
@@ -313,6 +313,8 @@ declare namespace __React {
|
||||
deltaZ: number;
|
||||
}
|
||||
|
||||
interface LoadEvent extends SyntheticEvent {}
|
||||
|
||||
//
|
||||
// Event Handler Types
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -330,6 +332,7 @@ declare namespace __React {
|
||||
interface TouchEventHandler extends EventHandler<TouchEvent> {}
|
||||
interface UIEventHandler extends EventHandler<UIEvent> {}
|
||||
interface WheelEventHandler extends EventHandler<WheelEvent> {}
|
||||
interface LoadEventHandler extends EventHandler<LoadEvent> {}
|
||||
|
||||
//
|
||||
// Props / DOM Attributes
|
||||
@@ -377,6 +380,7 @@ declare namespace __React {
|
||||
onTouchStart?: TouchEventHandler;
|
||||
onScroll?: UIEventHandler;
|
||||
onWheel?: WheelEventHandler;
|
||||
onLoad?: LoadEventHandler;
|
||||
|
||||
className?: string;
|
||||
id?: string;
|
||||
|
||||
@@ -1,17 +1,464 @@
|
||||
/// <reference path="request-promise.d.ts" />
|
||||
|
||||
import rp = require('request-promise');
|
||||
import nodeRequest = require('request');
|
||||
|
||||
rp('http://www.google.com')
|
||||
.then(console.dir)
|
||||
.catch(console.error);
|
||||
|
||||
var options: rp.Options = {
|
||||
var options: nodeRequest.Options = {
|
||||
uri : 'http://posttestserver.com/post.php',
|
||||
method : 'POST'
|
||||
method : 'POST',
|
||||
json: true,
|
||||
body: { some: 'payload' }
|
||||
};
|
||||
|
||||
rp(options)
|
||||
.then(console.dir)
|
||||
.catch(console.error);
|
||||
|
||||
// --> Displays length of response from server after post
|
||||
|
||||
// Get full response after DELETE
|
||||
options = {
|
||||
method: 'DELETE',
|
||||
uri: 'http://my-server/path/to/resource/1234'
|
||||
};
|
||||
|
||||
rp(options)
|
||||
.then(function (response: http.IncomingMessage) {
|
||||
console.log("DELETE succeeded with status %d", response.statusCode);
|
||||
})
|
||||
.catch(console.error);
|
||||
|
||||
//The following examples from https://github.com/request/request
|
||||
import fs = require('fs');
|
||||
import http = require('http');
|
||||
var request = rp;
|
||||
|
||||
request('http://www.google.com', function (error, response, body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
console.log(body); // Show the HTML for the Google homepage.
|
||||
}
|
||||
});
|
||||
|
||||
request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'));
|
||||
|
||||
fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json'));
|
||||
|
||||
request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png'));
|
||||
|
||||
request
|
||||
.get('http://google.com/img.png')
|
||||
.on('response', function(response: any) {
|
||||
console.log(response.statusCode); // 200
|
||||
console.log(response.headers['content-type']); // 'image/png'
|
||||
})
|
||||
.pipe(request.put('http://mysite.com/img.png'));
|
||||
|
||||
request
|
||||
.get('http://mysite.com/doodle.png')
|
||||
.on('error', function(err: any) {
|
||||
console.log(err);
|
||||
})
|
||||
.pipe(fs.createWriteStream('doodle.png'));
|
||||
|
||||
http.createServer(function (req, resp) {
|
||||
if (req.url === '/doodle.png') {
|
||||
if (req.method === 'PUT') {
|
||||
req.pipe(request.put('http://mysite.com/doodle.png'));
|
||||
} else if (req.method === 'GET' || req.method === 'HEAD') {
|
||||
request.get('http://mysite.com/doodle.png').pipe(resp);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
http.createServer(function (req, resp) {
|
||||
if (req.url === '/doodle.png') {
|
||||
var x = request('http://mysite.com/doodle.png');
|
||||
req.pipe(x);
|
||||
x.pipe(resp);
|
||||
}
|
||||
});
|
||||
|
||||
var resp: http.ServerResponse;
|
||||
var req: nodeRequest.Request;
|
||||
req.pipe(request('http://mysite.com/doodle.png')).pipe(resp);
|
||||
|
||||
var r = request;
|
||||
http.createServer(function (req, resp) {
|
||||
if (req.url === '/doodle.png') {
|
||||
r.get('http://google.com/doodle.png').pipe(resp);
|
||||
}
|
||||
});
|
||||
|
||||
request.post('http://service.com/upload', {form:{key:'value'}});
|
||||
// or
|
||||
request.post('http://service.com/upload').form({key:'value'});
|
||||
// or
|
||||
request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ });
|
||||
|
||||
var data = {
|
||||
// Pass a simple key-value pair
|
||||
my_field: 'my_value',
|
||||
// Pass data via Buffers
|
||||
my_buffer: new Buffer([1, 2, 3]),
|
||||
// Pass data via Streams
|
||||
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
|
||||
// Pass multiple values /w an Array
|
||||
attachments: [
|
||||
fs.createReadStream(__dirname + '/attachment1.jpg'),
|
||||
fs.createReadStream(__dirname + '/attachment2.jpg')
|
||||
],
|
||||
// Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS}
|
||||
// Use case: for some types of streams, you'll need to provide "file"-related information manually.
|
||||
// See the `form-data` README for more information about options: https://github.com/felixge/node-form-data
|
||||
custom_file: {
|
||||
value: fs.createReadStream('/dev/urandom'),
|
||||
options: {
|
||||
filename: 'topsecret.jpg',
|
||||
contentType: 'image/jpg'
|
||||
}
|
||||
}
|
||||
};
|
||||
request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) {
|
||||
if (err) {
|
||||
return console.error('upload failed:', err);
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
|
||||
var requestMultipart = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {});
|
||||
var form = requestMultipart.form();
|
||||
form.append('my_field', 'my_value');
|
||||
form.append('my_buffer', new Buffer([1, 2, 3]));
|
||||
form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'});
|
||||
|
||||
request({
|
||||
method: 'PUT',
|
||||
preambleCRLF: true,
|
||||
postambleCRLF: true,
|
||||
uri: 'http://service.com/upload',
|
||||
multipart: {
|
||||
chunked: false,
|
||||
data: [
|
||||
{
|
||||
'content-type': 'application/json',
|
||||
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
|
||||
},
|
||||
{ body: 'I am an attachment' }
|
||||
]
|
||||
}
|
||||
},
|
||||
function (error, response, body) {
|
||||
if (error) {
|
||||
return console.error('upload failed:', error);
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
request({
|
||||
method: 'PUT',
|
||||
preambleCRLF: true,
|
||||
postambleCRLF: true,
|
||||
uri: 'http://service.com/upload',
|
||||
multipart: [
|
||||
{
|
||||
'content-type': 'application/json',
|
||||
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
|
||||
},
|
||||
{ body: 'I am an attachment' },
|
||||
{ body: fs.createReadStream('image.png') }
|
||||
]
|
||||
},
|
||||
function (error, response, body) {
|
||||
if (error) {
|
||||
return console.error('upload failed:', error);
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
|
||||
request.get('http://some.server.com/').auth('username', 'password', false);
|
||||
// or
|
||||
request.get('http://some.server.com/', {
|
||||
'auth': {
|
||||
'user': 'username',
|
||||
'pass': 'password',
|
||||
'sendImmediately': false
|
||||
}
|
||||
});
|
||||
// or
|
||||
request.get('http://some.server.com/').auth(null, null, true, 'bearerToken');
|
||||
// or
|
||||
request.get('http://some.server.com/', {
|
||||
'auth': {
|
||||
'bearer': 'bearerToken'
|
||||
}
|
||||
});
|
||||
|
||||
var username = 'username',
|
||||
password = 'password',
|
||||
url = 'http://' + username + ':' + password + '@some.server.com';
|
||||
|
||||
request({url: url}, function (error, response, body) {
|
||||
// Do more stuff with 'body' here
|
||||
});
|
||||
|
||||
options = {
|
||||
url: 'https://api.github.com/repos/request/request',
|
||||
headers: {
|
||||
'User-Agent': 'request'
|
||||
}
|
||||
};
|
||||
|
||||
function callback(error: any, response: http.IncomingMessage, body: string) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
var info = JSON.parse(body);
|
||||
console.log(info.stargazers_count + " Stars");
|
||||
console.log(info.forks_count + " Forks");
|
||||
}
|
||||
}
|
||||
|
||||
request(options, callback);
|
||||
|
||||
// OAuth1.0 - 3-legged server side flow (Twitter example)
|
||||
// step 1
|
||||
import qs = require('querystring');
|
||||
const CONSUMER_KEY = 'key';
|
||||
const CONSUMER_SECRET = 'secret';
|
||||
var oauth =
|
||||
{ callback: 'http://mysite.com/callback/'
|
||||
, consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
}
|
||||
, url = 'https://api.twitter.com/oauth/request_token'
|
||||
;
|
||||
request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
// Ideally, you would take the body in the response
|
||||
// and construct a URL that a user clicks on (like a sign in button).
|
||||
// The verifier is only available in the response after a user has
|
||||
// verified with twitter that they are authorizing your app.
|
||||
|
||||
// step 2
|
||||
var req_data = qs.parse(body);
|
||||
var uri = 'https://api.twitter.com/oauth/authenticate'
|
||||
+ '?' + qs.stringify({oauth_token: req_data.oauth_token});
|
||||
// redirect the user to the authorize uri
|
||||
|
||||
// step 3
|
||||
// after the user is redirected back to your server
|
||||
var auth_data: any = qs.parse(body)
|
||||
, oauth =
|
||||
{ consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
, token: auth_data.oauth_token
|
||||
, token_secret: req_data.oauth_token_secret
|
||||
, verifier: auth_data.oauth_verifier
|
||||
}
|
||||
, url = 'https://api.twitter.com/oauth/access_token'
|
||||
;
|
||||
request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
// ready to make signed requests on behalf of the user
|
||||
var perm_data: any = qs.parse(body);
|
||||
var oauth =
|
||||
{ consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
, token: perm_data.oauth_token
|
||||
, token_secret: perm_data.oauth_token_secret
|
||||
};
|
||||
var url = 'https://api.twitter.com/1.1/users/show.json';
|
||||
var query = {
|
||||
screen_name: perm_data.screen_name,
|
||||
user_id: perm_data.user_id
|
||||
};
|
||||
request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) {
|
||||
console.log(user);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var path = require('path')
|
||||
, certFile = path.resolve(__dirname, 'ssl/client.crt')
|
||||
, keyFile = path.resolve(__dirname, 'ssl/client.key')
|
||||
, caFile = path.resolve(__dirname, 'ssl/ca.cert.pem');
|
||||
|
||||
options = {
|
||||
url: 'https://api.some-server.com/',
|
||||
cert: fs.readFileSync(certFile),
|
||||
key: fs.readFileSync(keyFile),
|
||||
passphrase: 'password',
|
||||
ca: fs.readFileSync(caFile)
|
||||
};
|
||||
|
||||
request.get(options);
|
||||
|
||||
var path = require('path')
|
||||
, certFile = path.resolve(__dirname, 'ssl/client.crt')
|
||||
, keyFile = path.resolve(__dirname, 'ssl/client.key');
|
||||
|
||||
options = {
|
||||
url: 'https://api.some-server.com/',
|
||||
agentOptions: {
|
||||
cert: fs.readFileSync(certFile),
|
||||
key: fs.readFileSync(keyFile),
|
||||
// Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format:
|
||||
// pfx: fs.readFileSync(pfxFilePath),
|
||||
passphrase: 'password',
|
||||
securityOptions: 'SSL_OP_NO_SSLv3'
|
||||
}
|
||||
};
|
||||
|
||||
request.get(options);
|
||||
|
||||
request.get({
|
||||
url: 'https://api.some-server.com/',
|
||||
agentOptions: {
|
||||
secureProtocol: 'SSLv3_method'
|
||||
}
|
||||
});
|
||||
|
||||
request.get({
|
||||
url: 'https://api.some-server.com/',
|
||||
agentOptions: {
|
||||
ca: fs.readFileSync('ca.cert.pem')
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
request({
|
||||
// will be ignored
|
||||
method: 'GET',
|
||||
uri: 'http://www.google.com',
|
||||
|
||||
// HTTP Archive Request Object
|
||||
har: {
|
||||
url: 'http://www.mockbin.com/har',
|
||||
method: 'POST',
|
||||
headers: [
|
||||
{
|
||||
name: 'content-type',
|
||||
value: 'application/x-www-form-urlencoded'
|
||||
}
|
||||
],
|
||||
postData: {
|
||||
mimeType: 'application/x-www-form-urlencoded',
|
||||
params: [
|
||||
{
|
||||
name: 'foo',
|
||||
value: 'bar'
|
||||
},
|
||||
{
|
||||
name: 'hello',
|
||||
value: 'world'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//requests using baseRequest() will set the 'x-token' header
|
||||
var baseRequest = request.defaults({
|
||||
headers: {'x-token': 'my-token'}
|
||||
});
|
||||
|
||||
//requests using specialRequest() will include the 'x-token' header set in
|
||||
//baseRequest and will also include the 'special' header
|
||||
var specialRequest = baseRequest.defaults({
|
||||
headers: {special: 'special value'}
|
||||
});
|
||||
|
||||
request.put(url);
|
||||
request.patch(url);
|
||||
request.post(url);
|
||||
request.head(url);
|
||||
request.del(url);
|
||||
request.get(url);
|
||||
request.cookie('key1=value1');
|
||||
request.jar();
|
||||
request.debug = true;
|
||||
|
||||
request.get('http://10.255.255.1', {timeout: 1500}, function(err) {
|
||||
console.log(err.code === 'ETIMEDOUT');
|
||||
// Set to `true` if the timeout was a connection timeout, `false` or
|
||||
// `undefined` otherwise.
|
||||
console.log(err.connect === true);
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
var rand = Math.floor(Math.random()*100000000).toString();
|
||||
request(
|
||||
{ method: 'PUT'
|
||||
, uri: 'http://mikeal.iriscouch.com/testjs/' + rand
|
||||
, multipart:
|
||||
[ { 'content-type': 'application/json'
|
||||
, body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
|
||||
}
|
||||
, { body: 'I am an attachment' }
|
||||
]
|
||||
}
|
||||
, function (error, response, body) {
|
||||
if(response.statusCode == 201){
|
||||
console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand)
|
||||
} else {
|
||||
console.log('error: '+ response.statusCode)
|
||||
console.log(body)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
request(
|
||||
{ method: 'GET'
|
||||
, uri: 'http://www.google.com'
|
||||
, gzip: true
|
||||
}
|
||||
, function (error, response, body) {
|
||||
// body is the decompressed response body
|
||||
console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity'))
|
||||
console.log('the decoded data is: ' + body)
|
||||
}
|
||||
).on('data', function(data: any) {
|
||||
// decompressed data as it is received
|
||||
console.log('decoded chunk: ' + data)
|
||||
})
|
||||
.on('response', function(response: http.IncomingMessage) {
|
||||
// unmodified http.IncomingMessage object
|
||||
response.on('data', function(data: any[]) {
|
||||
// compressed data as it is received
|
||||
console.log('received ' + data.length + ' bytes of compressed data')
|
||||
})
|
||||
});
|
||||
|
||||
var requestWithJar = request.defaults({jar: true})
|
||||
requestWithJar('http://www.google.com', function () {
|
||||
requestWithJar('http://images.google.com');
|
||||
});
|
||||
|
||||
var j = request.jar()
|
||||
requestWithJar = request.defaults({jar:j})
|
||||
requestWithJar('http://www.google.com', function () {
|
||||
requestWithJar('http://images.google.com');
|
||||
});
|
||||
|
||||
var j = request.jar();
|
||||
var cookie = request.cookie('key1=value1');
|
||||
var url = 'http://www.google.com';
|
||||
j.setCookie(cookie, url);
|
||||
request({url: url, jar: j}, function () {
|
||||
request('http://images.google.com');
|
||||
});
|
||||
|
||||
//TODO: add definitions for tough-cookie-filestore
|
||||
//var FileCookieStore = require('tough-cookie-filestore');
|
||||
// NOTE - currently the 'cookies.json' file must already exist!
|
||||
//var j = request.jar(new FileCookieStore('cookies.json'));
|
||||
requestWithJar = request.defaults({ jar : j })
|
||||
request('http://www.google.com', function() {
|
||||
request('http://images.google.com');
|
||||
});
|
||||
|
||||
var j = request.jar()
|
||||
request({url: 'http://www.google.com', jar: j}, function () {
|
||||
var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..."
|
||||
var cookies = j.getCookies(url);
|
||||
// [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...]
|
||||
});
|
||||
|
||||
34
request-promise/request-promise.d.ts
vendored
34
request-promise/request-promise.d.ts
vendored
@@ -1,32 +1,30 @@
|
||||
// Type definitions for request-promise v0.4.2
|
||||
// Project: https://www.npmjs.com/package/request-promise
|
||||
// Definitions by: Christopher Glantschnig <https://github.com/cglantschnig/>
|
||||
// Definitions by: Christopher Glantschnig <https://github.com/cglantschnig/>, Joe Skeen <http://github.com/joeskeen>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// Change [0]: 2015/08/20 - Aya Morisawa <https://github.com/AyaMorisawa>
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
/// <reference path="../form-data/form-data.d.ts" />
|
||||
/// <reference path="../request/request.d.ts" />
|
||||
/// <reference path="../bluebird/bluebird.d.ts" />
|
||||
|
||||
declare module 'request-promise' {
|
||||
import request = require('request');
|
||||
import stream = require('stream');
|
||||
import http = require('http');
|
||||
import FormData = require('form-data');
|
||||
|
||||
export = RequestPromiseAPI;
|
||||
|
||||
function RequestPromiseAPI(options: RequestPromiseAPI.Options): Promise<any>;
|
||||
function RequestPromiseAPI(uri: string): Promise<request.Request>;
|
||||
|
||||
module RequestPromiseAPI {
|
||||
interface AdditionalOptions {
|
||||
simple?: boolean;
|
||||
transform?: (body: any, response: http.IncomingMessage) => any;
|
||||
resolveWithFullResponse?: boolean;
|
||||
}
|
||||
export type Options = AdditionalOptions & request.Options;
|
||||
|
||||
interface RequestPromise extends request.Request {
|
||||
then(onFulfilled: Function, onRejected?: Function): Promise<any>;
|
||||
catch(onRejected: Function): Promise<any>;
|
||||
finally(onFinished: Function): Promise<any>;
|
||||
promise(): Promise<any>;
|
||||
}
|
||||
|
||||
interface RequestPromiseOptions extends request.OptionalOptions {
|
||||
simple?: boolean;
|
||||
transform?: (body: any, response: http.IncomingMessage) => any;
|
||||
resolveWithFullResponse?: boolean;
|
||||
}
|
||||
|
||||
var requestPromise: request.RequestAPI<RequestPromise, RequestPromiseOptions>;
|
||||
export = requestPromise;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import request = require('request');
|
||||
import http = require('http');
|
||||
import stream = require('stream');
|
||||
import formData = require('form-data');
|
||||
import fs = require('fs');
|
||||
|
||||
var value: any;
|
||||
var str: string;
|
||||
@@ -20,7 +21,7 @@ var headers: {[key: string]: string};
|
||||
var agent: http.Agent;
|
||||
var write: stream.Writable;
|
||||
var req: request.Request;
|
||||
var form: formData.FormData;
|
||||
var form1: formData.FormData;
|
||||
|
||||
var bodyArr: request.RequestPart[] = [{
|
||||
body: value
|
||||
@@ -32,7 +33,7 @@ var bodyArr: request.RequestPart[] = [{
|
||||
|
||||
// --- --- --- --- --- --- --- --- --- --- --- ---
|
||||
|
||||
str = req.toJSON();
|
||||
obj = req.toJSON();
|
||||
|
||||
var cookieValue: request.CookieValue;
|
||||
str = cookieValue.name;
|
||||
@@ -125,8 +126,6 @@ req.destroy();
|
||||
|
||||
// --- --- --- --- --- --- --- --- --- --- --- ---
|
||||
|
||||
var callback: (error: any, response: any, body: any) => void;
|
||||
|
||||
value = request.initParams;
|
||||
|
||||
req = request(uri);
|
||||
@@ -136,13 +135,6 @@ req = request(uri, callback);
|
||||
req = request(options);
|
||||
req = request(options, callback);
|
||||
|
||||
req = request.request(uri);
|
||||
req = request.request(uri, options);
|
||||
req = request.request(uri, options, callback);
|
||||
req = request.request(uri, callback);
|
||||
req = request.request(options);
|
||||
req = request.request(options, callback);
|
||||
|
||||
req = request.get(uri);
|
||||
req = request.get(uri, options);
|
||||
req = request.get(uri, options, callback);
|
||||
@@ -204,3 +196,428 @@ request
|
||||
// check response
|
||||
})
|
||||
.pipe(request.put('http://another.com/another.png'));
|
||||
|
||||
//The following examples from https://github.com/request/request
|
||||
request('http://www.google.com', function (error, response, body) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
console.log(body); // Show the HTML for the Google homepage.
|
||||
}
|
||||
});
|
||||
|
||||
request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'));
|
||||
|
||||
fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json'));
|
||||
|
||||
request.get('http://google.com/img.png').pipe(request.put('http://mysite.com/img.png'));
|
||||
|
||||
request
|
||||
.get('http://google.com/img.png')
|
||||
.on('response', function(response: any) {
|
||||
console.log(response.statusCode); // 200
|
||||
console.log(response.headers['content-type']); // 'image/png'
|
||||
})
|
||||
.pipe(request.put('http://mysite.com/img.png'));
|
||||
|
||||
request
|
||||
.get('http://mysite.com/doodle.png')
|
||||
.on('error', function(err: any) {
|
||||
console.log(err);
|
||||
})
|
||||
.pipe(fs.createWriteStream('doodle.png'));
|
||||
|
||||
http.createServer(function (req, resp) {
|
||||
if (req.url === '/doodle.png') {
|
||||
if (req.method === 'PUT') {
|
||||
req.pipe(request.put('http://mysite.com/doodle.png'));
|
||||
} else if (req.method === 'GET' || req.method === 'HEAD') {
|
||||
request.get('http://mysite.com/doodle.png').pipe(resp);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
http.createServer(function (req, resp) {
|
||||
if (req.url === '/doodle.png') {
|
||||
var x = request('http://mysite.com/doodle.png');
|
||||
req.pipe(x);
|
||||
x.pipe(resp);
|
||||
}
|
||||
});
|
||||
|
||||
var resp: http.ServerResponse;
|
||||
req.pipe(request('http://mysite.com/doodle.png')).pipe(resp);
|
||||
|
||||
http.createServer(function (req, resp) {
|
||||
if (req.url === '/doodle.png') {
|
||||
r.get('http://google.com/doodle.png').pipe(resp);
|
||||
}
|
||||
});
|
||||
|
||||
request.post('http://service.com/upload', {form:{key:'value'}});
|
||||
// or
|
||||
request.post('http://service.com/upload').form({key:'value'});
|
||||
// or
|
||||
request.post({url:'http://service.com/upload', form: {key:'value'}}, function(err,httpResponse,body){ /* ... */ });
|
||||
|
||||
var data = {
|
||||
// Pass a simple key-value pair
|
||||
my_field: 'my_value',
|
||||
// Pass data via Buffers
|
||||
my_buffer: new Buffer([1, 2, 3]),
|
||||
// Pass data via Streams
|
||||
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
|
||||
// Pass multiple values /w an Array
|
||||
attachments: [
|
||||
fs.createReadStream(__dirname + '/attachment1.jpg'),
|
||||
fs.createReadStream(__dirname + '/attachment2.jpg')
|
||||
],
|
||||
// Pass optional meta-data with an 'options' object with style: {value: DATA, options: OPTIONS}
|
||||
// Use case: for some types of streams, you'll need to provide "file"-related information manually.
|
||||
// See the `form-data` README for more information about options: https://github.com/felixge/node-form-data
|
||||
custom_file: {
|
||||
value: fs.createReadStream('/dev/urandom'),
|
||||
options: {
|
||||
filename: 'topsecret.jpg',
|
||||
contentType: 'image/jpg'
|
||||
}
|
||||
}
|
||||
};
|
||||
request.post({url:'http://service.com/upload', formData: data}, function optionalCallback(err, httpResponse, body) {
|
||||
if (err) {
|
||||
return console.error('upload failed:', err);
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
|
||||
var requestMultipart = request.post('http://service.com/upload', function optionalCallback(err, httpResponse, body) {});
|
||||
var form = requestMultipart.form();
|
||||
form.append('my_field', 'my_value');
|
||||
form.append('my_buffer', new Buffer([1, 2, 3]));
|
||||
form.append('custom_file', fs.createReadStream(__dirname + '/unicycle.jpg'), {filename: 'unicycle.jpg'});
|
||||
|
||||
request({
|
||||
method: 'PUT',
|
||||
preambleCRLF: true,
|
||||
postambleCRLF: true,
|
||||
uri: 'http://service.com/upload',
|
||||
multipart: {
|
||||
chunked: false,
|
||||
data: [
|
||||
{
|
||||
'content-type': 'application/json',
|
||||
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
|
||||
},
|
||||
{ body: 'I am an attachment' }
|
||||
]
|
||||
}
|
||||
},
|
||||
function (error, response, body) {
|
||||
if (error) {
|
||||
return console.error('upload failed:', error);
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
request({
|
||||
method: 'PUT',
|
||||
preambleCRLF: true,
|
||||
postambleCRLF: true,
|
||||
uri: 'http://service.com/upload',
|
||||
multipart: [
|
||||
{
|
||||
'content-type': 'application/json',
|
||||
body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
|
||||
},
|
||||
{ body: 'I am an attachment' },
|
||||
{ body: fs.createReadStream('image.png') }
|
||||
]
|
||||
},
|
||||
function (error, response, body) {
|
||||
if (error) {
|
||||
return console.error('upload failed:', error);
|
||||
}
|
||||
console.log('Upload successful! Server responded with:', body);
|
||||
});
|
||||
|
||||
request.get('http://some.server.com/').auth('username', 'password', false);
|
||||
// or
|
||||
request.get('http://some.server.com/', {
|
||||
'auth': {
|
||||
'user': 'username',
|
||||
'pass': 'password',
|
||||
'sendImmediately': false
|
||||
}
|
||||
});
|
||||
// or
|
||||
request.get('http://some.server.com/').auth(null, null, true, 'bearerToken');
|
||||
// or
|
||||
request.get('http://some.server.com/', {
|
||||
'auth': {
|
||||
'bearer': 'bearerToken'
|
||||
}
|
||||
});
|
||||
|
||||
var username = 'username',
|
||||
password = 'password',
|
||||
url = 'http://' + username + ':' + password + '@some.server.com';
|
||||
|
||||
request({url: url}, function (error, response, body) {
|
||||
// Do more stuff with 'body' here
|
||||
});
|
||||
|
||||
options = {
|
||||
url: 'https://api.github.com/repos/request/request',
|
||||
headers: {
|
||||
'User-Agent': 'request'
|
||||
}
|
||||
};
|
||||
|
||||
function callback(error: any, response: http.IncomingMessage, body: string) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
var info = JSON.parse(body);
|
||||
console.log(info.stargazers_count + " Stars");
|
||||
console.log(info.forks_count + " Forks");
|
||||
}
|
||||
}
|
||||
|
||||
request(options, callback);
|
||||
|
||||
// OAuth1.0 - 3-legged server side flow (Twitter example)
|
||||
// step 1
|
||||
import qs = require('querystring');
|
||||
const CONSUMER_KEY = 'key';
|
||||
const CONSUMER_SECRET = 'secret';
|
||||
oauth =
|
||||
{ callback: 'http://mysite.com/callback/'
|
||||
, consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
}
|
||||
, url = 'https://api.twitter.com/oauth/request_token'
|
||||
;
|
||||
request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
// Ideally, you would take the body in the response
|
||||
// and construct a URL that a user clicks on (like a sign in button).
|
||||
// The verifier is only available in the response after a user has
|
||||
// verified with twitter that they are authorizing your app.
|
||||
|
||||
// step 2
|
||||
var req_data = qs.parse(body);
|
||||
var uri = 'https://api.twitter.com/oauth/authenticate'
|
||||
+ '?' + qs.stringify({oauth_token: req_data.oauth_token});
|
||||
// redirect the user to the authorize uri
|
||||
|
||||
// step 3
|
||||
// after the user is redirected back to your server
|
||||
var auth_data: any = qs.parse(body)
|
||||
, oauth =
|
||||
{ consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
, token: auth_data.oauth_token
|
||||
, token_secret: req_data.oauth_token_secret
|
||||
, verifier: auth_data.oauth_verifier
|
||||
}
|
||||
, url = 'https://api.twitter.com/oauth/access_token'
|
||||
;
|
||||
request.post({url:url, oauth:oauth}, function (e, r, body) {
|
||||
// ready to make signed requests on behalf of the user
|
||||
var perm_data: any = qs.parse(body);
|
||||
var oauth =
|
||||
{ consumer_key: CONSUMER_KEY
|
||||
, consumer_secret: CONSUMER_SECRET
|
||||
, token: perm_data.oauth_token
|
||||
, token_secret: perm_data.oauth_token_secret
|
||||
};
|
||||
var url = 'https://api.twitter.com/1.1/users/show.json';
|
||||
var query = {
|
||||
screen_name: perm_data.screen_name,
|
||||
user_id: perm_data.user_id
|
||||
};
|
||||
request.get({url:url, oauth:oauth, qs:query, json:true}, function (e, r, user) {
|
||||
console.log(user);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var path = require('path')
|
||||
, certFile = path.resolve(__dirname, 'ssl/client.crt')
|
||||
, keyFile = path.resolve(__dirname, 'ssl/client.key')
|
||||
, caFile = path.resolve(__dirname, 'ssl/ca.cert.pem');
|
||||
|
||||
options = {
|
||||
url: 'https://api.some-server.com/',
|
||||
cert: fs.readFileSync(certFile),
|
||||
key: fs.readFileSync(keyFile),
|
||||
passphrase: 'password',
|
||||
ca: fs.readFileSync(caFile)
|
||||
};
|
||||
|
||||
request.get(options);
|
||||
|
||||
var path = require('path')
|
||||
, certFile = path.resolve(__dirname, 'ssl/client.crt')
|
||||
, keyFile = path.resolve(__dirname, 'ssl/client.key');
|
||||
|
||||
options = {
|
||||
url: 'https://api.some-server.com/',
|
||||
agentOptions: {
|
||||
cert: fs.readFileSync(certFile),
|
||||
key: fs.readFileSync(keyFile),
|
||||
// Or use `pfx` property replacing `cert` and `key` when using private key, certificate and CA certs in PFX or PKCS12 format:
|
||||
// pfx: fs.readFileSync(pfxFilePath),
|
||||
passphrase: 'password',
|
||||
securityOptions: 'SSL_OP_NO_SSLv3'
|
||||
}
|
||||
};
|
||||
|
||||
request.get(options);
|
||||
|
||||
request.get({
|
||||
url: 'https://api.some-server.com/',
|
||||
agentOptions: {
|
||||
secureProtocol: 'SSLv3_method'
|
||||
}
|
||||
});
|
||||
|
||||
request.get({
|
||||
url: 'https://api.some-server.com/',
|
||||
agentOptions: {
|
||||
ca: fs.readFileSync('ca.cert.pem')
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
request({
|
||||
// will be ignored
|
||||
method: 'GET',
|
||||
uri: 'http://www.google.com',
|
||||
|
||||
// HTTP Archive Request Object
|
||||
har: {
|
||||
url: 'http://www.mockbin.com/har',
|
||||
method: 'POST',
|
||||
headers: [
|
||||
{
|
||||
name: 'content-type',
|
||||
value: 'application/x-www-form-urlencoded'
|
||||
}
|
||||
],
|
||||
postData: {
|
||||
mimeType: 'application/x-www-form-urlencoded',
|
||||
params: [
|
||||
{
|
||||
name: 'foo',
|
||||
value: 'bar'
|
||||
},
|
||||
{
|
||||
name: 'hello',
|
||||
value: 'world'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//requests using baseRequest() will set the 'x-token' header
|
||||
var baseRequest = request.defaults({
|
||||
headers: {'x-token': 'my-token'}
|
||||
});
|
||||
|
||||
//requests using specialRequest() will include the 'x-token' header set in
|
||||
//baseRequest and will also include the 'special' header
|
||||
var specialRequest = baseRequest.defaults({
|
||||
headers: {special: 'special value'}
|
||||
});
|
||||
|
||||
request.put(url);
|
||||
request.patch(url);
|
||||
request.post(url);
|
||||
request.head(url);
|
||||
request.del(url);
|
||||
request.get(url);
|
||||
request.cookie('key1=value1');
|
||||
request.jar();
|
||||
request.debug = true;
|
||||
|
||||
request.get('http://10.255.255.1', {timeout: 1500}, function(err) {
|
||||
console.log(err.code === 'ETIMEDOUT');
|
||||
// Set to `true` if the timeout was a connection timeout, `false` or
|
||||
// `undefined` otherwise.
|
||||
console.log(err.connect === true);
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
var rand = Math.floor(Math.random()*100000000).toString();
|
||||
request(
|
||||
{ method: 'PUT'
|
||||
, uri: 'http://mikeal.iriscouch.com/testjs/' + rand
|
||||
, multipart:
|
||||
[ { 'content-type': 'application/json'
|
||||
, body: JSON.stringify({foo: 'bar', _attachments: {'message.txt': {follows: true, length: 18, 'content_type': 'text/plain' }}})
|
||||
}
|
||||
, { body: 'I am an attachment' }
|
||||
]
|
||||
}
|
||||
, function (error, response, body) {
|
||||
if(response.statusCode == 201){
|
||||
console.log('document saved as: http://mikeal.iriscouch.com/testjs/'+ rand)
|
||||
} else {
|
||||
console.log('error: '+ response.statusCode)
|
||||
console.log(body)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
request(
|
||||
{ method: 'GET'
|
||||
, uri: 'http://www.google.com'
|
||||
, gzip: true
|
||||
}
|
||||
, function (error, response, body) {
|
||||
// body is the decompressed response body
|
||||
console.log('server encoded the data as: ' + (response.headers['content-encoding'] || 'identity'))
|
||||
console.log('the decoded data is: ' + body)
|
||||
}
|
||||
).on('data', function(data: any) {
|
||||
// decompressed data as it is received
|
||||
console.log('decoded chunk: ' + data)
|
||||
})
|
||||
.on('response', function(response: http.IncomingMessage) {
|
||||
// unmodified http.IncomingMessage object
|
||||
response.on('data', function(data: any[]) {
|
||||
// compressed data as it is received
|
||||
console.log('received ' + data.length + ' bytes of compressed data')
|
||||
})
|
||||
});
|
||||
|
||||
var requestWithJar = request.defaults({jar: true})
|
||||
requestWithJar('http://www.google.com', function () {
|
||||
requestWithJar('http://images.google.com');
|
||||
});
|
||||
|
||||
var j = request.jar()
|
||||
requestWithJar = request.defaults({jar:j})
|
||||
requestWithJar('http://www.google.com', function () {
|
||||
requestWithJar('http://images.google.com');
|
||||
});
|
||||
|
||||
var j = request.jar();
|
||||
cookie = request.cookie('key1=value1');
|
||||
var url = 'http://www.google.com';
|
||||
j.setCookie(cookie, url);
|
||||
request({url: url, jar: j}, function () {
|
||||
request('http://images.google.com');
|
||||
});
|
||||
|
||||
//TODO: add definitions for tough-cookie-filestore
|
||||
//var FileCookieStore = require('tough-cookie-filestore');
|
||||
// NOTE - currently the 'cookies.json' file must already exist!
|
||||
//var j = request.jar(new FileCookieStore('cookies.json'));
|
||||
requestWithJar = request.defaults({ jar : j })
|
||||
request('http://www.google.com', function() {
|
||||
request('http://images.google.com');
|
||||
});
|
||||
|
||||
var j = request.jar()
|
||||
request({url: 'http://www.google.com', jar: j}, function () {
|
||||
var cookie_string = j.getCookieString(url); // "key1=value1; key2=value2; ..."
|
||||
var cookies = j.getCookies(url);
|
||||
// [{key: 'key1', value: 'value1', domain: "www.google.com", ...}, ...]
|
||||
});
|
||||
|
||||
127
request/request.d.ts
vendored
127
request/request.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for request
|
||||
// Project: https://github.com/mikeal/request
|
||||
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, bonnici <https://github.com/bonnici>, Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, bonnici <https://github.com/bonnici>, Bart van der Schoor <https://github.com/Bartvds>, Joe Skeen <http://github.com/joeskeen>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts
|
||||
@@ -13,49 +13,46 @@ declare module 'request' {
|
||||
import http = require('http');
|
||||
import FormData = require('form-data');
|
||||
import url = require('url');
|
||||
import fs = require('fs');
|
||||
|
||||
export = RequestAPI;
|
||||
namespace request {
|
||||
export interface RequestAPI<TRequest extends Request, TOptions extends OptionalOptions> {
|
||||
defaults(options: DefaultsOptions): RequestAPI<TRequest, TOptions>;
|
||||
(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
|
||||
(uri: string, callback?: RequestCallback): TRequest;
|
||||
(options?: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
|
||||
|
||||
function RequestAPI(uri: string, options?: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request;
|
||||
function RequestAPI(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request;
|
||||
function RequestAPI(options: RequestAPI.Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): RequestAPI.Request;
|
||||
get(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
|
||||
get(uri: string, callback?: RequestCallback): TRequest;
|
||||
get(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
|
||||
|
||||
module RequestAPI {
|
||||
export function defaults(options: DefaultsOptions): typeof RequestAPI;
|
||||
post(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
|
||||
post(uri: string, callback?: RequestCallback): TRequest;
|
||||
post(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
|
||||
|
||||
export function request(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function request(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function request(options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
put(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
|
||||
put(uri: string, callback?: RequestCallback): TRequest;
|
||||
put(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
|
||||
|
||||
export function get(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function get(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function get(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
head(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
|
||||
head(uri: string, callback?: RequestCallback): TRequest;
|
||||
head(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
|
||||
|
||||
export function post(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function post(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function post(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
patch(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
|
||||
patch(uri: string, callback?: RequestCallback): TRequest;
|
||||
patch(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
|
||||
|
||||
export function put(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function put(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function put(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
del(uri: string, options?: TOptions, callback?: RequestCallback): TRequest;
|
||||
del(uri: string, callback?: RequestCallback): TRequest;
|
||||
del(options: RequiredOptions & TOptions, callback?: RequestCallback): TRequest;
|
||||
|
||||
export function head(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function head(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function head(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
forever(agentOptions: any, optionsArg: any): TRequest;
|
||||
jar(): CookieJar;
|
||||
cookie(str: string): Cookie;
|
||||
|
||||
export function patch(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function patch(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function patch(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
|
||||
export function del(uri: string, options?: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function del(uri: string, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
export function del(options: Options, callback?: (error: any, response: http.IncomingMessage, body: any) => void): Request;
|
||||
|
||||
export function forever(agentOptions: any, optionsArg: any): Request;
|
||||
export function jar(): CookieJar;
|
||||
export function cookie(str: string): Cookie;
|
||||
|
||||
export var initParams: any;
|
||||
initParams: any;
|
||||
debug: boolean;
|
||||
}
|
||||
|
||||
interface UriOptions {
|
||||
uri: string;
|
||||
@@ -65,6 +62,11 @@ declare module 'request' {
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface OptionalUriUrl {
|
||||
uri?: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
interface OptionalOptions {
|
||||
baseUrl?: string;
|
||||
callback?: (error: any, response: http.IncomingMessage, body: any) => void;
|
||||
@@ -74,10 +76,10 @@ declare module 'request' {
|
||||
auth?: AuthOptions;
|
||||
oauth?: OAuthOptions;
|
||||
aws?: AWSOptions;
|
||||
hawk ?: HawkOptions;
|
||||
hawk?: HawkOptions;
|
||||
qs?: any;
|
||||
json?: any;
|
||||
multipart?: RequestPart[];
|
||||
multipart?: RequestPart[] | Multipart;
|
||||
agentOptions?: any;
|
||||
agentClass?: any;
|
||||
forever?: any;
|
||||
@@ -86,7 +88,7 @@ declare module 'request' {
|
||||
method?: string;
|
||||
headers?: Headers;
|
||||
body?: any;
|
||||
followRedirect?: boolean|((response: http.IncomingMessage) => boolean);
|
||||
followRedirect?: boolean | ((response: http.IncomingMessage) => boolean);
|
||||
followAllRedirects?: boolean;
|
||||
maxRedirects?: number;
|
||||
encoding?: string;
|
||||
@@ -95,14 +97,45 @@ declare module 'request' {
|
||||
proxy?: any;
|
||||
strictSSL?: boolean;
|
||||
gzip?: boolean;
|
||||
preambleCRLF?: boolean;
|
||||
postambleCRLF?: boolean;
|
||||
key?: Buffer;
|
||||
cert?: Buffer;
|
||||
passphrase?: string;
|
||||
ca?: Buffer;
|
||||
har?: HttpArchiveRequest;
|
||||
}
|
||||
|
||||
export interface DefaultsOptions extends OptionalOptions {
|
||||
url?: string,
|
||||
uri?: string
|
||||
export type RequiredOptions = UriOptions | UrlOptions;
|
||||
export type Options = RequiredOptions & OptionalOptions;
|
||||
export type DefaultsOptions = OptionalUriUrl & OptionalOptions;
|
||||
|
||||
export interface RequestCallback {
|
||||
(error: any, response: http.IncomingMessage, body: any): void;
|
||||
}
|
||||
|
||||
export type Options = (UriOptions|UrlOptions)&OptionalOptions;
|
||||
export interface HttpArchiveRequest {
|
||||
url?: string;
|
||||
method?: string;
|
||||
headers?: NameValuePair[];
|
||||
postData?: {
|
||||
mimeType?: string;
|
||||
params?: NameValuePair[];
|
||||
}
|
||||
}
|
||||
|
||||
export interface NameValuePair {
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface Multipart {
|
||||
chunked?: boolean;
|
||||
data?: {
|
||||
'content-type'?: string,
|
||||
body: string
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface RequestPart {
|
||||
headers?: Headers;
|
||||
@@ -143,7 +176,7 @@ declare module 'request' {
|
||||
resume(): void;
|
||||
abort(): void;
|
||||
destroy(): void;
|
||||
toJSON(): string;
|
||||
toJSON(): Object;
|
||||
}
|
||||
|
||||
export interface Headers {
|
||||
@@ -178,9 +211,9 @@ declare module 'request' {
|
||||
}
|
||||
|
||||
export interface CookieJar {
|
||||
setCookie(cookie: Cookie, uri: string|url.Url, options?: any): void
|
||||
getCookieString(uri: string|url.Url): string
|
||||
getCookies(uri: string|url.Url): Cookie[]
|
||||
setCookie(cookie: Cookie, uri: string | url.Url, options?: any): void
|
||||
getCookieString(uri: string | url.Url): string
|
||||
getCookies(uri: string | url.Url): Cookie[]
|
||||
}
|
||||
|
||||
export interface CookieValue {
|
||||
@@ -197,4 +230,6 @@ declare module 'request' {
|
||||
toString(): string;
|
||||
}
|
||||
}
|
||||
var request: request.RequestAPI<request.Request, request.OptionalOptions>;
|
||||
export = request;
|
||||
}
|
||||
|
||||
22214
sharepoint/SharePoint.d.ts
vendored
22214
sharepoint/SharePoint.d.ts
vendored
File diff suppressed because it is too large
Load Diff
9
sprintf-js/sprintf-js.d.ts
vendored
9
sprintf-js/sprintf-js.d.ts
vendored
@@ -10,7 +10,7 @@ Its prototype is simple:
|
||||
|
||||
string sprintf(string format , [mixed arg1 [, mixed arg2 [ ,...]]])
|
||||
*/
|
||||
declare module "sprintf-js" {
|
||||
declare module sprintf_js {
|
||||
/** sprintf.js is a complete open source JavaScript sprintf implementation for the browser and node.js.
|
||||
Its prototype is simple:
|
||||
string sprintf(string format , [mixed arg1 [, mixed arg2 [ ,...]]])
|
||||
@@ -69,3 +69,10 @@ X - yields an integer as a hexadecimal number (upper-case)
|
||||
*/
|
||||
export function vsprintf(fmt: string, args: any[]): string;
|
||||
}
|
||||
|
||||
declare module "sprintf-js" {
|
||||
export =sprintf_js;
|
||||
}
|
||||
|
||||
declare var sprintf: typeof sprintf_js.sprintf;
|
||||
declare var vsprintf: typeof sprintf_js.vsprintf;
|
||||
|
||||
@@ -12,9 +12,9 @@ columnDef.aggregationHideLabel = false;
|
||||
columnDef.aggregationType = 1;
|
||||
columnDef.aggregationType = function () { return 1; };
|
||||
columnDef.cellClass = 'test';
|
||||
columnDef.cellClass = (gridRow, gridCol, index) => {
|
||||
//types of gridRow, gridCol, and index are flowed in correctly
|
||||
return `${gridRow.entity.name}-${gridCol.field}-${index + 1}`;
|
||||
columnDef.cellClass = (grid, gridRow, gridCol, rowIndex, colIndex) => {
|
||||
//types of grid, gridRow, gridCol, rowIndex and colIndex are flowed in correctly
|
||||
return `${grid.footerHeight}-${gridRow.entity.name}-${gridCol.field}-${rowIndex + 1}-${colIndex + 1}`;
|
||||
};
|
||||
columnDef.cellFilter = 'date';
|
||||
columnDef.cellTemplate = '<div blah="something">hello</div>';
|
||||
@@ -44,17 +44,17 @@ columnDef.filter = {
|
||||
columnDef.filterCellFiltered = false;
|
||||
columnDef.filterHeaderTemplate = '<div blah="test"></div>';
|
||||
columnDef.filters = [columnDef.filter];
|
||||
columnDef.footerCellClass = (gridRow, rowRenderIndex, gridCol, colRenderIndex) => {
|
||||
//types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly
|
||||
return `${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`;
|
||||
columnDef.footerCellClass = (grid, gridRow, gridCol, rowRenderIndex, colRenderIndex) => {
|
||||
//types for grid, gridRow, gridCol, rowRenderIndex, and colRenderIndex flow in properly
|
||||
return `${grid.footerHeight}-${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`;
|
||||
};
|
||||
columnDef.footerCellClass = 'theClass';
|
||||
columnDef.footerCellFilter = 'currency:$';
|
||||
columnDef.footerCellTemplate = '<div class="yoshi"></div>';
|
||||
columnDef.headerCellClass =
|
||||
(gridRow, rowRenderIndex, gridCol, colRenderIndex) => {
|
||||
//types for gridRow, rowRenderIndex, gridCol, and colRenderIndex flow in properly
|
||||
return `${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`;
|
||||
(grid, gridRow, gridCol, rowRenderIndex, colRenderIndex) => {
|
||||
//types for grid, gridRow, gridCol, rowRenderIndex, and colRenderIndex flow in properly
|
||||
return `${grid.footerHeight}-${gridRow.entity.age}-${rowRenderIndex + 1}-${gridCol.field}-${colRenderIndex - 1}`;
|
||||
};
|
||||
columnDef.headerCellClass = 'classy';
|
||||
columnDef.headerCellFilter = 'currency:$';
|
||||
|
||||
4
ui-grid/ui-grid.d.ts
vendored
4
ui-grid/ui-grid.d.ts
vendored
@@ -3780,7 +3780,7 @@ declare module uiGrid {
|
||||
}
|
||||
|
||||
export interface ICellClassGetter<TEntity> {
|
||||
(gridRow?: IGridRowOf<TEntity>, gridCol?: IGridColumnOf<TEntity>, colRenderIndex?: number): string;
|
||||
(grid?: IGridInstanceOf<TEntity>, gridRow?: IGridRowOf<TEntity>, gridCol?: IGridColumnOf<TEntity>, rowRenderIndex?: number, colRenderIndex?: number): string;
|
||||
}
|
||||
|
||||
export interface ICellTooltipGetter<TEntity> {
|
||||
@@ -3790,7 +3790,7 @@ declare module uiGrid {
|
||||
(gridCol: IGridColumnOf<TEntity>): string;
|
||||
}
|
||||
export interface IHeaderFooterCellClassGetter<TEntity> {
|
||||
(gridRow: IGridRowOf<TEntity>, rowRenderIndex: number, gridCol: IGridColumnOf<TEntity>, colRenderIndex: number)
|
||||
(grid: IGridInstanceOf<TEntity>, gridRow: IGridRowOf<TEntity>, gridCol: IGridColumnOf<TEntity>, rowRenderIndex: number, colRenderIndex: number)
|
||||
: string;
|
||||
}
|
||||
export interface IMenuItem {
|
||||
|
||||
4
urijs/URIjs.d.ts
vendored
4
urijs/URIjs.d.ts
vendored
@@ -230,3 +230,7 @@ declare var URI: uri.URIStatic;
|
||||
declare module 'URI' {
|
||||
export = URI;
|
||||
}
|
||||
|
||||
declare module 'urijs' {
|
||||
export = URI;
|
||||
}
|
||||
|
||||
@@ -7,37 +7,37 @@ vox.init({
|
||||
micRequired: true
|
||||
});
|
||||
|
||||
vox.addEventListener("SDKReady", function(event: VoxImplant.Events.SDKReady) {
|
||||
vox.addEventListener(VoxImplant.Events.SDKReady, function(event: VoxImplant.Events.SDKReady) {
|
||||
console.log("VoxImplant SDK ver. " + event.version + " initialized");
|
||||
vox.connect();
|
||||
});
|
||||
|
||||
vox.addEventListener("ConnectionEstablished", function(event: VoxImplant.Events.ConnectionEstablished) {
|
||||
vox.addEventListener(VoxImplant.Events.ConnectionEstablished, function(event: VoxImplant.Events.ConnectionEstablished) {
|
||||
console.log("Connection established");
|
||||
vox.login("username", "password");
|
||||
});
|
||||
|
||||
vox.addEventListener("ConnectionClosed", function(event: VoxImplant.Events.ConnectionClosed) {
|
||||
vox.addEventListener(VoxImplant.Events.ConnectionClosed, function(event: VoxImplant.Events.ConnectionClosed) {
|
||||
console.log("Connection closed");
|
||||
});
|
||||
|
||||
vox.addEventListener("ConnectionFailed", function(event: VoxImplant.Events.ConnectionFailed) {
|
||||
vox.addEventListener(VoxImplant.Events.ConnectionFailed, function(event: VoxImplant.Events.ConnectionFailed) {
|
||||
console.log("Connection failed. Reason: " + event.message);
|
||||
});
|
||||
|
||||
vox.addEventListener("AuthEvent", function(event: VoxImplant.Events.AuthEvent) {
|
||||
vox.addEventListener(VoxImplant.Events.AuthResult, function(event: VoxImplant.Events.AuthResult) {
|
||||
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) {
|
||||
call.addEventListener(VoxImplant.CallEvents.Connected, function(callevent: VoxImplant.CallEvents.Connected) {
|
||||
console.log("Call connected");
|
||||
});
|
||||
call.addEventListener("Failed", function(callevent: VoxImplant.CallEvents.Failed) {
|
||||
call.addEventListener(VoxImplant.CallEvents.Failed, function(callevent: VoxImplant.CallEvents.Failed) {
|
||||
console.log("Call failed, reason: " + callevent.reason);
|
||||
});
|
||||
call.addEventListener("Disconnected", function(callevent: VoxImplant.CallEvents.Disconnected) {
|
||||
call.addEventListener(VoxImplant.CallEvents.Disconnected, function(callevent: VoxImplant.CallEvents.Disconnected) {
|
||||
console.log("Call disconnected");
|
||||
});
|
||||
|
||||
@@ -48,13 +48,13 @@ vox.addEventListener("AuthEvent", function(event: VoxImplant.Events.AuthEvent) {
|
||||
}
|
||||
});
|
||||
|
||||
vox.addEventListener("MicAccessResult", function(event: VoxImplant.Events.MicAccessResult) {
|
||||
vox.addEventListener(VoxImplant.Events.MicAccessResult, function(event: VoxImplant.Events.MicAccessResult) {
|
||||
console.log("Microphone access allowed: " + event.result);
|
||||
});
|
||||
|
||||
vox.addEventListener("IncomingCall", function(event: VoxImplant.Events.IncomingCall) {
|
||||
vox.addEventListener(VoxImplant.Events.IncomingCall, function(event: VoxImplant.Events.IncomingCall) {
|
||||
call = event.call;
|
||||
call.addEventListener("Connected", function(callevent: VoxImplant.CallEvents.Connected) {
|
||||
call.addEventListener(VoxImplant.CallEvents.Connected, function(callevent: VoxImplant.CallEvents.Connected) {
|
||||
console.log("Inbound Call Connected");
|
||||
setTimeout(function() {
|
||||
vox.disconnect();
|
||||
@@ -63,11 +63,11 @@ vox.addEventListener("IncomingCall", function(event: VoxImplant.Events.IncomingC
|
||||
call.answer();
|
||||
});
|
||||
|
||||
vox.addEventListener("MessageReceived", function(event: VoxImplant.IMEvents.MessageReceived) {
|
||||
vox.addEventListener(VoxImplant.IMEvents.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) {
|
||||
vox.addEventListener(VoxImplant.Events.SourcesInfoUpdated, function(event: VoxImplant.Events.SourcesInfoUpdated) {
|
||||
var audioSources: VoxImplant.AudioSourceInfo[] = vox.audioSources(),
|
||||
videoSources: VoxImplant.VideoSourceInfo[] = vox.videoSources();
|
||||
console.log("Received recording sources data:");
|
||||
@@ -78,7 +78,7 @@ vox.addEventListener("SourcesInfoUpdated", function(event: VoxImplant.Events.Sou
|
||||
vox.useVideoSource(videoSources[0].id, function() { console.log('OK'); }, function() { console.log('Failed'); });
|
||||
});
|
||||
|
||||
vox.addEventListener("RosterReceived", function(event: VoxImplant.IMEvents.RosterReceived) {
|
||||
vox.addEventListener(VoxImplant.IMEvents.RosterReceived, function(event: VoxImplant.IMEvents.RosterReceived) {
|
||||
var roster: VoxImplant.RosterItem[] = event.roster;
|
||||
console.log("Roster received: " + roster);
|
||||
});
|
||||
|
||||
60
voximplant-websdk/voximplant-websdk.d.ts
vendored
60
voximplant-websdk/voximplant-websdk.d.ts
vendored
@@ -5,12 +5,58 @@
|
||||
|
||||
declare namespace VoxImplant {
|
||||
|
||||
/**
|
||||
* VoxImplant.Client general events
|
||||
*/
|
||||
enum Events {
|
||||
AuthResult,
|
||||
ConnectionClosed,
|
||||
ConnectionEstablished,
|
||||
ConnectionFailed,
|
||||
IMError,
|
||||
IncomingCall,
|
||||
MicAccessResult,
|
||||
NetStatsReceived,
|
||||
PlaybackFinished,
|
||||
SDKReady,
|
||||
SourcesInfoUpdated
|
||||
}
|
||||
|
||||
/**
|
||||
* VoxImplant.Client Instant Messaging and Presence events
|
||||
*/
|
||||
enum IMEvents {
|
||||
ChatStateUpdate,
|
||||
MessageReceived,
|
||||
MessageStatus,
|
||||
PresenceUpdate,
|
||||
RosterItemChange,
|
||||
RosterPresenceUpdate,
|
||||
RosterReceived,
|
||||
SubscriptionRequest
|
||||
}
|
||||
|
||||
/**
|
||||
* VoxImplant.Call events
|
||||
*/
|
||||
enum CallEvents {
|
||||
Connected,
|
||||
Disconnected,
|
||||
Failed,
|
||||
InfoReceived,
|
||||
MessageReceived,
|
||||
ProgressToneStart,
|
||||
ProgressToneStop,
|
||||
TransferComplete,
|
||||
TransferFailed
|
||||
}
|
||||
|
||||
module Events {
|
||||
|
||||
/**
|
||||
* Event dispatched after login , loginWithOneTimeKey, requestOneTimeLoginKey or loginWithCode function call
|
||||
*/
|
||||
interface AuthEvent {
|
||||
interface AuthResult {
|
||||
/**
|
||||
* Auth error code, possible values are: 301 - code for 'code' auth type was sent, 302 - key for 'onetimekey' auth type received, 401 - invalid password, 404 - invalid username, 403 - user account is frozen, 500 - internal error
|
||||
*/
|
||||
@@ -20,7 +66,7 @@ declare namespace VoxImplant {
|
||||
*/
|
||||
displayName?: string;
|
||||
/**
|
||||
* This parameter is used to calculate hash parameter for loginWithOneTimeKey method. AuthEvent with the key dispatched after requestOneTimeLoginKey method was called
|
||||
* This parameter is used to calculate hash parameter for loginWithOneTimeKey method. AuthResult with the key dispatched after requestOneTimeLoginKey method was called
|
||||
*/
|
||||
key?: string;
|
||||
/**
|
||||
@@ -420,7 +466,7 @@ declare namespace VoxImplant {
|
||||
|
||||
}
|
||||
|
||||
type VoxImplantEvent = Events.AuthEvent | Events.ConnectionClosed | Events.ConnectionEstablished |
|
||||
type VoxImplantEvent = Events.AuthResult | Events.ConnectionClosed | Events.ConnectionEstablished |
|
||||
Events.ConnectionFailed | Events.IMError | Events.IncomingCall | Events.MicAccessResult |
|
||||
Events.NetStatsReceived | Events.PlaybackFinished | Events.SDKReady | Events.SourcesInfoUpdated;
|
||||
|
||||
@@ -666,7 +712,7 @@ declare namespace VoxImplant {
|
||||
* @param eventName Event name
|
||||
* @param eventHandler Handler function. A single parameter is passed - object with the event information
|
||||
*/
|
||||
addEventListener(eventName: string, eventHandler: (eventObject: VoxImplantEvent | VoxImplantIMEvent) => any): void;
|
||||
addEventListener(eventName: VoxImplant.Events | VoxImplant.IMEvents, eventHandler: (eventObject: VoxImplantEvent | VoxImplantIMEvent) => any): void;
|
||||
/**
|
||||
* Add roster item (IM)
|
||||
*
|
||||
@@ -777,7 +823,7 @@ declare namespace VoxImplant {
|
||||
* @param eventName Event name
|
||||
* @param eventHandler Handler function
|
||||
*/
|
||||
removeEventListener(eventName: string, eventHandler: () => any): void;
|
||||
removeEventListener(eventName: VoxImplant.Events | VoxImplant.IMEvents, eventHandler: () => any): void;
|
||||
/**
|
||||
* Remove roster item (IM)
|
||||
*
|
||||
@@ -942,7 +988,7 @@ declare namespace VoxImplant {
|
||||
* @param eventName Event name
|
||||
* @param eventHandler Handler function. A single parameter is passed - object with the event information
|
||||
*/
|
||||
addEventListener(eventName: string, eventHandler: (eventObject: VoxImplantCallEvent) => any): void;
|
||||
addEventListener(eventName: VoxImplant.CallEvents, eventHandler: (eventObject: VoxImplantCallEvent) => any): void;
|
||||
/**
|
||||
* Answer on incoming call
|
||||
*
|
||||
@@ -1002,7 +1048,7 @@ declare namespace VoxImplant {
|
||||
* @param eventName Event name
|
||||
* @param eventHandler Handler function
|
||||
*/
|
||||
removeEventListener(eventName: string, eventHandler: () => any): void;
|
||||
removeEventListener(eventName: VoxImplant.CallEvents, eventHandler: () => any): void;
|
||||
/**
|
||||
* Send Info (SIP INFO) message inside the call
|
||||
*
|
||||
|
||||
@@ -13,3 +13,68 @@ let contextModule = context<SomeModule>('./someModule');
|
||||
require(['./someModule', './otherModule'], (someModule: SomeModule, otherModule: any) => {
|
||||
|
||||
});
|
||||
|
||||
// check if HMR is enabled
|
||||
if(module.hot) {
|
||||
// accept update of dependency
|
||||
module.hot.accept("./handler.js", function() {
|
||||
//...
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = null;
|
||||
|
||||
// check if HMR is enabled
|
||||
if(module.hot) {
|
||||
|
||||
// accept itself
|
||||
module.hot.accept();
|
||||
|
||||
// dispose handler
|
||||
module.hot.dispose(function() {
|
||||
// revoke the side effect
|
||||
//...
|
||||
});
|
||||
}
|
||||
|
||||
class ModuleData {
|
||||
updated: boolean;
|
||||
}
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.accept((err: Error) => {
|
||||
//...
|
||||
});
|
||||
|
||||
module.hot.decline("./someModule");
|
||||
|
||||
module.hot.dispose((data: ModuleData) => {
|
||||
data.updated = true;
|
||||
// ...
|
||||
});
|
||||
|
||||
let disposeHandler: ((data: ModuleData) => void) = data => {
|
||||
// ...
|
||||
};
|
||||
module.hot.addDisposeHandler(disposeHandler);
|
||||
module.hot.removeDisposeHandler(disposeHandler);
|
||||
|
||||
module.hot.check(true, (err: Error, outdatedModules: (string|number)[]) => {
|
||||
// ...
|
||||
});
|
||||
|
||||
module.hot.apply({ ignoreUnaccepted: true }, (err: Error, outdatedModules: (string|number)[]) => {
|
||||
// ...
|
||||
});
|
||||
|
||||
var status: string = module.hot.status();
|
||||
let statusHandler: ((status: string) => void) = status => {
|
||||
// ...
|
||||
};
|
||||
module.hot.status(statusHandler);
|
||||
module.hot.addStatusHandler(statusHandler);
|
||||
module.hot.removeStatusHandler(statusHandler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
129
webpack/webpack-env.d.ts
vendored
129
webpack/webpack-env.d.ts
vendored
@@ -51,6 +51,133 @@ declare namespace __WebpackModuleApi {
|
||||
[id: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
interface Module {
|
||||
exports: any;
|
||||
require(id: string): any;
|
||||
id: string;
|
||||
filename: string;
|
||||
loaded: boolean;
|
||||
parent: any;
|
||||
children: any[];
|
||||
hot: Hot;
|
||||
}
|
||||
type ModuleId = string|number;
|
||||
|
||||
interface Hot {
|
||||
/**
|
||||
* Accept code updates for the specified dependencies. The callback is called when dependencies were replaced.
|
||||
* @param dependencies
|
||||
* @param callback
|
||||
*/
|
||||
accept(dependencies: string[], callback: (updatedDependencies: ModuleId[]) => void): void;
|
||||
/**
|
||||
* Accept code updates for the specified dependencies. The callback is called when dependencies were replaced.
|
||||
* @param dependency
|
||||
* @param callback
|
||||
*/
|
||||
accept(dependency: string, callback: () => void): void;
|
||||
/**
|
||||
* Accept code updates for this module without notification of parents.
|
||||
* This should only be used if the module doesn’t export anything.
|
||||
* The errHandler can be used to handle errors that occur while loading the updated module.
|
||||
* @param errHandler
|
||||
*/
|
||||
accept(errHandler?: (err: Error) => void): void;
|
||||
/**
|
||||
* Do not accept updates for the specified dependencies. If any dependencies is updated, the code update fails with code "decline".
|
||||
*/
|
||||
decline(dependencies: string[]): void;
|
||||
/**
|
||||
* Do not accept updates for the specified dependencies. If any dependencies is updated, the code update fails with code "decline".
|
||||
*/
|
||||
decline(dependency: string): void;
|
||||
/**
|
||||
* Flag the current module as not update-able. If updated the update code would fail with code "decline".
|
||||
*/
|
||||
decline(): void;
|
||||
/**
|
||||
* Add a one time handler, which is executed when the current module code is replaced.
|
||||
* Here you should destroy/remove any persistent resource you have claimed/created.
|
||||
* If you want to transfer state to the new module, add it to data object.
|
||||
* The data will be available at module.hot.data on the new module.
|
||||
* @param callback
|
||||
*/
|
||||
dispose<T>(callback: (data: T) => void): void;
|
||||
/**
|
||||
* Add a one time handler, which is executed when the current module code is replaced.
|
||||
* Here you should destroy/remove any persistent resource you have claimed/created.
|
||||
* If you want to transfer state to the new module, add it to data object.
|
||||
* The data will be available at module.hot.data on the new module.
|
||||
* @param callback
|
||||
*/
|
||||
addDisposeHandler<T>(callback: (data: T) => void): void;
|
||||
/**
|
||||
* Remove a handler.
|
||||
* This can useful to add a temporary dispose handler. You could i. e. replace code while in the middle of a multi-step async function.
|
||||
* @param callback
|
||||
*/
|
||||
removeDisposeHandler<T>(callback: (data: T) => void): void;
|
||||
/**
|
||||
* Throws an exceptions if status() is not idle.
|
||||
* Check all currently loaded modules for updates and apply updates if found.
|
||||
* If no update was found, the callback is called with null.
|
||||
* If autoApply is truthy the callback will be called with all modules that were disposed.
|
||||
* apply() is automatically called with autoApply as options parameter.
|
||||
* If autoApply is not set the callback will be called with all modules that will be disposed on apply().
|
||||
* @param autoApply
|
||||
* @param callback
|
||||
*/
|
||||
check(autoApply: boolean, callback: (err: Error, outdatedModules: ModuleId[]) => void): void;
|
||||
/**
|
||||
* Throws an exceptions if status() is not idle.
|
||||
* Check all currently loaded modules for updates and apply updates if found.
|
||||
* If no update was found, the callback is called with null.
|
||||
* The callback will be called with all modules that will be disposed on apply().
|
||||
* @param callback
|
||||
*/
|
||||
check(callback: (err: Error, outdatedModules: ModuleId[]) => void): void;
|
||||
/**
|
||||
* If status() != "ready" it throws an error.
|
||||
* Continue the update process.
|
||||
* @param options
|
||||
* @param callback
|
||||
*/
|
||||
apply(options: AcceptOptions, callback: (err: Error, outdatedModules: ModuleId[]) => void): void;
|
||||
/**
|
||||
* If status() != "ready" it throws an error.
|
||||
* Continue the update process.
|
||||
* @param callback
|
||||
*/
|
||||
apply(callback: (err: Error, outdatedModules: ModuleId[]) => void): void;
|
||||
/**
|
||||
* Return one of idle, check, watch, watch-delay, prepare, ready, dispose, apply, abort or fail.
|
||||
*/
|
||||
status(): string;
|
||||
/** Register a callback on status change. */
|
||||
status(callback: (status: string) => void): void;
|
||||
/** Register a callback on status change. */
|
||||
addStatusHandler(callback: (status: string) => void): void;
|
||||
/**
|
||||
* Remove a registered status change handler.
|
||||
* @param callback
|
||||
*/
|
||||
removeStatusHandler(callback: (status: string) => void): void;
|
||||
|
||||
active: boolean;
|
||||
data: {};
|
||||
}
|
||||
|
||||
interface AcceptOptions {
|
||||
/**
|
||||
* If true the update process continues even if some modules are not accepted (and would bubble to the entry point).
|
||||
*/
|
||||
ignoreUnaccepted?: boolean;
|
||||
/**
|
||||
* Indicates that apply() is automatically called by check function
|
||||
*/
|
||||
autoApply?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare var require: __WebpackModuleApi.RequireFunction;
|
||||
@@ -101,3 +228,5 @@ declare var __non_webpack_require__: any;
|
||||
* Equals the config option debug
|
||||
*/
|
||||
declare var DEBUG: boolean;
|
||||
|
||||
declare var module: __WebpackModuleApi.Module;
|
||||
|
||||
@@ -380,6 +380,10 @@ example = function () {
|
||||
|
||||
promise = nodefn.apply(nodeFn2, [1, '2']);
|
||||
|
||||
example = function() {
|
||||
nodefn.apply(fs.read, arguments);
|
||||
}
|
||||
|
||||
example = function () {
|
||||
var loadPasswd = nodefn.apply(fs.readFile, ['/etc/passwd']);
|
||||
|
||||
|
||||
12
when/when.d.ts
vendored
12
when/when.d.ts
vendored
@@ -316,12 +316,12 @@ declare module "when/node" {
|
||||
): when.Promise<T>;
|
||||
|
||||
|
||||
function apply<T>(fn: _.NodeFn0<T>, args: any[]): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn1<any, T>, args: any[]): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn2<any, any, T>, args: any[]): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn3<any, any, any, T>, args: any[]): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn4<any, any, any, any, T>, args: any[]): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn5<any, any, any, any, any, T>, args: any[]): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn0<T>, args: any[] | IArguments): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn1<any, T>, args: any[] | IArguments): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn2<any, any, T>, args: any[] | IArguments): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn3<any, any, any, T>, args: any[] | IArguments): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn4<any, any, any, any, T>, args: any[] | IArguments): when.Promise<T>;
|
||||
function apply<T>(fn: _.NodeFn5<any, any, any, any, any, T>, args: any[] | IArguments): when.Promise<T>;
|
||||
|
||||
|
||||
function liftAll(srcApi: any, transform?: (destApi: any, liftedFunc: Function, name: string) => any, destApi?: any): any;
|
||||
|
||||
7
youtube/youtube.d.ts
vendored
7
youtube/youtube.d.ts
vendored
@@ -50,8 +50,8 @@ declare module YT {
|
||||
}
|
||||
|
||||
export interface PlayerOptions {
|
||||
width?: number;
|
||||
height?: number;
|
||||
width?: string | number;
|
||||
height?: string | number;
|
||||
videoId?: string;
|
||||
playerVars?: PlayerVars;
|
||||
events?: Events;
|
||||
@@ -147,6 +147,9 @@ declare module YT {
|
||||
|
||||
// Event Listener
|
||||
addEventListener(event: string, handler: EventHandler): void;
|
||||
|
||||
// DOM
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export enum PlayerState {
|
||||
|
||||
Reference in New Issue
Block a user