Merge branch 'master' into patch-8

This commit is contained in:
unional
2017-10-31 11:52:22 -07:00
242 changed files with 9306 additions and 2273 deletions
+6
View File
@@ -114,6 +114,12 @@
"sourceRepoURL": "https://github.com/blakeembrey/camel-case",
"asOfVersion": "1.2.1"
},
{
"libraryName": "chalk",
"typingsPackageName": "chalk",
"sourceRepoURL": "https://github.com/chalk/chalk",
"asOfVersion": "2.2.0"
},
{
"libraryName": "change-case",
"typingsPackageName": "change-case",
-3
View File
@@ -731,9 +731,6 @@ declare namespace adone {
*/
creationData(): DatetimeCreationData;
/**
*
*/
parsingFlags(): DatetimeParsingFlags;
/**
+3
View File
@@ -644,6 +644,9 @@ isolateScope = element.find('div').isolateScope();
isolateScope = element.children().isolateScope();
let element2 = angular.element(element);
let elementArray = angular.element(document.querySelectorAll('div'));
let elementReadyFn = angular.element(() => {
console.log('ready');
});
// $timeout signature tests
namespace TestTimeout {
+1 -1
View File
@@ -684,7 +684,7 @@ interface JQuery {
}
interface JQueryStatic {
(element: string | Element | Document | JQuery | ArrayLike<Element>): JQLite;
(element: string | Element | Document | JQuery | ArrayLike<Element> | (() => void)): JQLite;
}
/**
+1 -1
View File
@@ -1,5 +1,5 @@
import * as angular from 'angular';
import { angulartics } from 'angulartics';
import * as angulartics from 'angulartics';
namespace Analytics {
angular.module("angulartics.app", ["angulartics"])
+39 -10
View File
@@ -1,11 +1,14 @@
// Type definitions for Angulartics 1.3
// Type definitions for Angulartics 1.4
// Project: http://luisfarzati.github.io/angulartics/
// Definitions by: Steven Fan <https://github.com/stevenfan>
// Bateast2 <https://github.com/bateast2>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as angular from 'angular';
export = angulartics;//AMD/Require module support
export as namespace angulartics;//UMD module support
declare namespace angulartics {
interface IAngularticsStatic {
@@ -13,41 +16,67 @@ declare namespace angulartics {
}
interface IAnalyticsService {
eventTrack(eventName: string, properties?: any): any;
getOptOut(): boolean;
pageTrack(path: string, location?: angular.ILocationService): any;
eventTrack(eventName: string, properties?: any): any;
exceptionTrack(error: any, cause: string): any;
transactionTrack: any;
setAlias(alias: string): any;
setOptOut(value: boolean): void;
setUsername(username: string): any;
setUserProperties(properties: any): any;
setSuperProperties(properties: any): any;
setUserProperties(userProperties: any): any;
setUserPropertiesOnce(userProperties: any): any;
setSuperProperties(superProperties: any): any;
setSuperPropertiesOnce(superProperties: any): any;
incrementProperty(property: string, value?: any): any;
userTimings(properties: any): any;
clearCookies: any;
getOptOut(): boolean;
setOptOut(value: boolean): void;
}
interface IAnalyticsServiceProvider extends angular.IServiceProvider {
virtualPageviews(value: boolean): void;
trackStates(value: boolean): void;
trackRoutes(value: boolean): void;
excludeRoutes(value: string[]): void;
queryKeysWhitelist(keys: string[]): void
queryKeysBlacklist(keys: string[]): void
firstPageview(value: boolean): void;
withBase(value: boolean): void;
withAutoBase(value: boolean): void;
developerMode(value: boolean): void;
trackExceptions(value: boolean): void;
trackRoutes(value: boolean): void;
trackStates(value: boolean): void;
developerMode(value: boolean): void;
registerPageTrack(callback: (path: string, location?: angular.ILocationService) => any): void;
registerEventTrack(callback: (eventName: string, properties?: any) => any): void;
registerTransactionTrack(callback: any): void;
registerSetAlias(callback: (alias: string) => any): void;
registerSetUsername(callback: (username: string) => any): void;
registerSetUserProperties(callback: (userProperties: any) => any): void;
registerSetUserPropertiesOnce(callback: (userProperties: any) => any): void;
registerSetSuperProperties(callback: (superProperties: any) => any): void;
registerSetSuperPropertiesOnce(callback: (superProperties: any) => any): void;
registerIncrementProperty(callback: (property: string, value?: any) => any): void;
registerUserTimings(callback: (properties: any) => any): void;
registerClearCookies(callback: any): void;
settings: {
pageTracking: {
autoTrackingVirtualPages: boolean,
autoTrackingFirstPage: boolean,
trackRelativePath: boolean,
trackRoutes: boolean,
trackStates: boolean,
autoBasePath: boolean,
basePath: string,
autoBasePath: boolean
excludedRoutes: string[],
queryKeysWhitelisted: string[],
queryKeysBlacklisted: string[]
},
eventTracking: {},
bufferFlushDelay: number,
trackExceptions: boolean,
optOut: boolean,
developerMode: boolean
};
}
@@ -1,4 +1,3 @@
import * as errorHandler from 'api-error-handler';
import * as express from 'express';
+1 -3
View File
@@ -2,9 +2,7 @@
// Project: https://github.com/expressjs/api-error-handler
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import * as express from 'express';
+3 -2
View File
@@ -15,6 +15,7 @@ export interface AsyncResultArrayCallback<T, E> { (err?: E, results?: (T | undef
export interface AsyncResultObjectCallback<T, E> { (err: E | undefined, results: Dictionary<T | undefined>): void; }
export interface AsyncFunction<T, E> { (callback: (err?: E, result?: T) => void): void; }
export interface AsyncFunctionEx<T, E> { (callback: (err?: E, ...results: T[]) => void): void; }
export interface AsyncIterator<T, E> { (item: T, callback: ErrorCallback<E>): void; }
export interface AsyncForEachOfIterator<T, E> { (item: T, key: number|string, callback: ErrorCallback<E>): void; }
export interface AsyncResultIterator<T, R, E> { (item: T, callback: AsyncResultCallback<R, E>): void; }
@@ -174,9 +175,9 @@ export function parallel<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, callback?
export function parallelLimit<T, E>(tasks: Array<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultArrayCallback<T, E>): void;
export function parallelLimit<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultObjectCallback<T, E>): void;
export function whilst<E>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doWhilst<E>(fn: AsyncVoidFunction<E>, test: () => boolean, callback: ErrorCallback<E>): void;
export function doWhilst<T, E>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
export function until<E>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doUntil<E>(fn: AsyncVoidFunction<E>, test: () => boolean, callback: ErrorCallback<E>): void;
export function doUntil<T, E>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
export function during<E>(test: (testCallback : AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doDuring<E>(fn: AsyncVoidFunction<E>, test: (testCallback: AsyncBooleanResultCallback<E>) => void, callback: ErrorCallback<E>): void;
export function forever<E>(next: (next : ErrorCallback<E>) => void, errBack: ErrorCallback<E>) : void;
+4 -4
View File
@@ -47,13 +47,13 @@ interface NumberCallback { (err?: Error, result?: number): void; }
interface AsyncNumberGetter { (callback: NumberCallback): void; }
var taskDict: Lookup<AsyncNumberGetter> = {
one: function(callback){
setTimeout(function(){
one: function(callback) {
setTimeout(function() {
callback(undefined, 1);
}, 200);
},
two: function(callback){
setTimeout(function(){
two: function(callback) {
setTimeout(function() {
callback(undefined, 2);
}, 100);
}
+4 -4
View File
@@ -239,16 +239,16 @@ async.parallelLimit({
function whileFn(callback: any) {
count++;
setTimeout(callback, 1000);
setTimeout(() => callback(null, ++count), 1000);
}
function whileTest() { return count < 5; }
function doWhileTest(count: number) { return count < 5; }
var count = 0;
async.whilst(whileTest, whileFn, function (err) { });
async.until(whileTest, whileFn, function (err) { });
async.doWhilst(whileFn, whileTest, function (err) { });
async.doUntil(whileFn, whileTest, function (err) { });
async.doWhilst(whileFn, doWhileTest, function (err) { });
async.doUntil(whileFn, doWhileTest, function (err) { });
async.during(function (testCallback) { testCallback(new Error(), false); }, function (callback) { callback() }, function (error) { console.log(error) });
async.doDuring(function (callback) { callback() }, function (testCallback) { testCallback(new Error(), false); }, function (error) { console.log(error) });
+36 -28
View File
@@ -4,6 +4,7 @@ var anyObj: any = { abc: 123 };
var num: number = 5;
var error: Error = new Error();
var b: boolean = true;
var apiGwEvtReqCtx: AWSLambda.APIGatewayEventRequestContext;
var apiGwEvt: AWSLambda.APIGatewayEvent;
var customAuthorizerEvt: AWSLambda.CustomAuthorizerEvent;
var clientCtx: AWSLambda.ClientContext;
@@ -22,33 +23,33 @@ var snsEvtRec: AWSLambda.SNSEventRecord;
var snsMsg: AWSLambda.SNSMessage;
var snsMsgAttr: AWSLambda.SNSMessageAttribute;
var snsMsgAttrs: AWSLambda.SNSMessageAttributes;
var S3EvtRec: AWSLambda.S3EventRecord = {
var S3EvtRec: AWSLambda.S3EventRecord = {
eventVersion: '2.0',
eventSource: 'aws:s3',
awsRegion: 'us-east-1',
eventTime: '1970-01-01T00:00:00.000Z',
eventName: 'ObjectCreated:Put',
userIdentity: {
userIdentity: {
principalId: 'AIDAJDPLRKLG7UEXAMPLE'
},
requestParameters:{
requestParameters:{
sourceIPAddress: '127.0.0.1'
},
responseElements: {
responseElements: {
'x-amz-request-id': 'C3D13FE58DE4C810',
'x-amz-id-2': 'FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD'
},
s3: {
s3: {
s3SchemaVersion: '1.0',
configurationId: 'testConfigRule',
bucket: {
bucket: {
name: 'mybucket',
ownerIdentity: {
ownerIdentity: {
principalId: 'A3NL1KOZZKExample'
},
arn: 'arn:aws:s3:::mybucket'
},
object: {
object: {
key: 'HappyFace.jpg',
size: 1024,
eTag: 'd41d8cd98f00b204e9800998ecf8427e',
@@ -65,6 +66,27 @@ var cognitoUserPoolEvent: AWSLambda.CognitoUserPoolEvent;
var cloudformationCustomResourceEvent: AWSLambda.CloudFormationCustomResourceEvent;
var cloudformationCustomResourceResponse: AWSLambda.CloudFormationCustomResourceResponse;
/* API Gateway Event request context */
str = apiGwEvtReqCtx.accountId;
str = apiGwEvtReqCtx.apiId;
str = apiGwEvtReqCtx.httpMethod;
str = apiGwEvtReqCtx.identity.accessKey;
str = apiGwEvtReqCtx.identity.accountId;
str = apiGwEvtReqCtx.identity.apiKey;
str = apiGwEvtReqCtx.identity.caller;
str = apiGwEvtReqCtx.identity.cognitoAuthenticationProvider;
str = apiGwEvtReqCtx.identity.cognitoAuthenticationType;
str = apiGwEvtReqCtx.identity.cognitoIdentityId;
str = apiGwEvtReqCtx.identity.cognitoIdentityPoolId;
str = apiGwEvtReqCtx.identity.sourceIp;
str = apiGwEvtReqCtx.identity.user;
str = apiGwEvtReqCtx.identity.userAgent;
str = apiGwEvtReqCtx.identity.userArn;
str = apiGwEvtReqCtx.stage;
str = apiGwEvtReqCtx.requestId;
str = apiGwEvtReqCtx.resourceId;
str = apiGwEvtReqCtx.resourcePath;
/* API Gateway Event */
str = apiGwEvt.body;
str = apiGwEvt.headers["example"];
@@ -74,31 +96,17 @@ 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;
apiGwEvtReqCtx = apiGwEvt.requestContext;
str = apiGwEvt.resource;
/* API Gateway CustomAuthorizer Event */
str = customAuthorizerEvt.type;
str = customAuthorizerEvt.authorizationToken;
str = customAuthorizerEvt.methodArn;
str = customAuthorizerEvt.authorizationToken;
str = apiGwEvt.pathParameters["example"];
str = apiGwEvt.queryStringParameters["example"];
str = apiGwEvt.stageVariables["example"];
apiGwEvtReqCtx = apiGwEvt.requestContext;
/* SNS Event */
snsEvtRecs = snsEvt.Records;
+32 -24
View File
@@ -8,9 +8,35 @@
// Yoriki Yamaguchi <https://github.com/y13i>
// wwwy3y3 <https://github.com/wwwy3y3>
// Ishaan Malhi <https://github.com/OrthoDex>
// Daniel Cottone <https://github.com/daniel-cottone>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// API Gateway "event" request context
interface APIGatewayEventRequestContext {
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;
}
// API Gateway "event"
interface APIGatewayEvent {
body: string | null;
@@ -21,37 +47,19 @@ interface APIGatewayEvent {
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;
};
requestContext: APIGatewayEventRequestContext;
resource: string;
}
// API Gateway CustomAuthorizer "event"
interface CustomAuthorizerEvent {
type: string;
authorizationToken: string;
methodArn: string;
authorizationToken?: string;
headers?: { [name: string]: string };
pathParameters?: { [name: string]: string } | null;
queryStringParameters?: { [name: string]: string } | null;
requestContext?: APIGatewayEventRequestContext;
}
// SNS "event"
+1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/awslabs/aws-serverless-express
// Definitions by: Ben Speakman <https://github.com/threesquared>, Josh Caffey <https://github.com/jcaffey>, Matthias Meyer <https://github.com/mattmeye>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node"/>
import * as http from 'http';
@@ -0,0 +1,95 @@
import { Parser } from "binary-parser";
// Build an IP packet header Parser
const ipHeader = new Parser()
.endianess('big')
.bit4('version')
.bit4('headerLength')
.uint8('tos')
.uint16('packetLength')
.uint16('id')
.bit3('offset')
.bit13('fragOffset')
.uint8('ttl')
.uint8('protocol')
.uint16('checksum')
.array('src', {
type: 'uint8',
length: 4
})
.array('dst', {
type: 'uint8',
length: 4
});
// Prepare buffer to parse.
const buf = new Buffer('450002c5939900002c06ef98adc24f6c850186d1', 'hex');
// Parse buffer and show result
ipHeader.parse(buf);
const parser2 = new Parser()
// Signed 32-bit integer (little endian)
.int32le('a')
// Unsigned 8-bit integer
.uint8('b')
// Signed 16-bit integer (big endian)
.int16be('c');
const parser3 = new Parser()
// 32-bit floating value (big endian)
.floatbe('a')
// 64-bit floating value (little endian)
.doublele('b');
const parser4 = new Parser()
// Statically sized array
.array('data', {
type: 'int32',
length: 8
})
// Dynamically sized array (references another variable)
.uint8('dataLength')
.array('data2', {
type: 'int32',
length: 'dataLength'
})
// Dynamically sized array (with some calculation)
.array('data3', {
type: 'int32',
length: () => 4 // other fields are available through this
})
// Statically sized array
.array('data4', {
type: 'int32',
lengthInBytes: 16
})
// Dynamically sized array (references another variable)
.uint8('dataLengthInBytes')
.array('data5', {
type: 'int32',
lengthInBytes: 'dataLengthInBytes'
})
// Dynamically sized array (with some calculation)
.array('data6', {
type: 'int32',
lengthInBytes: () => 4, // other fields are available through this
})
// Dynamically sized array (with stop-check on parsed item)
.array('data7', {
type: 'int32',
readUntil: (item, buffer) => true // stop when specific item is parsed. buffer can be used to perform a read-ahead.
});
const parser5 = new Parser()
.array('ipv4', {
type: 'uint8',
length: '4',
formatter: (arr) => { }
});
+147
View File
@@ -0,0 +1,147 @@
// Type definitions for binary-parser 1.3
// Project: https://github.com/keichi/binary-parser
// Definitions by: Benjamin Riggs <https://github.com/riggs>, Dolan Miu <https://github.com/dolanmiu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export interface Parser {
parse(buffer: Buffer, callback?: (err?: Error, result?: any) => void): Parser.Parsed;
create(constructorFunction: ObjectConstructor): Parser;
int8(name: string, options?: Parser.Options): Parser;
uint8(name: string, options?: Parser.Options): Parser;
int16(name: string, options?: Parser.Options): Parser;
uint16(name: string, options?: Parser.Options): Parser;
int16le(name: string, options?: Parser.Options): Parser;
int16be(name: string, options?: Parser.Options): Parser;
uint16le(name: string, options?: Parser.Options): Parser;
uint16be(name: string, options?: Parser.Options): Parser;
int32(name: string, options?: Parser.Options): Parser;
uint32(name: string, options?: Parser.Options): Parser;
int32le(name: string, options?: Parser.Options): Parser;
int32be(name: string, options?: Parser.Options): Parser;
uint32le(name: string, options?: Parser.Options): Parser;
uint32be(name: string, options?: Parser.Options): Parser;
bit1(name: string, options?: Parser.Options): Parser;
bit2(name: string, options?: Parser.Options): Parser;
bit3(name: string, options?: Parser.Options): Parser;
bit4(name: string, options?: Parser.Options): Parser;
bit5(name: string, options?: Parser.Options): Parser;
bit6(name: string, options?: Parser.Options): Parser;
bit7(name: string, options?: Parser.Options): Parser;
bit8(name: string, options?: Parser.Options): Parser;
bit9(name: string, options?: Parser.Options): Parser;
bit10(name: string, options?: Parser.Options): Parser;
bit11(name: string, options?: Parser.Options): Parser;
bit12(name: string, options?: Parser.Options): Parser;
bit13(name: string, options?: Parser.Options): Parser;
bit14(name: string, options?: Parser.Options): Parser;
bit15(name: string, options?: Parser.Options): Parser;
bit16(name: string, options?: Parser.Options): Parser;
bit17(name: string, options?: Parser.Options): Parser;
bit18(name: string, options?: Parser.Options): Parser;
bit19(name: string, options?: Parser.Options): Parser;
bit20(name: string, options?: Parser.Options): Parser;
bit21(name: string, options?: Parser.Options): Parser;
bit22(name: string, options?: Parser.Options): Parser;
bit23(name: string, options?: Parser.Options): Parser;
bit24(name: string, options?: Parser.Options): Parser;
bit25(name: string, options?: Parser.Options): Parser;
bit26(name: string, options?: Parser.Options): Parser;
bit27(name: string, options?: Parser.Options): Parser;
bit28(name: string, options?: Parser.Options): Parser;
bit29(name: string, options?: Parser.Options): Parser;
bit30(name: string, options?: Parser.Options): Parser;
bit31(name: string, options?: Parser.Options): Parser;
bit32(name: string, options?: Parser.Options): Parser;
float(name: string, options?: Parser.Options): Parser;
floatle(name: string, options?: Parser.Options): Parser;
floatbe(name: string, options?: Parser.Options): Parser;
double(name: string, options?: Parser.Options): Parser;
doublele(name: string, options?: Parser.Options): Parser;
doublebe(name: string, options?: Parser.Options): Parser;
string(name: string, options?: Parser.StringOptions): Parser;
buffer(name: string, options: Parser.BufferOptions): Parser;
array(name: string, options: Parser.ArrayOptions): Parser;
choice(name: string, options: Parser.ChoiceOptions): Parser;
nest(name: string, options: Parser.NestOptions): Parser;
skip(length: number): Parser;
endianess(endianess: Parser.Endianness): Parser; /* [sic] */
namely(alias: string): Parser;
compile(): void;
getCode(): string;
}
export interface ParserConstructor {
new(): Parser;
}
export const Parser: ParserConstructor;
export namespace Parser {
type Data = number | string | Array<number | Parsed> | Parsed | Buffer;
interface Parsed {
[name: string]: Data;
}
interface Options {
formatter?: ((value: Data) => any);
assert?: string | number | ((value: Data) => boolean);
}
interface StringOptions extends Options {
encoding?: string;
length?: number | string | ((this: Parsed) => number);
zeroTerminated?: boolean;
greedy?: boolean;
stripNull?: boolean;
}
interface BufferOptions extends Options {
clone?: boolean;
length?: number | string | ((this: Parsed) => number);
readUntil?: string | ((item: number, buffer: Buffer) => boolean);
}
interface ArrayOptions extends Options {
type: string | Parser;
length?: number | string | ((this: Parsed) => number);
lengthInBytes?: number | string | ((this: Parsed) => number);
readUntil?: string | ((item: number, buffer: Buffer) => boolean);
}
interface ChoiceOptions extends Options {
tag: string | ((this: Parsed) => number);
choices: { [item: number]: Parser | string };
defaultChoice?: Parser | string;
}
interface NestOptions extends Options {
type: Parser | string;
}
type Endianness =
'little' |
'big';
interface Context {
[name: string]: Parsed;
}
}
@@ -2,8 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
@@ -19,6 +18,6 @@
},
"files": [
"index.d.ts",
"chalk-tests.ts"
"binary-parser-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+224 -62
View File
@@ -43,24 +43,37 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
constructor(callback: (resolve: (thenableOrResult?: R | PromiseLike<R>) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void);
/**
* Promises/A+ `.then()`. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
* Promises/A+ `.then()`. Returns a new promise chained from this promise.
*
* The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
*/
// Based on PromiseLike.then, but returns a Bluebird instance.
then<U>(onFulfill?: (value: R) => U | PromiseLike<U>, onReject?: (error: any) => U | PromiseLike<U>): Bluebird<U>; // For simpler signature help.
then<TResult1 = R, TResult2 = never>(onfulfilled?: ((value: R) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Bluebird<TResult1 | TResult2>;
then<TResult1 = R, TResult2 = never>(
onfulfilled?: ((value: R) => TResult1 | PromiseLike<TResult1>) | null,
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
): Bluebird<TResult1 | TResult2>;
/**
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise.
*
* Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
catch(onReject: (error: any) => R | PromiseLike<R>): Bluebird<R>;
catch<U>(onReject?: ((error: any) => U | PromiseLike<U>) | undefined | null): Bluebird<U | R>;
catch<U>(onReject: ((error: any) => U | PromiseLike<U>) | undefined | null): Bluebird<U | R>;
/**
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
* This extends `.catch` to work more like catch-clauses in languages like Java or C#.
*
* This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
* Instead of manually checking `instanceof` or `.name === "SomeError"`,
* you may specify a number of error constructors which are eligible for this catch handler.
* The catch handler that is first met that has eligible constructors specified, is the one that will be called.
*
* This method also supports predicate-based filters.
* If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument.
* The return result of the predicate will be used determine whether the error handler should be called.
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
@@ -190,17 +203,23 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
): Bluebird<U | R>;
/**
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise.
*
* Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
caught(onReject: (error: any) => R | PromiseLike<R>): Bluebird<R>;
caught<U>(onReject?: ((error: any) => U | PromiseLike<U>) | undefined | null): Bluebird<U | R>;
caught<U>(onReject: ((error: any) => U | PromiseLike<U>) | undefined | null): Bluebird<U | R>;
/**
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
* This extends `.catch` to work more like catch-clauses in languages like Java or C#.
*
* This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
* Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler.
* The catch handler that is first met that has eligible constructors specified, is the one that will be called.
*
* This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument.
* The return result of the predicate will be used determine whether the error handler should be called.
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
@@ -335,7 +354,9 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
error<U>(onReject: (reason: any) => U | PromiseLike<U>): Bluebird<U>;
/**
* Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
* Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise.
*
* There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
*
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
*/
@@ -344,7 +365,9 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
lastly<U>(handler: () => U | PromiseLike<U>): Bluebird<R>;
/**
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`.
*
* Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
*/
bind(thisArg: any): Bluebird<R>;
@@ -409,7 +432,11 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
timeout(ms: number, message?: string | Error): Bluebird<R>;
/**
* Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
* Register a node-style callback on this promise.
*
* When this promise is is either fulfilled or rejected,
* the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument.
* The error argument will be `null` in case of success.
* If the `callback` argument is not a function, this method does not do anything.
*/
nodeify(callback: (err: any, value?: R) => void, options?: Bluebird.SpreadOption): this;
@@ -694,7 +721,8 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
/**
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
*
* Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call.
* Note about second argument: if it's specifically a true array, its values become respective arguments for the function call.
* Otherwise it is passed as is as the first argument for the function call.
*
* Alias for `attempt();` for compatibility with earlier ECMAScript version.
*/
@@ -702,7 +730,8 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
static attempt<R>(fn: () => R | PromiseLike<R>): Bluebird<R>;
/**
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
* Returns a new function that wraps the given function `fn`.
* The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
* This method is convenient when a function can sometimes return synchronously or throw synchronously.
*/
static method<R, A1>(fn: (arg1: A1) => R | PromiseLike<R>): (arg1: A1) => Bluebird<R>;
@@ -729,7 +758,10 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
static defer<R>(): Bluebird.Resolver<R>;
/**
* Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable.
* Cast the given `value` to a trusted promise.
*
* If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value.
* If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable.
*/
static cast<R>(value: R | PromiseLike<R>): Bluebird<R>;
@@ -744,7 +776,10 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
static is(value: any): boolean;
/**
* Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have already been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
* Call this right after the library is loaded to enabled long stack traces.
*
* Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have already been created.
* Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
*/
static longStackTraces(): void;
@@ -757,24 +792,49 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
static delay(ms: number): Bluebird<void>;
/**
* Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.
* Returns a function that will wrap the given `nodeFunction`.
*
* Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function.
* The node function should conform to node.js convention of accepting a callback as last argument and
* calling that callback with error as the first argument and success value on the second argument.
*
* If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them.
*
* If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
*/
static promisify<T>(func: (callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): () => Bluebird<T>;
static promisify<T, A1>(func: (arg1: A1, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1) => Bluebird<T>;
static promisify<T, A1, A2>(func: (arg1: A1, arg2: A2, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2) => Bluebird<T>;
static promisify<T, A1, A2, A3>(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3) => Bluebird<T>;
static promisify<T, A1, A2, A3, A4>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird<T>;
static promisify<T, A1, A2, A3, A4, A5>(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird<T>;
static promisify<T>(
func: (callback: (err: any, result?: T) => void) => void,
options?: Bluebird.PromisifyOptions
): () => Bluebird<T>;
static promisify<T, A1>(
func: (arg1: A1, callback: (err: any, result?: T) => void) => void,
options?: Bluebird.PromisifyOptions
): (arg1: A1) => Bluebird<T>;
static promisify<T, A1, A2>(
func: (arg1: A1, arg2: A2, callback: (err: any, result?: T) => void) => void,
options?: Bluebird.PromisifyOptions
): (arg1: A1, arg2: A2) => Bluebird<T>;
static promisify<T, A1, A2, A3>(
func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result?: T) => void) => void,
options?: Bluebird.PromisifyOptions
): (arg1: A1, arg2: A2, arg3: A3) => Bluebird<T>;
static promisify<T, A1, A2, A3, A4>(
func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result?: T) => void) => void,
options?: Bluebird.PromisifyOptions
): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird<T>;
static promisify<T, A1, A2, A3, A4, A5>(
func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result?: T) => void) => void,
options?: Bluebird.PromisifyOptions
): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird<T>;
static promisify(nodeFunction: (...args: any[]) => void, options?: Bluebird.PromisifyOptions): (...args: any[]) => Bluebird<any>;
/**
* Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
* Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain.
*
* Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
* The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
*
* Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example,
* if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
*/
// TODO how to model promisifyAll?
static promisifyAll<T extends object>(target: T, options?: Bluebird.PromisifyAllOptions<T>): T;
@@ -788,19 +848,49 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
static fromCallback<T>(resolver: (callback: (err: any, result?: T) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird<T>;
/**
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
* Returns a function that can use `yield` to run asynchronous code synchronously.
*
* This feature requires the support of generators which are drafted in the next version of the language.
* Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
*/
// TODO: After https://github.com/Microsoft/TypeScript/issues/2983 is implemented, we can use
// the return type propagation of generators to automatically infer the return type T.
static coroutine<T>(generatorFunction: () => IterableIterator<any>, options?: Bluebird.CoroutineOptions): () => Bluebird<T>;
static coroutine<T, A1>(generatorFunction: (a1: A1) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1) => Bluebird<T>;
static coroutine<T, A1, A2>(generatorFunction: (a1: A1, a2: A2) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2) => Bluebird<T>;
static coroutine<T, A1, A2, A3>(generatorFunction: (a1: A1, a2: A2, a3: A3) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4>(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5>(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5, A6>(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5, A6, A7>(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5, A6, A7, A8>(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => IterableIterator<any>, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => Bluebird<T>;
static coroutine<T>(
generatorFunction: () => IterableIterator<any>,
options?: Bluebird.CoroutineOptions
): () => Bluebird<T>;
static coroutine<T, A1>(
generatorFunction: (a1: A1) => IterableIterator<any>,
options?: Bluebird.CoroutineOptions
): (a1: A1) => Bluebird<T>;
static coroutine<T, A1, A2>(
generatorFunction: (a1: A1, a2: A2) => IterableIterator<any>,
options?: Bluebird.CoroutineOptions
): (a1: A1, a2: A2) => Bluebird<T>;
static coroutine<T, A1, A2, A3>(
generatorFunction: (a1: A1, a2: A2, a3: A3) => IterableIterator<any>,
options?: Bluebird.CoroutineOptions
): (a1: A1, a2: A2, a3: A3) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4>(
generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4) => IterableIterator<any>,
options?: Bluebird.CoroutineOptions
): (a1: A1, a2: A2, a3: A3, a4: A4) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5>(
generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => IterableIterator<any>,
options?: Bluebird.CoroutineOptions
): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5, A6>(
generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => IterableIterator<any>,
options?: Bluebird.CoroutineOptions
): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5, A6, A7>(
generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => IterableIterator<any>,
options?: Bluebird.CoroutineOptions
): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => Bluebird<T>;
static coroutine<T, A1, A2, A3, A4, A5, A6, A7, A8>(
generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => IterableIterator<any>,
options?: Bluebird.CoroutineOptions
): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => Bluebird<T>;
/**
* Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
@@ -820,7 +910,9 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
static onPossiblyUnhandledRejection(handler?: (error: Error, promise: Bluebird<any>) => void): void;
/**
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled.
* The promise's fulfillment value is an array with fulfillment values at respective positions to the original array.
* If any promise in the array rejects, the returned promise is rejected with the rejection reason.
*/
// TODO enable more overloads
// array with promises of different types
@@ -833,9 +925,13 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
static all<R>(values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>): Bluebird<R[]>;
/**
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled.
*
* If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
* The promise's fulfillment value is an object with fulfillment values at respective keys to the original object.
* If any promise in the object rejects, the returned promise is rejected with the rejection reason.
*
* If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties.
* All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
*
* *The original object is not modified.*
*/
@@ -859,7 +955,8 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
static race<R>(values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>): Bluebird<R>;
/**
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises).
* When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
*
* If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in.
*
@@ -874,60 +971,112 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
* ) -> Promise
* For coordinating multiple concurrent discrete promises.
*
* Note: In 1.x and 0.x Promise.join used to be a Promise.all that took the values in as arguments instead in an array. This behavior has been deprecated but is still supported partially - when the last argument is an immediate function value the new semantics will apply
* Note: In 1.x and 0.x Promise.join used to be a Promise.all that took the values in as arguments instead in an array.
* This behavior has been deprecated but is still supported partially - when the last argument is an immediate function value the new semantics will apply
*/
static join<R, A1>(arg1: A1 | PromiseLike<A1>, handler: (arg1: A1) => R | PromiseLike<R>): Bluebird<R>;
static join<R, A1, A2>(arg1: A1 | PromiseLike<A1>, arg2: A2 | PromiseLike<A2>, handler: (arg1: A1, arg2: A2) => R | PromiseLike<R>): Bluebird<R>;
static join<R, A1, A2, A3>(arg1: A1 | PromiseLike<A1>, arg2: A2 | PromiseLike<A2>, arg3: A3 | PromiseLike<A3>, handler: (arg1: A1, arg2: A2, arg3: A3) => R | PromiseLike<R>): Bluebird<R>;
static join<R, A1, A2, A3, A4>(arg1: A1 | PromiseLike<A1>, arg2: A2 | PromiseLike<A2>, arg3: A3 | PromiseLike<A3>, arg4: A4 | PromiseLike<A4>, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | PromiseLike<R>): Bluebird<R>;
static join<R, A1, A2, A3, A4, A5>(arg1: A1 | PromiseLike<A1>, arg2: A2 | PromiseLike<A2>, arg3: A3 | PromiseLike<A3>, arg4: A4 | PromiseLike<A4>, arg5: A5 | PromiseLike<A5>, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | PromiseLike<R>): Bluebird<R>;
static join<R, A1>(
arg1: A1 | PromiseLike<A1>,
handler: (arg1: A1) => R | PromiseLike<R>
): Bluebird<R>;
static join<R, A1, A2>(
arg1: A1 | PromiseLike<A1>,
arg2: A2 | PromiseLike<A2>,
handler: (arg1: A1, arg2: A2) => R | PromiseLike<R>
): Bluebird<R>;
static join<R, A1, A2, A3>(
arg1: A1 | PromiseLike<A1>,
arg2: A2 | PromiseLike<A2>,
arg3: A3 | PromiseLike<A3>,
handler: (arg1: A1, arg2: A2, arg3: A3) => R | PromiseLike<R>
): Bluebird<R>;
static join<R, A1, A2, A3, A4>(
arg1: A1 | PromiseLike<A1>,
arg2: A2 | PromiseLike<A2>,
arg3: A3 | PromiseLike<A3>,
arg4: A4 | PromiseLike<A4>,
handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | PromiseLike<R>
): Bluebird<R>;
static join<R, A1, A2, A3, A4, A5>(
arg1: A1 | PromiseLike<A1>,
arg2: A2 | PromiseLike<A2>,
arg3: A3 | PromiseLike<A3>,
arg4: A4 | PromiseLike<A4>,
arg5: A5 | PromiseLike<A5>,
handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | PromiseLike<R>
): Bluebird<R>;
// variadic array
/** @deprecated use .all instead */
static join<R>(...values: Array<R | PromiseLike<R>>): Bluebird<R[]>;
/**
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array.
* If any promise in the input array is rejected the returned promise is rejected as well.
*
* If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
*
* *The original array is not modified.*
*/
static map<R, U>(values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
static map<R, U>(
values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>,
mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>,
options?: Bluebird.ConcurrencyOption
): Bluebird<U[]>;
/**
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array.
* If any promise in the input array is rejected the returned promise is rejected as well.
*
* If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
*
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned.
* If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
*/
static reduce<R, U>(values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
static reduce<R, U>(
values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>,
reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>,
initialValue?: U
): Bluebird<U>;
/**
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array.
* If any promise in the input array is rejected the returned promise is rejected as well.
*
* The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.
*
* *The original array is not modified.
*/
static filter<R>(values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
static filter<R>(
values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>,
filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>,
option?: Bluebird.ConcurrencyOption
): Bluebird<R[]>;
/**
* Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.
* Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array.
* Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.
*
* Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
* Resolves to the original array unmodified, this method is meant to be used for side effects.
* If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
*/
static each<R, U>(values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<R[]>;
static each<R, U>(
values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>,
iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>
): Bluebird<R[]>;
/**
* Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values), iterate over all the values in the Iterable into an array and iterate over the array serially, in-order.
*
* Returns a promise for an array that contains the values returned by the iterator function in their respective positions. The iterator won't be called for an item until its previous item, and the promise returned by the iterator for that item are fulfilled. This results in a mapSeries kind of utility but it can also be used simply as a side effect iterator similar to Array#forEach.
* Returns a promise for an array that contains the values returned by the iterator function in their respective positions.
* The iterator won't be called for an item until its previous item, and the promise returned by the iterator for that item are fulfilled.
* This results in a mapSeries kind of utility but it can also be used simply as a side effect iterator similar to Array#forEach.
*
* If any promise in the input array is rejected or any promise returned by the iterator function is rejected, the result will be rejected as well.
*/
static mapSeries<R, U>(values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<U[]>;
static mapSeries<R, U>(
values: PromiseLike<Iterable<PromiseLike<R> | R>> | Iterable<PromiseLike<R> | R>,
iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>
): Bluebird<U[]>;
/**
* A meta method used to specify the disposer method that cleans up a resource when using `Promise.using`.
@@ -946,9 +1095,21 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
* will be called when the promise returned by the callback passed to using has settled. The disposer is
* necessary because there is no standard interface in node for disposing resources.
*/
static using<R, T>(disposer: Bluebird.Disposer<R>, executor: (transaction: R) => PromiseLike<T>): Bluebird<T>;
static using<R1, R2, T>(disposer: Bluebird.Disposer<R1>, disposer2: Bluebird.Disposer<R2>, executor: (transaction1: R1, transaction2: R2) => PromiseLike<T>): Bluebird<T>;
static using<R1, R2, R3, T>(disposer: Bluebird.Disposer<R1>, disposer2: Bluebird.Disposer<R2>, disposer3: Bluebird.Disposer<R3>, executor: (transaction1: R1, transaction2: R2, transaction3: R3) => PromiseLike<T>): Bluebird<T>;
static using<R, T>(
disposer: Bluebird.Disposer<R>,
executor: (transaction: R) => PromiseLike<T>
): Bluebird<T>;
static using<R1, R2, T>(
disposer: Bluebird.Disposer<R1>,
disposer2: Bluebird.Disposer<R2>,
executor: (transaction1: R1, transaction2: R2
) => PromiseLike<T>): Bluebird<T>;
static using<R1, R2, R3, T>(
disposer: Bluebird.Disposer<R1>,
disposer2: Bluebird.Disposer<R2>,
disposer3: Bluebird.Disposer<R3>,
executor: (transaction1: R1, transaction2: R2, transaction3: R3) => PromiseLike<T>
): Bluebird<T>;
/**
* Configure long stack traces, warnings, monitoring and cancellation.
@@ -1083,7 +1244,8 @@ declare namespace Bluebird {
reject(reason: any): void;
/**
* Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
* Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property.
* The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
*
* If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values.
*/
+1 -2
View File
@@ -1,8 +1,7 @@
{
"extends": "dtslint/dt.json",
"rules": {
"max-line-length": [true, 490],
"no-redundant-undefined": false,
"max-line-length": [true, 280],
"no-unnecessary-generics": false,
"prefer-const": false
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/expressjs/body-parser
// Definitions by: Santi Albo <https://github.com/santialbo>, Vilic Vane <https://github.com/vilic>, Jonathan Häberle <https://github.com/dreampulse>, Gevik Babakhani <https://github.com/blendsdk>, Tomasz Łaziuk <https://github.com/tlaziuk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.1
/// <reference types="node" />
-42
View File
@@ -1,42 +0,0 @@
import chalk = require('chalk');
var str = '';
var bool = false;
var chain: chalk.ChalkChain;
chalk.enabled = bool;
str = chalk.stripColor(str);
bool = chalk.supportsColor;
bool = chalk.hasColor(str);
// style a string
console.log( chalk.blue('Hello world!') );
// combine styled and normal strings
console.log( chalk.blue('Hello'), 'World' + chalk.red('!') );
// compose multiple styles using the chainable API
console.log( chalk.blue.bgRed.bold('Hello world!') );
// pass in multiple arguments
console.log( chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz') );
// nest styles
console.log( chalk.red('Hello', chalk.underline.bgBlue('world') + '!') );
// nest styles of the same type even (color, underline, background)
console.log( chalk.green('I am a green line ' + chalk.blue('with a blue substring') + ' that becomes green again!') );
chain = chalk.green;
chain = chain.underline;
str = chain('someString');
chalk.enabled = chalk.supportsColor = bool;
var chalkObj = new chalk.constructor({enabled: false});
chain = chalkObj.green;
chain = chalkObj.underline;
chalkObj.enabled = true;
str = chain('foo');
-133
View File
@@ -1,133 +0,0 @@
// Type definitions for chalk v0.4.0
// Project: https://github.com/sindresorhus/chalk
// Definitions by: Diullei Gomes <https://github.com/Diullei>, Bart van der Schoor <https://github.com/Bartvds>, Nico Jansen <https://github.com/nicojs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = Chalk;
declare namespace Chalk {
export var enabled: boolean;
export var supportsColor: boolean;
export var styles: ChalkStyleMap;
export function stripColor(value: string): any;
export function hasColor(str: string): boolean;
export interface ChalkChain extends ChalkStyle {
(): boolean;
(...text: string[]): string;
}
export interface ChalkStyleElement {
open: string;
close: string;
}
// General
export var reset: ChalkChain;
export var bold: ChalkChain;
export var dim: ChalkChain;
export var italic: ChalkChain;
export var underline: ChalkChain;
export var inverse: ChalkChain;
export var hidden: ChalkChain;
export var strikethrough: ChalkChain;
// Text colors
export var black: ChalkChain;
export var red: ChalkChain;
export var green: ChalkChain;
export var yellow: ChalkChain;
export var blue: ChalkChain;
export var magenta: ChalkChain;
export var cyan: ChalkChain;
export var white: ChalkChain;
export var gray: ChalkChain;
export var grey: ChalkChain;
// Background colors
export var bgBlack: ChalkChain;
export var bgRed: ChalkChain;
export var bgGreen: ChalkChain;
export var bgYellow: ChalkChain;
export var bgBlue: ChalkChain;
export var bgMagenta: ChalkChain;
export var bgCyan: ChalkChain;
export var bgWhite: ChalkChain;
export interface ChalkStyle {
// General
reset: ChalkChain;
bold: ChalkChain;
dim: ChalkChain;
italic: ChalkChain;
underline: ChalkChain;
inverse: ChalkChain;
hidden: ChalkChain;
strikethrough: ChalkChain;
// Text colors
black: ChalkChain;
red: ChalkChain;
green: ChalkChain;
yellow: ChalkChain;
blue: ChalkChain;
magenta: ChalkChain;
cyan: ChalkChain;
white: ChalkChain;
gray: ChalkChain;
grey: ChalkChain;
// Background colors
bgBlack: ChalkChain;
bgRed: ChalkChain;
bgGreen: ChalkChain;
bgYellow: ChalkChain;
bgBlue: ChalkChain;
bgMagenta: ChalkChain;
bgCyan: ChalkChain;
bgWhite: ChalkChain;
}
export interface ChalkStyleMap {
// General
reset: ChalkStyleElement;
bold: ChalkStyleElement;
dim: ChalkStyleElement;
italic: ChalkStyleElement;
underline: ChalkStyleElement;
inverse: ChalkStyleElement;
hidden: ChalkStyleElement;
strikethrough: ChalkStyleElement;
// Text colors
black: ChalkStyleElement;
red: ChalkStyleElement;
green: ChalkStyleElement;
yellow: ChalkStyleElement;
blue: ChalkStyleElement;
magenta: ChalkStyleElement;
cyan: ChalkStyleElement;
white: ChalkStyleElement;
gray: ChalkStyleElement;
// Background colors
bgBlack: ChalkStyleElement;
bgRed: ChalkStyleElement;
bgGreen: ChalkStyleElement;
bgYellow: ChalkStyleElement;
bgBlue: ChalkStyleElement;
bgMagenta: ChalkStyleElement;
bgCyan: ChalkStyleElement;
bgWhite: ChalkStyleElement;
}
export const constructor: {
new (options: {enabled: boolean}): Chalk;
}
export interface Chalk extends ChalkStyle {
enabled: boolean;
}
}
-79
View File
@@ -1,79 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
}
}
+1 -1
View File
@@ -154,7 +154,7 @@ declare namespace Chart {
responsiveAnimationDuration?: number;
maintainAspectRatio?: boolean;
events?: string[];
onClick?(any?: any): any;
onClick?(event?: MouseEvent, activeElements?: Array<{}>): any;
title?: ChartTitleOptions;
legend?: ChartLegendOptions;
tooltips?: ChartTooltipOptions;
+2 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for Cheerio v0.22.0
// Project: https://github.com/cheeriojs/cheerio
// Definitions by: Bret Little <https://github.com/blittle>, VILIC VANE <http://vilic.info>, Wayne Maurer <https://github.com/wmaurer>, Umar Nizamani <https://github.com/umarniz>
// Definitions by: Bret Little <https://github.com/blittle>, VILIC VANE <http://vilic.info>, Wayne Maurer <https://github.com/wmaurer>, Umar Nizamani <https://github.com/umarniz>, LiJinyao <https://github.com/LiJinyao>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Cheerio {
@@ -255,6 +255,7 @@ interface CheerioElement {
children: CheerioElement[];
childNodes: CheerioElement[];
lastChild: CheerioElement;
firstChild: CheerioElement;
next: CheerioElement;
nextSibling: CheerioElement;
prev: CheerioElement;
+15 -3
View File
@@ -1426,8 +1426,7 @@ declare namespace chrome.declarativeContent {
ports?: (number | number[])[];
}
/** Matches the state of a web page by various criteria. */
interface PageStateMatcher {
class PageStateMatcherProperties {
/** Optional. Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */
pageUrl?: PageStateUrlDetails;
/** Optional. Matches if all of the CSS selectors in the array match displayed elements in a frame with the same origin as the page's main frame. All selectors in this array must be compound selectors to speed up matching. Note that listing hundreds of CSS selectors or CSS selectors that match hundreds of times per page can still slow down web sites. */
@@ -1439,6 +1438,19 @@ declare namespace chrome.declarativeContent {
*/
isBookmarked?: boolean;
}
/** Matches the state of a web page by various criteria. */
class PageStateMatcher {
constructor(options: PageStateMatcherProperties);
}
/** Declarative event action that shows the extension's page action while the corresponding conditions are met. */
class ShowPageAction {}
/** Provides the Declarative Event API consisting of addRules, removeRules, and getRules. */
interface PageChangedEvent extends chrome.events.Event<() => void> {}
var onPageChanged: PageChangedEvent;
}
////////////////////
@@ -5126,7 +5138,7 @@ declare namespace chrome.runtime {
actions?: {
type: string;
}[];
conditions?: chrome.declarativeContent.PageStateMatcher[]
conditions?: chrome.declarativeContent.PageStateMatcherProperties[]
}[];
externally_connectable?: {
ids?: string[];
+17
View File
@@ -52,6 +52,23 @@ function test_config() {
[ 'list', 'indent', 'blocks', 'align', 'bidi' ],
],
};
var config3: CKEDITOR.config = {
toolbarGroups: [
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
{ name: 'links', groups: [ 'links' ] },
{ name: 'insert', groups: [ 'insert' ] },
{ name: 'tools', groups: [ 'tools' ] },
{ name: 'document', groups: [ 'mode' ] },
{ name: 'about', groups: [ 'about' ] },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'paragraph' ] },
'/',
{ name: 'styles', groups: [ 'styles' ] },
{ name: 'colors', groups: [ 'colors' ] },
],
}
}
function test_dom_comment() {
+2 -1
View File
@@ -1,6 +1,7 @@
// Type definitions for CKEditor
// Project: http://ckeditor.com/
// Definitions by: Ondrej Sevcik <https://github.com/ondrejsevcik>
// Thomas Wittwer <https://github.com/wittwert>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// WORK-IN-PROGRESS: Any contribution support welcomed.
@@ -814,7 +815,7 @@ declare namespace CKEDITOR {
toolbar?: string | (string | string[])[];
toolbarCanCollapse?: boolean;
toolbarGroupCycling?: boolean;
toolbarGroups?: toolbarGroups[];
toolbarGroups?: (toolbarGroups | string)[];
toolbarLocation?: string;
toolbarStartupExpanded?: boolean;
+1
View File
@@ -4,6 +4,7 @@
// jKey Lu <https://github.com/jkeylu>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
import { IncomingMessage, ServerResponse } from 'http';
+3 -2
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/Foliotek/Croppie
// Definitions by: Connor Peet <https://github.com/connor4312>
// dklmuc <https://github.com/dklmuc>
// Sarun Intaralawan <https://github.com/sarunint>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export default class Croppie {
@@ -15,10 +16,10 @@ export default class Croppie {
useCanvas?: boolean,
}): Promise<void>;
result(options: ResultOptions & { type: 'base64' }): Promise<string>;
result(options: ResultOptions & { type: 'base64' | 'canvas' }): Promise<string>;
result(options: ResultOptions & { type: 'html' }): Promise<HTMLElement>;
result(options: ResultOptions & { type: 'blob' }): Promise<Blob>;
result(options: ResultOptions & { type: 'canvas' }): Promise<HTMLCanvasElement>;
result(options: ResultOptions & { type: 'rawcanvas' }): Promise<HTMLCanvasElement>;
result(options?: ResultOptions): Promise<HTMLCanvasElement>;
rotate(degrees: 90 | 180 | 270 | -90 | -180 | -270): void;
+4 -4
View File
@@ -118,10 +118,10 @@ var types = paymentCountByType.all();
paymentsByTotal.dispose();
crossfilter.bisect([], null, 0, 0);
var bisectBy = crossfilter.bisect.by(t => t);
bisectBy([], null, 0, 0);
bisectBy.left([], null, 0, 0);
bisectBy.right([], null, 0, 0);
var bisectBy = crossfilter.bisect.by<{value: string}, string>(t => t.value);
bisectBy([{value: 'a'}, {value: 'b'}], 'c', 0, 0); // 2
bisectBy.left([], 'string', 0, 0); // 0
bisectBy.right([], 'string', 0, 0); // 0
crossfilter.heap([], 0, 0);
var heapBy = crossfilter.heap.by(t => t);
+7 -7
View File
@@ -1,6 +1,6 @@
// Type definitions for CrossFilter
// Project: https://github.com/square/crossfilter
// Definitions by: Schmulik Raskin <https://github.com/schmuli>, Izaak Baker <https://github.com/iebaker>
// Definitions by: Schmulik Raskin <https://github.com/schmuli>, Izaak Baker <https://github.com/iebaker>, Einar Norðfjörð <https://github.com/nordfjord>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace CrossFilter {
@@ -15,7 +15,7 @@ declare namespace CrossFilter {
permute<T>(array: T[], index: number[]): T[];
bisect: {
<T>(array: T[], value: T, lo: number, hi: number): number;
by<T>(value: Selector<T>): Bisector<T>;
by<T,U>(accessor: (x: T)=> U): Bisector<T,U>;
}
heap: {
<T>(array: T[], lo: number, hi: number): T[];
@@ -36,13 +36,13 @@ declare namespace CrossFilter {
}
}
export interface Bisection<T> {
(array: T[], value: T, lo: number, hi: number): number;
export interface Bisection<T,U> {
(array: T[], value: U, lo: number, hi: number): number;
}
export interface Bisector<T> extends Bisection<T> {
left: Bisection<T>
right: Bisection<T>
export interface Bisector<T,U> extends Bisection<T,U> {
left: Bisection<T,U>
right: Bisection<T,U>
}
export interface Heap<T> {
+1 -1
View File
@@ -569,7 +569,7 @@ export interface Transition<GElement extends BaseType, Datum, PElement extends B
*
* @param name Name of the transition.
*/
export function transition<OldDatum>(name: string): Transition<HTMLElement, OldDatum, null, undefined>;
export function transition<OldDatum>(name?: string): Transition<HTMLElement, OldDatum, null, undefined>;
/**
* Returns a new transition from an existing transition.
+20
View File
@@ -121,6 +121,26 @@ let svgZoom: d3Zoom.ZoomBehavior<SVGRectElement, SVGDatum>;
svgZoom = d3Zoom.zoom<SVGRectElement, SVGDatum>();
// constrain() -------------------------------------------------------------
// chainable
svgZoom = svgZoom.constrain((transform, extent, translateExtent) => {
const t: d3Zoom.ZoomTransform = transform;
const ve: [[number, number], [number, number]] = extent;
const te: [[number, number], [number, number]] = translateExtent;
const dx0 = t.invertX(ve[0][0]) - te[0][0];
const dx1 = t.invertX(ve[1][0]) - te[1][0];
const dy0 = transform.invertY(ve[0][1]) - te[0][1];
const dy1 = transform.invertY(ve[1][1]) - te[1][1];
return t.translate(
dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
);
});
let constraintFn: (transform: d3Zoom.ZoomTransform, extent: [[number, number], [number, number]], translateExtent: [[number, number], [number, number]]) => d3Zoom.ZoomTransform;
constraintFn = svgZoom.constrain();
// filter() ----------------------------------------------------------------
// chainable
+16 -3
View File
@@ -1,9 +1,9 @@
// Type definitions for d3JS d3-zoom module 1.6
// Type definitions for d3JS d3-zoom module 1.7
// Project: https://github.com/d3/d3-zoom/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 1.6.0
// Last module patch version validated against: 1.7.0
import { ArrayLike, Selection, TransitionLike, ValueFn } from 'd3-selection';
import { ZoomView, ZoomInterpolator } from 'd3-interpolate';
@@ -499,6 +499,19 @@ export interface ZoomBehavior<ZoomRefElement extends ZoomedElementBaseType, Datu
*/
scaleTo(transition: TransitionLike<ZoomRefElement, Datum>, k: ValueFn<ZoomRefElement, Datum, number>): void;
/**
* Returns the current constraint function.
* The default implementation attempts to ensure that the viewport extent does not go outside the translate extent.
*/
constrain(): (transform: ZoomTransform, extent: [[number, number], [number, number]], translateExtent: [[number, number], [number, number]]) => ZoomTransform;
/**
* Sets the transform constraint function to the specified function and returns the zoom behavior.
*
* @param constraint A constraint function which returns a transform given the current transform, viewport extent and translate extent.
* The default implementation attempts to ensure that the viewport extent does not go outside the translate extent.
*/
constrain(constraint: ((transform: ZoomTransform, extent: [[number, number], [number, number]], translateExtent: [[number, number], [number, number]]) => ZoomTransform)): this;
/**
* Returns the current filter function.
*/
@@ -647,7 +660,7 @@ export interface ZoomBehavior<ZoomRefElement extends ZoomedElementBaseType, Datu
/**
* Set the maximum distance that the mouse can move between mousedown and mouseup that will trigger
* a subsequent click event. If at any point between mousedown and mouseup the mouse is greater than or equal to
* distance from its position on mousedown, the click event follwing mouseup will be suppressed.
* distance from its position on mousedown, the click event following mouseup will be suppressed.
*
* @param distance The distance threshold between mousedown and mouseup measured in client coordinates (event.clientX and event.clientY).
* The default is zero.
+6 -4
View File
@@ -1,5 +1,7 @@
import { detect } from 'detect-browser';
const browser = detect();
import detectBrowser = require("detect-browser");
const n: string = detectBrowser.name;
const v: string = detectBrowser.version;
if (browser) {
const name: string = browser.name;
const version: string = browser.version;
}
+22 -9
View File
@@ -1,14 +1,27 @@
// Type definitions for detect-browser v1.6.2
// Type definitions for detect-browser 2.0
// Project: https://github.com/DamonOehlman/detect-browser
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/**
* Browser name
*/
export const name: "edge" | "yandexbrowser" | "chrome" | "crios" | "firefox" | "opera" | "ie" | "bb10" | "android" | "ios" | "safari";
export type BrowserName =
"android" |
"bb10" |
"chrome" |
"crios" |
"edge" |
"firefox" |
"fxios" |
"ie" |
"ios" |
"kakaotalk" |
"opera" |
"phantomjs" |
"safari" |
"vivaldi" |
"yandexbrowser";
/**
* Browser version
*/
export const version: string;
export function detect(): null | {
name: BrowserName | "node";
version: string;
os: string;
};
+1 -1
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
+5 -74
View File
@@ -1,79 +1,10 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
"indent": [
true,
"spaces",
4
]
}
}
+1
View File
@@ -56,6 +56,7 @@ const dropzoneWithOptions = new Dropzone(".test", {
dictRemoveFile: "",
dictRemoveFileConfirmation: "",
dictMaxFilesExceeded: "",
dictFileSizeUnits: { tb: "", gb: "", mb: "", kb: "", b: "" },
accept: (file: Dropzone.DropzoneFile, done: (error?: string | Error) => void) => {
if (file.accepted) {
+9
View File
@@ -26,6 +26,14 @@ declare namespace Dropzone {
accepted: boolean;
xhr?: XMLHttpRequest;
}
export interface DropzoneDictFileSizeUnits {
tb?: string;
gb?: string;
mb?: string;
kb?: string;
b?: string;
}
export interface DropzoneOptions {
url?: string;
@@ -72,6 +80,7 @@ declare namespace Dropzone {
dictRemoveFile?: string;
dictRemoveFileConfirmation?: string;
dictMaxFilesExceeded?: string;
dictFileSizeUnits?: DropzoneDictFileSizeUnits;
accept?(file: DropzoneFile, done: (error?: string | Error) => void): void;
init?(): void;
+72 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for EaselJS 0.8.0
// Type definitions for EaselJS 1.0.0
// Project: http://www.createjs.com/#!/EaselJS
// Definitions by: Pedro Ferreira <https://bitbucket.org/drk4>, Chris Smith <https://github.com/evilangelist>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -53,6 +53,22 @@ declare namespace createjs {
clone(): Bitmap;
}
export class BitmapCache {
constructor();
// properties
cacheID: number;
// methods
static getFilterBounds(target: DisplayObject, output?: Rectangle): Rectangle;
toString(): string;
define(target: DisplayObject, x: number, y: number, width: number, height: number, scale?: number): void;
update(compositeOperation?: string): void;
release(): void;
getCacheDataURL(): string;
draw(ctx: CanvasRenderingContext2D): boolean;
}
export class ScaleBitmap extends DisplayObject {
constructor(imageOrUrl: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Object | string, scale9Grid: Rectangle);
@@ -211,6 +227,7 @@ declare namespace createjs {
// properties
alpha: number;
bitmapCache: BitmapCache;
cacheCanvas: HTMLCanvasElement | Object;
cacheID: number;
compositeOperation: string;
@@ -924,6 +941,60 @@ declare namespace createjs {
}
interface IStageGLOptions {
preserveBuffer?: boolean;
antialias?: boolean;
transparent?: boolean;
premultiply?: boolean;
autoPurge?: number;
}
export class StageGL extends Stage {
constructor(canvas: HTMLCanvasElement | string | Object, options?: IStageGLOptions);
// properties
static VERTEX_PROPERTY_COUNT: number;
static INDICIES_PER_CARD: number;
static DEFAULT_MAX_BATCH_SIZE: number;
static WEBGL_MAX_INDEX_NUM: number;
static UV_RECT: number;
static COVER_VERT: Float32Array;
static COVER_UV: Float32Array;
static COVER_UV_FLIP: Float32Array;
static REGULAR_VARYING_HEADER: string;
static REGULAR_VERTEX_HEADER: string;
static REGULAR_FRAGMENT_HEADER: string;
static REGULAR_VERTEX_BODY: string;
static REGULAR_FRAGMENT_BODY: string;
static REGULAR_FRAG_COLOR_NORMAL: string;
static REGULAR_FRAG_COLOR_PREMULTIPLY: string;
static PARTICLE_VERTEX_BODY: string;
static PARTICLE_FRAGMENT_BODY: string;
static COVER_VARYING_HEADER: string;
static COVER_VERTEX_HEADER: string;
static COVER_FRAGMENT_HEADER: string;
static COVER_VERTEX_BODY: string;
static COVER_FRAGMENT_BODY: string;
isWebGL: boolean;
autoPurge: number;
vocalDebug: boolean;
// methods
static buildUVRects(spritesheet: SpriteSheet, target?: number, onlyTarget?: boolean): Object;
static isWebGLActive(ctx: CanvasRenderingContext2D): boolean;
cacheDraw(target: DisplayObject, filters: Filter[], manager: BitmapCache): boolean;
getBaseTexture(w?: number, h?: number): WebGLTexture | null;
getFilterShader(filter: Filter | Object): WebGLProgram;
getRenderBufferTexture (w: number, h: number): WebGLTexture;
getTargetRenderTexture (target: DisplayObject, w: number, h: number): Object;
protectTextureSlot(id: number, lock?: boolean): void;
purgeTextures(count?: number): void;
releaseTexture(item: DisplayObject | WebGLTexture | HTMLImageElement | HTMLCanvasElement): void;
setTextureParams(gl: WebGLRenderingContext, isPOT?: boolean): void;
updateSimultaneousTextureCount(count?: number): void;
updateViewport(width: number, height: number): void;
}
export class Text extends DisplayObject {
constructor(text?: string, font?: string, color?: string);
@@ -2,8 +2,9 @@ import electron = require('electron');
import storage = require('electron-json-storage');
const DATA_PATH = '~/Downloads';
const NEW_DATA_PATH = `${DATA_PATH}/new-data-path`;
console.log(storage.DEFAULT_DATA_PATH.length);
console.log(storage.getDefaultDataPath().length);
storage.setDataPath(DATA_PATH);
console.log(DATA_PATH.length);
@@ -12,31 +13,59 @@ console.log(storage.getDataPath().length);
storage.set('foo', { foo: 'bar' }, (err: any) => { });
storage.set('bar', { foo: 'bar' }, (err: any) => { });
storage.set('baz', { foo: 'bar' }, {dataPath: NEW_DATA_PATH}, (err: any) => { });
storage.get('foo', (err: any, data: object) => {
console.log(JSON.stringify(data));
});
storage.get('baz', {dataPath: NEW_DATA_PATH}, (err: any, data: object) => {
console.log(JSON.stringify(data));
});
storage.getMany(['foo', 'bar'], (err: any, data: object) => {
console.log(JSON.stringify(data));
});
storage.getMany(['baz'], {dataPath: NEW_DATA_PATH}, (err: any, data: object) => {
console.log(JSON.stringify(data));
});
storage.getAll((err: any, data: object) => {
console.log(JSON.stringify(data));
});
storage.getAll({dataPath: NEW_DATA_PATH}, (err: any, data: object) => {
console.log(JSON.stringify(data));
});
storage.has('foo', (err: any, hasKey: boolean) => {
console.log("hasKey?: %s", hasKey);
});
storage.has('baz', {dataPath: NEW_DATA_PATH}, (err: any, hasKey: boolean) => {
console.log("hasKey?: %s", hasKey);
});
storage.keys((err: any, keys: string[]) => {
console.log(keys);
});
storage.keys({dataPath: NEW_DATA_PATH}, (err: any, keys: string[]) => {
console.log(keys);
});
storage.remove("foo", (err: any) => {
console.log(err);
});
storage.remove("baz", {dataPath: NEW_DATA_PATH}, (err: any) => {
console.log(err);
});
storage.clear((err: any) => {
console.log(err);
});
storage.clear({dataPath: NEW_DATA_PATH}, (err: any) => {
console.log(err);
});
+14 -4
View File
@@ -1,18 +1,28 @@
// Type definitions for electron-json-storage 3.1
// Type definitions for electron-json-storage 4.0
// Project: https://github.com/electron-userland/electron-json-storage
// Definitions by: Sam Saint-Pettersen <https://github.com/stpettersens>,
// nrlquaker <https://github.com/nrlquaker>
// nrlquaker <https://github.com/nrlquaker>,
// John Woodruff <https://github.com/jbw91>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export const DEFAULT_DATA_PATH: string;
export function setDataPath(directory: string): void;
export interface DataOptions { dataPath: string; }
export function getDefaultDataPath(): string;
export function setDataPath(directory?: string): void;
export function getDataPath(): string;
export function get(key: string, callback: (error: any, data: object) => void): void;
export function get(key: string, options: DataOptions, callback: (error: any, data: object) => void): void;
export function getMany(keys: ReadonlyArray<string>, callback: (error: any, data: object) => void): void;
export function getMany(keys: ReadonlyArray<string>, options: DataOptions, callback: (error: any, data: object) => void): void;
export function getAll(callback: (error: any, data: object) => void): void;
export function getAll(options: DataOptions, callback: (error: any, data: object) => void): void;
export function set(key: string, json: object, callback: (error: any) => void): void;
export function set(key: string, json: object, options: DataOptions, callback: (error: any) => void): void;
export function has(key: string, callback: (error: any, hasKey: boolean) => void): void;
export function has(key: string, options: DataOptions, callback: (error: any, hasKey: boolean) => void): void;
export function keys(callback: (error: any, keys: string[]) => void): void;
export function keys(options: DataOptions, callback: (error: any, keys: string[]) => void): void;
export function remove(key: string, callback: (error: any) => void): void;
export function remove(key: string, options: DataOptions, callback: (error: any) => void): void;
export function clear(callback: (error: any) => void): void;
export function clear(options: DataOptions, callback: (error: any) => void): void;
+4 -3
View File
@@ -21,6 +21,7 @@ class MyNewProxy<T> extends Ember.ArrayProxy<T> {
isNew = true;
}
let x: MyNewProxy<number> = MyNewProxy.create({ content: Ember.A([1, 2, 3]) });
assertType<number | undefined>(x.get('firstObject'));
assertType<boolean>(x.isNew);
let x = MyNewProxy.create({ content: Ember.A([1, 2, 3]) });
// TODO: type inference can't infer 'number', just '{}'
// x.get('firstObject'); // $ExpectType number | undefined
x.isNew; // $ExpectType boolean
+2
View File
@@ -18,6 +18,7 @@ function ModuleTest(): void {
Module.print = function(text) { alert('stdout: ' + text) };
var int_sqrt = Module.cwrap('int_sqrt', 'number', ['number'])
int_sqrt = Module.cwrap('int_sqrt', null, ['number'])
int_sqrt(12)
int_sqrt(28)
@@ -27,6 +28,7 @@ function ModuleTest(): void {
var x = Module.getValue(buf, 'i32') + 123;
Module.HEAPU8.set(myTypedArray, buf);
Module.ccall('my_function', 'number', ['number'], [buf]);
Module.ccall('my_function', null, ['number'], [buf]);
Module._free(buf);
Module.destroy({});
}
+2 -2
View File
@@ -40,8 +40,8 @@ declare namespace Module {
var Runtime: any;
function ccall(ident: string, returnType: string, argTypes: string[], args: any[]): any;
function cwrap(ident: string, returnType: string, argTypes: string[]): any;
function ccall(ident: string, returnType: string | null, argTypes: string[], args: any[]): any;
function cwrap(ident: string, returnType: string | null, argTypes: string[]): any;
function setValue(ptr: number, value: any, type: string, noSafe?: boolean): void;
function getValue(ptr: number, type: string, noSafe?: boolean): number;
+1
View File
@@ -437,6 +437,7 @@ export class ShallowWrapper<P = {}, S = {}> {
parent(): ShallowWrapper<any, any>;
}
// tslint:disable-next-line no-empty-interface
export interface ReactWrapper<P = {}, S = {}> extends CommonWrapper<P, S> {}
export class ReactWrapper<P = {}, S = {}> {
constructor(nodes: JSX.Element | JSX.Element[], root?: ReactWrapper, options?: MountRendererProps);
+2 -1
View File
@@ -1,10 +1,11 @@
// Type definitions for escape-string-regexp
// Project: https://github.com/sindresorhus/escape-string-regexp
// Definitions by: kruncher <https://github.com/kruncher>
// faergeek <https://github.com/faergeek>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function escapeStringRegexp(str: string): string;
declare const escapeStringRegexp: (str: string) => string;
export = escapeStringRegexp;
@@ -0,0 +1,7 @@
import * as express from 'express';
import * as expressEjsLayouts from 'express-ejs-layouts';
function expressRequestHandlerTest() {
const app = express()
.use(expressEjsLayouts());
}
+15
View File
@@ -0,0 +1,15 @@
// Type definitions for express-ejs-layouts 2.3
// Project: https://github.com/Soarez/express-ejs-layouts
// Definitions by: Erik Mavrinac <https://github.com/erikma>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { RequestHandler } from 'express';
declare function expressEjsLayouts(): RequestHandler;
declare namespace expressEjsLayouts {
}
export = expressEjsLayouts;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"express-ejs-layouts-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/nfriedly/express-rate-limit
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>, makepost <https://github.com/makepost>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.1
import express = require("express");
@@ -1,5 +1,3 @@
import * as express from 'express-serve-static-core';
// null test file - everything should be tested from express.d.ts and serve-static.d.ts
// null test file - everything should be tested from express.d.ts and serve-static.d.ts
File diff suppressed because it is too large Load Diff
+3 -71
View File
@@ -1,79 +1,11 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
// TODOs
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
"unified-signatures": false
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Hiroki Horiuchi <https://github.com/horiuchi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Definitions by: Jacob Bogers <https://github.com/jacobbogers
// TypeScript Version: 2.3
// TypeScript Version: 2.1
/// <reference types="node" />
+3 -4
View File
@@ -17,10 +17,9 @@ namespace express_tests {
next();
});
app.use((err: any, req: express.Request<{ hello: string; }>, res: express.Response, next: express.NextFunction) => {
console.log(req.body.hello);
console.error(err);
next(err);
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
console.error(err);
next(err);
});
app.get('/', (req, res) => {
+2 -7
View File
@@ -2,7 +2,7 @@
// Project: http://expressjs.com
// Definitions by: Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.2
/* =================== USAGE ===================
@@ -76,12 +76,7 @@ declare namespace e {
interface IRouterMatcher<T> extends core.IRouterMatcher<T> { }
interface MediaType extends core.MediaType { }
interface NextFunction extends core.NextFunction { }
interface Request<
Body = any,
Query = any,
Params = any,
Cookies = any
> extends core.Request<Body, Query, Params, Cookies> { }
interface Request extends core.Request { }
interface RequestHandler extends core.RequestHandler { }
interface RequestParamHandler extends core.RequestParamHandler { }
export interface Response extends core.Response { }
+2 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for fossil-delta 0.2.5
// Type definitions for fossil-delta 1.0.0
// Project: https://github.com/dchest/fossil-delta-js
// Definitions by: Endel Dreyer <https://github.com/endel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -8,5 +8,5 @@
type ByteArray = Array<number> | Uint8Array | Buffer;
export function create(origin: ByteArray, target: ByteArray): Array<number>;
export function apply(origin: ByteArray, delta: Array<number>): Array<number>;
export function apply(origin: ByteArray, delta: Array<number>, ops?: { verifyChecksum: boolean }): Array<number>;
export function outputSize(delta: Array<number>): number;
+1 -1
View File
@@ -223,7 +223,7 @@ declare module '@google-cloud/datastore/request' {
runQuery(query: Query, options: QueryOptions, callback: QueryCallback): void;
runQuery(query: Query, callback: QueryCallback): void;
runQuery(query: Query, options?: QueryOptions): QueryResult;
runQuery(query: Query, options?: QueryOptions): Promise<QueryResult>;
runQueryStream(query: Query, options?: QueryOptions): NodeJS.ReadableStream;
@@ -0,0 +1,578 @@
import * as PubSub from '@google-cloud/pubsub';
// AUTHOR NOTES: We use the examples directly from the library documentation
// where possible. If there is a problem with a given example (e.g. undocumented
// feature or option), we make a note of it and provide an alternative example
// call instead.
///////////////////////////////////////////////////////////////////////////////
// PUBSUB
///////////////////////////////////////////////////////////////////////////////
{
let pubsub: PubSub.PubSub;
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=PubSub
// When running on Google Cloud Platform:
pubsub = PubSub();
// When running elsewhere:
pubsub = PubSub({
projectId: 'grape-spaceship-123',
keyFilename: '/path/to/keyfile.json',
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=createSubscription
// Subscribe to a topic:
pubsub.createSubscription('messageCenter', 'newMessages', (err, subscription, apiResponse) => { });
// Customize the subscription:
// NOTE: ackDeadline, as given in the example, is undocumented, so create a subscription only with the KNOWN options
pubsub.createSubscription('messageCenter', 'newMessages', {
retainAckedMessages: true,
}, (err, subscription, apiResponse) => { });
// If the callback is omitted, we'll return a Promise.
pubsub.createSubscription('messageCenter', 'newMessages').then((data) => {
const subscription = data[0];
const apiResponse = data[1];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=createTopic
// Create topic with callback
pubsub.createTopic('my-new-topic', (err, topic, apiResponse) => {
if (!err) {
// The topic was created successfully.
}
});
// If the callback is omitted, we'll return a Promise.
pubsub.createTopic('my-new-topic').then((data) => {
const topic = data[0];
const apiResponse = data[1];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getSnapshots
// Get snapshots:
pubsub.getSnapshots((err, snapshots) => {
if (!err) {
// snapshots is an array of Snapshot objects.
}
});
// If the callback is omitted, we'll return a Promise.
pubsub.getSnapshots().then((data) => {
const snapshots = data[0];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getSnapshotsStream
// Get snapshots stream
pubsub.getSnapshotsStream()
.on('error', console.error)
.on('data', (snapshot) => {
// snapshot is a Snapshot object.
})
.on('end', () => {
// All snapshots retrieved.
});
// If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests.
// NOTE: this had to be modified to work around the 'this' keyword as used in the example
{
const stream = pubsub.getSnapshotsStream();
stream.on('data', (snapshot) => {
stream.end();
});
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getSubscriptions
// Get subscriptions:
pubsub.getSubscriptions((err, subscriptions) => {
if (!err) {
// subscriptions is an array of Subscription objects.
}
});
// If the callback is omitted, we'll return a Promise.
pubsub.getSubscriptions().then((data) => {
const subscriptions = data[0];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getSubscriptionsStream
// Get subscriptions stream
pubsub.getSubscriptionsStream()
.on('error', console.error)
.on('data', (subscription) => {
// subscription is a Subscription object.
})
.on('end', () => {
// All subscriptions retrieved.
});
// If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests.
// Note: this had to be modified to work around the 'this' keyword as used in the example.
{
const stream = pubsub.getSubscriptionsStream();
stream.on('data', (subscription) => {
stream.end();
});
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getTopics
// Get topics:
pubsub.getTopics((err, topics) => {
if (!err) {
// topics is an array of Topic objects.
}
});
// Customize the query:
pubsub.getTopics({
pageSize: 3
}, (err, topics) => { });
// If the callback is omitted, we'll return a Promise.
pubsub.getTopics().then((data) => {
const topics = data[0];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getTopicsStream
// Get topics stream:
pubsub.getTopicsStream()
.on('error', console.error)
.on('data', (topic) => {
// topic is a Topic object.
})
.on('end', () => {
// All topics retrieved.
});
// If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests.
// Note: this had to be modified to work around the 'this' keyword as used in the example.
{
const stream = pubsub.getTopicsStream();
stream.on('data', (topic) => {
stream.end();
});
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=snapshot
// Snapshot:
{
const snapshot = pubsub.snapshot('my-snapshot');
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=subscription
// Subscription:
{
const subscription = pubsub.subscription('my-subscription');
// Register a listener for `message` events.
subscription.on('message', (message) => {
// Called every time a message is received.
// message.id = ID of the message.
// message.ackId = ID used to acknowledge the message receival.
// message.data = Contents of the message.
// message.attributes = Attributes of the message.
// message.publishTime = Timestamp when Pub/Sub received the message.
});
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=topic
// Topic:
{
const topic = pubsub.topic('my-topic');
}
}
///////////////////////////////////////////////////////////////////////////////
// PUBLISHER
///////////////////////////////////////////////////////////////////////////////
{
const pubsub = PubSub();
const topic = pubsub.topic('my-topic');
const publisher = topic.publisher();
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/publisher?method=publish
// Publish:
publisher.publish(new Buffer('Hello, world!'), (err, messageId) => {
if (err) {
// Error handling omitted.
}
});
// Optionally you can provide an object containing attributes for the message.
publisher.publish(new Buffer('Hello, world!'), { key: 'value' }, (err, messageId) => {
if (err) {
// Error handling omitted.
}
});
}
///////////////////////////////////////////////////////////////////////////////
// SNAPSHOT
///////////////////////////////////////////////////////////////////////////////
{
const pubsub = PubSub();
const subscription = pubsub.subscription('my-subscription');
// There are two type of snapshots; the ones obtained from subscription.createSnapshot() have more functionality
const snapshot = pubsub.snapshot('my-snapshot');
const snapshotFromSubscription = subscription.snapshot('my-snapshot');
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/snapshot?method=create
// Note: Only available to snapshots created via methods of Subscription
// Create snapshot
snapshotFromSubscription.create('my-snapshot', (err, snapshot, apiResponse) => {
if (!err) {
// The snapshot was created successfully.
}
});
// If the callback is omitted, we'll return a Promise.
snapshotFromSubscription.create('my-snapshot').then((data) => {
const snapshot = data[0];
const apiResponse = data[1];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/snapshot?method=delete
// Delete the snapshot
snapshot.delete((err, apiResponse) => { });
// If the callback is omitted, we'll return a Promise.
snapshot.delete().then((data) => {
const apiResponse = data[0];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/snapshot?method=seek
// Note: Only available to snapshots created via methods of Subscription
// Seek:
snapshotFromSubscription.seek((err, apiResponse) => { });
// If the callback is omitted, we'll return a Promise.
snapshotFromSubscription.seek().then((data) => {
const apiResponse = data[0];
});
}
///////////////////////////////////////////////////////////////////////////////
// SUBSCRIPTION
///////////////////////////////////////////////////////////////////////////////
{
const pubsub = PubSub();
const topic = pubsub.topic('my-topic');
const subscription = topic.subscription('my-subscription');
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=close
// Close:
subscription.close((err) => {
if (err) {
// Error handling omitted.
}
});
// If the callback is omitted, we'll return a Promise.
subscription.close().then(() => { });
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=createSnapshot
// Create snapshot:
subscription.createSnapshot('my-snapshot', (err, snapshot, apiResponse) => {
if (!err) {
// The snapshot was created successfully.
}
});
// If the callback is omitted, we'll return a Promise.
subscription.createSnapshot('my-snapshot').then((data) => {
const snapshot = data[0];
const apiResponse = data[1];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=delete
// Delete:
subscription.delete((err, apiResponse) => { });
// If the callback is omitted, we'll return a Promise.
subscription.delete().then((data) => {
const apiResponse = data[0];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=exists
// Exists:
subscription.exists((err, exists) => { });
// If the callback is omitted, we'll return a Promise.
subscription.exists().then((data) => {
const exists = data[0];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=get
// Get:
subscription.get((err, subscription, apiResponse) => {
// The `subscription` data has been populated.
});
// If the callback is omitted, we'll return a Promise.
subscription.get().then((data) => {
const subscription = data[0];
const apiResponse = data[1];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=getMetadata
// Get metadata:
subscription.getMetadata((err, apiResponse) => {
if (err) {
// Error handling omitted.
}
});
// If the callback is omitted, we'll return a Promise.
subscription.getMetadata().then((data) => {
const apiResponse = data[0];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=modifyPushConfig
// Modify push config:
// Note: Had to modify the code to force typings
{
const pushConfig: PubSub.Subscription.PushConfig = {
pushEndpoint: 'https://mydomain.com/push',
attributes: {
'x-goog-version': 'v1',
}
};
subscription.modifyPushConfig(pushConfig, (err, apiResponse) => {
if (err) {
// Error handling omitted.
}
});
// If the callback is omitted, we'll return a Promise.
subscription.modifyPushConfig(pushConfig).then((data) => {
const apiResponse = data[0];
});
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=seek
// Seek:
{
const callback: PubSub.Subscription.SeekCallback = (err, resp) => {
if (!err) {
// Seek was successful.
}
};
subscription.seek('my-snapshot', callback);
// Alternatively, to specify a certain point in time, you can provide a Date object.
subscription.seek(new Date('October 21 2015'), callback);
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=setMetadata
{
const metadata = {
key: 'value'
};
// Set metadata
subscription.setMetadata(metadata, (err, apiResponse) => {
if (err) {
// Error handling omitted.
}
});
// If the callback is omitted, we'll return a Promise.
subscription.setMetadata(metadata).then((data) => {
const apiResponse = data[0];
});
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=snapshot
// Snapshot:
subscription.snapshot('my-snapshot');
}
///////////////////////////////////////////////////////////////////////////////
// TOPIC
///////////////////////////////////////////////////////////////////////////////
{
const pubsub = PubSub();
const topic = pubsub.topic('my-topic');
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=create
// Create:
topic.create((err, topic, apiResponse) => {
if (!err) {
// The topic was created successfully.
}
});
// If the callback is omitted, we'll return a Promise.
topic.create().then((data) => {
const topic = data[0];
const apiResponse = data[1];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=createSubscription
{
const callback: PubSub.Topic.CreateSubscriptionCallback = (err, subscription, apiResponse) => { };
// Without specifying any options.
topic.createSubscription('newMessages', callback);
// With options.
// Note: ackDeadline not documented, so we use a different option
topic.createSubscription('newMessages', {
// ackDeadline: 90000 // 90 seconds
retainAckedMessages: true,
}, callback);
// If the callback is omitted, we'll return a Promise.
topic.createSubscription('newMessages').then((data) => {
const subscription = data[0];
const apiResponse = data[1];
});
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=delete
// Delete:
topic.delete((err, apiResponse) => { });
// If the callback is omitted, we'll return a Promise.
topic.delete().then((data) => {
const apiResponse = data[0];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=exists
// Exists:
topic.exists((err, exists) => { });
// If the callback is omitted, we'll return a Promise.
topic.exists().then((data) => {
const exists = data[0];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=get
// Get:
topic.get((err, topic, apiResponse) => {
// The `topic` data has been populated.
});
// If the callback is omitted, we'll return a Promise.
topic.get().then((data) => {
const topic = data[0];
const apiResponse = data[1];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=getMetadata
// Get metadata
topic.getMetadata((err, apiResponse) => { });
// If the callback is omitted, we'll return a Promise.
topic.getMetadata().then((data) => {
const apiResponse = data[0];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=getSubscriptions
// Get subscriptions:
// Note: Modified so that the callback is a constant
{
const callback: PubSub.Topic.GetSubscriptionsCallback = (err, subscriptions) => {
// subscriptions is an array of `Subscription` objects.
};
topic.getSubscriptions(callback);
// Customize the query.
topic.getSubscriptions({
pageSize: 3
}, callback);
// If the callback is omitted, we'll return a Promise.
topic.getSubscriptions().then((data) => {
const subscriptions = data[0];
});
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=getSubscriptionsStream
// Get subscriptions stream:
topic.getSubscriptionsStream()
.on('error', console.error)
.on('data', (subscription) => {
// subscription is a Subscription object.
})
.on('end', () => {
// All subscriptions retrieved.
});
// If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests.
{
const stream = topic.getSubscriptionsStream();
stream.on('data', (subscription) => {
stream.end();
});
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=publisher
topic.publisher().publish(new Buffer('Hello, world!'), (err, messageId) => {
if (err) {
// Error handling omitted.
}
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=subscription
// Register a listener for `message` events.
topic.subscription('my-subscription').on('message', (message) => {
// Called every time a message is received.
// message.id = ID of the message.
// message.ackId = ID used to acknowledge the message receival.
// message.data = Contents of the message.
// message.attributes = Attributes of the message.
// message.publishTime = Timestamp when Pub/Sub received the message.
});
}
///////////////////////////////////////////////////////////////////////////////
// IAM
///////////////////////////////////////////////////////////////////////////////
{
const pubsub = PubSub();
const topic = pubsub.topic('my-topic');
const subscription = topic.subscription('my-subscription');
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=iam.getPolicy
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=iam.getPolicy
// Get policy:
topic.iam.getPolicy((err, policy, apiResponse) => { });
subscription.iam.getPolicy((err, policy, apiResponse) => { });
// If the callback is omitted, we'll return a Promise.
topic.iam.getPolicy().then((data) => {
const policy = data[0];
const apiResponse = data[1];
});
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=iam.setPolicy
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=iam.setPolicy
{
const myPolicy = {
bindings: [
{
role: 'roles/pubsub.subscriber',
members: ['serviceAccount:myotherproject@appspot.gserviceaccount.com']
}
]
};
// Set policy:
topic.iam.setPolicy(myPolicy, (err, policy, apiResponse) => { });
subscription.iam.setPolicy(myPolicy, (err, policy, apiResponse) => { });
// If the callback is omitted, we'll return a Promise.
topic.iam.setPolicy(myPolicy).then((data) => {
const policy = data[0];
const apiResponse = data[1];
});
}
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=iam.testPermissions
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=iam.testPermissions
{
const test = 'pubsub.topics.update';
// Test permission
topic.iam.testPermissions(test, (err, permissions, apiResponse) => {
console.log(permissions);
// {
// "pubsub.topics.update": true
// }
});
// Test several permissions at once.
const tests = [
'pubsub.subscriptions.consume',
'pubsub.subscriptions.update'
];
subscription.iam.testPermissions(tests, (err, permissions) => {
console.log(permissions);
// {
// "pubsub.subscriptions.consume": true,
// "pubsub.subscriptions.update": false
// }
});
// If the callback is omitted, we'll return a Promise.
topic.iam.testPermissions(test).then((data) => {
const permissions = data[0];
const apiResponse = data[1];
});
}
}
+344
View File
@@ -0,0 +1,344 @@
// Type definitions for @google-cloud/pubsub 0.14
// Project: https://github.com/GoogleCloudPlatform/google-cloud-node/tree/master/packages/pubsub
// Definitions by: Paul Huynh <https://github.com/pheromonez>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node"/>
import { EventEmitter } from "events";
import { Duplex } from "stream";
declare namespace PubSub {
// TODO write definitions for the for v1
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/v1
function v1(config?: GCloudConfiguration): any;
interface GCloudConfiguration {
projectId?: string;
keyFilename?: string;
email?: string;
credentials?: {
client_email?: string;
private_key?: string
};
autoRetry?: boolean;
maxRetries?: number;
promise?: any;
}
interface PubSub {
createSubscription(topic: Topic | string, name: string, options?: PubSub.CreateSubscriptionOptions): Promise<any[]>;
createSubscription(topic: Topic | string, name: string, callback: PubSub.CreateSubscriptionCallback): void;
createSubscription(topic: Topic | string, name: string, options: PubSub.CreateSubscriptionOptions, callback: PubSub.CreateSubscriptionCallback): void;
createTopic(name: string, gaxOpts?: GAX.CallOptions): Promise<any[]>;
createTopic(name: string, callback: PubSub.CreateTopicCallback): void;
createTopic(name: string, gaxOpts: GAX.CallOptions, callback: PubSub.CreateTopicCallback): void;
getSnapshots(options?: PubSub.GetSnapshotsOptions): Promise<any[]>;
getSnapshots(callback: PubSub.GetSnapshotsCallback): void;
getSnapshots(options: PubSub.GetSnapshotsOptions, callback: PubSub.GetSnapshotsCallback): void;
getSnapshotsStream(options?: PubSub.GetSnapshotsOptions): Duplex;
getSubscriptions(options?: PubSub.GetSubscriptionsOptions): Promise<any[]>;
getSubscriptions(callback: PubSub.GetSubscriptionsCallback): void;
getSubscriptions(options: PubSub.GetSubscriptionsOptions, callback: PubSub.GetSubscriptionsCallback): void;
getSubscriptionsStream(options?: PubSub.GetSubscriptionsOptions): Duplex;
getTopics(query?: PubSub.GetTopicsQuery): Promise<any[]>;
getTopics(callback: PubSub.GetTopicsCallback): void;
getTopics(query: PubSub.GetTopicsQuery, callback: PubSub.GetTopicsCallback): void;
getTopicsStream(query?: PubSub.GetTopicsQuery): Duplex;
snapshot(name: string): Snapshot;
subscription(name: string, options?: PubSub.SubscriptionOptions): Subscription;
topic(name: string): Topic;
}
namespace PubSub {
interface CreateSubscriptionOptions {
flowControl?: {
maxBytes?: number;
maxMessages?: number;
};
gaxOpts?: GAX.CallOptions;
messageRetentionDuration?: number | Date;
pushEndpoint?: string;
retainAckedMessages?: boolean;
}
type CreateSubscriptionCallback = (err: Error | null, subscription: Subscription, apiResponse: object) => void;
type CreateTopicCallback = (err: Error | null, topic: Topic, apiResponse: object) => void;
interface GetSnapshotsOptions {
autoPaginate?: boolean;
gaxOpts?: GAX.CallOptions;
pageSize?: number;
pageToken?: string;
}
type GetSnapshotsCallback = (err: Error | null, snapshots: Snapshot[]) => void;
interface GetSubscriptionsOptions {
autoPaginate?: boolean;
gaxOpts?: GAX.CallOptions;
pageSize?: number;
pageToken?: string;
topic?: Topic | string;
}
type GetSubscriptionsCallback = (err: Error | null, subscriptions: Subscription[], apiResponse: object) => void;
interface GetTopicsQuery {
autoPaginate?: boolean;
gaxOpts?: GAX.CallOptions;
pageSize?: number;
pageToken?: string;
}
type GetTopicsCallback = (err: Error | null, topics: Topic[], apiResponse: object) => void;
interface SubscriptionOptions {
flowControl?: {
maxBytes?: number;
maxMessages?: number;
};
maxConnections?: number;
}
}
interface Publisher {
publish(data: Buffer, callback: Publisher.PublishCallback): void;
publish(data: Buffer, attributes: object, callback: Publisher.PublishCallback): void;
publish(data: Buffer, attributes?: object): Promise<any[]>;
}
namespace Publisher {
type PublishCallback = (error: Error | null, messageId: string) => void;
}
interface Snapshot {
delete(): Promise<any[]>;
delete(callback: Snapshot.DeleteCallback): void;
}
interface SnapshotFromSubscription extends Snapshot {
create(name: string): Promise<any[]>;
create(name: string, callback: Snapshot.CreateCallback): void;
seek(): Promise<any[]>;
seek(callback: Snapshot.SeekCallback): void;
}
namespace Snapshot {
type DeleteCallback = (err: Error | null, apiResponse: object) => void;
type CreateCallback = (err: Error | null, snapshot: Snapshot, apiResponse: object) => void;
type SeekCallback = (err: Error | null, apiResponse: object) => void;
}
interface Subscription extends EventEmitter {
close(): Promise<void>;
close(callback: Subscription.CloseCallback): void;
createSnapshot(name: string, gaxOpts?: GAX.CallOptions): Promise<any[]>;
createSnapshot(name: string, callback: Subscription.CreateSnapshotCallback): void;
createSnapshot(name: string, gaxOpts: GAX.CallOptions, callback: Subscription.CreateSnapshotCallback): void;
delete(gaxOpts?: GAX.CallOptions): Promise<any[]>;
delete(callback: Subscription.DeleteCallback): void;
delete(gaxOpts: GAX.CallOptions, callback: Subscription.DeleteCallback): void;
exists(): Promise<any[]>;
exists(callback: Subscription.ExistsCallback): void;
get(gaxOpts?: GAX.CallOptions): Promise<any[]>; // TODO: only expose autoCreate
// NOTE: The following are not documented, but are possible signatures base on the source code
get(callback: Subscription.GetCallback): void;
get(gaxOpts: GAX.CallOptions, callback: Subscription.GetCallback): void;
getMetadata(gaxOpts?: GAX.CallOptions): Promise<any[]>;
getMetadata(callback: Subscription.GetMetadataCallback): void;
getMetadata(gaxOpts: GAX.CallOptions, callback: Subscription.GetMetadataCallback): void;
iam: IAM;
modifyPushConfig(config: Subscription.PushConfig, gaxOpts?: GAX.CallOptions): Promise<any[]>;
modifyPushConfig(config: Subscription.PushConfig, callback: Subscription.ModifyPushConfigCallback): void;
modifyPushConfig(config: Subscription.PushConfig, gaxOpts: GAX.CallOptions, callback: Subscription.ModifyPushConfigCallback): void;
seek(snapshot: string | Date, callback: Subscription.SeekCallback): void;
seek(snapshot: string | Date, gaxOpts: GAX.CallOptions, callback: Subscription.SeekCallback): void;
setMetadata(metadata: object, gaxOpts?: GAX.CallOptions): Promise<any[]>;
setMetadata(metadata: object, callback: Subscription.SetMetadataCallback): void;
setMetadata(metadata: object, gaxOpts: GAX.CallOptions, callback: Subscription.SetMetadataCallback): void;
snapshot(name: string): SnapshotFromSubscription;
}
namespace Subscription {
type CloseCallback = (err: Error | null) => void;
type CreateSnapshotCallback = (err: Error | null, snapshot: SnapshotFromSubscription, apiResponse: object) => void;
type DeleteCallback = (err: Error | null, apiResponse: object) => void;
type ExistsCallback = (err: Error | null, exists: boolean) => void;
type GetCallback = (err: Error | null, subscription: Subscription, apiResponse: object) => void;
type GetMetadataCallback = (err: Error | null, apiResponse: object) => void;
interface PushConfig {
pushEndpoint?: string;
// https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#pushconfig
attributes?: PushConfigAttributes;
}
interface PushConfigAttributes {
'x-goog-version': 'v1beta' | 'v1' | 'v1beta2';
}
type ModifyPushConfigCallback = (err: Error | null, apiResponse: object) => void;
type SeekCallback = (err: Error | null, apiResponse: object) => void;
type SetMetadataCallback = (err: Error | null, apiResponse: object) => void;
}
interface Topic {
create(gaxOpts?: GAX.CallOptions): Promise<any[]>;
create(callback: Topic.CreateCallback): void;
create(gaxOpts: GAX.CallOptions, callback: Topic.CreateCallback): void;
createSubscription(nameOrOptions?: string | Topic.CreateSubscriptionOptions): Promise<any[]>;
createSubscription(name: string, options: Topic.CreateSubscriptionOptions): Promise<any[]>;
createSubscription(callback: Topic.CreateSubscriptionCallback): void;
createSubscription(nameOrOptions: string | Topic.CreateSubscriptionOptions, callback: Topic.CreateSubscriptionCallback): void;
createSubscription(name: string, options: Topic.CreateSubscriptionOptions, callback: Topic.CreateSubscriptionCallback): void;
delete(gaxOpts?: GAX.CallOptions): Promise<any[]>;
delete(callback: Topic.DeleteCallback): void;
delete(gaxOpts: GAX.CallOptions, callback: Topic.DeleteCallback): void;
exists(): Promise<any[]>;
exists(callback: Topic.ExistsCallback): void;
// NOTE: The documentation in the link is incomplete; the function takes a callback
// as second argument (in the source):
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=get
get(gaxOpts?: GAX.CallOptions): Promise<any[]>;
get(callback: Topic.GetCallback): void;
get(gaxOpts: GAX.CallOptions, callback: Topic.GetCallback): void;
getMetadata(gaxOpts?: GAX.CallOptions): Promise<any[]>;
getMetadata(callback: Topic.GetMetadataCallback): void;
getMetadata(gaxOpts: GAX.CallOptions, callback: Topic.GetMetadataCallback): void;
getSubscriptions(options?: Topic.GetSubscriptionsOptions): Promise<any[]>;
getSubscriptions(callback: Topic.GetSubscriptionsCallback): void;
getSubscriptions(options: Topic.GetSubscriptionsOptions, callback: Topic.GetSubscriptionsCallback): void;
// Note: The documention lists the parameter as 'query', when it probably should be 'options'.
getSubscriptionsStream(options?: Topic.GetSubscriptionsOptions): Duplex;
iam: IAM;
publisher(options?: Topic.PublisherOptions): Publisher;
subscription(name: string, options?: Topic.SubscriptionOptions): Subscription;
}
namespace Topic {
type CreateCallback = PubSub.CreateTopicCallback;
type CreateSubscriptionOptions = PubSub.CreateSubscriptionOptions;
type CreateSubscriptionCallback = PubSub.CreateSubscriptionCallback;
// Note: This is not fully documented in the link; browse the source code to find the callback parameters
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=delete
type DeleteCallback = (err: Error | null, apiResponse: object) => void;
type ExistsCallback = (err: Error | null, exists: boolean) => void;
// Note: This is not fully documented in the link; browse the source code to find the callback parameters
// https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=get
type GetCallback = (err: Error | null, topic: Topic, apiResponse: object) => void;
type GetMetadataCallback = (err: Error | null, apiResponse: object) => void;
// Options are SLIGHTLY different to PubSub.getSubscriptions(...), so we can't just reuse it
interface GetSubscriptionsOptions {
autoPaginate?: boolean;
gaxOpts?: GAX.CallOptions;
pageSize?: number;
pageToken?: string;
}
// Callback signature also slightly different to PubSub.getSubscriptions(callback), so we can't just reuse it
type GetSubscriptionsCallback = (err: Error | null, subscriptions: Subscription[]) => void;
interface PublisherOptions {
batching?: {
maxBytes?: number;
maxMessages?: number;
maxMilliseconds?: number;
};
}
type SubscriptionOptions = PubSub.SubscriptionOptions;
}
// Allow this interface to start with 'I', since it's an acronym!
// tslint:disable-next-line interface-name
interface IAM {
getPolicy(): Promise<any[]>;
getPolicy(callback: IAM.GetPolicyCallback): void;
setPolicy(policy: IAM.Policy): Promise<any[]>;
setPolicy(policy: IAM.Policy, callback: IAM.SetPolicyCallback): void;
testPermissions(permissions: string | string[]): Promise<any[]>;
testPermissions(permissions: string | string[], callback: IAM.TestPermissionsCallback): void;
}
namespace IAM {
type GetPolicyCallback = (err: Error | null, policy: Policy, apiResponse: object) => void;
type SetPolicyCallback = (err: Error | null, policy: Policy, apiResponse: object) => void;
type TestPermissionsCallback = (err: Error | null, permissions: string | string[], apiResponse: object) => void;
interface Policy {
bindings?: any[];
rules?: object[];
etag?: string;
}
}
namespace GAX {
/** https://googleapis.github.io/gax-nodejs/global.html#CallOptions */
interface CallOptions {
timeout?: number;
retry?: RetryOptions;
autoPaginate?: boolean;
pageToken?: object;
isBundling?: boolean;
longrunning?: BackoffSettings;
promise?: PromiseConstructor; // FIXME Unsure if this is the correct type; remove this comment if it is
}
/** https://googleapis.github.io/gax-nodejs/global.html#RetryOptions */
interface RetryOptions {
retryCodes: string[];
backoffSettings: BackoffSettings;
}
/** https://googleapis.github.io/gax-nodejs/global.html#BackoffSettings */
interface BackoffSettings {
initialRetryDelayMillis: number;
retryDelayMultiplier: number;
maxRetryDelayMillis: number;
initialRpcTimeoutMillis: number;
maxRpcTimeoutMillis: number;
totalTimeoutMillis: number;
}
}
}
declare function PubSub(config?: PubSub.GCloudConfiguration): PubSub.PubSub;
export = PubSub;
+28
View File
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"paths": {
"@google-cloud/pubsub": [
"google-cloud__pubsub"
]
},
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"google-cloud__pubsub-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -41,14 +41,39 @@ describe('UniversalAnalytics', () => {
});
it('should excercise Tracker APIs', () => {
const tracker: UniversalAnalytics.Tracker = ga.create('UA-65432-1', 'auto');
const aString: string = tracker.get<string>('aString');
const aNumber: number = tracker.get<number>('aNumber');
const anObject: {} = tracker.get<{}>('anObject');
tracker.get('fieldName');
tracker.set('aString', 'aString');
tracker.set('aNumber', 1);
tracker.set('anObject', {});
tracker.set({
several: 'values',
at: 'once'
});
tracker.send('pageview');
tracker.send('pageview', '/some-path');
tracker.send('pageview', {some: 'details'});
tracker.set('aString', aString);
tracker.set('aNumber', aNumber);
tracker.set('anObject', anObject);
});
it('should exercise Model APIs', () => {
const tracker: UniversalAnalytics.Tracker = ga.create('UA-65432-1', 'auto');
tracker.set('sendHitTask', (gaHitModel: UniversalAnalytics.Model) => {
gaHitModel.get('hitPayload');
gaHitModel.set('hitCallback', () => console.log('hit sent'), true);
gaHitModel.set('hitCallback', () => console.log('hit sent'));
gaHitModel.set({
hitPayload: 'a=1&b=2',
otherField: 3
});
gaHitModel.set({
hitPayload: 'a=1&b=2',
otherField: 3
}, null, false);
});
});
});
+12 -7
View File
@@ -1,6 +1,6 @@
// Type definitions for Google Analytics (Classic and Universal)
// Project: https://developers.google.com/analytics/devguides/collection/gajs/, https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference
// Definitions by: Ronnie Haakon Hegelund <http://ronniehegelund.blogspot.dk>, Pat Kujawa <http://patkujawa.com>
// Definitions by: Ronnie Haakon Hegelund <http://ronniehegelund.blogspot.dk>, Pat Kujawa <http://patkujawa.com>, Tyler Murphy <https://github.com/tyler-murphy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Tracker {
@@ -620,12 +620,17 @@ declare namespace UniversalAnalytics {
}
interface Tracker {
get<T>(fieldName: string): T;
send(hitType: string, opt_fieldObject?: {}): void;
set(fieldName: string, value: string): void;
set(fieldName: string, value: {}): void;
set(fieldName: string, value: number): void;
set(fieldName: string, value: boolean): void;
get(fieldName: string): any;
set(fieldName: string, fieldValue: any): void;
set(fieldsObject: {}): void;
send(hitType: string, ...fields: any[]): void;
send(hitType: string, fieldsObject: {}): void;
}
interface Model {
get(fieldName: string): any;
set(fieldName: string, fieldValue: any, temporary?: boolean): void;
set(fields: {}, fieldValue?: null, temporary?: boolean): void;
}
}
+50
View File
@@ -0,0 +1,50 @@
import fs = require("fs");
import * as grasp from "grasp";
grasp(); // $ExpectError
grasp({ args: [] }); // $ExpectType void
// $ExpectType void
grasp({
args: [],
error: console.error,
callback: console.log,
exit: process.exit,
console,
stdin: process.stdin,
fs,
input: "foo bar"
});
// $ExpectError
grasp({
args: [],
textFormat: { cyan: "cyan" }
});
// $ExpectType string
grasp.VERSION;
const fooquery = grasp.search("fooquery"); // $ExpectError
const equery = grasp.search("equery");
const squery = grasp.search("squery");
// $ExpectType Node[]
grasp.search("equery", "pattern", "input");
// $ExpectType Node[]
equery("pattern")("input");
// $ExpectType (input: string) => Node[]
squery("pattern");
const replacer = grasp.replace("equery", "pattern");
// $ExpectType string
replacer("replacement", "input");
// $ExpectType string
replacer((getRaw, node, query, named) => {
getRaw(node); // $ExpectType string
return "foo";
}, "input");
+72
View File
@@ -0,0 +1,72 @@
// Type definitions for grasp 0.6
// Project: http://graspjs.com
// Definitions by: Isaac Wolkerstorfer <https://github.com/agnoster>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="node" />
import * as fs from "fs";
import * as cliColor from "cli-color";
// Though Grasp does not use esprima, the parser it uses (flow-parser) has a compatible Node type and existing typedefs
import { Node } from "estree";
export = grasp;
declare function grasp(options: {
args: string[] | Record<string, any> | string;
error?: (message: string) => void;
callback?: (result: string) => void;
exit?: (code: number) => void;
input?: string;
// The following are "overrides" for defaults, such as console, cli-color,
// process.stdin, or fs. In most cases grasp only makes use of a small
// surface area of the types, but I think if someone really wants to pass a
// fake fs that only implements the subset of methods they think grasp uses,
// it should be up to them to use a cast rather than the typedef to be
// overly lenient. We never know if grasp might change their internal use of
// fs, after all.
fs?: typeof fs;
console?: typeof console;
textFormat?: typeof cliColor;
stdin?: typeof process.stdin;
}): void;
declare namespace grasp {
const VERSION: string;
// Both the search and replace functions are curryable, which leads to quite
// a bit of noise. Using generic currying will discard variable name
// information, so we hand-roll it here
function search(engine: QueryEngineType, selector: string, input: string): Node[];
function search(engine: QueryEngineType, selector: string): (input: string) => Node[];
function search(engine: QueryEngineType): GraspSearchWithQueryEngine;
function replace(engine: QueryEngineType, selector: string, replacement: Replacement, input: string): string;
function replace(engine: QueryEngineType, selector: string, replacement: Replacement): (input: string) => string;
function replace(engine: QueryEngineType, selector: string): GraspReplaceWithSelector;
function replace(engine: QueryEngineType): GraspReplaceWithQueryEngine;
type QueryEngineType = "squery" | "equery";
type Replacement =
| string
| ((
getRaw: (node: Node) => string,
node: Node,
query: (q: string) => Node[],
named: { [key: string]: string | Node }
) => string);
type GraspSearchWithQueryEngine = ((selector: string, input: string) => Node[]) &
((selector: string) => (input: string) => Node[]);
type GraspReplaceWithQueryEngine = ((selector: string) => GraspReplaceWithSelector) &
((selector: string, replacement: Replacement) => (input: string) => string) &
((selector: string, replacement: Replacement, input: string) => string);
type GraspReplaceWithSelector = ((replacement: Replacement) => (input: string) => string) &
((replacement: Replacement, input: string) => string);
}
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "grasp-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+117 -117
View File
@@ -7,15 +7,16 @@ import path = require('path');
import should = require('should');
import Stream = require('stream');
import through = require('through2');
var es = require('event-stream');
const es = require('event-stream');
//TODO: import es = require('event-stream');
// ReSharper disable WrongExpressionStatement
describe('File()', () => {
it('should return a valid file', done => {
var fname = path.join(__dirname, './fixtures/test.coffee');
var base = path.join(__dirname, './fixtures/');
var file = new util.File({
base: base,
const fname = path.join(__dirname, './fixtures/test.coffee');
const base = path.join(__dirname, './fixtures/');
const file = new util.File({
base,
cwd: __dirname,
path: fname
});
@@ -32,10 +33,10 @@ describe('File()', () => {
});
it('should return a valid file 2', done => {
var fname = path.join(__dirname, './fixtures/test.coffee');
var base = __dirname;
var file = new util.File({
base: base,
const fname = path.join(__dirname, './fixtures/test.coffee');
const base = __dirname;
const file = new util.File({
base,
cwd: __dirname,
path: fname
});
@@ -54,32 +55,31 @@ describe('File()', () => {
describe('replaceExtension()', () => {
it('should return a valid replaced extension on nested', done => {
var fname = path.join(__dirname, './fixtures/test.coffee');
var expected = path.join(__dirname, './fixtures/test.js');
var nu = util.replaceExtension(fname, '.js');
const fname = path.join(__dirname, './fixtures/test.coffee');
const expected = path.join(__dirname, './fixtures/test.js');
const nu = util.replaceExtension(fname, '.js');
should.exist(nu);
nu.should.equal(expected);
done();
});
it('should return a valid replaced extension on flat', done => {
var fname = 'test.coffee';
var expected = 'test.js';
var nu = util.replaceExtension(fname, '.js');
const fname = 'test.coffee';
const expected = 'test.js';
const nu = util.replaceExtension(fname, '.js');
should.exist(nu);
nu.should.equal(expected);
done();
});
it('should not return a valid replaced extension on empty string', done => {
var fname = '';
var expected = '';
var nu = util.replaceExtension(fname, '.js');
const fname = '';
const expected = '';
const nu = util.replaceExtension(fname, '.js');
should.exist(nu);
nu.should.equal(expected);
done();
});
});
describe('colors', () => {
@@ -96,14 +96,14 @@ describe('date', () => {
done();
});
it('should return today\'s date', done => {
var time = new Date();
var dateutil = util.date('HH:MM:ss');
dateutil.should.equal(('0' + time.getHours()).slice(-2) + ':' + ('0' + time.getMinutes()).slice(-2) + ':' + ('0' + time.getSeconds()).slice(-2));
const time = new Date();
const dateutil = util.date('HH:MM:ss');
dateutil.should.equal(`${('0' + time.getHours()).slice(-2)}:${('0' + time.getMinutes()).slice(-2)}:${('0' + time.getSeconds()).slice(-2)}`);
done();
});
});
var now = new Date();
const now = new Date();
// Basic usage
util.date(now, 'dddd, mmmm dS, yyyy, h:MM:ss TT');
@@ -157,11 +157,11 @@ util.date(now, 'N');
describe('log()', () => {
it('should work i guess', done => {
var writtenValue = '';
const writtenValue = '';
util.log(1, 2, 3, 4, 'five');
var time = util.date(new Date(), 'HH:MM:ss');
writtenValue.should.eql('[' + util.colors.gray(time) + '] 1 2 3 4 five\n');
const time = util.date(new Date(), 'HH:MM:ss');
writtenValue.should.eql(`[${util.colors.gray(time)}] 1 2 3 4 five\n`);
done();
});
@@ -169,34 +169,34 @@ describe('log()', () => {
describe('template()', () => {
it('should work with just a template', done => {
var opt = {
const opt = {
name: 'todd',
file: {
path: 'hi.js'
}
};
var expected = 'test todd hi.js';
const expected = 'test todd hi.js';
var tmpl = util.template('test <%= name %> <%= file.path %>');
const tmpl = util.template('test <%= name %> <%= file.path %>');
should.exist(tmpl);
'function'.should.equal(typeof (tmpl));
// eval it now
var etmpl = tmpl(opt);
const etmpl = tmpl(opt);
'string'.should.equal(typeof (etmpl));
etmpl.should.equal(expected);
done();
});
it('should work with a template and data', done => {
var opt = {
const opt = {
name: 'todd',
file: {
path: 'hi.js'
}
};
var expected = 'test todd hi.js';
var tmpl = util.template('test <%= name %> <%= file.path %>', opt);
const expected = 'test todd hi.js';
const tmpl = util.template('test <%= name %> <%= file.path %>', opt);
should.exist(tmpl);
'string'.should.equal(typeof (tmpl));
tmpl.should.equal(expected);
@@ -204,11 +204,11 @@ describe('template()', () => {
});
//it('should throw an error when no file object is passed', done => {
// var opt = {
// const opt = {
// name: 'todd'
// };
// try {
// var tmpl = util.template('test <%= name %> <%= file.path %>', opt);
// const tmpl = util.template('test <%= name %> <%= file.path %>', opt);
// } catch (err) {
// should.exist(err);
// done();
@@ -216,23 +216,23 @@ describe('template()', () => {
//});
it('should ignore modified templateSettings', done => {
var templateSettings = require('lodash.templatesettings');
const templateSettings = require('lodash.templatesettings');
templateSettings.interpolate = /\{\{([\s\S]+?)\}\}/g;
var opt = {
const opt = {
name: 'todd',
file: {
path: 'hi.js'
}
};
var expected = 'test {{name}} hi.js';
const expected = 'test {{name}} hi.js';
var tmpl = util.template('test {{name}} <%= file.path %>');
const tmpl = util.template('test {{name}} <%= file.path %>');
should.exist(tmpl);
'function'.should.equal(typeof (tmpl));
// eval it now
var etmpl = tmpl(opt);
const etmpl = tmpl(opt);
'string'.should.equal(typeof (etmpl));
etmpl.should.equal(expected);
@@ -240,26 +240,25 @@ describe('template()', () => {
});
it('should allow ES6 delimiters', done => {
var opt = {
const opt = {
name: 'todd',
file: {
path: 'hi.js'
}
};
var expected = 'test todd hi.js';
const expected = 'test todd hi.js';
var tmpl = util.template('test ${name} ${file.path}');
const tmpl = util.template('test ${name} ${file.path}'); // tslint:disable-line no-invalid-template-strings
should.exist(tmpl);
'function'.should.equal(typeof (tmpl));
// eval it now
var etmpl = tmpl(opt);
const etmpl = tmpl(opt);
'string'.should.equal(typeof (etmpl));
etmpl.should.equal(expected);
done();
});
});
describe('env', () => {
@@ -276,8 +275,8 @@ describe('noop()', () => {
done();
});
it('should return a stream that passes through all data', done => {
var inp = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var stream = util.noop();
const inp = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const stream = util.noop();
es.readArray(inp)
.pipe(stream)
.pipe(es.writeArray((err: Error, arr: any[]) => {
@@ -291,7 +290,7 @@ describe('noop()', () => {
describe('beep()', () => {
it('should send the right code to stdout', done => {
var writtenValue = '';
const writtenValue = '';
util.beep();
writtenValue.should.equal('\x07');
@@ -338,45 +337,45 @@ describe('isNull()', () => {
});
// linefeed
declare var lines: string[];
declare const lines: string[];
lines.join(util.linefeed);
describe('combine()', () => {
it('should return a function', done => {
var src = [1, 2, 3];
var inp = es.readArray(src);
var factory = util.combine(inp);
const src = [1, 2, 3];
const inp = es.readArray(src);
const factory = util.combine(inp);
factory.should.be.type('function');
done();
});
it('should return a function that returns a stream combination', done => {
var src = [1, 2, 3];
var inp = es.readArray(src);
var inp2 = es.writeArray((err: Error, data: any[]) => {
const src = [1, 2, 3];
const inp = es.readArray(src);
const inp2 = es.writeArray((err: Error, data: any[]) => {
should.not.exist(err);
data.should.eql(src);
done();
});
var factory = util.combine(inp, inp2);
const factory = util.combine(inp, inp2);
factory().should.be.instanceof(Stream.Readable);
});
it('should return a function that returns a stream combination when given an array', done => {
var src = [1, 2, 3];
var inp = es.readArray(src);
var inp2 = es.writeArray((err: Error, data: any[]) => {
const src = [1, 2, 3];
const inp = es.readArray(src);
const inp2 = es.writeArray((err: Error, data: any[]) => {
should.not.exist(err);
data.should.eql(src);
done();
});
var factory = util.combine([inp, inp2]);
const factory = util.combine([inp, inp2]);
factory().should.be.instanceof(Stream.Readable);
});
});
describe('buffer()', () => {
it('should buffer stuff and return an array into the callback', done => {
var src = [1, 2, 3];
var inp = es.readArray(src);
const src = [1, 2, 3];
const inp = es.readArray(src);
inp.pipe(util.buffer((err: Error, data: any[]) => {
should.not.exist(err);
should.exist(data);
@@ -385,8 +384,8 @@ describe('buffer()', () => {
}));
});
it('should buffer stuff and emit it as a data event', done => {
var src = [1, 2, 3];
var inp = es.readArray(src);
const src = [1, 2, 3];
const inp = es.readArray(src);
inp.pipe(util.buffer()).on('data', (data: any[]) => {
should.exist(data);
data.should.eql(src);
@@ -394,8 +393,8 @@ describe('buffer()', () => {
});
});
it('should buffer stuff and return a stream with the buffered data', done => {
var src = [1, 2, 3];
var inp = es.readArray(src);
const src = [1, 2, 3];
const inp = es.readArray(src);
inp.pipe(util.buffer()).pipe(es.through((data: any[]) => {
should.exist(data);
data.should.eql(src);
@@ -406,35 +405,35 @@ describe('buffer()', () => {
describe('PluginError()', () => {
it('should default name to Error', () => {
var err = new util.PluginError('test', 'something broke');
const err = new util.PluginError('test', 'something broke');
err.name.should.equal('Error');
});
it('should default name to Error, even when wrapped error has no name', () => {
var realErr = { message: 'something broke' };
var err = new util.PluginError('test', realErr);
const realErr = { message: 'something broke' };
const err = new util.PluginError('test', realErr);
err.name.should.equal('Error');
});
it('should print the plugin name in toString', () => {
var err = new util.PluginError('test', 'something broke');
const err = new util.PluginError('test', 'something broke');
err.toString().indexOf('test').should.not.equal(-1);
});
it('should not include the stack by default in toString', () => {
var err = new util.PluginError('test', 'something broke');
const err = new util.PluginError('test', 'something broke');
// just check that there are no 'at' lines
err.toString().indexOf('at').should.equal(-1);
});
it('should include the stack when specified in toString', () => {
var err = new util.PluginError('test', 'something broke', { stack: "at huh", showStack: true });
const err = new util.PluginError('test', 'something broke', { stack: "at huh", showStack: true });
// just check that there are 'at' lines
err.toString().indexOf('at').should.not.equal(-1);
});
it('should take arguments as one object', () => {
var err = new util.PluginError({
const err = new util.PluginError({
plugin: 'test',
message: 'something broke'
});
@@ -443,7 +442,7 @@ describe('PluginError()', () => {
});
it('should take arguments as plugin name and one object', () => {
var err = new util.PluginError('test', {
const err = new util.PluginError('test', {
message: 'something broke'
});
err.plugin.should.equal('test');
@@ -451,22 +450,22 @@ describe('PluginError()', () => {
});
it('should take arguments as plugin name and message', () => {
var err = new util.PluginError('test', 'something broke');
const err = new util.PluginError('test', 'something broke');
err.plugin.should.equal('test');
err.message.should.equal('something broke');
});
it('should take arguments as plugin name, message, and one object', () => {
var err = new util.PluginError('test', 'something broke', { showStack: true });
const err = new util.PluginError('test', 'something broke', { showStack: true });
err.plugin.should.equal('test');
err.message.should.equal('something broke');
err.showStack.should.equal(true);
});
it('should take arguments as plugin name, error, and one object', () => {
var realErr = new Error('something broke');
(<any>realErr).fileName = 'original.js';
var err = new util.PluginError('test', realErr, { showStack: true, fileName: 'override.js' });
const realErr = new Error('something broke') as Error & { fileName: string };
realErr.fileName = 'original.js';
const err = new util.PluginError('test', realErr, { showStack: true, fileName: 'override.js' });
err.plugin.should.equal('test');
err.message.should.equal('something broke');
err.fileName.should.equal('override.js');
@@ -474,26 +473,27 @@ describe('PluginError()', () => {
});
it('should take properties from error', () => {
var realErr = new Error('something broke');
(<any>realErr).abstractProperty = 'abstract';
var err = new util.PluginError('test', realErr);
const realErr = new Error('something broke') as Error & { abstractProperty: string };
realErr.abstractProperty = 'abstract';
const err = new util.PluginError('test', realErr);
err.plugin.should.equal('test');
err.message.should.equal('something broke');
(<any>err).abstractProperty.should.equal('abstract');
// TODO: use generics to make this work without a cast?
(err as util.PluginError & { abstractProperty: string }).abstractProperty.should.equal('abstract');
});
it('should be configured to show properties by default', () => {
var err = new util.PluginError('test', 'something broke');
const err = new util.PluginError('test', 'something broke');
err.showProperties.should.be.true;
});
it('should not be configured to take option to show properties', () => {
var err = new util.PluginError('test', 'something broke', { showProperties: false });
const err = new util.PluginError('test', 'something broke', { showProperties: false });
err.showProperties.should.be.false;
});
it('should show properties', () => {
var err = new util.PluginError('test', 'it broke', { showProperties: true });
const err = new util.PluginError('test', 'it broke', { showProperties: true });
err.fileName = 'original.js';
err.lineNumber = 35;
err.toString().indexOf('it broke').should.not.equal(-1);
@@ -502,25 +502,25 @@ describe('PluginError()', () => {
});
it('should show properties', () => {
var realErr = new Error('something broke');
(<any>realErr).fileName = 'original.js';
(<any>realErr).lineNumber = 35;
var err = new util.PluginError('test', realErr, { showProperties: true });
const realErr = new Error('something broke') as Error & { fileName: string, lineNumber: number };
realErr.fileName = 'original.js';
realErr.lineNumber = 35;
const err = new util.PluginError('test', realErr, { showProperties: true });
err.toString().indexOf('message:').should.equal(-1);
err.toString().indexOf('fileName:').should.not.equal(-1);
});
it('should not show properties', () => {
var realErr = new Error('something broke');
(<any>realErr).fileName = 'original.js';
(<any>realErr).lineNumber = 35;
var err = new util.PluginError('test', realErr, { showProperties: false });
const realErr = new Error('something broke') as Error & { fileName: string, lineNumber: number };
realErr.fileName = 'original.js';
realErr.lineNumber = 35;
const err = new util.PluginError('test', realErr, { showProperties: false });
err.toString().indexOf('message:').should.equal(-1);
err.toString().indexOf('fileName:').should.equal(-1);
});
it('should not show properties, but should show stack', () => {
var err = new util.PluginError('test', 'it broke', { stack: 'test stack', showStack: true, showProperties: false });
const err = new util.PluginError('test', 'it broke', { stack: 'test stack', showStack: true, showProperties: false });
err.fileName = 'original.js';
err.lineNumber = 35;
err.toString().indexOf('message:').should.equal(-1);
@@ -529,40 +529,40 @@ describe('PluginError()', () => {
});
it('should not show properties, but should show stack for real error', () => {
var realErr = new Error('something broke');
(<any>realErr).fileName = 'original.js';
(<any>realErr).lineNumber = 35;
(<any>realErr).stack = 'test stack';
var err = new util.PluginError('test', realErr, { showStack: true, showProperties: false });
const realErr = new Error('something broke') as Error & { fileName: string, lineNumber: number };
realErr.fileName = 'original.js';
realErr.lineNumber = 35;
realErr.stack = 'test stack';
const err = new util.PluginError('test', realErr, { showStack: true, showProperties: false });
err.toString().indexOf('message:').should.equal(-1);
err.toString().indexOf('fileName:').should.equal(-1);
err.toString().indexOf('test stack').should.not.equal(-1);
});
it('should not show properties, but should show stack for _stack', () => {
var realErr = new Error('something broke');
(<any>realErr).fileName = 'original.js';
(<any>realErr).lineNumber = 35;
(<any>realErr)._stack = 'test stack';
var err = new util.PluginError('test', realErr, { showStack: true, showProperties: false });
const realErr = new Error('something broke') as Error & { fileName: string, lineNumber: number, _stack: string };
realErr.fileName = 'original.js';
realErr.lineNumber = 35;
realErr._stack = 'test stack';
const err = new util.PluginError('test', realErr, { showStack: true, showProperties: false });
err.toString().indexOf('message:').should.equal(-1);
err.toString().indexOf('fileName:').should.equal(-1);
err.toString().indexOf('test stack').should.not.equal(-1);
});
it('should show properties and stack', () => {
var realErr = new Error('something broke');
(<any>realErr).fileName = 'original.js';
(<any>realErr).stack = 'test stack';
var err = new util.PluginError('test', realErr, { showStack: true });
const realErr = new Error('something broke') as Error & { fileName: string };
realErr.fileName = 'original.js';
realErr.stack = 'test stack';
const err = new util.PluginError('test', realErr, { showStack: true });
err.toString().indexOf('message:').should.equal(-1);
err.toString().indexOf('fileName:').should.not.equal(-1);
err.toString().indexOf('test stack').should.not.equal(-1);
});
it('should show properties added after the error is created', () => {
var realErr = new Error('something broke');
var err = new util.PluginError('test', realErr);
const realErr = new Error('something broke');
const err = new util.PluginError('test', realErr);
err.fileName = 'original.js';
err.toString().indexOf('message:').should.equal(-1);
err.toString().indexOf('fileName:').should.not.equal(-1);
@@ -571,8 +571,8 @@ describe('PluginError()', () => {
it('should toString quickly', function(done) {
this.timeout(100);
var err = new util.PluginError('test', 'it broke', { showStack: true });
var str = err.toString();
const err = new util.PluginError('test', 'it broke', { showStack: true });
const str = err.toString();
done();
});
@@ -580,15 +580,15 @@ describe('PluginError()', () => {
it('should toString quickly with original error', function(done) {
this.timeout(100);
var realErr = new Error('it broke');
var err = new util.PluginError('test', realErr, { showStack: true });
var str = err.toString();
const realErr = new Error('it broke');
const err = new util.PluginError('test', realErr, { showStack: true });
const str = err.toString();
done();
});
it('should not show "Details:" if there are no properties to show', () => {
var err = new util.PluginError('plugin', 'message');
const err = new util.PluginError('plugin', 'message');
err.toString().indexOf('Details:').should.equal(-1);
});
});
+51 -55
View File
@@ -1,53 +1,50 @@
// Type definitions for gulp-util v3.0.x
// Type definitions for gulp-util 3.0
// Project: https://github.com/gulpjs/gulp-util
// Definitions by: jedmao <https://github.com/jedmao>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
/// <reference types="chalk" />
/// <reference types="vinyl" />
import vinyl = require('vinyl');
import chalk = require('chalk');
import chalk from 'chalk';
import through2 = require('through2');
export { vinyl as File };
/**
* Replaces a file extension in a path. Returns the new path.
*/
* Replaces a file extension in a path. Returns the new path.
*/
export function replaceExtension(npath: string, ext: string): string;
export var colors: typeof chalk;
export const colors: typeof chalk;
export var date: {
(now?: Date, mask?: string, convertLocalTimeToUTC?: boolean): any;
(date?: string, mask?: string, convertLocalTimeToUTC?: boolean): any;
export const date: {
(now?: Date | string, mask?: string, convertLocalTimeToUTC?: boolean): any;
masks: any;
};
/**
* Logs stuff. Already prefixed with [gulp] and all that. Use the right colors
* for values. If you pass in multiple arguments it will join them by a space.
*/
* Logs stuff. Already prefixed with [gulp] and all that. Use the right colors
* for values. If you pass in multiple arguments it will join them by a space.
*/
export function log(message?: any, ...optionalParams: any[]): void;
/**
* This is a lodash.template function wrapper. You must pass in a valid gulp
* file object so it is available to the user or it will error. You can not
* configure any of the delimiters. Look at the lodash docs for more info.
*/
* This is a lodash.template function wrapper. You must pass in a valid gulp
* file object so it is available to the user or it will error. You can not
* configure any of the delimiters. Look at the lodash docs for more info.
*/
export function template(tmpl: string): (opt: { file: { path: string } }) => string;
export function template(tmpl: string, opt: { file: { path: string } }): string;
export var env: any;
export const env: any;
export function beep(): void;
/**
* Returns a stream that does nothing but pass data straight through.
*/
export var noop: typeof through2;
* Returns a stream that does nothing but pass data straight through.
*/
export const noop: typeof through2;
export function isStream(obj: any): boolean;
@@ -55,47 +52,46 @@ export function isBuffer(obj: any): boolean;
export function isNull(obj: any): boolean;
export var linefeed: string;
export const linefeed: string;
export function combine(streams: NodeJS.ReadWriteStream[]): () => NodeJS.ReadWriteStream;
export function combine(...streams: NodeJS.ReadWriteStream[]): () => NodeJS.ReadWriteStream;
/**
* This is similar to es.wait but instead of buffering text into one string
* it buffers anything into an array (so very useful for file objects).
*/
* This is similar to es.wait but instead of buffering text into one string
* it buffers anything into an array (so very useful for file objects).
*/
export function buffer(cb?: (err: Error, data: any[]) => void): NodeJS.ReadWriteStream;
export class PluginError implements Error, PluginErrorOptions {
constructor(options?: PluginErrorOptions);
constructor(pluginName: string, options?: PluginErrorOptions);
constructor(pluginName: string, message: string, options?: PluginErrorOptions);
constructor(pluginName: string, message: Error, options?: PluginErrorOptions);
constructor(pluginName: string, message: string | Error, options?: PluginErrorOptions);
/**
* The module name of your plugin.
*/
* The module name of your plugin.
*/
name: string;
/**
* Can be a string or an existing error.
*/
* Can be a string or an existing error.
*/
message: any;
fileName: string;
lineNumber: number;
/**
* You need to include the message along with this stack. If you pass an
* error in as the message the stack will be pulled from that, otherwise one
* will be created.
*/
* You need to include the message along with this stack. If you pass an
* error in as the message the stack will be pulled from that, otherwise one
* will be created.
*/
stack: string;
/**
* By default the stack will not be shown. Set this to true if you think the
* stack is important for your error.
*/
* By default the stack will not be shown. Set this to true if you think the
* stack is important for your error.
*/
showStack: boolean;
/**
* Error properties will be included in err.toString(). Can be omitted by
* setting this to false.
*/
* Error properties will be included in err.toString(). Can be omitted by
* setting this to false.
*/
showProperties: boolean;
plugin: string;
error: Error;
@@ -103,30 +99,30 @@ export class PluginError implements Error, PluginErrorOptions {
export interface PluginErrorOptions {
/**
* The module name of your plugin.
*/
* The module name of your plugin.
*/
name?: string;
/**
* Can be a string or an existing error.
*/
* Can be a string or an existing error.
*/
message?: any;
fileName?: string;
lineNumber?: number;
/**
* You need to include the message along with this stack. If you pass an
* error in as the message the stack will be pulled from that, otherwise one
* will be created.
*/
* You need to include the message along with this stack. If you pass an
* error in as the message the stack will be pulled from that, otherwise one
* will be created.
*/
stack?: string;
/**
* By default the stack will not be shown. Set this to true if you think the
* stack is important for your error.
*/
* By default the stack will not be shown. Set this to true if you think the
* stack is important for your error.
*/
showStack?: boolean;
/**
* Error properties will be included in err.toString(). Can be omitted by
* setting this to false.
*/
* Error properties will be included in err.toString(). Can be omitted by
* setting this to false.
*/
showProperties?: boolean;
plugin?: string;
error?: Error;
+3 -75
View File
@@ -1,80 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"adjacent-overload-signatures": false,
"array-type": false,
"arrow-return-shorthand": false,
"ban-types": false,
"callable-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"export-just-namespace": false,
"import-spacing": false,
"interface-name": false,
"interface-over-type-literal": false,
"jsdoc-format": false,
"max-line-length": false,
"member-access": false,
"new-parens": false,
"no-any-union": false,
"no-boolean-literal-compare": false,
"no-conditional-assignment": false,
"no-consecutive-blank-lines": false,
"no-construct": false,
"no-declare-current-package": false,
"no-duplicate-imports": false,
"no-duplicate-variable": false,
"no-empty-interface": false,
"no-for-in-array": false,
"no-inferrable-types": false,
"no-internal-module": false,
"no-invalid-template-strings": false,
"no-irregular-whitespace": false,
"no-mergeable-namespace": false,
"no-misused-new": false,
"no-namespace": false,
"no-object-literal-type-assertion": false,
"no-padding": false,
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-redundant-undefined": false,
"no-reference-import": false,
"no-relative-import-in-test": false,
"no-self-import": false,
"no-single-declare-module": false,
"no-string-throw": false,
"no-unnecessary-callback-wrapper": false,
"no-unnecessary-class": false,
"no-unnecessary-generics": false,
"no-unnecessary-qualifier": false,
"no-unnecessary-type-assertion": false,
"no-useless-files": false,
"no-var-keyword": false,
"no-var-requires": false,
"no-void-expression": false,
"no-trailing-whitespace": false,
"object-literal-key-quotes": false,
"object-literal-shorthand": false,
"one-line": false,
"one-variable-per-declaration": false,
"only-arrow-functions": false,
"prefer-conditional-expression": false,
"prefer-const": false,
"prefer-declare-function": false,
"prefer-for-of": false,
"prefer-method-signature": false,
"prefer-template": false,
"radix": false,
"semicolon": false,
"space-before-function-paren": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"triple-equals": false,
"typedef-whitespace": false,
"unified-signatures": false,
"void-return": false,
"whitespace": false
"comment-format": false, // TODO
"no-reference-import": false, // TODO: fix "should"
"no-var-requires": false // TODO
}
}
+13
View File
@@ -179,3 +179,16 @@ pixelProjection.rescale(12);
const point = pixelProjection.geoToPixel({ lat: 53, lng: 12 });
pixelProjection.xyToGeo(point.x, point.y);
const engine = map.getEngine();
engine.getAnimationDuration();
engine.setAnimationDuration(1000);
engine.getAnimationEase();
engine.setAnimationEase(H.util.animation.ease.EASE_IN_QUAD);
const engineListener = (e: Event) => {
console.log(e);
};
engine.addEventListener('tap', engineListener);
engine.removeEventListener('tap', engineListener);
+261
View File
@@ -264,6 +264,12 @@ declare namespace H {
* @param opt_scope {Object=} - An optional scope to call the callback in.
*/
addOnDisposeCallback(callback: () => void, opt_scope?: {}): void;
/**
* This returns the map's render engine
* @return {H.map.render.p2d.RenderEngine} - map render engine
*/
getEngine(): H.map.render.p2d.RenderEngine;
}
namespace Map {
@@ -3606,6 +3612,261 @@ declare namespace H {
}
}
}
namespace render {
/**
* This is an abstract class representing a render engine. Render engines are used to render the geographical position from a view model on the
* screen (viewport element). The rendered result may be different for different engines, because every engine uses its own capabilities and
* specific implementation to present the current view model data in best possible way. For example, 2D engines create a two-dimensional flat
* map composed of tiles, while 3D engines can generate panoramas displaying the same coordinates as a 'street view'.
*/
class RenderEngine extends H.util.EventTarget {
/**
* Constructor
* @param viewPort {H.map.ViewPort} - An object representing the map viewport
* @param viewModel {H.map.ViewModel} - An object representing a view of the map
* @param dataModel {H.map.DataModel} - An object encapsulating the data to be rendered on the map (layers and objects)
* @param options {H.map.render.RenderEngine.Options} - An object containing the render engine initialization options
*/
constructor(viewPort: H.map.ViewPort, viewModel: H.map.ViewModel, dataModel: H.map.DataModel, options: H.map.render.RenderEngine.Options);
/**
* This method adds a listener for a specific event.
* Note that to prevent potential memory leaks, you must either call removeEventListener or dispose on the given object when you no longer need it.
* @param type {string} - The name of the event
* @param handler {!Function} - An event handler function
* @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise)
* @param opt_scope {Object=} - An object defining the scope for the handler function
*/
addEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void;
/**
* This method removes a previously added listener from the EventTarget instance.
* @param type {string} - The name of the event
* @param handler {!Function} - A previously added event handler
* @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise)
* @param opt_scope {Object=} - An object defining the scope for the handler function
*/
removeEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void;
/**
* This method dispatches an event on the EventTarget object.
* @param evt {H.util.Event|string} - An object representing the event or a string with the event name
*/
dispatchEvent(evt: H.util.Event | string): void;
/**
* This method removes listeners from the given object. Classes that extend EventTarget may need to override this method in order to remove
* references to DOM Elements and additional listeners.
*/
dispose(): void;
/**
* This method adds a callback which is triggered when the EventTarget object is being disposed.
* @param callback {!Function} - The callback function.
* @param opt_scope {Object=} - An optional scope for the callback function
*/
addOnDisposeCallback(callback: () => void, opt_scope?: {}): void;
}
namespace RenderEngine {
/**
* An object containing the render engine initialization options
*/
interface Options {
[key: string]: string;
}
/**
* This object defines the modifiers to use for H.map.ViewPort#startInteraction.
*/
enum InteractionModifiers {
/** changes zoom level during the interaction */
ZOOM,
/** changes map center during the interaction */
HEADING,
/** changes heading angle during the interaction */
TILT,
/** changes tilt angle during the interaction */
INCLINE,
/** changes incline angle during the interaction */
COORD,
}
}
/**
* The rendering states of the layer.
*/
enum RenderState {
/**
* Data loading/processing is still in progress, but there is nothing to render. In this state rendering engine might go to sleep mode after
* certain amount of time to prevent draining of battery on the user device.
*/
PENDING,
/** Data rendering or animation is in progress. */
ACTIVE,
/** Data rendering or animation is done. */
DONE,
}
/**
* An object containing rendering parameters.
*/
interface RenderingParams {
/**
* The geographical area to render. Note that it is not the same as visible viewport. Specified bounds also include H.Map.Options#margin and
* optionally an additional margin in case of DOM node rendering for a better rendering experience.
* @type {H.geo.Rect}
*/
bounds: H.geo.Rect;
/**
* The zoom level to render the data for.
* @type {number}
*/
zoom: number;
/**
* The coordinates of the screen center in CSS pixels.
* @type {H.math.Point}
*/
screenCenter: H.math.Point;
/**
* The coordinates relative to the screen center where the rendering has the highest priority. If the layer has to request and/or process data
* asynchronously, it's recommended to prioritize the rendering close to this center.
* @type {H.math.Point}
*/
priorityCenter: H.math.Point;
/**
* The pixel projection to use to project geographical coordinates into screen coordinates and vice versa.
* @type {H.geo.PixelProjection}
*/
projection: H.geo.PixelProjection;
/**
* Indicates whether only cached data should be considered.
* @type {boolean}
*/
cacheOnly: boolean;
/**
* The size of the area to render.
* @type {H.math.Size}
*/
size: H.math.Size;
/**
* The pixelRatio to use for over-sampling in cases of high-resolution displays.
* See https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio.
* @type {number}
*/
pixelRatio: number;
}
/**
* Contains functionality specific to 2D map rendering.
*/
namespace p2d {
/**
* This class implements a map render engine. It presents a geographic location (camera data from a view model) and renders all map layers in
* the order in which they are provided in a single 2D canvas element.
*/
class RenderEngine extends H.map.render.RenderEngine {
/**
* Constructor
* @param viewPort {H.map.ViewPort} - An object representing the map viewport
* @param viewModel {H.map.ViewModel} - An object representing a view of the map
* @param dataModel {H.map.DataModel} - An object encapsulating the data to be rendered on the map (layers and objects)
* @param options {H.map.render.RenderEngine.Options} - An object containing the render engine initialization options
*/
constructor(viewPort: H.map.ViewPort, viewModel: H.map.ViewModel, dataModel: H.map.DataModel, options: H.map.render.RenderEngine.Options);
/**
* This method sets the length (duration) for all animations run by the render engine in milliseconds.
* @param duration {number} - A value indicating the duration of animations in milliseconds
*/
setAnimationDuration(duration: number): void;
/**
* This method retrieves the current setting indicating the length of animations (duration) run by the the render engine in milliseconds.
* @return {number}
*/
getAnimationDuration(): number;
/**
* This method sets a value indicating the easing to apply to animations run by the render engine.
* @param easeFunction {Function(number)} - A function that alters the progress ratio of an animation. It receives an argument indicating
* animation progress as a numeric value in the range between 0 and 1 and must return a numeric value in the same range.
*/
setAnimationEase(easeFunction: (progress: number) => number): void;
/**
* This method retrieves the current setting representing the easing to be applied to animations.
* @return {Function(number) => number} - A numeric value in the range 0 to 1
*/
getAnimationEase(): (progress: number) => number;
/**
* This method resets animation settings on the render engine to defaults.
* Duration is set to 300ms and easing to H.util.animation.ease.EASE_OUT_QUAD.
*/
resetAnimationDefaults(): void;
/**
* This method adds a listener for a specific event.
* Note that to prevent potential memory leaks, you must either call removeEventListener or dispose on the given object when you no longer need it.
* @param type {string} - The name of the event
* @param handler {!Function} - An event handler function
* @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise)
* @param opt_scope {Object=} - An object defining the scope for the handler function
*/
addEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void;
/**
* This method removes a previously added listener from the EventTarget instance.
* @param type {string} - The name of the event
* @param handler {!Function} - A previously added event handler
* @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise)
* @param opt_scope {Object=} - An object defining the scope for the handler function
*/
removeEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void;
/**
* This method dispatches an event on the EventTarget object.
* @param evt {H.util.Event|string} - An object representing the event or a string with the event name
*/
dispatchEvent(evt: H.util.Event | string): void;
/**
* This method removes listeners from the given object. Classes that extend EventTarget may need to override this method in order to remove
* references to DOM Elements and additional listeners.
*/
dispose(): void;
/**
* This method adds a callback which is triggered when the EventTarget object is being disposed.
* @param callback {!Function} - The callback function.
* @param opt_scope {Object=} - An optional scope for the callback function
*/
addOnDisposeCallback(callback: () => void, opt_scope?: {}): void;
}
namespace RenderEngine {
interface Options {
/** Object describes how many cached zoom levels should be used as a base map background while base map tiles are */
renderBaseBackground?: {};
/** The pixelRatio to use for over-sampling in cases of high-resolution displays */
pixelRatio: number;
/** optional */
enableSubpixelRendering?: boolean;
}
}
}
}
}
/***** mapevents *****/
-6
View File
@@ -1753,9 +1753,6 @@ declare namespace Highcharts {
* @deprecated
*/
defaultSeriesType?: string;
/**
*
*/
description?: string;
/**
* Event listeners for the chart.
@@ -3666,9 +3663,6 @@ declare namespace Highcharts {
* @default 0.1
*/
brightness?: number;
/**
*
*/
color?: string | Gradient;
/**
* Enable separate styles for the hovered series to visualize that the user hovers either the series itself or the
+1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/analog-nico/hpp
// Definitions by: Michael Strobel <https://github.com/kryops>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as express from 'express';
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
// FindQ <https://github.com/FindQ>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.1
declare namespace i18n {
interface ConfigurationOptions {
-36
View File
@@ -26081,8 +26081,6 @@ interface IgNumericEditor {
*/
toUpper?: any;
/**
*/
textMode?: any;
/**
@@ -26636,8 +26634,6 @@ interface IgCurrencyEditor {
*/
toUpper?: any;
/**
*/
textMode?: any;
/**
@@ -27068,8 +27064,6 @@ interface IgPercentEditor {
*/
toUpper?: any;
/**
*/
textMode?: any;
/**
@@ -27429,8 +27423,6 @@ interface IgMaskEditor {
*/
dropDownOnReadOnly?: boolean;
/**
*/
textMode?: any;
/**
@@ -27928,8 +27920,6 @@ interface IgDateEditor {
*/
dropDownOrientation?: string;
/**
*/
textMode?: any;
/**
@@ -28450,8 +28440,6 @@ interface IgDatePicker {
*/
dropDownOrientation?: string;
/**
*/
textMode?: any;
/**
@@ -30868,12 +30856,8 @@ interface JQuery {
*/
igNumericEditor(optionLiteral: 'option', optionName: "toUpper", optionValue: any): void;
/**
*/
igNumericEditor(optionLiteral: 'option', optionName: "textMode"): any;
/**
*/
igNumericEditor(optionLiteral: 'option', optionName: "textMode", optionValue: any): void;
/**
@@ -31777,12 +31761,8 @@ interface JQuery {
*/
igCurrencyEditor(optionLiteral: 'option', optionName: "toUpper", optionValue: any): void;
/**
*/
igCurrencyEditor(optionLiteral: 'option', optionName: "textMode"): any;
/**
*/
igCurrencyEditor(optionLiteral: 'option', optionName: "textMode", optionValue: any): void;
/**
@@ -32563,12 +32543,8 @@ interface JQuery {
*/
igPercentEditor(optionLiteral: 'option', optionName: "toUpper", optionValue: any): void;
/**
*/
igPercentEditor(optionLiteral: 'option', optionName: "textMode"): any;
/**
*/
igPercentEditor(optionLiteral: 'option', optionName: "textMode", optionValue: any): void;
/**
@@ -33206,12 +33182,8 @@ interface JQuery {
*/
igMaskEditor(optionLiteral: 'option', optionName: "dropDownOnReadOnly", optionValue: boolean): void;
/**
*/
igMaskEditor(optionLiteral: 'option', optionName: "textMode"): any;
/**
*/
igMaskEditor(optionLiteral: 'option', optionName: "textMode", optionValue: any): void;
/**
@@ -34144,12 +34116,8 @@ interface JQuery {
*/
igDateEditor(optionLiteral: 'option', optionName: "dropDownOrientation", optionValue: string): void;
/**
*/
igDateEditor(optionLiteral: 'option', optionName: "textMode"): any;
/**
*/
igDateEditor(optionLiteral: 'option', optionName: "textMode", optionValue: any): void;
/**
@@ -35092,12 +35060,8 @@ interface JQuery {
*/
igDatePicker(optionLiteral: 'option', optionName: "dropDownOrientation", optionValue: string): void;
/**
*/
igDatePicker(optionLiteral: 'option', optionName: "textMode"): any;
/**
*/
igDatePicker(optionLiteral: 'option', optionName: "textMode", optionValue: any): void;
/**
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for jest-json-schema 1.2
// Project: https://github.com/americanexpress/jest-json-schema#readme
// Definitions by: Igor Korolev <https://github.com/deadNightTiger>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jest" />
import * as ajv from "ajv";
declare global {
namespace jest {
interface Matchers<R> {
toMatchSchema(schema: object): R;
}
}
}
export const matchers: jest.ExpectExtendMap;
export function matchersWithOptions(options: ajv.Options): jest.ExpectExtendMap;
@@ -0,0 +1,13 @@
import { matchers } from 'jest-json-schema';
expect.extend(matchers);
it('validates my json', () => {
const schema = {
properties: {
hello: { type: 'string' },
},
required: ['hello'],
};
expect({ hello: 'world' }).toMatchSchema(schema);
});
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"ajv": "^4.11.5"
}
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jest-json-schema-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+6 -6
View File
@@ -4,19 +4,19 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import * as chalk from 'chalk';
import { Chalk } from 'chalk';
export const EXPECTED_COLOR: chalk.ChalkChain;
export const RECEIVED_COLOR: chalk.ChalkChain;
export const EXPECTED_BG: chalk.ChalkChain; // TODO: removed in b430e51a
export const RECEIVED_BG: chalk.ChalkChain; // TODO: removed in b430e51a
export const EXPECTED_COLOR: Chalk;
export const RECEIVED_COLOR: Chalk;
export const EXPECTED_BG: Chalk; // TODO: removed in b430e51a
export const RECEIVED_BG: Chalk; // TODO: removed in b430e51a
export const SUGGEST_TO_EQUAL: string;
export function stringify(object: any, maxDepth?: number): string;
export function highlightTrailingWhitespace(
text: string,
bgColor: chalk.ChalkChain // removed in b430e51a
bgColor: Chalk // removed in b430e51a
): string;
export function printReceived(object: any): string;
@@ -1,8 +1,8 @@
import * as chalk from 'chalk';
import chalk from 'chalk';
import * as utils from 'jest-matcher-utils';
utils.EXPECTED_COLOR; // $ExpectType ChalkChain
utils.RECEIVED_COLOR; // $ExpectType ChalkChain
utils.EXPECTED_COLOR; // $ExpectType Chalk
utils.RECEIVED_COLOR; // $ExpectType Chalk
utils.SUGGEST_TO_EQUAL; // $ExpectType string
utils.stringify({}); // $ExpectType string
+6
View File
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"chalk": "^2.2.0"
}
}
+3 -5
View File
@@ -235,7 +235,6 @@ interface JQueryStatic<TElement extends Node = HTMLElement> {
*
* @param element The DOM element to query for the data.
* @param key Name of the data stored.
* @param undefined
* @see {@link https://api.jquery.com/jQuery.data/}
* @since 1.2.3
*/
@@ -728,7 +727,7 @@ interface JQueryStatic<TElement extends Node = HTMLElement> {
* @see {@link https://api.jquery.com/jQuery.parseHTML/}
* @since 1.8
*/
parseHTML(data: string, context_keepScripts?: Document | null | undefined | boolean): JQuery.Node[];
parseHTML(data: string, context_keepScripts?: Document | null | boolean): JQuery.Node[];
/**
* Takes a well-formed JSON string and returns the resulting JavaScript value.
*
@@ -3422,7 +3421,6 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* data(name, value) or by an HTML5 data-* attribute.
*
* @param key Name of the data stored.
* @param undefined
* @see {@link https://api.jquery.com/data/}
* @since 1.2.3
*/
@@ -6774,7 +6772,7 @@ declare namespace JQuery {
(failFilter?: ((t: TJ, u: UJ, v: VJ, ...s: SJ[]) => PromiseBase<ARF, AJF, ANF,
BRF, BJF, BNF,
CRF, CJF, CNF,
RRF, RJF, RNF> | Thenable<ARF> | ARF) | undefined | null): PromiseBase<ARF, AJF, ANF,
RRF, RJF, RNF> | Thenable<ARF> | ARF) | null): PromiseBase<ARF, AJF, ANF,
BRF, BJF, BNF,
CRF, CJF, CNF,
RRF, RJF, RNF>;
@@ -7355,7 +7353,7 @@ declare namespace JQuery {
(failFilter?: ((...t: TJ[]) => PromiseBase<ARF, AJF, ANF,
BRF, BJF, BNF,
CRF, CJF, CNF,
RRF, RJF, RNF> | Thenable<ARF> | ARF) | undefined | null): PromiseBase<ARF, AJF, ANF,
RRF, RJF, RNF> | Thenable<ARF> | ARF) | null): PromiseBase<ARF, AJF, ANF,
BRF, BJF, BNF,
CRF, CJF, CNF,
RRF, RJF, RNF>;
+6 -3
View File
@@ -7193,7 +7193,8 @@ function JQuery_Promise3() {
}
async function testAsync(p: JQuery.Promise3<string, {}, {}, {}, {}, {}, {}, {}, {}>): Promise<string> {
return await p;
const s: string = await p;
return s;
}
function compatibleWithPromise(): Promise<any> {
@@ -7336,7 +7337,8 @@ function JQuery_Promise2(p: JQuery.Promise2<string, Error, number, JQuery, strin
}
async function testAsync(p: JQuery.Promise2<string, {}, {}, {}, {}, {}>): Promise<string> {
return await p;
const s: string = await p;
return s;
}
function compatibleWithPromise(): Promise<any> {
@@ -7456,7 +7458,8 @@ function JQuery_Promise(p: JQuery.Promise<string, Error, number>) {
}
async function testAsync(p: JQuery.Promise<string, Error, number>): Promise<string> {
return await p;
const s: string = await p;
return s;
}
function compatibleWithPromise(): Promise<any> {
+17 -16
View File
@@ -2215,8 +2215,8 @@ function test_hide() {
$("p").hide("slow");
});
$("#hidr").click(function () {
$("span:last-child").hide("fast", function () {
$(this).prev().hide("fast", arguments.callee);
$("span:last-child").hide("fast", function f() {
$(this).prev().hide("fast", f);
});
});
$("#showr").click(function () {
@@ -3126,20 +3126,21 @@ function test_map() {
}).get().join(", "));
var mappedItems = $("li").map(function (index) {
var replacement:any = $("<li>").text($(this).text()).get(0);
if (index === 0) {
// Make the first item all caps
$(replacement).text($(replacement).text().toUpperCase());
} else if (index === 1 || index === 3) {
// Delete the second and fourth items
replacement = null;
} else if (index === 2) {
// Make two of the third item and add some text
replacement = [replacement, $("<li>").get(0)];
$(replacement[0]).append("<b> - A</b>");
$(replacement[1]).append("Extra <b> - B</b>");
switch (index) {
case 0:
// Make the first item all caps
$(replacement).text($(replacement).text().toUpperCase());
break;
case 1:
case 3:
// Delete the second and fourth items
replacement = null;
break;
case 2:
// Make two of the third item and add some text
replacement = [replacement, $("<li>").get(0)];
$(replacement[0]).append("<b> - A</b>");
$(replacement[1]).append("Extra <b> - B</b>");
}
// Replacement will be a dom element, null,
+17 -16
View File
@@ -2215,8 +2215,8 @@ function test_hide() {
$("p").hide("slow");
});
$("#hidr").click(function () {
$("span:last-child").hide("fast", function () {
$(this).prev().hide("fast", arguments.callee);
$("span:last-child").hide("fast", function f() {
$(this).prev().hide("fast", f);
});
});
$("#showr").click(function () {
@@ -3126,20 +3126,21 @@ function test_map() {
}).get().join(", "));
var mappedItems = $("li").map(function (index) {
var replacement:any = $("<li>").text($(this).text()).get(0);
if (index === 0) {
// Make the first item all caps
$(replacement).text($(replacement).text().toUpperCase());
} else if (index === 1 || index === 3) {
// Delete the second and fourth items
replacement = null;
} else if (index === 2) {
// Make two of the third item and add some text
replacement = [replacement, $("<li>").get(0)];
$(replacement[0]).append("<b> - A</b>");
$(replacement[1]).append("Extra <b> - B</b>");
switch (index) {
case 0:
// Make the first item all caps
$(replacement).text($(replacement).text().toUpperCase());
break;
case 1:
case 3:
// Delete the second and fourth items
replacement = null;
break;
case 2:
// Make two of the third item and add some text
replacement = [replacement, $("<li>").get(0)];
$(replacement[0]).append("<b> - A</b>");
$(replacement[1]).append("Extra <b> - B</b>");
}
// Replacement will be a dom element, null,
+2 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for klaw v1.3.0
// Type definitions for klaw v2.1.0
// Project: https://github.com/jprichardson/node-klaw
// Definitions by: Matthew McEachen <https://github.com/mceachen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -25,6 +25,7 @@ declare module "klaw" {
pathSorter?: (pathA: string, pathB: string) => number
fs?: any // fs or mock-fs
filter?: (path: string) => boolean
depthLimit?: number
}
type Event = "close" | "data" | "end" | "readable" | "error"
+44
View File
@@ -0,0 +1,44 @@
// Type definitions for klaw v1.3.0
// Project: https://github.com/jprichardson/node-klaw
// Definitions by: Matthew McEachen <https://github.com/mceachen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare module "klaw" {
import * as fs from "fs"
import { Readable, ReadableOptions } from 'stream'
function K(root: string, options?: K.Options): K.Walker
namespace K {
interface Item {
path: string
stats: fs.Stats
}
type QueueMethod = "shift" | "pop"
interface Options extends ReadableOptions {
queueMethod?: QueueMethod
pathSorter?: (pathA: string, pathB: string) => number
fs?: any // fs or mock-fs
filter?: (path: string) => boolean
}
type Event = "close" | "data" | "end" | "readable" | "error"
interface Walker {
on(event: Event, listener: Function): this
on(event: "close", listener: () => void): this
on(event: "data", listener: (item: Item) => void): this
on(event: "end", listener: () => void): this
on(event: "readable", listener: () => void): this
on(event: "error", listener: (err: Error) => void): this
read(): Item
}
}
export = K
}
+43
View File
@@ -0,0 +1,43 @@
import * as klaw from "klaw";
const path = require('path');
// README.md: Streams 1 (push) example:
let items: klaw.Item[] = [] // files, directories, symlinks, etc
klaw('/some/dir')
.on('data', function(item: klaw.Item) {
items.push(item)
})
.on('end', function() {
console.dir(items) // => [ ... array of files]
})
// README.md: Streams 2 & 3 (pull) with error handling
klaw('/some/dir')
.on('readable', function() {
let item: klaw.Item;
while (item = this.read()) {
items.push(item)
}
})
.on('error', function(err: Error, item: klaw.Item) {
console.log(err.message)
console.log(item.path) // the file the error occurred on
})
.on('end', function() {
console.log(items) // => [ ... array of files]
})
// README.md: Example (ignore hidden directories):
var filterFunc = function(item: string): boolean {
var basename = path.basename(item);
return basename === '.' || basename[0] !== '.'
}
klaw('/some/dir', { filter: filterFunc })
.on('data', function(item: klaw.Item) {
// only items of none hidden folders will reach here
})
+28
View File
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"paths": {
"klaw": [
"klaw/v1"
]
},
"noImplicitAny": true,
"noImplicitThis": false,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"klaw-tests.ts"
]
}
+3 -1
View File
@@ -3,6 +3,8 @@
"rules": {
// TODOs
"no-mergeable-namespace": false,
"no-unnecsesary-class": false
"no-redundant-jsdoc": false,
"no-redundant-jsdoc-2": false,
"no-unnecessary-class": false
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/koa-modules/morgan
// Definitions by: Vesa Poikajärvi <https://github.com/vesse>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.1
import { IncomingMessage, ServerResponse } from 'http';
import * as Koa from 'koa';

Some files were not shown because too many files have changed in this diff Show More