This commit is contained in:
Kagami Sascha Rosylight
2017-02-08 02:31:53 +09:00
64 changed files with 1182 additions and 1091 deletions
+2 -2
View File
@@ -3,8 +3,8 @@ Please fill in this template.
- [ ] Make your PR against the `master` branch.
- [ ] Use a meaningful title for the pull request. Include the name of the package modified.
- [ ] Test the change in your own code. (Compile and run.)
- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped#make-a-pull-request).
- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes).
- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#make-a-pull-request).
- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/README.md#common-mistakes).
- [ ] Run `tsc` without errors.
- [ ] Run `npm run lint package-name` if a `tslint.json` is present.
+47
View File
@@ -6,11 +6,48 @@ var anyObj: any = { abc: 123 };
var num: number = 5;
var error: Error = new Error();
var b: boolean = true;
var apiGwEvt: AWSLambda.APIGatewayEvent;
var clientCtx: AWSLambda.ClientContext;
var clientContextEnv: AWSLambda.ClientContextEnv;
var clientContextClient: AWSLambda.ClientContextClient;
var context: AWSLambda.Context;
var identity: AWSLambda.CognitoIdentity;
var proxyResult: AWSLambda.ProxyResult;
/* API Gateway Event */
str = apiGwEvt.body;
str = apiGwEvt.headers["example"];
str = apiGwEvt.httpMethod;
b = apiGwEvt.isBase64Encoded;
str = apiGwEvt.path;
str = apiGwEvt.pathParameters["example"];
str = apiGwEvt.queryStringParameters["example"];
str = apiGwEvt.stageVariables["example"];
str = apiGwEvt.requestContext.accountId;
str = apiGwEvt.requestContext.apiId;
str = apiGwEvt.requestContext.httpMethod;
str = apiGwEvt.requestContext.identity.accessKey;
str = apiGwEvt.requestContext.identity.accountId;
str = apiGwEvt.requestContext.identity.apiKey;
str = apiGwEvt.requestContext.identity.caller;
str = apiGwEvt.requestContext.identity.cognitoAuthenticationProvider;
str = apiGwEvt.requestContext.identity.cognitoAuthenticationType;
str = apiGwEvt.requestContext.identity.cognitoIdentityId;
str = apiGwEvt.requestContext.identity.cognitoIdentityPoolId;
str = apiGwEvt.requestContext.identity.sourceIp;
str = apiGwEvt.requestContext.identity.user;
str = apiGwEvt.requestContext.identity.userAgent;
str = apiGwEvt.requestContext.identity.userArn;
str = apiGwEvt.requestContext.stage;
str = apiGwEvt.requestContext.requestId;
str = apiGwEvt.requestContext.resourceId;
str = apiGwEvt.requestContext.resourcePath;
str = apiGwEvt.resource;
/* Lambda Proxy Result */
num = proxyResult.statusCode;
str = proxyResult.headers["example"];
str = proxyResult.body
/* Context */
b = context.callbackWaitsForEmptyEventLoop;
@@ -54,6 +91,15 @@ function callback(cb: AWSLambda.Callback) {
cb(error);
cb(null, anyObj);
}
/* Proxy Callback */
function proxyCallback(cb: AWSLambda.ProxyCallback) {
cb();
cb(null);
cb(error);
cb(null, proxyResult);
}
/* Compatibility functions */
context.done();
context.done(error);
@@ -66,3 +112,4 @@ context.fail(str);
/* Handler */
let handler: AWSLambda.Handler = (event: any, context: AWSLambda.Context, cb: AWSLambda.Callback) => {};
let proxyHandler: AWSLambda.ProxyHandler = (event: AWSLambda.APIGatewayEvent, context: AWSLambda.Context, cb: AWSLambda.ProxyCallback) => {};
+47 -1
View File
@@ -1,8 +1,44 @@
// Type definitions for AWS Lambda
// Project: http://docs.aws.amazon.com/lambda
// Definitions by: James Darbyshire <https://github.com/darbio/aws-lambda-typescript>, Michael Skarum <https://github.com/skarum>, Stef Heyenrath <https://github.com/StefH/DefinitelyTyped>, Toby Hede <https://github.com/tobyhede>
// Definitions by: James Darbyshire <https://github.com/darbio/aws-lambda-typescript>, Michael Skarum <https://github.com/skarum>, Stef Heyenrath <https://github.com/StefH/DefinitelyTyped>, Toby Hede <https://github.com/tobyhede>, Rich Buggy <https://github.com/buggy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// API Gateway "event"
interface APIGatewayEvent {
body: string | null;
headers: { [name: string]: string };
httpMethod: string;
isBase64Encoded: boolean;
path: string;
pathParameters: { [name: string]: string } | null;
queryStringParameters: { [name: string]: string } | null;
stageVariables: { [name: string]: string } | null;
requestContext: {
accountId: string;
apiId: string;
httpMethod: string;
identity: {
accessKey: string | null;
accountId: string | null;
apiKey: string | null;
caller: string | null;
cognitoAuthenticationProvider: string | null;
cognitoAuthenticationType: string | null;
cognitoIdentityId: string | null;
cognitoIdentityPoolId: string | null;
sourceIp: string;
user: string | null;
userAgent: string | null;
userArn: string | null;
},
stage: string;
requestId: string;
resourceId: string;
resourcePath: string;
};
resource: string;
}
// Context
// http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html
interface Context {
@@ -58,6 +94,14 @@ interface ClientContextEnv {
locale: string;
}
interface ProxyResult {
statusCode: number;
headers?: {
[header: string]: string;
},
body: string;
}
/**
* AWS Lambda handler function.
* http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html
@@ -67,6 +111,7 @@ interface ClientContextEnv {
* @param callback – optional callback to return information to the caller, otherwise return value is null.
*/
export type Handler = (event: any, context: Context, callback?: Callback) => void;
export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?: ProxyCallback) => void;
/**
* Optional callback parameter.
@@ -76,5 +121,6 @@ export type Handler = (event: any, context: Context, callback?: Callback) => vo
* @param result – an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible.
*/
export type Callback = (error?: Error, result?: any) => void;
export type ProxyCallback = (error?: Error, result?: ProxyResult) => void;
export as namespace AWSLambda;
-125
View File
@@ -1,125 +0,0 @@
enum HttpMethod { GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH }
enum ResponseType { arraybuffer, blob, document, json, text }
interface Repository {
id: number;
name: string;
}
interface Issue {
id: number;
title: string;
}
function makePromise(val: any) {
return <Axios.IPromise<any>>{
then: () => val,
catch: () => val
};
}
axios.interceptors.request.use<any>(config => {
console.log("Method:" + config.method + " Url:" +config.url);
return config;
});
const requestId: number = axios.interceptors.request.use<any>(
(config) => {
console.log("Method:" + config.method + " Url:" +config.url);
return config;
},
(error: any) => error);
axios.interceptors.request.eject(requestId);
axios.interceptors.request.eject(7);
const requestId2: number = axios.interceptors.request.use<any>(
(config) => {
console.log("Method:" + config.method + " Url:" +config.url);
return makePromise(config);
},
(error: any) => error);
axios.interceptors.response.use<any>(config => {
console.log("Status:" + config.status);
return config;
});
axios.interceptors.response.use<any>(config => {
console.log("Status:" + config.status);
return makePromise(config);
});
const responseId: number = axios.interceptors.response.use<any>(
config => {
console.log("Status:" + config.status);
return config;
},
(error: any) => error);
axios.interceptors.response.eject(responseId);
axios.get<Repository>("https://api.github.com/repos/mzabriskie/axios")
.then(r => console.log(r.config.method));
var getRepoDetails = axios<Repository>({
url: "https://api.github.com/repos/mzabriskie/axios",
method: HttpMethod[HttpMethod.GET],
headers: {},
}).then(r => {
console.log("ID:" + r.data.id + " Name: " + r.data.name);
return r;
});
axios.post("http://example.com/", {}, {
transformRequest: (data: any) => data
});
axios.post("http://example.com/", {
headers: {'X-Custom-Header': 'foobar'}
}, {
transformRequest: [
(data: any) => data
]
});
var config: Axios.AxiosXHRConfigBase<any> = {headers: {}};
config.headers['X-Custom-Header'] = 'baz';
axios.post("http://example.com/", config);
var getRepoIssue = axios.get<Issue>("https://api.github.com/repos/mzabriskie/axios/issues/1");
var axiosInstance = axios.create({
baseURL: "https://api.github.com/repos/mzabriskie/axios/",
timeout: 1000
});
axiosInstance.request({url: "issues/1"}).then(res => {
if (res.headers['content-type'].startsWith('application/json')) {
throw new Error('Unexpected content-type');
}
});
axios.all<Repository, Repository>([getRepoDetails, getRepoDetails]).then(([repo1, repo2]) => {
var sumIds = repo1.data.id + repo2.data.id;
console.log("Sum ID:" + sumIds);
return sumIds;
});
var repoSum = (repo1: Axios.AxiosXHR<Repository>, repo2: Axios.AxiosXHR<Repository>) => {
var sumIds = repo1.data.id + repo2.data.id;
console.log("Sum ID:" + sumIds);
return sumIds;
};
axios.all<Repository, Repository>([getRepoDetails, getRepoDetails]).then(axios.spread(repoSum));
axios.defaults.baseURL = 'https://api.example.com';
axios.defaults.headers.common['Authorization'] = "AUTH_TOKEN";
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axiosInstance.defaults.headers.common['Authorization'] = "AUTH_TOKEN";
-328
View File
@@ -1,328 +0,0 @@
// Type definitions for axios 0.9.1
// Project: https://github.com/mzabriskie/axios
// Definitions by: Marcel Buesing <https://github.com/marcelbuesing>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Axios {
interface IThenable<R> {
then<U>(onFulfilled?: (value: R) => U | IThenable<U>, onRejected?: (error: any) => U | IThenable<U>): IThenable<U>;
then<U>(onFulfilled?: (value: R) => U | IThenable<U>, onRejected?: (error: any) => void): IThenable<U>;
}
interface IPromise<R> extends IThenable<R> {
then<U>(onFulfilled?: (value: R) => U | IThenable<U>, onRejected?: (error: any) => U | IThenable<U>): IPromise<U>;
then<U>(onFulfilled?: (value: R) => U | IThenable<U>, onRejected?: (error: any) => void): IPromise<U>;
catch<U>(onRejected?: (error: any) => U | IThenable<U>): IPromise<U>;
}
/**
* HTTP Basic auth details
*/
interface AxiosHttpBasicAuth {
username: string;
password: string;
}
/**
* Common axios XHR config interface
* <T> - request body data type
*/
interface AxiosXHRConfigBase<T> {
/**
* will be prepended to `url` unless `url` is absolute.
* It can be convenient to set `baseURL` for an instance
* of axios to pass relative URLs to methods of that instance.
*/
baseURL?: string;
/**
* custom headers to be sent
*/
headers?: {[key: string]: any};
/**
* URL parameters to be sent with the request
*/
params?: Object;
/**
* optional function in charge of serializing `params`
* (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)
*/
paramsSerializer?: (params: Object) => string;
/**
* specifies the number of milliseconds before the request times out.
* If the request takes longer than `timeout`, the request will be aborted.
*/
timeout?: number;
/**
* indicates whether or not cross-site Access-Control requests
* should be made using credentials
*/
withCredentials?: boolean;
/**
* indicates that HTTP Basic auth should be used, and supplies
* credentials. This will set an `Authorization` header,
* overwriting any existing `Authorization` custom headers you have
* set using `headers`.
*/
auth?: AxiosHttpBasicAuth;
/**
* indicates the type of data that the server will respond with
* options are 'arraybuffer', 'blob', 'document', 'json', 'text'
*/
responseType?: string;
/**
* name of the cookie to use as a value for xsrf token
*/
xsrfCookieName?: string;
/**
* name of the http header that carries the xsrf token value
*/
xsrfHeaderName?: string;
/**
* Change the request data before it is sent to the server.
* This is only applicable for request methods 'PUT', 'POST', and 'PATCH'
* The last function in the array must return a string or an ArrayBuffer
*/
transformRequest?: (<U>(data: T) => U) | [<U>(data: T) => U];
/**
* change the response data to be made before it is passed to then/catch
*/
transformResponse?: <U>(data: T) => U;
/**
* defines whether to resolve or reject the promise for a given HTTP response status code.
* If returns `true` (or is set to `null` or `undefined`), the promise will be resolved;
* otherwise, the promise will be rejected
*/
validateStatus?: (status: number) => boolean | undefined;
}
/**
* <T> - request body data type
*/
interface AxiosXHRConfig<T> extends AxiosXHRConfigBase<T> {
/**
* server URL that will be used for the request, options are:
* GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH
*/
url: string;
/**
* request method to be used when making the request
*/
method?: string;
/**
* data to be sent as the request body
* Only applicable for request methods 'PUT', 'POST', and 'PATCH'
* When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash
*/
data?: T;
}
interface AxiosXHRConfigDefaults<T> extends AxiosXHRConfigBase<T> {
/**
* custom headers to be sent
*/
headers: {
common: {[index: string]: string};
patch: {[index: string]: string};
post: {[index: string]: string};
put: {[index: string]: string};
};
}
/**
* <T> - expected response type,
* <U> - request body data type
*/
interface AxiosXHR<T> {
/**
* Response that was provided by the server
*/
data: T;
/**
* HTTP status code from the server response
*/
status: number;
/**
* HTTP status message from the server response
*/
statusText: string;
/**
* headers that the server responded with
*/
headers: {[index: string]: any};
/**
* config that was provided to `axios` for the request
*/
config: AxiosXHRConfig<T>;
}
interface Interceptor {
/**
* intercept request before it is sent
*/
request: RequestInterceptor;
/**
* intercept response of request when it is received.
*/
response: ResponseInterceptor
}
type InterceptorId = number;
interface RequestInterceptor {
/**
* <U> - request body data type
*/
use<U>(fulfilledFn: (config: AxiosXHRConfig<U>) => AxiosXHRConfig<U>): InterceptorId;
use<U>(fulfilledFn: (config: AxiosXHRConfig<U>) => AxiosXHRConfig<U>,
rejectedFn: (error: any) => any)
: InterceptorId;
use<U>(fulfilledFn: (config: AxiosXHRConfig<U>) => IPromise<AxiosXHRConfig<U>>): InterceptorId;
use<U>(fulfilledFn: (config: AxiosXHRConfig<U>) => IPromise<AxiosXHRConfig<U>>,
rejectedFn: (error: any) => any)
: InterceptorId;
eject(interceptorId: InterceptorId): void;
}
interface ResponseInterceptor {
/**
* <T> - expected response type
*/
use<T>(fulfilledFn: (config: Axios.AxiosXHR<T>) => Axios.AxiosXHR<T>): InterceptorId;
use<T>(fulfilledFn: (config: Axios.AxiosXHR<T>) => IPromise<Axios.AxiosXHR<T>>): InterceptorId;
use<T>(fulfilledFn: (config: Axios.AxiosXHR<T>) => Axios.AxiosXHR<T>,
rejectedFn: (error: any) => any)
: InterceptorId;
use<T>(fulfilledFn: (config: Axios.AxiosXHR<T>) => IPromise<Axios.AxiosXHR<T>>,
rejectedFn: (error: any) => any)
: InterceptorId;
eject(interceptorId: InterceptorId): void;
}
/**
* <T> - expected response type,
* <U> - request body data type
*/
interface AxiosInstance {
/**
* Send request as configured
*/
<T>(config: AxiosXHRConfig<T>): IPromise<AxiosXHR<T>>;
/**
* Send request as configured
*/
new <T>(config: AxiosXHRConfig<T>): IPromise<AxiosXHR<T>>;
/**
* Send request as configured
*/
request<T>(config: AxiosXHRConfig<T>): IPromise<AxiosXHR<T>>;
/**
* intercept requests or responses before they are handled by then or catch
*/
interceptors: Interceptor;
/**
* Config defaults
*/
defaults: AxiosXHRConfigDefaults<any>;
/**
* equivalent to `Promise.all`
*/
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>, T6 | IPromise<AxiosXHR<T6>>, T7 | IPromise<AxiosXHR<T7>>, T8 | IPromise<AxiosXHR<T8>>, T9 | IPromise<AxiosXHR<T9>>, T10 | IPromise<AxiosXHR<T10>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>, AxiosXHR<T6>, AxiosXHR<T7>, AxiosXHR<T8>, AxiosXHR<T9>, AxiosXHR<T10>]>;
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>, T6 | IPromise<AxiosXHR<T6>>, T7 | IPromise<AxiosXHR<T7>>, T8 | IPromise<AxiosXHR<T8>>, T9 | IPromise<AxiosXHR<T9>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>, AxiosXHR<T6>, AxiosXHR<T7>, AxiosXHR<T8>, AxiosXHR<T9>]>;
all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>, T6 | IPromise<AxiosXHR<T6>>, T7 | IPromise<AxiosXHR<T7>>, T8 | IPromise<AxiosXHR<T8>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>, AxiosXHR<T6>, AxiosXHR<T7>, AxiosXHR<T8>]>;
all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>, T6 | IPromise<AxiosXHR<T6>>, T7 | IPromise<AxiosXHR<T7>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>, AxiosXHR<T6>, AxiosXHR<T7>]>;
all<T1, T2, T3, T4, T5, T6>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>, T6 | IPromise<AxiosXHR<T6>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>, AxiosXHR<T6>]>;
all<T1, T2, T3, T4, T5>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>, T5 | IPromise<AxiosXHR<T5>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>, AxiosXHR<T5>]>;
all<T1, T2, T3, T4>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>, T4 | IPromise<AxiosXHR<T4>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>, AxiosXHR<T4>]>;
all<T1, T2, T3>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>, T3 | IPromise<AxiosXHR<T3>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>, AxiosXHR<T3>]>;
all<T1, T2>(values: [T1 | IPromise<AxiosXHR<T1>>, T2 | IPromise<AxiosXHR<T2>>]): IPromise<[AxiosXHR<T1>, AxiosXHR<T2>]>;
/**
* spread array parameter to `fn`.
* note: alternative to `spread`, destructuring assignment.
*/
spread<T1, T2, U>(fn: (t1: T1, t2: T2) => U): (arr: ([T1, T2])) => U;
/**
* convenience alias, method = GET
*/
get<T>(url: string, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
/**
* convenience alias, method = DELETE
*/
delete<T>(url: string, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
/**
* convenience alias, method = HEAD
*/
head<T>(url: string, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
/**
* convenience alias, method = POST
*/
post<T>(url: string, data?: any, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
/**
* convenience alias, method = PUT
*/
put<T>(url: string, data?: any, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
/**
* convenience alias, method = PATCH
*/
patch<T>(url: string, data?: any, config?: AxiosXHRConfigBase<T>): IPromise<AxiosXHR<T>>;
}
/**
* <T> - expected response type,
*/
interface AxiosStatic extends AxiosInstance {
/**
* create a new instance of axios with a custom config
*/
create<T>(config: AxiosXHRConfigBase<T>): AxiosInstance;
}
}
declare var axios: Axios.AxiosStatic;
declare module "axios" {
export = axios;
}
+1 -1
View File
@@ -5,7 +5,7 @@
declare module 'bintrees' {
type Callback = <T>(err: Error, item: T) => void;
type Callback = <T>(item: T) => void;
type Comparator = <T>(a: T, b: T) => number;
class Iterator<T> {
+1
View File
@@ -55,6 +55,7 @@ declare namespace ChaiHttp {
send(data: Object): Request;
auth(user: string, name: string): Request;
field(name: string, val: string): Request;
buffer(): Request;
end(callback?: (err: any, res: Response) => void): FinishedRequest;
}
+1
View File
@@ -7267,6 +7267,7 @@ declare namespace chrome.webRequest {
interface WebResponseHeadersDetails extends WebResponseDetails {
/** Optional. The HTTP response headers that have been received with this response. */
responseHeaders?: HttpHeader[];
method: string; /** standard HTTP method i.e. GET, POST, PUT, etc. */
}
interface WebResponseCacheDetails extends WebResponseHeadersDetails {
+2 -2
View File
@@ -329,7 +329,7 @@ interface CommonWrapper<P, S> {
* @param fn A callback to be run for every node in the collection. Should expect a ShallowWrapper as the first
* argument, and will be run with a context of the original instance.
*/
forEach(fn: (wrapper: this) => any): this;
forEach(fn: (wrapper: this, index: number) => any): this;
/**
* Maps the current array of nodes to another array. Each node is passed in as a ShallowWrapper to the map
@@ -339,7 +339,7 @@ interface CommonWrapper<P, S> {
* to the returned array. Should expect a ShallowWrapper as the first argument, and will be run
* with a context of the original instance.
*/
map<V>(fn: (wrapper: this) => V): V[];
map<V>(fn: (wrapper: this, index: number) => V): V[];
/**
* Applies the provided reducing function to every node in the wrapper to reduce to a single value. Each node
+2
View File
@@ -1,3 +1,5 @@
import * as FusionCharts from "fusioncharts";
FusionCharts.addEventListener('ready',(eventObject)=>{
eventObject.stopPropagation();
});
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var charts: (H: FusionChartStatic) => FusionChartStatic;
export = charts;
export as namespace charts;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var gantt: (H: FusionChartStatic) => FusionChartStatic;
export = gantt;
export as namespace gantt;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var maps: (H: FusionChartStatic) => FusionChartStatic;
export = maps;
export as namespace maps;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var powercharts: (H: FusionChartStatic) => FusionChartStatic;
export = powercharts;
export as namespace powercharts;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var ssgrid: (H: FusionChartStatic) => FusionChartStatic;
export = ssgrid;
export as namespace ssgrid;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var treemap: (H: FusionChartStatic) => FusionChartStatic;
export = treemap;
export as namespace treemap;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var widgets: (H: FusionChartStatic) => FusionChartStatic;
export = widgets;
export as namespace widgets;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var zoomscatter: (H: FusionChartStatic) => FusionChartStatic;
export = zoomscatter;
export as namespace zoomscatter;
+7 -7
View File
@@ -1,6 +1,6 @@
// Type definitions for FusionCharts 3.11.2
// Type definitions for fusioncharts 3.11
// Project: http://www.fusioncharts.com
// Definitions by: Shivaraj KV <https://github.com/shivarajkv>
// Definitions by: Rohit Kumar <https://github.com/rohitkr>, Shivaraj KV <https://github.com/shivarajkv>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -136,9 +136,9 @@ declare namespace FusionCharts {
outputTo(callback: (message: any) => any): void;
enable(state:any,outputTo?:(message: any) =>any,outputFormat?:any):void
enable(state: any, outputTo?: (message: any) => any, outputFormat?: any): void;
enableFirebugLite():any;
enableFirebugLite(): any;
}
interface FusionCharts {
@@ -154,7 +154,7 @@ declare namespace FusionCharts {
configureLink(param: {} | any[], level?: number): void;
setChartAttribute(attributes: ChartObject | String, value?: string): void;
setChartAttribute(attributes: ChartObject | string, value?: string): void;
getChartAttribute(attribute?: string | string[]): ChartObject;
@@ -273,7 +273,7 @@ declare namespace FusionCharts {
formatNumber(num: number, type?: string, config?: {}): Element;
setCurrentRenderer(name: string): void
setCurrentRenderer(name: string): void;
getCurrentRenderer(): string;
@@ -285,7 +285,7 @@ declare namespace FusionCharts {
options: {};
debugger:Debugger;
debugger: Debugger;
}
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var usa: (H: FusionChartStatic) => FusionChartStatic;
export = usa;
export as namespace usa;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var world: (H: FusionChartStatic) => FusionChartStatic;
export = world;
export as namespace world;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var carbon: (H: FusionChartStatic) => FusionChartStatic;
export = carbon;
export as namespace carbon;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var fint: (H: FusionChartStatic) => FusionChartStatic;
export = fint;
export as namespace fint;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var ocean: (H: FusionChartStatic) => FusionChartStatic;
export = ocean;
export as namespace ocean;
+7
View File
@@ -0,0 +1,7 @@
import { FusionChartStatic } from "fusioncharts";
declare var zune: (H: FusionChartStatic) => FusionChartStatic;
export = zune;
export as namespace zune;
+14
View File
@@ -18,6 +18,20 @@
},
"files": [
"index.d.ts",
"fusioncharts.charts.d.ts",
"fusioncharts.powercharts.d.ts",
"fusioncharts.widgets.d.ts",
"fusioncharts.maps.d.ts",
"fusioncharts.zoomscatter.d.ts",
"fusioncharts.ssgrid.d.ts",
"fusioncharts.gantt.d.ts",
"fusioncharts.treemap.d.ts",
"maps/fusioncharts.usa.d.ts",
"maps/fusioncharts.world.d.ts",
"themes/fusioncharts.theme.carbon.d.ts",
"themes/fusioncharts.theme.fint.d.ts",
"themes/fusioncharts.theme.ocean.d.ts",
"themes/fusioncharts.theme.zune.d.ts",
"fusioncharts-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+2 -1
View File
@@ -33,7 +33,8 @@ class AppController {
title: {
text: 'My Awesome Chart'
},
loading: true
loading: true,
noData: 'No data here'
};
constructor($timeout: ng.ITimeoutService) {
var vm = this;
+2
View File
@@ -35,6 +35,8 @@ declare global {
};
//function (optional) - setup some logic for the chart
func?: (chart: ChartObject) => void;
//no data text (optional) to show if all series are empty
noData?: string;
}
//Instantiated Chart
+4
View File
@@ -986,3 +986,7 @@ declare namespace mapboxgl {
declare module 'mapbox-gl' {
export = mapboxgl;
}
declare module 'mapbox-gl/dist/mapbox-gl' {
export = mapboxgl;
}
+141 -59
View File
@@ -1,71 +1,153 @@
// Type definitions for msgpack-lite 0.1.20
// Type definitions for msgpack-lite 0.1
// Project: https://github.com/kawanet/msgpack-lite
// Definitions by: Endel Dreyer <https://github.com/endel/>
// Definitions by: Endel Dreyer <https://github.com/endel/>, Edmund Fokschaner <https://github.com/efokschaner>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare module "msgpack-lite" {
import { Transform } from "stream";
import * as stream from 'stream';
namespace MsgpackLite {
interface BufferOptions { codec: any; }
/**
* encode from JS Object to MessagePack
*/
export function encode(input: any, options?: EncoderOptions): Buffer;
interface Encoder {
bufferish: any;
maxBufferSize: number;
minBufferSize: number;
offset: number;
start: number;
write: (chunk: any) => void;
fetch: () => void;
flush: () => void;
push: (chunk: any) => void;
pull: () => number;
read: () => number;
reserve: (length: number) => number;
send: (buffer: Buffer) => void;
encode: (chunk: any) => void;
end: (chunk: any) => void;
}
/**
* decode from MessagePack to JS Object
*/
export function decode(input: Buffer | Uint8Array | number[], options?: DecoderOptions): any;
interface Decoder {
bufferish: any;
offset: number;
fetch: () => void;
flush: () => void;
pull: () => number;
read: () => number;
write: (chunk: any) => void;
reserve: (length: number) => number;
decode: (chunk: any) => void;
push: (chunk: any) => void;
end: (chunk: any) => void;
}
/**
* create a stream that encodes from JS Object to MessagePack
*/
export function createEncodeStream(options?: EncoderOptions & stream.TransformOptions ): EncodeStream;
interface EncodeStream extends Transform {
encoder: Encoder;
}
interface DecodeStream extends Transform {
decoder: Decoder;
}
/**
* create a stream that decodes from MessagePack (Buffer) to JS Object
*/
export function createDecodeStream(options?: DecoderOptions & stream.TransformOptions): DecodeStream;
interface Codec {
new (options?: any): Codec;
options: any;
init (): void;
addExtPacker (etype: number, Class: any, packer: (value: any) => any): void;
getExtPacker (value: any): (value: any) => any;
addExtUnpacker (etype: number, unpacker: (value: any) => any): void;
getExtUnpacker (etype: number): (value: any) => any;
}
/**
* Codecs allow for Custom Extension Types
* Register a custom extension type number to serialize/deserialize your own class instances.
* https://github.com/kawanet/msgpack-lite#custom-extension-types-codecs
* If you wish to modify the default built-in codec, you can access it at msgpack.codec.preset
*/
export function createCodec(options?: CodecOptions): Codec;
export function encode(input: any, options?: BufferOptions): any;
export function decode(input: Buffer | Uint8Array | Array<number>, options?: BufferOptions): any;
export function createEncodeStream (): EncodeStream;
export function createDecodeStream (): DecodeStream;
export function createCodec (options?: any): Codec;
export function codec (): { preset: Codec };
}
/**
* The default built-in codec
*/
export var codec: {
/**
* The default built-in codec
*/
preset: Codec;
};
export = MsgpackLite;
export interface Codec {
/**
* Register a custom extension to serialize your own class instances
*
* @param etype an integer within the range of 0 and 127 (0x0 and 0x7F)
* @param Class the constructor of the type you wish to serialize
* @param packer a function that converts an instance of T to bytes
*/
addExtPacker<T>(
etype: number,
Class: new(...args: any[]) => T,
packer: (t: T) => Buffer | Uint8Array): void;
/**
* Register a custom extension to deserialize your own class instances
*
* @param etype an integer within the range of 0 and 127 (0x0 and 0x7F)
* @param unpacker a function that converts bytes to an instance of T
*/
addExtUnpacker<T>(etype: number, unpacker: (data: Buffer | Uint8Array) => T): void;
}
export interface Encoder {
bufferish: any;
maxBufferSize: number;
minBufferSize: number;
offset: number;
start: number;
write: (chunk: any) => void;
fetch: () => void;
flush: () => void;
push: (chunk: any) => void;
pull: () => number;
read: () => number;
reserve: (length: number) => number;
send: (buffer: Buffer) => void;
encode: (chunk: any) => void;
end: (chunk: any) => void;
}
export interface Decoder {
bufferish: any;
offset: number;
fetch: () => void;
flush: () => void;
pull: () => number;
read: () => number;
write: (chunk: any) => void;
reserve: (length: number) => number;
decode: (chunk: any) => void;
push: (chunk: any) => void;
end: (chunk: any) => void;
}
export interface EncodeStream extends stream.Transform {
encoder: Encoder;
}
export interface DecodeStream extends stream.Transform {
decoder: Decoder;
}
export interface CodecOptions {
/**
* It includes the preset extensions for JavaScript native objects.
* @see https://github.com/kawanet/msgpack-lite#extension-types
* @default false
*/
preset?: boolean;
/**
* It runs a validation of the value before writing it into buffer.
* This is the default behavior for some old browsers which do not support ArrayBuffer object.
* @default varies
*/
safe?: boolean;
/**
* It uses raw formats instead of bin and str.
* Set true for compatibility with msgpack's old spec.
* @see https://github.com/kawanet/msgpack-lite#compatibility-mode
* @default false
*/
raw?: boolean;
/**
* It decodes msgpack's int64/uint64 formats with int64-buffer object.
* int64-buffer is a cutom integer type with 64 bits of precision instead
* of the built-in IEEE-754 53 bits. See https://github.com/kawanet/int64-buffer
* @default false
*/
int64?: boolean;
/**
* It ties msgpack's bin format with ArrayBuffer object, instead of Buffer object.
* @default false
*/
binarraybuffer?: boolean;
/**
* It returns Uint8Array object when encoding, instead of Buffer object.
*/
uint8array?: boolean;
}
export interface EncoderOptions {
codec?: Codec;
}
export interface DecoderOptions {
codec?: Codec;
}
+72 -3
View File
@@ -1,5 +1,74 @@
import * as msgpack from 'msgpack-lite';
import * as msgpack from "msgpack-lite";
// https://github.com/kawanet/msgpack-lite#encoding-and-decoding-messagepack
function encodingAndDecoding() {
// encode from JS Object to MessagePack (Buffer)
var buffer = msgpack.encode({"foo": "bar"});
var encoded = msgpack.encode("");
msgpack.decode(encoded);
// decode from MessagePack (Buffer) to JS Object
var data = msgpack.decode(buffer); // => {"foo": "bar"}
}
// https://github.com/kawanet/msgpack-lite#writing-to-messagepack-stream
function writingToStream() {
var fs = require("fs");
var writeStream = fs.createWriteStream("test.msp");
var encodeStream = msgpack.createEncodeStream();
encodeStream.pipe(writeStream);
// send multiple objects to stream
encodeStream.write({foo: "bar"});
encodeStream.write({baz: "qux"});
// call this once you're done writing to the stream.
encodeStream.end();
}
// https://github.com/kawanet/msgpack-lite#reading-from-messagepack-stream
function readingFromStream() {
var fs = require("fs");
var readStream = fs.createReadStream("test.msp");
var decodeStream = msgpack.createDecodeStream();
// show multiple objects decoded from stream
readStream.pipe(decodeStream).on("data", console.warn);
}
// https://github.com/kawanet/msgpack-lite#decoding-messagepack-bytes-array
function decodingBytesArray() {
// decode() accepts Buffer instance per default
msgpack.decode(new Buffer([0x81, 0xA3, 0x66, 0x6F, 0x6F, 0xA3, 0x62, 0x61, 0x72]));
// decode() also accepts Array instance
msgpack.decode([0x81, 0xA3, 0x66, 0x6F, 0x6F, 0xA3, 0x62, 0x61, 0x72]);
// decode() accepts raw Uint8Array instance as well
msgpack.decode(new Uint8Array([0x81, 0xA3, 0x66, 0x6F, 0x6F, 0xA3, 0x62, 0x61, 0x72]));
}
// https://github.com/kawanet/msgpack-lite#custom-extension-types-codecs
function customExtensionTypes() {
var codec = msgpack.createCodec();
codec.addExtPacker(0x3F, MyVector, myVectorPacker);
codec.addExtUnpacker(0x3F, myVectorUnpacker);
var data = new MyVector(1, 2);
var encoded = msgpack.encode(data, {codec: codec});
var decoded = msgpack.decode(encoded, {codec: codec});
class MyVector {
constructor(public x: number, public y: number) {}
}
function myVectorPacker(vector: MyVector) {
var array = [vector.x, vector.y];
return msgpack.encode(array); // return Buffer serialized
}
function myVectorUnpacker(buffer: Buffer | Uint8Array): MyVector {
var array = msgpack.decode(buffer);
return new MyVector(array[0], array[1]); // return Object deserialized
}
}
+1 -1
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+15 -19
View File
@@ -1,29 +1,25 @@
// Type definitions for ngstorage 0.3.10
// Type definitions for ngstorage 0.3.11
// Project: https://github.com/gsklee/ngStorage
// Definitions by: Jakub Pistek <https://github.com/kubiq>
// Definitions: https://github.com/kubiq/DefinitelyTyped
import * as angular from 'angular';
declare module 'ngstorage' {
declare module 'angular' {
export namespace storage {
interface IStorageService {
$default(items: {}): IStorageService;
$reset(items?: {}): IStorageService;
$apply(): void;
$sync(): void;
get<T>(key: string): T;
}
export interface IStorageService {
$default(items: {}): IStorageService;
$reset(items?: {}): IStorageService;
$apply(): void;
$sync(): void;
get<T>(key: string): T;
}
interface IStorageProvider extends angular.IServiceProvider {
export interface IStorageProvider extends angular.IServiceProvider {
get<T>(key: string): T;
set<T>(key: string, value: T): T;
get<T>(key: string): T;
set<T>(key: string, value: T): T;
setKeyPrefix(prefix: string): void;
setSerializer(serializer: (value: any) => string): void;
setDeserializer(deserializer: (value: string) => any): void;
}
setKeyPrefix(prefix: string): void;
setSerializer(serializer: (value: any) => string): void;
setDeserializer(deserializer: (value: string) => any): void;
}
}
+34 -34
View File
@@ -1,9 +1,9 @@
/// <reference types="angular" />
/// <reference types="angular"/>
import {IStorageService, IStorageProvider} from "ngstorage";
var app: any;
app.controller('LocalCtrl', function ($localStorage: angular.storage.IStorageService) {
app.controller('LocalCtrl', function ($localStorage: IStorageService) {
$localStorage.$default({
counter: 1
@@ -12,15 +12,15 @@ app.controller('LocalCtrl', function ($localStorage: angular.storage.IStorageSer
$localStorage.$reset({
counter: 1
});
$localStorage.$reset();
$localStorage.$apply();
$localStorage.$sync();
});
app.controller('SessionCtrl', function ($sessionStorage: angular.storage.IStorageService) {
app.controller('SessionCtrl', function ($sessionStorage: IStorageService) {
$sessionStorage.$default({
counter: 1
@@ -29,50 +29,50 @@ app.controller('SessionCtrl', function ($sessionStorage: angular.storage.IStorag
$sessionStorage.$reset({
counter: 1
});
$sessionStorage.$reset();
$sessionStorage.$apply();
$sessionStorage.$sync();
});
app.config(['$localStorageProvider', function ($localStorageProvider: angular.storage.IStorageProvider) {
app.config(['$localStorageProvider', function ($localStorageProvider: IStorageProvider) {
$localStorageProvider.setKeyPrefix('NewPrefix');
$localStorageProvider.setKeyPrefix('NewPrefix');
$localStorageProvider.get('MyKey');
$localStorageProvider.get('MyKey');
$localStorageProvider.set('MyKey', { counter: 'value' });
$localStorageProvider.set('MyKey', {counter: 'value'});
var mySerializer = function (value:any):string {
return value.toString();
};
var mySerializer = function (value: any): string {
return value.toString();
};
var myDeserializer = function (value:string):any {
return value;
};
var myDeserializer = function (value: string): any {
return value;
};
$localStorageProvider.setSerializer(mySerializer);
$localStorageProvider.setDeserializer(myDeserializer);
}
]).config(['$sessionStorageProvider', function ($sessionStorageProvider: angular.storage.IStorageProvider) {
$localStorageProvider.setSerializer(mySerializer);
$localStorageProvider.setDeserializer(myDeserializer);
}
]).config(['$sessionStorageProvider', function ($sessionStorageProvider: IStorageProvider) {
$sessionStorageProvider.setKeyPrefix('NewPrefix');
$sessionStorageProvider.setKeyPrefix('NewPrefix');
$sessionStorageProvider.get('MyKey');
$sessionStorageProvider.get('MyKey');
$sessionStorageProvider.set('MyKey', { counter: 'value' });
$sessionStorageProvider.set('MyKey', {counter: 'value'});
var mySerializer = function (value:any):string {
return value.toString();
};
var mySerializer = function (value: any): string {
return value.toString();
};
var myDeserializer = function (value:string):any {
return value;
};
var myDeserializer = function (value: string): any {
return value;
};
$sessionStorageProvider.setSerializer(mySerializer);
$sessionStorageProvider.setDeserializer(myDeserializer);
}
$sessionStorageProvider.setSerializer(mySerializer);
$sessionStorageProvider.setDeserializer(myDeserializer);
}
]);
+1 -1
View File
@@ -20,4 +20,4 @@
"index.d.ts",
"ngstorage-tests.ts"
]
}
}
+6
View File
@@ -293,6 +293,12 @@
"typingsPackageName": "redux-saga",
"sourceRepoURL": "https://github.com/redux-saga/redux-saga",
"asOfVersion": "0.10.5"
},
{
"libraryName": "axios",
"typingsPackageName": "axios",
"sourceRepoURL": "https://github.com/mzabriskie/axios",
"asOfVersion": "0.14.0"
}
]
}
+1 -4
View File
@@ -88,10 +88,7 @@ export declare class Client extends events.EventEmitter {
end(callback?: (err: Error) => void): void;
release(): void;
query(queryText: string, values?: any[]): Promise<QueryResult>;
query(queryText: string, callback?: (err: Error, result: QueryResult) => void): Query;
query(config: QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query;
query(queryTextOrConfig: string | QueryConfig, callback?: (err: Error, result: QueryResult) => void): Query;
query(queryText: string, values: any[], callback?: (err: Error, result: QueryResult) => void): Query;
copyFrom(queryText: string): stream.Writable;
+3 -2
View File
@@ -5,12 +5,13 @@
// TypeScript Version: 2.1
/// <reference types="react" />
/// <reference types="bootstrap-datepicker" />
/// <reference types="daterangepicker" />
declare namespace ReactBootstrapDaterangepicker {
export interface EventHandler { (event?: any, picker?: any): any; }
export interface Props extends DatepickerOptions {
export interface Props extends daterangepicker.Settings{
onShow?: EventHandler;
onHide?: EventHandler;
onShowCalendar?: EventHandler;
+1 -1
View File
@@ -75,7 +75,7 @@ declare namespace ReactDayPicker {
toMonth?: Date;
localeUtils?: LocaleUtils;
locale?: string;
captionElement?: React.ReactElement<CaptionElementProps> | null;
captionElement?: React.ReactElement<CaptionElementProps>;
onDayClick?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any;
onDayTouchTap?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any;
onDayMouseEnter?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any;
+2 -2
View File
@@ -28,7 +28,7 @@ declare namespace ReactDOM {
container: Element | null,
callback?: (component: T) => any): T;
function render<P>(
element: ReactElement<P> | null,
element: ReactElement<P>,
container: Element | null,
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
@@ -57,7 +57,7 @@ declare namespace ReactDOM {
callback?: () => any): void;
function unstable_renderSubtreeIntoContainer<P>(
parentComponent: Component<any, any>,
element: ReactElement<P> | null,
element: ReactElement<P>,
container: Element,
callback?: (component?: Component<P, ComponentState> | Element) => any): Component<P, ComponentState> | Element | void;
}
+50 -20
View File
@@ -1,32 +1,62 @@
// Type definitions for react-modal v1.6.1
// Type definitions for react-modal 1.6
// Project: https://github.com/reactjs/react-modal
// Definitions by: Rajab Shakirov <https://github.com/radziksh>
// Definitions by: Rajab Shakirov <https://github.com/radziksh>, Drew Noakes <https://github.com/drewnoakes>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="react"/>
import * as React from "react";
declare module "react-modal" {
interface ReactModal {
isOpen: boolean;
export as namespace ReactModal;
export = ReactModal;
declare namespace ReactModal {
export interface Styles {
style?: {
content?: {
[key: string]: any;
},
};
overlay?: {
[key: string]: any;
}
},
appElement?: HTMLElement | {},
onAfterOpen?: Function,
onRequestClose?: Function,
closeTimeoutMS?: number,
ariaHideApp?: boolean,
shouldCloseOnOverlayClick?: boolean,
overlayClassName?: string,
className?: string
contentLabel?: string
};
};
}
export interface Props {
/* Boolean describing if the modal should be shown or not. Defaults to false. */
isOpen: boolean;
/* Object indicating styles to be used for the modal, divided into overlay and content styles. */
style?: Styles;
/* Set this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */
appElement?: HTMLElement | {};
/* Function that will be run after the modal has opened. */
onAfterOpen?: () => void;
/* Function that will be run when the modal is requested to be closed, prior to actually closing. */
onRequestClose?: () => void;
/* Number indicating the milliseconds to wait before closing the modal. Defaults to zero (no timeout). */
closeTimeoutMS?: number;
/* Boolean indicating if the appElement should be hidden. Defaults to true. */
ariaHideApp?: boolean;
/* Boolean indicating if the overlay should close the modal. Defaults to true. */
shouldCloseOnOverlayClick?: boolean;
/* String className to be applied to the portal. Defaults to "ReactModalPortal". */
portalClassName?: string;
/* String className to be applied to the overlay. */
overlayClassName?: string;
/* String className to be applied to the modal content. */
className?: string;
/* String indicating how the content container should be announced to screenreaders. */
contentLabel?: string;
/* String indicating the role of the modal, allowing the 'dialog' role to be applied if desired. */
role?: string;
/* Function that will be called to get the parent element that the modal will be attached to. */
parentSelector?: () => HTMLElement;
}
let ReactModal: React.ClassicComponentClass<ReactModal>;
export = ReactModal;
}
declare class ReactModal extends React.Component<ReactModal.Props, {}> {
/* Override base styles for all instances of this component. */
static defaultStyles: ReactModal.Styles;
/* Call this to properly hide your application from assistive screenreaders and other assistive technologies while the modal is open. */
static setAppElement(appElement: HTMLElement): void;
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+34
View File
@@ -0,0 +1,34 @@
// Type definitions for react-native-datepicker 1.4
// Project: https://github.com/xgfe/react-native-datepicker
// Definitions by: Jacob Baskin <https://github.com/jacobbaskin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
import * as React from 'react';
interface DatePickerProps {
mode?: 'date' | 'datetime' | 'time';
date?: string | Date;
format?: string;
minDate?: string | Date;
maxDate?: string | Date;
height?: number;
duration?: number;
confirmBtnText?: string;
cancelBtnText?: string;
showIcon?: boolean;
disabled?: boolean;
onDateChange?: (dateStr: string, date: Date) => void;
placeholder?: string;
modalOnResponderTerminationRequest?: (e: any) => boolean;
is24Hour?: boolean;
style?: any;
customStyles?: any;
minuteInterval?: number;
}
declare class DatePicker extends React.Component<DatePickerProps, {}> {
constructor(props: DatePickerProps);
}
export default DatePicker;
@@ -0,0 +1,42 @@
import * as React from 'react';
import DatePicker from 'react-native-datepicker';
interface MyDatePickerState {
date: string;
}
export default class MyDatePicker extends React.Component<{}, MyDatePickerState> {
constructor(props: {}) {
super(props);
this.state = {date: "2016-05-15"};
}
render() {
return (
<DatePicker
style={{width: 200}}
date={this.state.date}
mode="date"
placeholder="select date"
format="YYYY-MM-DD"
minDate="2016-05-01"
maxDate="2016-06-01"
confirmBtnText="Confirm"
cancelBtnText="Cancel"
customStyles={{
dateIcon: {
position: 'absolute',
left: 0,
top: 4,
marginLeft: 0
},
dateInput: {
marginLeft: 36
}
}}
onDateChange={(date: string) => {this.setState({date});}}
/>
);
}
}
@@ -7,17 +7,18 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
"jsx": "react"
},
"files": [
"index.d.ts",
"axios-tests.ts"
"react-native-datepicker-tests.tsx"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
@@ -18,7 +18,7 @@ class SwiperTest extends React.Component<IProperties, IState> {
super(props);
}
public render(): React.ReactElement<any> | null {
public render(): React.ReactElement<any> {
return (
<Swiper
style={styles.wrapper}>
+5 -5
View File
@@ -86,11 +86,11 @@ export interface InjectedRouter {
}
export interface RouteComponentProps<P, R> {
location?: Location;
params?: P & R;
route?: PlainRoute;
router?: InjectedRouter;
routeParams?: R;
location: Location;
params: P & R;
route: PlainRoute;
router: InjectedRouter;
routeParams: R;
}
export interface RouterProps extends ClassAttributes<any> {
+4
View File
@@ -246,6 +246,10 @@ declare namespace ReactSelectClass {
* onInputChange handler: function (inputValue) {}
*/
onInputChange?: (inputValue: string) => void;
/**
* onInputKeyDown handler: function (keyboardEvent) {}
*/
onInputKeyDown?: (event: KeyboardEvent) => void;
/**
* fires when the menu is scrolled to the bottom; can be used to paginate options
*/
+4
View File
@@ -7,6 +7,10 @@
/// <reference types="react"/>
interface __config {
accessibility?: boolean
nextArrow?: HTMLElement | any
prevArrow?: HTMLElement | any
pauseOnHover?: boolean
className?: string
adaptiveHeight?: boolean
arrows?: boolean
+2 -1
View File
@@ -10,7 +10,8 @@ class SliderTest extends React.Component<React.Props<{}>, {}> {
slidesToShow: 8,
slidesToScroll: 1,
draggable: false,
infinite: false
infinite: false,
prevArrow: <a href="#">link</a>
};
return (
+4 -6
View File
@@ -171,7 +171,7 @@ declare namespace React {
setState<K extends keyof S>(f: (prevState: S, props: P) => Pick<S, K>, callback?: () => any): void;
setState<K extends keyof S>(state: Pick<S, K>, callback?: () => any): void;
forceUpdate(callBack?: () => any): void;
render(): JSX.Element;
render(): JSX.Element | null;
// React.Props<T> is now deprecated, which means that the `children`
// property is not available on `P` by default, even though you can
@@ -204,7 +204,7 @@ declare namespace React {
type SFC<P> = StatelessComponent<P>;
interface StatelessComponent<P> {
(props: P & { children?: ReactNode }, context?: any): ReactElement<any> | null;
(props: P & { children?: ReactNode }, context?: any): ReactElement<any>;
propTypes?: ValidationMap<P>;
contextTypes?: ValidationMap<any>;
defaultProps?: P;
@@ -2628,11 +2628,9 @@ declare namespace React {
declare global {
namespace JSX {
interface JSXElement extends React.ReactElement<any> { }
type Element = JSXElement | null;
interface Element extends React.ReactElement<any> { }
interface ElementClass extends React.Component<any, any> {
render(): JSX.Element;
render(): JSX.Element | null;
}
interface ElementAttributesProperty { props: {}; }
-3
View File
@@ -32,6 +32,3 @@ StatelessComponent2.defaultProps = {
</text>
</g>
</svg>;
const CustomComponent = (props: { flag: boolean }) => props.flag ? React.createElement('div') : null;
const UseComponent2 = (f: boolean) => <CustomComponent flag={f} />;
+2 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for Recompose v0.20.2
// Type definitions for Recompose v0.20.3
// Project: https://github.com/acdlite/recompose
// Definitions by: Iskander Sierra <https://github.com/iskandersierra>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -103,7 +103,7 @@ declare module 'recompose' {
export function branch<TOutter>(
test: predicate<TOutter>,
trueEnhancer: InferableComponentEnhancer,
falseEnhancer: InferableComponentEnhancer
falseEnhancer?: InferableComponentEnhancer
): ComponentEnhancer<any, TOutter>;
// renderComponent: https://github.com/acdlite/recompose/blob/master/docs/API.md#renderComponent
+6
View File
@@ -148,13 +148,19 @@ function testBranch() {
const innerComponent: React.StatelessComponent<InnerProps> = (props: InnerProps) =>
<div onClick={() => props.update()}>{props.count}</div>;
const innerComponent2 = () => <div>Hello</div>;
const enhancer = branch(
(props: OutterProps) => props.toggled,
withState("count", "update", 0),
withState("count", "update", 100)
);
const enhancer2 = branch(
(props: OutterProps) => props.toggled,
renderComponent(innerComponent),
)
const enhanced: React.ComponentClass<OutterProps> = enhancer(innerComponent);
const enhanced2: React.ComponentClass<OutterProps> = enhancer2(innerComponent);
}
function testRenderComponent() {
+12 -12
View File
@@ -1,24 +1,24 @@
// Type definitions for serialport 4.0.1
// Type definitions for serialport 4.0
// Project: https://github.com/EmergingTechnologyAdvisors/node-serialport
// Definitions by: Jeremy Foster <https://github.com/codefoster>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'serialport' {
class SerialPort {
constructor(path: string, options?: Object, openImmediately?: boolean, callback?: (err: string) => void)
isOpen: boolean;
constructor(path: string, options?: Object, openImmediately?: boolean, callback?: (err: any) => void)
isOpen(): boolean;
on(event: string, callback?: (data?: any) => void): void;
open(callback?: () => void): void;
write(buffer: any, callback?: (err: string, bytesWritten: number) => void): void
open(callback?: (err: any) => void): void;
write(buffer: any, callback?: (err: any, bytesWritten: number) => void): void
pause(): void;
resume(): void;
disconnected(err: Error): void;
close(callback?: (err:any) => void): void;
flush(callback?: (err:any) => void): void;
set(options: SerialPort.setOptions, callback: () => void): void;
drain(callback?: (err:any) => void): void;
update(options: SerialPort.updateOptions, callback?: () => void): void;
static list(callback: (err: string, ports: SerialPort.portConfig[]) => void): void;
close(callback?: (err: any) => void): void;
flush(callback?: (err: any) => void): void;
set(options: SerialPort.setOptions, callback: (err: any) => void): void;
drain(callback?: (err: any) => void): void;
update(options: SerialPort.updateOptions, callback?: (err: any) => void): void;
static list(callback: (err: any, ports: SerialPort.portConfig[]) => void): void;
static parsers: {
readline: (delimiter: string) => void,
raw: (emitter: any, buffer: string) => void
@@ -49,5 +49,5 @@ declare module 'serialport' {
}
}
export = SerialPort
export = SerialPort;
}
+4
View File
@@ -3586,6 +3586,10 @@ declare namespace THREE {
export class Spherical {
constructor(radius?: number, phi?: number, theta?: number);
radius: number;
phi: number;
theta: number;
set(radius: number, phi: number, theta: number): Spherical;
clone(): this;
copy(other: this): this;
+43 -31
View File
@@ -3,9 +3,8 @@
// Definitions by: Konstantin Burkalev <https://github.com/KSDaemon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface WampyOptions {
interface WampyOptions
{
autoReconnect?: boolean;
reconnectInterval?: number;
maxRetries?: number;
@@ -23,82 +22,95 @@ interface WampyOptions {
msgpackCoder?: any;
}
interface WampyOpStatus {
interface WampyOpStatus
{
code: number;
description: string;
reqId?: number;
}
interface SuccessErrorCallbacksHash {
interface SuccessErrorCallbacksHash
{
onSuccess?: (data: any) => void;
onError?: (err: string) => void;
onError?: (err: string, details: any) => void;
}
interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash {
onEvent: (data: any) => void;
interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash
{
onEvent: (args: any[], kwargs: any) => void;
}
interface RegisterCallbacksHash extends SuccessErrorCallbacksHash {
interface RegisterCallbacksHash extends SuccessErrorCallbacksHash
{
rpc: (data: any, options: any) => any[];
}
interface CallSuccessErrorCallbacksHash {
onSuccess: (data: any) => any;
onError?: (err: string) => void;
interface CallSuccessErrorCallbacksHash
{
onSuccess: (args: any[], kwargs: any) => any;
onError?: (err: string, details: any, args: any[], kwargs: any) => void;
}
interface AdvancedOptions {
interface AdvancedOptions
{
exclude?: number | number[];
eligible?: number | number[];
exclude_me?: boolean;
disclose_me?: boolean;
}
interface PublishAdvancedOptions extends AdvancedOptions {
interface PublishAdvancedOptions extends AdvancedOptions
{
exclude_authid?: string | string[];
exclude_authrole?: string | string[];
eligible_authid?: string | string[];
eligible_authrole?: string | string[];
}
interface CallAdvancedOptions {
interface CallAdvancedOptions
{
disclose_me?: boolean;
receive_progress?: boolean;
timeout?: number;
}
interface CancelAdvancedOptions {
interface CancelAdvancedOptions
{
mode?: "skip" | "kill" | "killnowait";
}
interface Wampy {
interface Wampy
{
new (url?: string, options?: WampyOptions): Wampy;
options(opts?: WampyOptions): WampyOptions | Wampy;
getOpStatus(): WampyOpStatus;
getSessionId(): number;
connect(url?: string): Wampy;
disconnect(): Wampy;
abort(): Wampy;
subscribe(topicURI: string, callbacks: (((data: any) => void) | SubscribeCallbacksHash)): Wampy;
unsubscribe(topicURI: string, callbacks?: (((data: any) => void) | SubscribeCallbacksHash)): Wampy;
subscribe(topicURI: string, callbacks: (((args: any[], kwargs: any) => void) | SubscribeCallbacksHash)): Wampy;
unsubscribe(topicURI: string, callbacks?: (((args: any[], kwargs: any) => void) | SubscribeCallbacksHash)): Wampy;
publish(topicURI: string,
payload?: any,
callbacks?: SuccessErrorCallbacksHash,
advancedOptions?: PublishAdvancedOptions): Wampy;
payload?: any,
callbacks?: SuccessErrorCallbacksHash,
advancedOptions?: PublishAdvancedOptions): Wampy;
call(topicURI: string,
payload?: any,
callbacks?: (((data: any) => void) | CallSuccessErrorCallbacksHash),
advancedOptions?: CallAdvancedOptions): Wampy;
payload?: any,
callbacks?: (((args: any[], kwargs: any) => void) | CallSuccessErrorCallbacksHash),
advancedOptions?: CallAdvancedOptions): Wampy;
cancel(reqId: number,
callbacks?: ((() => void) | SuccessErrorCallbacksHash),
advancedOptions?: CancelAdvancedOptions): Wampy;
callbacks?: ((() => void) | SuccessErrorCallbacksHash),
advancedOptions?: CancelAdvancedOptions): Wampy;
register(topicURI: string, callbacks: (((data: any, options: any) => any[]) | RegisterCallbacksHash)): Wampy;
unregister(topicURI: string, callbacks?: ((() => void) | SuccessErrorCallbacksHash)): Wampy;
}
interface WampyInstance {
new (url?: string, options?: WampyOptions): Wampy;
declare var wampy: Wampy;
declare module 'wampy'
{
export = wampy;
}
declare var wampy: WampyInstance;
export default wampy;
+34 -50
View File
@@ -1,47 +1,50 @@
/// <reference types="node" />
import Wampy from 'wampy';
import * as Wampy from 'wampy';
var ws = new Wampy('http://wamp.router.url', {realm: 'WAMPRealm'});
let ws = new Wampy('http://wamp.router.url', {realm: 'WAMPRealm'});
ws.options();
ws.options({
reconnectInterval: 1000,
maxRetries: 999,
onConnect: function () { console.log('Yahoo! We are online!'); },
onClose: function () { console.log('See you next time!'); },
onError: function () { console.log('Breakdown happened'); },
onReconnect: function () { console.log('Reconnecting...'); },
onReconnectSuccess: function () { console.log('Successfully reconnected!'); }
onConnect: () => console.log('Yahoo! We are online!'),
onClose: () => console.log('See you next time!'),
onError: () => console.log('Breakdown happened'),
onReconnect: () => console.log('Reconnecting...'),
onReconnectSuccess: () => console.log('Successfully reconnected!')
});
ws.connect();
ws.connect('/my-socket-path');
ws.connect('wss://socket.server.com:5000/ws');
var id: number = ws.getSessionId();
let id: number = ws.getSessionId();
ws.disconnect();
ws.abort();
ws.subscribe('system.monitor.update', function (data) {
ws.subscribe('system.monitor.update', (args: any[], kwargs: any) => {
console.log('Received system.monitor.update event!');
})
.subscribe('client.message', function (data) {
.subscribe('client.message', function (args: any[], kwargs: any) {
console.log('Received client.message event!');
});
var f1 = function () { console.log('Subscribe processing!'); };
let f1 = () => console.log('Subscribe processing!');
ws.unsubscribe('subscribed.topic', f1);
ws.unsubscribe('chat.message.received');
ws.call('get.server.time', null, {
onSuccess: function (stime) {
onSuccess: (args: any[], kwargs: any) => {
console.log('RPC successfully called');
console.log('Server time is ' + stime);
console.log('Server time is ' + kwargs);
},
onError: function (err) {
onError: (err: string, details: any, args: any[], kwargs: any) => {
console.log('RPC call failed with error ' + err);
}
});
@@ -54,67 +57,48 @@ ws.publish('chat.message.received', 'user message');
ws.publish('chat.message.received', ['user message1', 'user message2']);
ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 });
ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 }, {
onSuccess: function () { console.log('User successfully modified'); }
onSuccess: () => console.log('User successfully modified')
});
ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 }, {
onSuccess: function () { console.log('User successfully modified'); },
onError: function (err) { console.log('User modification failed', err); }
onSuccess: () => console.log('User successfully modified'),
onError: (err: string, details: any) => console.log('User modification failed', err)
});
ws.publish('chat.message.received', ['Private message'], null, { eligible: 123456789 });
ws.call('server.time', null, function (data) { console.log('Server time is ' + data[0]); });
ws.call('server.time', null, (args: any[], kwargs: any) => console.log('Server time is ' + args[0]));
ws.call('start.migration', null, {
onSuccess: function (data) {
console.log('RPC successfully called');
},
onError: function (err) {
console.log('RPC call failed!',err);
}
onSuccess: (args: any[], kwargs: any) => console.log('RPC successfully called'),
onError: (err: string, details: any, args: any[], kwargs: any) => console.log('RPC call failed!',err)
});
ws.call('restore.backup', { backupFile: 'backup.zip' }, {
onSuccess: function (data) {
console.log('Backup successfully restored');
},
onError: function (err) {
console.log('Restore failed!',err);
}
onSuccess: (args: any[], kwargs: any) => console.log('Backup successfully restored'),
onError: (err: string, details: any, args: any[], kwargs: any) => console.log('Restore failed!',err)
});
ws.call('start.migration', null, {
onSuccess: function (data) {
console.log('RPC successfully called');
},
onError: function (err) {
console.log('RPC call failed!',err);
}
onSuccess: (args: any[], kwargs: any) => console.log('RPC successfully called'),
onError: (err: string, details: any, args: any[], kwargs: any) => console.log('RPC call failed!',err)
});
var status = ws.getOpStatus();
let status = ws.getOpStatus();
ws.cancel(status.reqId);
var sqrt_f = function (x: number, y: any) { return [{}, x*x]; };
let sqrt_f = (x: number, y: any) => [{}, x*x];
ws.register('sqrt.value', sqrt_f);
ws.register('sqrt.value', {
rpc: sqrt_f,
onSuccess: function (data) {
console.log('RPC successfully registered');
},
onError: function (err) {
console.log('RPC registration failed!',err);
}
onSuccess: (data: any) => console.log('RPC successfully registered'),
onError: (err: string, details: any) => console.log('RPC registration failed!',err)
});
ws.unregister('sqrt.value');
ws.unregister('sqrt.value', {
onSuccess: function (data) {
console.log('RPC successfully unregistered');
},
onError: function (err) {
console.log('RPC unregistration failed!',err);
}
onSuccess: (data: any) => console.log('RPC successfully unregistered'),
onError: (err: string, details: any) => console.log('RPC unregistration failed!', err)
});
+5
View File
@@ -0,0 +1,5 @@
[*.ts]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
+23 -3
View File
@@ -1,6 +1,6 @@
// Type definitions for yargs 6.5.0
// Type definitions for yargs 6.6.0
// Project: https://github.com/chevex/yargs
// Definitions by: Martin Poelstra <https://github.com/poelstra>, Mizunashi Mana <https://github.com/mizunashi-mana>, Jeffery Grajkowski <https://github.com/pushplay>
// Definitions by: Martin Poelstra <https://github.com/poelstra>, Mizunashi Mana <https://github.com/mizunashi-mana>, Jeffery Grajkowski <https://github.com/pushplay>, Jeff Kenney <https://github.com/jeffkenney>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace yargs {
@@ -28,6 +28,9 @@ declare namespace yargs {
default(key: string, value: any, description?: string): Argv;
default(defaults: { [key: string]: any }, description?: string): Argv;
/**
* @deprecated since version 6.6.0
*/
demand(key: string, msg: string): Argv;
demand(key: string, required?: boolean): Argv;
demand(keys: string[], msg: string): Argv;
@@ -36,6 +39,15 @@ declare namespace yargs {
demand(positionals: number, msg: string): Argv;
demand(positionals: number, max: number, msg?: string): Argv;
demandCommand(min: number, minMsg?: string): Argv;
demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv;
demandOption(key: string | string[], msg?: string): Argv;
demandOption(key: string | string[], demand?: boolean): Argv;
/**
* @deprecated since version 6.6.0
*/
require(key: string, msg: string): Argv;
require(key: string, required: boolean): Argv;
require(keys: number[], msg: string): Argv;
@@ -43,6 +55,9 @@ declare namespace yargs {
require(positionals: number, required: boolean): Argv;
require(positionals: number, msg: string): Argv;
/**
* @deprecated since version 6.6.0
*/
required(key: string, msg: string): Argv;
required(key: string, required: boolean): Argv;
required(keys: number[], msg: string): Argv;
@@ -103,6 +118,9 @@ declare namespace yargs {
config(key: string, parseFn: (configPath: string) => Object): Argv;
config(keys: string[], parseFn: (configPath: string) => Object): Argv;
conflicts(key: string, value: string): Argv;
conflicts(conflicts: { [key: string]: string }): Argv;
wrap(columns: number): Argv;
strict(): Argv;
@@ -147,7 +165,7 @@ declare namespace yargs {
fail(func: (msg: string, err: Error) => any): Argv;
coerce<T, U>(key: string|string[], func: (arg: T) => U): Argv;
coerce<T, U>(key: string | string[], func: (arg: T) => U): Argv;
coerce<T, U>(opts: { [key: string]: (arg: T) => U; }): Argv;
getCompletion(args: string[], done: (completions: string[]) => void): Argv;
@@ -186,7 +204,9 @@ declare namespace yargs {
count?: boolean;
default?: any;
defaultDescription?: string;
/** @deprecated since version 6.6.0 */
demand?: boolean | string;
demandOption?: boolean | string;
desc?: string;
describe?: string;
description?: string;
+391 -360
View File
@@ -12,539 +12,539 @@ const stringVal = 'string';
// With yargs, the options be just a hash!
function xup() {
var argv = yargs.argv;
var argv = yargs.argv;
if (argv.rif - 5 * argv.xup > 7.138) {
console.log('Plunder more riffiwobbles!');
}
else {
console.log('Drop the xupptumblers!');
}
if (argv.rif - 5 * argv.xup > 7.138) {
console.log('Plunder more riffiwobbles!');
}
else {
console.log('Drop the xupptumblers!');
}
}
// And non-hyphenated options too! Just use argv._!
function nonopt() {
var argv = yargs.argv;
console.log('(%d,%d)', argv.x, argv.y);
console.log(argv._);
var argv = yargs.argv;
console.log('(%d,%d)', argv.x, argv.y);
console.log(argv._);
}
// Yargs even counts your booleans!
function count() {
var argv = yargs
.count('verbose')
.alias('v', 'verbose')
.argv;
var argv = yargs
.count('verbose')
.alias('v', 'verbose')
.argv;
var VERBOSE_LEVEL: number = argv.verbose;
var VERBOSE_LEVEL: number = argv.verbose;
function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); }
function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); }
function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); }
function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); }
function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); }
function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); }
}
// Tell users how to use yer options and make demands.
function divide() {
var argv = yargs
.usage('Usage: $0 -x [num] -y [num]')
.demand(['x', 'y'])
.argv;
var argv = yargs
.usage('Usage: $0 -x [num] -y [num]')
.demand(['x', 'y'])
.argv;
console.log(argv.x / argv.y);
console.log(argv.x / argv.y);
}
// After yer demands have been met, demand more! Ask for non-hypenated arguments!
function demand_count() {
var argv = yargs
.demand(2)
.demand(2, false)
.demand(2, 2)
.demand(2, 2, "message")
.argv;
console.dir(argv);
var argv = yargs
.demand(2)
.demand(2, false)
.demand(2, 2)
.demand(2, 2, "message")
.argv;
console.dir(argv);
}
// EVEN MORE SHIVER ME TIMBERS!
function default_singles() {
var argv = yargs
.default('x', 10)
.default('y', 10)
.argv
;
console.log(argv.x + argv.y);
var argv = yargs
.default('x', 10)
.default('y', 10)
.argv
;
console.log(argv.x + argv.y);
}
function default_hash() {
var argv = yargs
.default({ x: 10, y: 10 })
.argv
;
console.log(argv.x + argv.y);
var argv = yargs
.default({ x: 10, y: 10 })
.argv
;
console.log(argv.x + argv.y);
}
// And if you really want to get all descriptive about it...
function boolean_single() {
var argv = yargs
.boolean('v')
.argv
;
console.dir(argv.v);
console.dir(argv._);
var argv = yargs
.boolean('v')
.argv
;
console.dir(argv.v);
console.dir(argv._);
}
function boolean_double() {
var argv = yargs
.boolean(['x', 'y', 'z'])
.argv
;
console.dir([argv.x, argv.y, argv.z]);
console.dir(argv._);
var argv = yargs
.boolean(['x', 'y', 'z'])
.argv
;
console.dir([argv.x, argv.y, argv.z]);
console.dir(argv._);
}
// Yargs is here to help you...
function line_count() {
var argv = yargs
.usage('Count the lines in a file.\nUsage: $0')
.example('$0 -f', 'count the lines in the given file')
.demand('f')
.alias('f', 'file')
.describe('f', 'Load a file')
.argv
;
var argv = yargs
.usage('Count the lines in a file.\nUsage: $0')
.example('$0 -f', 'count the lines in the given file')
.demand('f')
.alias('f', 'file')
.describe('f', 'Load a file')
.argv
;
}
// Below are tests for individual methods.
// Not all methods are covered yet, and neither are all possible invocations of methods.
function Argv_parsing() {
var argv1 = yargs.argv;
var argv2 = yargs(['-x', '1', '-y', '2']).argv;
var argv3 = yargs.parse(['-x', '1', '-y', '2']);
console.log(argv1.x, argv2.x, argv3.x);
var argv1 = yargs.argv;
var argv2 = yargs(['-x', '1', '-y', '2']).argv;
var argv3 = yargs.parse(['-x', '1', '-y', '2']);
console.log(argv1.x, argv2.x, argv3.x);
}
function Argv$options() {
var argv1 = yargs
.options('f', {
alias: 'file',
default: '/etc/passwd',
defaultDescription: 'The /etc/passwd file',
group: 'files',
normalize: true,
global: false,
array: true,
nargs: 3
})
.argv
;
var argv1 = yargs
.options('f', {
alias: 'file',
default: '/etc/passwd',
defaultDescription: 'The /etc/passwd file',
group: 'files',
normalize: true,
global: false,
array: true,
nargs: 3
})
.argv
;
var argv2 = yargs
.alias('f', 'file')
.default('f', '/etc/passwd')
.argv
;
var argv2 = yargs
.alias('f', 'file')
.default('f', '/etc/passwd')
.argv
;
}
function Argv$global() {
var argv = yargs
.global('foo')
.global(['bar', 'baz', 'fizz', 'buzz'])
var argv = yargs
.global('foo')
.global(['bar', 'baz', 'fizz', 'buzz'])
}
function Argv$group() {
var argv = yargs
.group('foo', 'foogroup')
.group(['bing', 'bang', 'buzz'], 'onomatopoeia')
var argv = yargs
.group('foo', 'foogroup')
.group(['bing', 'bang', 'buzz'], 'onomatopoeia')
}
function Argv$env() {
var argv = yargs
.env('YARGS_PREFIX_')
.env()
.env(true);
var argv = yargs
.env('YARGS_PREFIX_')
.env()
.env(true);
}
function Argv$array() {
var argv = yargs
.array('foo')
.array(['bar', 'baz'])
var argv = yargs
.array('foo')
.array(['bar', 'baz'])
}
function Argv$nargs() {
var argv = yargs
.nargs('foo', 12)
.nargs({ 'bing': 3, 'bang': 2, 'buzz': 4 })
var argv = yargs
.nargs('foo', 12)
.nargs({ 'bing': 3, 'bang': 2, 'buzz': 4 })
}
function Argv$choices() {
// example from documentation
var argv = yargs
.alias('i', 'ingredient')
.describe('i', 'choose your sandwich ingredients')
.choices('i', ['peanut-butter', 'jelly', 'banana', 'pickles'])
.help('help')
.argv
// example from documentation
var argv = yargs
.alias('i', 'ingredient')
.describe('i', 'choose your sandwich ingredients')
.choices('i', ['peanut-butter', 'jelly', 'banana', 'pickles'])
.help('help')
.argv
}
function command() {
var argv = yargs
.usage('npm <command>')
.command('install', 'tis a mighty fine package to install')
.command('publish', 'shiver me timbers, should you be sharing all that', yargs =>
yargs.option('f', {
alias: 'force',
description: 'yar, it usually be a bad idea'
})
.help('help')
)
.command("build", "arghh, build it mate", {
tag: {
default: true,
demand: true,
description: "Tag the build, mate!"
},
publish: {
default: false,
description:"Should i publish?"
}
})
.command({
command: "test",
describe: "test package",
builder: {
mateys: {
demand: false
}
},
handler: (args: any) => {
/* handle me mateys! */
}
})
.command("test", "test mateys", {
handler: (args: any) => {
/* handle me mateys! */
}
})
.help('help')
.argv;
var argv = yargs
.usage('npm <command>')
.command('install', 'tis a mighty fine package to install')
.command('publish', 'shiver me timbers, should you be sharing all that', yargs =>
yargs.option('f', {
alias: 'force',
description: 'yar, it usually be a bad idea'
})
.help('help')
)
.command("build", "arghh, build it mate", {
tag: {
default: true,
demand: true,
description: "Tag the build, mate!"
},
publish: {
default: false,
description:"Should i publish?"
}
})
.command({
command: "test",
describe: "test package",
builder: {
mateys: {
demand: false
}
},
handler: (args: any) => {
/* handle me mateys! */
}
})
.command("test", "test mateys", {
handler: (args: any) => {
/* handle me mateys! */
}
})
.help('help')
.argv;
yargs
.command('get', 'make a get HTTP request', function (yargs) {
return yargs.option('url', {
alias: 'u',
default: 'http://yargs.js.org/'
})
})
.help()
.argv
yargs
.command('get', 'make a get HTTP request', function (yargs) {
return yargs.option('url', {
alias: 'u',
default: 'http://yargs.js.org/'
})
})
.help()
.argv
yargs
.command(
'get',
'make a get HTTP request',
function (yargs) {
return yargs.option('u', {
alias: 'url',
describe: 'the URL to make an HTTP request to'
})
},
function (argv: { url: string }) {
console.dir(argv.url)
}
)
.help()
.argv
yargs
.command(
'get',
'make a get HTTP request',
function (yargs) {
return yargs.option('u', {
alias: 'url',
describe: 'the URL to make an HTTP request to'
})
},
function (argv: { url: string }) {
console.dir(argv.url)
}
)
.help()
.argv
}
function completion_sync() {
var argv = yargs
.completion('completion', (current, argv) => {
// 'current' is the current command being completed.
// 'argv' is the parsed arguments so far.
// simply return an array of completions.
return [
'foo',
'bar'
];
})
.argv;
var argv = yargs
.completion('completion', (current, argv) => {
// 'current' is the current command being completed.
// 'argv' is the parsed arguments so far.
// simply return an array of completions.
return [
'foo',
'bar'
];
})
.argv;
}
function completion_async() {
var argv = yargs
.completion('completion', (current: string, argv: any, done: (completion: string[]) => void) => {
setTimeout(function () {
done([
'apple',
'banana'
]);
}, 500);
})
.argv;
var argv = yargs
.completion('completion', (current: string, argv: any, done: (completion: string[]) => void) => {
setTimeout(function () {
done([
'apple',
'banana'
]);
}, 500);
})
.argv;
}
function Argv$help() {
var argv = yargs
.usage("$0 -operand1 number -operand2 number -operation [add|subtract]")
.help()
.argv;
var argv = yargs
.usage("$0 -operand1 number -operand2 number -operation [add|subtract]")
.help()
.argv;
}
function Argv$showHelpOnFail() {
var argv = yargs
.usage('Count the lines in a file.\nUsage: $0')
.demand('f')
.alias('f', 'file')
.describe('f', 'Load a file')
.showHelpOnFail(false, "Specify --help for available options")
.argv;
var argv = yargs
.usage('Count the lines in a file.\nUsage: $0')
.demand('f')
.alias('f', 'file')
.describe('f', 'Load a file')
.showHelpOnFail(false, "Specify --help for available options")
.argv;
}
function Argv$showHelp() {
var yargs1 = yargs
.usage("$0 -operand1 number -operand2 number -operation [add|subtract]");
yargs1.showHelp();
var yargs1 = yargs
.usage("$0 -operand1 number -operand2 number -operation [add|subtract]");
yargs1.showHelp();
}
function Argv$version() {
var argv1 = yargs
.version();
var argv1 = yargs
.version();
var argv2 = yargs
.version('1.0.0');
var argv2 = yargs
.version('1.0.0');
var argv3 = yargs
.version('1.0.0', '--version');
var argv3 = yargs
.version('1.0.0', '--version');
var argv4 = yargs
.version('1.0.0', '--version', 'description');
var argv4 = yargs
.version('1.0.0', '--version', 'description');
var argv5 = yargs
.version(function () { return '1.0.0'; }, '--version', 'description');
var argv5 = yargs
.version(function () { return '1.0.0'; }, '--version', 'description');
}
function Argv$wrap() {
var argv1 = yargs
.wrap(null);
var argv1 = yargs
.wrap(null);
var argv2 = yargs
.wrap(yargs.terminalWidth());
var argv2 = yargs
.wrap(yargs.terminalWidth());
}
function Argv$locale() {
var argv = yargs
.usage('./$0 - follow ye instructions true')
.option('option', {
alias: 'o',
describe: "'tis a mighty fine option",
demand: true
})
.command('run', "Arrr, ya best be knowin' what yer doin'")
.example('$0 run foo', "shiver me timbers, here's an example for ye")
.help('help')
.wrap(70)
.locale('pirate')
.argv
var argv = yargs
.usage('./$0 - follow ye instructions true')
.option('option', {
alias: 'o',
describe: "'tis a mighty fine option",
demand: true
})
.command('run', "Arrr, ya best be knowin' what yer doin'")
.example('$0 run foo', "shiver me timbers, here's an example for ye")
.help('help')
.wrap(70)
.locale('pirate')
.argv
}
function Argv$epilogue() {
var argv = yargs
.epilogue('for more information, find our manual at http://example.com');
var argv = yargs
.epilogue('for more information, find our manual at http://example.com');
}
function Argv$reset() {
var ya = yargs
.usage('$0 command')
.command('hello', 'hello command')
.command('world', 'world command')
.demand(1, 'must provide a valid command'),
argv = yargs.argv,
command = argv._[0];
var ya = yargs
.usage('$0 command')
.command('hello', 'hello command')
.command('world', 'world command')
.demand(1, 'must provide a valid command'),
argv = yargs.argv,
command = argv._[0];
if (command === 'hello') {
ya.reset()
.usage('$0 hello')
.help('h')
.example('$0 hello', 'print the hello message!')
.argv
if (command === 'hello') {
ya.reset()
.usage('$0 hello')
.help('h')
.example('$0 hello', 'print the hello message!')
.argv
console.log('hello!');
} else if (command === 'world') {
ya.reset()
.usage('$0 world')
.help('h')
.example('$0 world', 'print the world message!')
.argv
console.log('hello!');
} else if (command === 'world') {
ya.reset()
.usage('$0 world')
.help('h')
.example('$0 world', 'print the world message!')
.argv
console.log('world!');
} else {
ya.showHelp();
}
console.log('world!');
} else {
ya.showHelp();
}
}
// http://yargs.js.org/docs/#methods-commanddirdirectory-opts
function Argv$commandDir() {
var ya = yargs
.commandDir('.')
.argv
var ya = yargs
.commandDir('.')
.argv
}
// http://yargs.js.org/docs/#methods-commanddirdirectory-opts
function Argv$commandDirWithOptions() {
var ya = yargs
.commandDir('.', {
recurse: false,
extensions: ['js'],
visit: (commandObject: any, pathToFile: string, filename: string) => { },
include: /.*\.js$/,
exclude: /.*\.spec.js$/,
})
.argv
var ya = yargs
.commandDir('.', {
recurse: false,
extensions: ['js'],
visit: (commandObject: any, pathToFile: string, filename: string) => { },
include: /.*\.js$/,
exclude: /.*\.spec.js$/,
})
.argv
}
function Argv$normalize() {
var ya = yargs
.normalize('path')
.normalize(['user', 'group'])
.argv
var ya = yargs
.normalize('path')
.normalize(['user', 'group'])
.argv
}
// From http://yargs.js.org/docs/#methods-coercekey-fn
function Argv$coerce() {
var ya = yargs
.coerce('file', function (arg: string) {
return fs.readFileSync(arg, 'utf8');
})
.argv
var ya = yargs
.coerce('file', function (arg: string) {
return fs.readFileSync(arg, 'utf8');
})
.argv
}
function Argv$coerces() {
var ya = yargs
.coerce({
date: Date.parse,
json: JSON.parse
})
.argv
var ya = yargs
.coerce({
date: Date.parse,
json: JSON.parse
})
.argv
}
function Argv$coerceWithKeys() {
var ya = yargs
.coerce(['src', 'dest'], path.resolve)
.argv
var ya = yargs
.coerce(['src', 'dest'], path.resolve)
.argv
}
// From http://yargs.js.org/docs/#methods-failfn
function Argv$fail() {
var ya = yargs
.fail(function (msg, err) {
if (err) throw err // preserve stack
console.error('You broke it!')
console.error(msg)
process.exit(1)
})
.argv
var ya = yargs
.fail(function (msg, err) {
if (err) throw err // preserve stack
console.error('You broke it!')
console.error(msg)
process.exit(1)
})
.argv
}
function Argv$implies() {
var ya = yargs
.implies('foo', 'snuh')
.implies({
x: 'y'
})
.argv
var ya = yargs
.implies('foo', 'snuh')
.implies({
x: 'y'
})
.argv
}
function Argv$count() {
var ya = yargs
.count('size')
.count(['w', 'h'])
.argv
var ya = yargs
.count('size')
.count(['w', 'h'])
.argv
}
function Argv$number() {
var ya = yargs
.number('n')
.number(['width', 'height'])
.argv
var ya = yargs
.number('n')
.number(['width', 'height'])
.argv
}
function Argv$updateStrings() {
var ya = yargs
.command('run', 'the run command')
.help('help')
.updateStrings({
'Commands:': 'My Commands -->\n'
})
.wrap(null)
.argv
var ya = yargs
.command('run', 'the run command')
.help('help')
.updateStrings({
'Commands:': 'My Commands -->\n'
})
.wrap(null)
.argv
}
function Argv$default() {
var ya = yargs
.default('random', function randomValue() {
return Math.random() * 256;
})
.argv
var ya = yargs
.default('random', function randomValue() {
return Math.random() * 256;
})
.argv
}
function Argv$configObject() {
var ya = yargs
.config({foo: 1, bar: 2})
.argv
var ya = yargs
.config({foo: 1, bar: 2})
.argv
}
function Argv$configParseFunction() {
var ya = yargs
.config('settings', function (configPath) {
return JSON.parse(fs.readFileSync(configPath, 'utf-8'))
})
.config('settings', 'description', function (configPath) {
return JSON.parse(fs.readFileSync(configPath, 'utf-8'))
})
.argv
var ya = yargs
.config('settings', function (configPath) {
return JSON.parse(fs.readFileSync(configPath, 'utf-8'))
})
.config('settings', 'description', function (configPath) {
return JSON.parse(fs.readFileSync(configPath, 'utf-8'))
})
.argv
}
function Argv$helpDescriptionExplicit() {
var ya = yargs
.help('help', 'description', true)
.argv
var ya = yargs
.help('help', 'description', true)
.argv
}
function Argv$showHelpConsoleLevel() {
yargs.showHelp("log"); //prints to stdout using console.log()
yargs.showHelp("log"); //prints to stdout using console.log()
}
function Argv$getCompletion() {
var ya = yargs
.option('foobar', {})
.option('foobaz', {})
.completion()
.getCompletion(['./test.js', '--foo'], function (completions) {
console.log(completions)
})
.argv
var ya = yargs
.option('foobar', {})
.option('foobaz', {})
.completion()
.getCompletion(['./test.js', '--foo'], function (completions) {
console.log(completions)
})
.argv
}
function Argv$pkgConf() {
var ya = yargs
.pkgConf(['key1', 'key2'], 'configFile.json')
.argv
var ya = yargs
.pkgConf(['key1', 'key2'], 'configFile.json')
.argv
}
function Argv$recommendCommands() {
var ya = yargs
.recommendCommands()
.argv
var ya = yargs
.recommendCommands()
.argv
}
function Argv$showCompletionScript() {
var ya = yargs
.showCompletionScript()
.argv
var ya = yargs
.showCompletionScript()
.argv
}
function Argv$skipValidation() {
var ya = yargs
.skipValidation('arg1')
.skipValidation(['arg2', 'arg3'])
.argv
var ya = yargs
.skipValidation('arg1')
.skipValidation(['arg2', 'arg3'])
.argv
}
function Argv$commandObject() {
@@ -562,6 +562,7 @@ function Argv$commandObject() {
default: "myvalue",
defaultDescription: "description",
demand: true,
demandOption: true,
desc: "desc",
describe: "describe",
description: "description",
@@ -577,3 +578,33 @@ function Argv$commandObject() {
}
})
}
function Argv$demandCommand() {
var ya = yargs
.demandCommand(1)
.demandCommand(1, 'at least 1 command required')
.demandCommand(1, 2)
.demandCommand(1, 2, 'at least 1 command required')
.demandCommand(1, 2, 'at least 1 command required', 'at most 2 commands required')
.argv;
}
function Argv$demandOption() {
var ya = yargs
.demandOption('a')
.demandOption('a', 'a is required')
.demandOption('a', true)
.demandOption(['a', 'b'])
.demandOption(['a', 'b'], 'a and b are required')
.demandOption(['a', 'b'], true)
.argv;
}
function Argv$conflicts() {
var ya = yargs
.conflicts('a', 'b')
.conflicts({
a: 'b'
})
.argv;
}