Merge remote-tracking branch 'dt/master'

This commit is contained in:
taoqf
2018-09-03 15:31:20 +08:00
155 changed files with 2735 additions and 473 deletions
+349 -150
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -390,6 +390,12 @@
"sourceRepoURL": "https://github.com/MikeMcl/decimal.js",
"asOfVersion": "7.4.0"
},
{
"libraryName": "delay",
"typingsPackageName": "delay",
"sourceRepoURL": "https://github.com/sindresorhus/delay",
"asOfVersion": "3.1.0"
},
{
"libraryName": "DevExtreme",
"typingsPackageName": "devextreme",
+4
View File
@@ -0,0 +1,4 @@
export default function and(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
+33
View File
@@ -0,0 +1,33 @@
import bitsAnd from './and';
import bitsNor from './nor';
import bitsNot from './not';
import bitsOr from './or';
import bitsReduceAnd from './reduce-and';
import bitsReduceNand from './reduce-nand';
import bitsReduceNor from './reduce-nor';
import bitsReduceOr from './reduce-or';
import bitsReduceXnor from './reduce-xnor';
import bitsReduceXor from './reduce-xor';
import bitsToBoolean from './to-boolean';
import bitsToString from './to-string';
import bitsXnor from './xnor';
import bitsXor from './xor';
declare namespace bits {
const and: typeof bitsAnd;
const nor: typeof bitsNor;
const not: typeof bitsNot;
const or: typeof bitsOr;
const reduceAnd: typeof bitsReduceAnd;
const reduceNand: typeof bitsReduceNand;
const reduceNor: typeof bitsReduceNor;
const reduceOr: typeof bitsReduceOr;
const reduceXnor: typeof bitsReduceXnor;
const reduceXor: typeof bitsReduceXor;
const toBoolean: typeof bitsToBoolean;
const toString: typeof bitsToString;
const xnor: typeof bitsXnor;
const xor: typeof bitsXor;
}
export default bits;
+4
View File
@@ -0,0 +1,4 @@
export default function nand(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
+4
View File
@@ -0,0 +1,4 @@
export default function nor(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
+4
View File
@@ -0,0 +1,4 @@
export default function not(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
+4
View File
@@ -0,0 +1,4 @@
export default function or(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
+1
View File
@@ -0,0 +1 @@
export default function reduceAnd(bits: ReadonlyArray<number>): number;
+1
View File
@@ -0,0 +1 @@
export default function reduceNand(bits: ReadonlyArray<number>): number;
+1
View File
@@ -0,0 +1 @@
export default function reduceNor(bits: ReadonlyArray<number>): number;
+1
View File
@@ -0,0 +1 @@
export default function reduceOr(bits: ReadonlyArray<number>): number;
+1
View File
@@ -0,0 +1 @@
export default function reduceXnor(bits: ReadonlyArray<number>): number;
+1
View File
@@ -0,0 +1 @@
export default function reduceXor(bits: ReadonlyArray<number>): number;
+3
View File
@@ -0,0 +1,3 @@
export default function toBoolean(
bits: ReadonlyArray<number>
): ReadonlyArray<boolean>;
+5
View File
@@ -0,0 +1,5 @@
export default function toString(
bit: ReadonlyArray<number>,
spacing?: number,
spacer?: string
): string;
+4
View File
@@ -0,0 +1,4 @@
export default function xnor(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
+4
View File
@@ -0,0 +1,4 @@
export default function xor(
bits1: ReadonlyArray<number>,
bits2: ReadonlyArray<number>
): ReadonlyArray<number>;
+56
View File
@@ -0,0 +1,56 @@
// Demonstrating cherry-picking
import bitwise from 'bitwise';
import bits from 'bitwise/bits';
import toBoolean from 'bitwise/bits/to-boolean';
import buffer from 'bitwise/buffer';
import create from 'bitwise/buffer/create';
import byte from 'bitwise/byte';
import read from 'bitwise/byte/read';
import integer from 'bitwise/integer';
import setBit from 'bitwise/integer/set-bit';
import nibble from 'bitwise/nibble';
import nibbleRead from 'bitwise/nibble/read';
import string from 'bitwise/string';
import toBits from 'bitwise/string/to-bits';
// Testing basic functions
const testBits = [0, 1, 1, 0, 1];
// $ExpectType string
bitwise.bits.toString(testBits);
// $ExpectType ReadonlyArray<boolean>
bits.toBoolean(testBits);
// $ExpectType ReadonlyArray<boolean>
toBoolean(testBits);
// $ExpectType ReadonlyArray<number>
byte.read(12);
// $ExpectType ReadonlyArray<number>
read(12);
// $ExpectType Buffer
buffer.create(testBits);
// $ExpectType Buffer
create(testBits);
// $ExpectType ReadonlyArray<number>
integer.setBit(12, 1, 0);
// $ExpectType ReadonlyArray<number>
setBit(12, 1, 0);
// $ExpectType ReadonlyArray<number>
nibble.read(15);
// $ExpectType ReadonlyArray<number>
nibbleRead(15);
// $ExpectType ReadonlyArray<number>
string.toBits('10 10 12$%_.0');
// $ExpectType ReadonlyArray<number>
toBits('10 10 12$%_.0');
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function and(
buffer1: Buffer,
buffer2: Buffer,
isLooping?: boolean
): Buffer;
+3
View File
@@ -0,0 +1,3 @@
/// <reference types= "node" />
export default function create(bits: ReadonlyArray<number>): Buffer;
+31
View File
@@ -0,0 +1,31 @@
import bufferAnd from './and';
import bufferCreate from './create';
import bufferModify from './modify';
import bufferNand from './nand';
import bufferNor from './nor';
import bufferNot from './not';
import bufferOr from './or';
import bufferRead from './read';
import bufferReadCInt from './read-c-int';
import bufferReadInt from './read-int';
import bufferReadUInt from './read-u-int';
import bufferXnor from './xnor';
import bufferXor from './xor';
declare namespace buffer {
const and: typeof bufferAnd;
const create: typeof bufferCreate;
const modify: typeof bufferModify;
const nand: typeof bufferNand;
const nor: typeof bufferNor;
const not: typeof bufferNot;
const or: typeof bufferOr;
const read: typeof bufferRead;
const readCInt: typeof bufferReadCInt;
const readInt: typeof bufferReadInt;
const readUInt: typeof bufferReadUInt;
const xnor: typeof bufferXnor;
const xor: typeof bufferXor;
}
export default buffer;
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function modify(
buffer: Buffer,
newBits: ReadonlyArray<number>,
bitOffset?: number
): void;
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function nand(
buffer1: Buffer,
buffer2: Buffer,
isLooping?: boolean
): Buffer;
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function nor(
buffer1: Buffer,
buffer2: Buffer,
isLooping: boolean
): Buffer;
+3
View File
@@ -0,0 +1,3 @@
/// <reference types= "node" />
export default function not(buffer: Buffer): Buffer;
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function or(
buffer1: Buffer,
buffer2: Buffer,
isLooping?: boolean
): Buffer;
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function readCInt(
buffer: Buffer,
bitOffset?: number,
bitLength?: number
): number;
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function readInt(
buffer: Buffer,
bitOffset?: number,
bitLength?: number
): number;
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function readUInt(
buffer: Buffer,
bitOffset?: number,
bitLength?: number
): number;
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function read(
buffer: Buffer,
bitOffset?: number,
bitLength?: number
): ReadonlyArray<number>;
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function xnor(
buffer1: Buffer,
buffer2: Buffer,
isLooping?: boolean
): Buffer;
+7
View File
@@ -0,0 +1,7 @@
/// <reference types= "node" />
export default function xor(
buffer1: Buffer,
buffer2: Buffer,
isLooping?: boolean
): Buffer;
+9
View File
@@ -0,0 +1,9 @@
import byteRead from './read';
import byteWrite from './write';
declare namespace byte {
const read: typeof byteRead;
const write: typeof byteWrite;
}
export default byte;
+1
View File
@@ -0,0 +1 @@
export default function read(byte: number): ReadonlyArray<number>;
+1
View File
@@ -0,0 +1 @@
export default function write(bits: ReadonlyArray<number>): number;
+22
View File
@@ -0,0 +1,22 @@
// Type definitions for bitwise 1.5
// Project: https://github.com/dodekeract/bitwise
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import bitwiseBits from './bits';
import bitwiseBuffer from './buffer';
import bitwiseByte from './byte';
import bitwiseInteger from './integer';
import bitwiseNibble from './nibble';
import bitwiseString from './string';
declare namespace bitwise {
const bits: typeof bitwiseBits;
const buffer: typeof bitwiseBuffer;
const byte: typeof bitwiseByte;
const integer: typeof bitwiseInteger;
const nibble: typeof bitwiseNibble;
const string: typeof bitwiseString;
}
export default bitwise;
+1
View File
@@ -0,0 +1 @@
export default function getBit(number: number, position: number): number;
+11
View File
@@ -0,0 +1,11 @@
import integerGetBit from './get-bit';
import integerSetBit from './set-bit';
import integerToggleBit from './toggle-bit';
declare namespace integer {
const getBit: typeof integerGetBit;
const setBit: typeof integerSetBit;
const toggleBit: typeof integerToggleBit;
}
export default integer;
+5
View File
@@ -0,0 +1,5 @@
export default function setBit(
number: number,
position: number,
value: number
): ReadonlyArray<number>;
+4
View File
@@ -0,0 +1,4 @@
export default function toggleBit(
number: number,
position: number
): ReadonlyArray<number>;
+9
View File
@@ -0,0 +1,9 @@
import nibbleRead from './read';
import nibbleWrite from './write';
declare namespace nibble {
const read: typeof nibbleRead;
const write: typeof nibbleWrite;
}
export default nibble;
+1
View File
@@ -0,0 +1 @@
export default function read(nibble: number): ReadonlyArray<number>;
+1
View File
@@ -0,0 +1 @@
export default function write(nibble: ReadonlyArray<number>): number;
+7
View File
@@ -0,0 +1,7 @@
import stringToBits from './to-bits';
declare namespace string {
const toBits: typeof stringToBits;
}
export default string;
+1
View File
@@ -0,0 +1 @@
export default function toBits(string: string): ReadonlyArray<number>;
+60
View File
@@ -0,0 +1,60 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bitwise-tests.ts",
"bits/and.d.ts",
"bits/index.d.ts",
"bits/nand.d.ts",
"bits/nor.d.ts",
"bits/not.d.ts",
"bits/or.d.ts",
"bits/reduce-and.d.ts",
"bits/reduce-nand.d.ts",
"bits/reduce-nor.d.ts",
"bits/reduce-or.d.ts",
"bits/reduce-xnor.d.ts",
"bits/reduce-xor.d.ts",
"bits/to-boolean.d.ts",
"bits/to-string.d.ts",
"bits/xnor.d.ts",
"bits/xor.d.ts",
"buffer/and.d.ts",
"buffer/create.d.ts",
"buffer/modify.d.ts",
"buffer/nand.d.ts",
"buffer/nor.d.ts",
"buffer/not.d.ts",
"buffer/or.d.ts",
"buffer/read-c-int.d.ts",
"buffer/read-int.d.ts",
"buffer/read-u-int.d.ts",
"buffer/read.d.ts",
"buffer/xnor.d.ts",
"buffer/xor.d.ts",
"byte/index.d.ts",
"byte/read.d.ts",
"byte/write.d.ts",
"integer/get-bit.d.ts",
"integer/index.d.ts",
"integer/set-bit.d.ts",
"integer/toggle-bit.d.ts",
"nibble/index.d.ts",
"nibble/read.d.ts",
"nibble/write.d.ts",
"string/index.d.ts",
"string/to-bits.d.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+4
View File
@@ -0,0 +1,4 @@
import xor = require('buffer-xor');
// $ExpectType Buffer
xor(Buffer.from('a'), Buffer.from('b'));
+10
View File
@@ -0,0 +1,10 @@
// Type definitions for buffer-xor 2.0
// Project: https://github.com/crypto-browserify/buffer-xor
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types = "node" />
declare function xor(a: Buffer, b: Buffer): Buffer;
export = xor;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"buffer-xor-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1
View File
@@ -51,4 +51,5 @@ export interface CleaveOptions {
noImmediatePrefix?: boolean;
rawValueTrimPrefix?: boolean;
uppercase?: boolean;
onValueChanged?(event: any): void;
}
+1 -1
View File
@@ -64,7 +64,7 @@ export class Node {
/**
* either Bullet or Ordered (or undefined).
*/
listType: 'Bullet' | 'Ordered';
listType: 'bullet' | 'ordered';
/**
* true if list is tight
*/
@@ -0,0 +1,13 @@
import quantile = require('compute-quantile');
// $ExpectType number
quantile([1, 2, 3], 0.5);
// $ExpectType number
quantile([1, 2, 3], 0.5, undefined);
// $ExpectType number
quantile([1, 2, 3], 0.5, {});
// $ExpectType number
quantile([1, 2, 3], 0.5, { sorted: true });
+23
View File
@@ -0,0 +1,23 @@
// Type definitions for compute-quantile 1.0
// Project: https://github.com/compute-io/quantile
// Definitions by: mrmlnc <https://github.com/mrmlnc>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Computes a quantile for a numeric array.
*/
declare function quantile(array: ArrayLike<number>, quantile: number, options?: quantile.Options): number;
declare namespace quantile {
interface Options {
/**
* If the input `array` is already sorted in `__ascending__` order, you can set the `sorted` option to `true`.
*
* @default
* false
*/
sorted?: boolean;
}
}
export = quantile;
+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",
"compute-quantile-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
-47
View File
@@ -1,47 +0,0 @@
import delay = require('delay');
delay(200)
.then(() => {
});
let str: string;
let num: number;
Promise.resolve(delay(100))
.then(() => {
});
Promise.resolve("foo")
.then(delay<string>(100))
.then(result => {
str = result;
});
Promise.resolve('foo')
.then(delay(100, 10))
.then(result => {
num = result;
});
Promise.resolve('foo')
.then(delay.reject(100))
.then(x => 10)
.catch(err => {
});
Promise.resolve('foo')
.then(delay.reject(100, 'bar'))
.then(x => 10)
.catch(err => {
});
(async () => {
const delaying = delay(1000);
delaying.cancel();
try {
await delaying;
} catch (err) {
// `err` is an instance of `delay.CancelError`
}
})();
throw new delay.CancelError('bar');
-30
View File
@@ -1,30 +0,0 @@
// Type definitions for delay 2.0
// Project: https://github.com/sindresorhus/delay#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
export = delay;
declare function delay<T>(ms: number): delay.PDelayedPassThroughThunk<T>;
declare function delay<T>(ms: number, value: T): delay.PDelayedThunk<T>;
declare namespace delay {
function reject(ms: number, rejectionValue?: any): PDelayedThunk<never>;
class CancelError extends Error {
readonly name: 'CancelError';
constructor(message?: string);
}
type PDelayedThunk<T> = ((value: any) => DelayedPromiseLike<T>) & DelayedPromiseLike<T>;
type PDelayedPassThroughThunk<TValue> = ((value: TValue) => DelayedPromiseLike<TValue>) & DelayedPromiseLike<void>;
interface DelayedPromiseLike<T> {
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
cancel(): void;
}
}
-8
View File
@@ -1,8 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODO
"await-promise": false,
"no-unnecessary-generics": false
}
}
+6
View File
@@ -562,6 +562,12 @@ export interface QueryResult {
outputContexts: Context[];
intent: Intent;
intentDetectionConfidence: number;
sentimentAnalysisResult?: {
queryTextSentiment: {
magnitude: number;
score: number;
};
};
diagnosticInfo: any;
}
+56
View File
@@ -0,0 +1,56 @@
import * as et from 'elementtree';
// Example 1
// https://github.com/racker/node-elementtree#example-1--creating-an-xml-document
const XML = et.XML;
const ElementTree = et.ElementTree;
const element = et.Element;
const subElement = et.SubElement;
const root = element('entry');
root.set('xmlns', 'http://www.w3.org/2005/Atom');
const tenantId = subElement(root, 'TenantId');
tenantId.text = '12345';
const serviceName = subElement(root, 'ServiceName');
serviceName.text = 'MaaS';
const resourceId = subElement(root, 'ResourceID');
resourceId.text = 'enAAAA';
const usageId = subElement(root, 'UsageID');
usageId.text = '550e8400-e29b-41d4-a716-446655440000';
const eventType = subElement(root, 'EventType');
eventType.text = 'create';
const category = subElement(root, 'category');
category.set('term', 'monitoring.entity.create');
const dataCenter = subElement(root, 'DataCenter');
dataCenter.text = 'global';
const region = subElement(root, 'Region');
region.text = 'global';
const startTime = subElement(root, 'StartTime');
startTime.text = new Date();
const resourceName = subElement(root, 'ResourceName');
resourceName.text = 'entity';
const etree1 = new ElementTree(root);
const xml = etree1.write({ xml_declaration: false });
// Example 2
// https://github.com/racker/node-elementtree#example-2--parsing-an-xml-document
const data = '<xml></xml>';
const etree2 = et.parse(data);
etree2.findall('./entry/TenantId').length; // 2
etree2.findtext('./entry/ServiceName'); // MaaS
etree2.findall('./entry/category')[0].get('term'); // monitoring.entity.create
etree2.findall('*/category/[@term="monitoring.entity.update"]').length; // 1
+88
View File
@@ -0,0 +1,88 @@
// Type definitions for elementtree 0.1
// Project: https://github.com/racker/node-elementtree
// Definitions by: Daniel Imhoff <https://github.com/dwieeb>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface ElementTreeWriteOptions {
default_namespace?: string;
encoding?: string; // default is 'utf-8'
indent?: number;
method?: 'xml' | 'text'; // default is 'xml'
xml_declaration?: boolean; // on by default
}
export class ElementTree {
constructor(element: Element);
getroot(): Element;
_setroot(element: Element): void;
parse(source: string): Element;
find(path: string): Element | null;
findtext(path: string): ElementText | undefined;
findall(path: string): Element[];
write(options?: ElementTreeWriteOptions): string;
}
export interface Attributes {
[key: string]: string | undefined;
}
export type ElementTag = typeof Comment | typeof CData | typeof ProcessingInstruction | string;
export type ElementText = { toString(): string; } | string;
export interface Element {
tag: ElementTag;
attrib: Attributes;
text: ElementText | null;
tail: string | null;
toString(): string;
makeelement(tag: ElementTag, attrib?: Attributes): Element;
len(): number;
getItem(index: number): Element | undefined;
setItem(index: number, element: Element): void;
delItem(index: number): void;
getSlice(start: number, stop: number): Element[];
setSlice(start: number, stop: number, elements: ReadonlyArray<Element>): void;
delSlice(start: number, stop: number): void;
append(element: Element): void;
extend(elements: ReadonlyArray<Element>): void;
insert(index: number, element: Element): void;
remove(element: Element): void;
getchildren(): Element[];
find(path: string): Element | null;
findtext(path: string): ElementText | undefined;
findall(path: string): Element[];
clear(): void;
get(k: string): string | undefined;
set(k: string, v?: string): string;
keys(): string[];
items(): Array<[string, string]>;
}
export class QName {
text: string;
constructor(text_or_uri: string, tag?: string);
toString(): string;
}
// special tags
export function CData(text?: ElementText): Element;
export function Comment(text?: ElementText): Element;
export function ProcessingInstruction(target: ElementText, text?: ElementText): Element;
export function XML(data: string): Element;
export function Element(ElementTag: string, attrib?: Attributes): Element;
export function SubElement(parent: Element, ElementTag: string, attrib?: Attributes): Element;
export function parse(source: string): ElementTree;
export function register_namespace(prefix: string, uri: string): void;
export function tostring(element: Element, options: ElementTreeWriteOptions): string;
@@ -18,6 +18,6 @@
},
"files": [
"index.d.ts",
"delay-tests.ts"
"elementtree-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -34,9 +34,11 @@ app.use(expressWinston.logger({
],
}));
const logger = winston.createLogger();
// Logger with minimum options (winstonInstance)
app.use(expressWinston.logger({
winstonInstance: winston,
winstonInstance: logger,
}));
// Error Logger with all options
@@ -62,7 +64,7 @@ app.use(expressWinston.errorLogger({
// Error Logger with min options (winstonInstance)
app.use(expressWinston.errorLogger({
winstonInstance: winston,
winstonInstance: logger,
}));
expressWinston.bodyBlacklist.push('potato');
+3 -3
View File
@@ -1,4 +1,4 @@
// Type definitions for express-winston 2.4
// Type definitions for express-winston 3.0
// Project: https://github.com/bithavoc/express-winston#readme
// Definitions by: Alex Brick <https://github.com/bricka>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -44,7 +44,7 @@ export interface LoggerOptionsWithTransports extends BaseLoggerOptions {
}
export interface LoggerOptionsWithWinstonInstance extends BaseLoggerOptions {
winstonInstance: typeof winston;
winstonInstance: winston.Logger;
}
export type LoggerOptions = LoggerOptionsWithTransports | LoggerOptionsWithWinstonInstance;
@@ -66,7 +66,7 @@ export interface ErrorLoggerOptionsWithTransports extends BaseErrorLoggerOptions
}
export interface ErrorLoggerOptionsWithWinstonInstance extends BaseErrorLoggerOptions {
winstonInstance: typeof winston;
winstonInstance: winston.Logger;
}
export type ErrorLoggerOptions = ErrorLoggerOptionsWithTransports | ErrorLoggerOptionsWithWinstonInstance;
+1
View File
@@ -131,6 +131,7 @@ export interface Props {
onChildClick?(hoverKey: any, childProps: any): void;
onChildMouseEnter?(hoverKey: any, childProps: any): void;
onChildMouseLeave?(hoverKey: any, childProps: any): void;
onDrag?(args: any): void;
onZoomAnimationStart?(args: any): void;
onZoomAnimationEnd?(args: any): void;
onMapTypeIdChange?(args: any): void;
+7
View File
@@ -0,0 +1,7 @@
import GRPCError = require('grpc-error');
const error1 = new GRPCError('test');
const error2 = new GRPCError({status_code: 'invalid'});
const error3 = new GRPCError('test', 12);
const error4 = new GRPCError('test', {status_code: 'invalid'});
const error5 = new GRPCError('test', 12, {status_code: 'invalid'});
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for grpc-error 1.0
// Project: https://github.com/bojand/grpc-error
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
declare class GRPCError extends Error {
constructor(value: string | object);
constructor(message: string, value: number | object);
constructor(message: string, code: number, metadata: object);
code: number;
metadata: object;
}
export = GRPCError;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"grpc-error-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+8
View File
@@ -248,6 +248,7 @@ declare namespace karma {
* you can specify how many browsers should be running at once at any given point in time.
*/
concurrency?: number;
customLaunchers?: { [key: string]: CustomLauncher };
/**
* @default []
* @description List of files/patterns to exclude from loaded files.
@@ -470,6 +471,13 @@ declare namespace karma {
*/
nocache?: boolean;
}
interface CustomLauncher {
base: string;
browserName?: string;
flags?: string[];
platform?: string;
}
}
declare var karma: karma.Karma;
+6
View File
@@ -106,6 +106,12 @@ module.exports = function(config: karma.Config) {
'Chrome',
'Firefox'
],
customLaunchers: {
ChromiumHeadless_without_security: {
base: 'ChromiumHeadless',
flags: ['--no-sandbox', '--disable-setuid-sandbox'],
},
},
singleRun: true
});
+32
View File
@@ -0,0 +1,32 @@
// Type definitions for level-codec 9.0
// Project: https://github.com/Level/codec
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface CodecEncoder {
encode: (val: any) => any;
decode: (val: any) => any;
buffer: boolean;
type: string;
}
export interface CodecOptions {
keyEncoding?: string | CodecEncoder;
valueEncoding?: string | CodecEncoder;
}
export interface Codec {
encodeKey(key: any, opts?: CodecOptions, batchOpts?: CodecOptions): any;
encodeValue(value: any, opts?: CodecOptions, batchOpts?: CodecOptions): any;
decodeKey(key: any, opts?: CodecOptions): any;
decodeValue(value: any, opts?: CodecOptions): any;
encodeBatch(ops: any, opts?: CodecOptions): any;
encodeLtgt(ltgt: any): any;
createStreamDecoder(opts: CodecOptions): any;
keyAsBuffer(opts?: CodecOptions): any;
valueAsBuffer(opts?: CodecOptions): any;
}
export interface CodecConstructor {
new (options?: CodecOptions): Codec;
(options?: CodecOptions): Codec;
}
export const Codec: CodecConstructor;
+12
View File
@@ -0,0 +1,12 @@
import { Codec } from "level-codec";
const test = (codec: Codec) => {
return codec.keyAsBuffer();
};
test(new Codec({ keyEncoding: "hex" }));
test(new Codec());
// new not needed
test(Codec({ keyEncoding: "hex" }));
test(Codec());
+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",
"level-codec-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+15
View File
@@ -0,0 +1,15 @@
// Type definitions for mali 1.1
// Project: https://github.com/malijs/mali-compose
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
import { Context } from "mali";
declare function compose(
middleware: ReadonlyArray<
(ctx: Context, next: () => Promise<void>) => Promise<void>
>
): (context: Context, next: () => Promise<void>) => Promise<void>;
export = compose;
+39
View File
@@ -0,0 +1,39 @@
import compose = require('mali-compose');
import { Context } from 'mali';
type middleware = (context: Context, next: () => Promise<void>) => Promise<void>;
const arr: number[] = [];
const stack: middleware[] = [];
function _sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
stack.push(async (ctx: Context, next: () => Promise<void>) => {
arr.push(1);
await _sleep(1);
await next();
await _sleep(1);
arr.push(6);
});
stack.push(async (ctx: Context, next: () => Promise<void>) => {
arr.push(2);
await _sleep(1);
await next();
await _sleep(1);
arr.push(5);
});
stack.push(async (ctx: Context, next: () => Promise<void>) => {
arr.push(3);
await _sleep(1);
await next();
await _sleep(1);
arr.push(4);
});
compose(stack);
compose([]);
compose([compose(stack)]);
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"mali-compose-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+77
View File
@@ -0,0 +1,77 @@
// Type definitions for mali 0.9
// Project: https://github.com/malijs/mali
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
/// <reference types="node" />
import { EventEmitter } from 'events';
import { Stream } from 'stream';
declare class Mali extends EventEmitter {
constructor(path: any, name?: string | ReadonlyArray<string>, options?: any);
name: string;
env: string;
ports: ReadonlyArray<string | number>; // ? not sure which it is
silent: boolean;
addService(path: any, name: string | ReadonlyArray<string>, options?: any): void;
use(service?: any, name?: any, fns?: any): void;
start(port?: any, creds?: any, options?: any): any; // gnarly type asserting for these functions so Im just gonna let them handle it.
toJSON(): any;
close(): void;
inspect(): any;
}
declare namespace Mali {
interface Context {
name: string;
fullName: string;
service: string;
package: string;
app: any; // ? app
call: any;
request: Request;
response: Response;
req: any; // ?
res: any; // ?
type: string;
metadata: string;
get(field: string): any;
set(field: any, val?: any): void; // do I need `?:` if its of type `any`?
sendMetadata(md: any): void;
getStatus(field: string): any;
setStatus(field: any, val?: any): void; // ^
}
class Request {
constructor(call: any, type: string);
call: any;
type: string;
metadata: any;
req: any; // ?
getMetadata(): any;
get(field: string): any;
}
class Response {
constructor(call: any, type: string);
call: any;
type: string;
metadata: any;
status: any;
res: any; // ?
set(field: any, val?: any): void; // is `val?:` necessary when its of type `any`?
get(field: string): any;
getMetadata(): any;
sendMetadata(md?: any): void;
getStatus(field: string): any;
setStatus(field: any, val?: any): void; // ^ same as above
}
function exec(ctx: Context, handler: any, cb?: any): void;
}
export = Mali;
+16
View File
@@ -0,0 +1,16 @@
// example from https://github.com/malijs/mali#example
import Mali = require('mali');
import path = require('path');
const PROTO_PATH = path.resolve(__dirname, '../protos/helloworld.proto');
async function sayHello(ctx: Mali.Context) {
ctx.res = { message: 'Hello '.concat(ctx.req.name) };
}
const app = new Mali(PROTO_PATH);
// $ExpectType void
app.use({sayHello});
// $ExpectType any
app.start('127.0.0.1:50051');
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"mali-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+116
View File
@@ -0,0 +1,116 @@
// Type definitions for megajs 0.14
// Project: https://github.com/qgustavor/mega
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
import { Readable, Writable, Stream } from 'stream';
export interface AccountInfo {
type: string;
spaceUsed: number;
spaceTotal: number;
downloadBandwidthUsed: number;
downloadBandwidthTotal: number;
sharedBandwidthUsed: number;
sharedBandwidthLimit: number;
}
export interface DownloadOptions {
maxConnections?: number;
initialChunkSize?: number;
chunkSizeIncrement?: number;
maxChunkSize?: number;
returnCiphertext?: boolean;
start?: any;
end?: any;
}
export interface UploadOptions {
name: string;
attributes?: object;
size?: any;
thumbnailImage?: Buffer | Readable;
previewImage?: Buffer | Readable;
}
export interface LinkOptions {
noKey?: boolean;
key?: string | Buffer;
}
export interface MakeDirectoryOptions {
name: string;
attributes?: object;
key?: string | Buffer;
}
export interface FileOptions {
downloadId: string;
key: string;
directory: boolean;
}
export interface StorageOptions {
email: string;
password: string;
keepalive?: boolean;
autologin?: boolean;
autoload?: boolean;
}
export class File {
constructor(options: FileOptions | string);
static fromURL(options: FileOptions | string): File;
static unpackAttributes(at: any): JSON;
name: string;
attributes: object;
size: number;
key: Buffer;
timestamp: number;
nodeId: string;
downloadId: string;
directory: boolean;
children: ReadonlyArray<File>;
loadAttributes(cb?: any): Readable;
download(options?: DownloadOptions, cb?: any): Readable;
}
export class Storage {
constructor(options: StorageOptions, callback?: any);
static fromJSON(json: JSON): Storage;
name: string;
key: Buffer;
sid: string;
files: {[id in string]: MutableFile};
root: MutableFile;
trash: MutableFile;
inbox: MutableFile;
mounts: ReadonlyArray<File>;
upload(options: UploadOptions | string, buffer?: Buffer, cb?: any): Writable;
mkdir(options: MakeDirectoryOptions | string, cb: (err: Error | undefined, file: MutableFile) => void): Readable;
reload(cb: any): Readable;
login(cb: any): Readable;
getAccountInfo(cb: any): AccountInfo;
toJSON(): JSON;
}
export class MutableFile extends File {
constructor(options: FileOptions | string, storage: Storage);
upload(options: UploadOptions | string, buffer?: Buffer, cb?: any): Writable;
mkdir(options: MakeDirectoryOptions | string, cb?: any): Readable;
importFile(file: File | string, cb: (err: Error | undefined, file: MutableFile) => void): Readable;
link(options: LinkOptions | undefined, cb: (err: Error | undefined, url: string) => void): Readable;
shareFolder(options: LinkOptions | undefined, cb: (err: Error | undefined, url: string) => void): Readable;
delete(permanent: true | undefined, cb: (err: Error | undefined) => void): Readable;
moveTo(target: MutableFile | string, cb: (err: Error | undefined) => void): Readable;
setAttributes(attributes: object, cb: (err: Error | undefined) => void): Readable;
uploadAttribute(type: string | number, opt?: Buffer | Stream, cb?: any): Readable;
rename(newFileName: string, cb: (err: Error | undefined) => void): Readable;
setLabel(label: string, cb: (err: Error | undefined) => void): Readable;
setFavorite(isFavorite: boolean, cb: (err: Error | undefined) => void): Readable;
}
export default function mega(options: StorageOptions, cb?: any): Storage;
+9
View File
@@ -0,0 +1,9 @@
import mega from 'megajs';
// $ExpectType Storage
mega({email: 'test@test.net', password: '1234'});
// tslint:disable-next-line no-duplicate-imports
import { Storage } from 'megajs';
const storage = new Storage({email: 'test@test.net', password: '1234'});
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"megajs-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+4
View File
@@ -19,10 +19,13 @@ declare module "meteor/browser-policy-common" {
allowStyleOrigin(origin: string): void;
allowScriptOrigin(origin: string): void;
allowFrameOrigin(origin: string): void;
allowFrameAncestorsOrigin(origin: string): void;
allowContentTypeSniffing(): void;
allowAllContentOrigin(): void;
allowAllContentDataUrl(): void;
allowAllContentSameOrigin(): void;
allowConnectOrigin(origin: string): void;
allowObjectOrigin(origin: string): void;
disallowAll(): void;
disallowInlineStyles(): void;
@@ -31,6 +34,7 @@ declare module "meteor/browser-policy-common" {
disallowFont(): void;
disallowObject(): void;
disallowAllContent(): void;
disallowConnect(): void;
};
}
}
+126
View File
@@ -0,0 +1,126 @@
// Type definitions for node-localstorage 1.3
// Project: https://github.com/lmaccherone/node-localstorage
// Definitions by: Allen Gammel <https://github.com/intolerance>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { EventEmitter } from 'events';
/**
* A drop-in substitute for the browser native localStorage API that runs on node.js.
* Copyright (c) 2012, Lawrence S. Maccherone, Jr. -- https://github.com/lmaccherone/node-localstorage
* (MIT License)
*/
export class LocalStorage extends EventEmitter {
/**
* The number of keys in the local storage.
*/
length: number;
/**
* Clears the local storage
*/
clear(): void;
/**
* Gets the value of the given [key]
* @param key The key whose value you want to retrieve.
*/
getItem(key: string): string | null;
/**
* Retrieves the value of the key at the [index].
* @param index The index of the key in which you want to return the value of.
*/
key(index: number): string;
/**
* Removes the specified [key] from local storage.
* @param key The key you want to remove.
*/
removeItem(key: string): void;
/**
* Stores a `key` and it's `value` in to the local store.
* @param key Unique identifier for the new local storage item
* @param value The value of the item
*/
setItem(key: string, value: string): void;
/**
* Internal event `storage` is fired on the `removeItem`, `setItem` and `clear` methods, if subscribed.
* @param eventName The only `eventName` that is supported is `storage`.
* @param callback The call back type is of `StorageEvent`.
*/
on(eventName: 'storage', callback: (event: StorageEvent) => void): this;
/**
* Creates a new LocalStorage instance
* @param location The location in which the local storage resides
* @param quota The partitioned size of the local storage
*/
constructor(location: string, quota?: number);
}
export class JSONStorage extends LocalStorage {
/**
* Gets the value of the given `key`. This method performs a `JSON.parse` on the `value` before returning it.
* @param key The key whose value you want to retrieve.
* @returns `Array of Objects` or an `Object`. This `getItem` method performs a `JSON.parse` on the `value` before returning it.
*/
getItem(key: string): any;
/**
* Stores a `key` and it's `value` in to the local store. The given `value` will have `JSON.stringify` performed on it prior to storing.
* @param key Unique identifier for the new local storage item
* @param value The value associated with the `key`. This `setItem` method performs a `JSON.stringify` on the value before storage. The `value` *must* be a valid `JSON` object.
*/
setItem(key: string, value: any): void;
/**
* Creates a new LocalStorage instance
* @param location The location in which the local storage resides
* @param quota The partitioned size of the local storage
*/
constructor(location: string, quota?: number);
}
/**
* Contains information regarding a `storage` event.
*/
export class StorageEvent {
/**
* Affected `key`.
*/
key: string;
/**
* Previous `value` associated with the `key`.
*/
oldValue: string;
/**
* Current `value` associated with the `key`.
*/
newValue: string;
/**
* The current `process.pid` for the calling process.
*/
url: string;
/**
* The location of the storage area. Defaults to `localStorage`.
*/
storageArea: string;
/**
* Creates an object containing information regarding a `storage` event.
* @param key Affected `key`.
* @param oldValue Previous `value` associated with the `key`.
* @param newValue Current `value` associated with the `key`.
* @param url The current `process.pid` for the calling process.
* @param storageArea The location of the storage area. Defaults to `localStorage`.
*/
constructor(key: string, oldValue: string, newValue: string, url: string, storageArea: string);
}
/**
* Provides a specific `Error` object for **Quota Exceeded Errors**.
*/
export class QUOTA_EXCEEDED_ERR extends Error {
/**
* Message explaining the error.
*/
message: string;
/**
* Creates a specific `Error` object for **Quota Exceeded Errors**.
* @param message Message explaining the error.
*/
constructor(message: string);
}
@@ -0,0 +1,58 @@
import { LocalStorage, JSONStorage } from 'node-localstorage';
const jsonStore = new JSONStorage('./jsonStore');
const textStore = new LocalStorage('./textStore');
interface Person {
givenName: string;
middleName: string;
familyName: string;
}
const mjkModel: Person = {
givenName: 'Maynard',
middleName: 'James',
familyName: 'Keenan',
};
textStore.clear();
jsonStore.clear();
textStore.on('storage', (event) => {
if (textStore.getItem(event.key) !== event.newValue) {
throw new Error('textStore: An error occurred with the event handler.');
}
});
jsonStore.on('storage', (event) => {
if (jsonStore.getItem(event.key) !== event.newValue) {
throw new Error('jsonStore: An error occurred with the event handler.');
}
});
textStore.setItem('tool', '46&2');
if (textStore.getItem('tool') !== '46&2') {
throw new Error('.setItem method is not working!');
}
jsonStore.setItem('mjk', mjkModel);
if (jsonStore.getItem('mjk') === null) {
throw new Error('.getItem failed.');
}
const mjkTest: Person = jsonStore.getItem('mjk');
if (mjkTest === null || mjkTest.givenName !== mjkModel.givenName || mjkTest.middleName !== mjkModel.middleName || mjkTest.familyName !== mjkModel.familyName) {
throw new Error('.setItem method is not working!');
}
const keyCheck = textStore.key(0);
if (keyCheck && keyCheck !== 'tool') {
throw new Error('.key method has failed.');
}
textStore.clear();
jsonStore.clear();
+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",
"node-localstorage-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+175
View File
@@ -0,0 +1,175 @@
// Type definitions for p-progress 0.2
// Project: https://github.com/sindresorhus/p-progress#readme
// Definitions by: icopp <https://github.com/icopp>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
declare namespace pProgress {
interface Options {
/**
* Number of concurrently pending promises.
*
* To run the promises in series, set it to 1.
*
* When this option is set, the first argument must be an array of
* promise-returning functions.
*
* Minimum 1.
*
* @default {Infinity}
*/
concurrency?: number;
}
}
type PromiseFactory<T> = () => Promise<T> | PromiseLike<T>;
declare class PProgress<T> extends Promise<T> {
/**
* The current progress percentage of the promise as a number between 0 and
* 1.
*/
progress: number;
/**
* Convenience method to run multiple promises and get a total progress of
* all of them. It counts normal promises with progress `0` when pending and
* progress `1` when resolved. For PProgress type promises, it listens to
* their onProgress() method for more fine grained progress reporting. You
* can mix and match normal promises and PProgress promises.
*
* @param promises Array of promises or promise-returning functions.
* @throws {TypeError}
*/
static all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
promises: [
PromiseFactory<T1>,
PromiseFactory<T2>,
PromiseFactory<T3>,
PromiseFactory<T4>,
PromiseFactory<T5>,
PromiseFactory<T6>,
PromiseFactory<T7>,
PromiseFactory<T8>,
PromiseFactory<T9>,
PromiseFactory<T10>
],
options?: pProgress.Options
): PProgress<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
static all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
promises: [
PromiseFactory<T1>,
PromiseFactory<T2>,
PromiseFactory<T3>,
PromiseFactory<T4>,
PromiseFactory<T5>,
PromiseFactory<T6>,
PromiseFactory<T7>,
PromiseFactory<T8>,
PromiseFactory<T9>
],
options?: pProgress.Options
): PProgress<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
static all<T1, T2, T3, T4, T5, T6, T7, T8>(
promises: [
PromiseFactory<T1>,
PromiseFactory<T2>,
PromiseFactory<T3>,
PromiseFactory<T4>,
PromiseFactory<T5>,
PromiseFactory<T6>,
PromiseFactory<T7>,
PromiseFactory<T8>
],
options?: pProgress.Options
): PProgress<[T1, T2, T3, T4, T5, T6, T7, T8]>;
static all<T1, T2, T3, T4, T5, T6, T7>(
promises: [
PromiseFactory<T1>,
PromiseFactory<T2>,
PromiseFactory<T3>,
PromiseFactory<T4>,
PromiseFactory<T5>,
PromiseFactory<T6>,
PromiseFactory<T7>
],
options?: pProgress.Options
): PProgress<[T1, T2, T3, T4, T5, T6, T7]>;
static all<T1, T2, T3, T4, T5, T6>(
promises: [
PromiseFactory<T1>,
PromiseFactory<T2>,
PromiseFactory<T3>,
PromiseFactory<T4>,
PromiseFactory<T5>,
PromiseFactory<T6>
],
options?: pProgress.Options
): PProgress<[T1, T2, T3, T4, T5, T6]>;
static all<T1, T2, T3, T4, T5>(
promises: [
PromiseFactory<T1>,
PromiseFactory<T2>,
PromiseFactory<T3>,
PromiseFactory<T4>,
PromiseFactory<T5>
],
options?: pProgress.Options
): PProgress<[T1, T2, T3, T4, T5]>;
static all<T1, T2, T3, T4>(
promises: [
PromiseFactory<T1>,
PromiseFactory<T2>,
PromiseFactory<T3>,
PromiseFactory<T4>
],
options?: pProgress.Options
): PProgress<[T1, T2, T3, T4]>;
static all<T1, T2, T3>(
promises: [PromiseFactory<T1>, PromiseFactory<T2>, PromiseFactory<T3>],
options?: pProgress.Options
): PProgress<[T1, T2, T3]>;
static all<T1, T2>(
promises: [PromiseFactory<T1>, PromiseFactory<T2>],
options?: pProgress.Options
): PProgress<[T1, T2]>;
static all<T1>(
promises: [PromiseFactory<T1>],
options?: pProgress.Options
): PProgress<[T1]>;
static all<TAll>(
promises: Array<PromiseFactory<TAll>>,
options?: pProgress.Options
): PProgress<TAll>;
/**
* Same as the Promise constructor, but with an appended `progress`
* parameter in `executor`.
*
* @param progress
* Call this with progress updates. It expects a number between 0 and 1.
*
* Multiple calls with the same number will result in only one
* `onProgress()` event.
*
* Progress percentage `1` is reported for you when the promise resolves.
* If you set it yourself, it will simply be ignored.
*/
constructor(
executor: (
resolve: (value?: T | PromiseLike<T>) => void,
reject: (reason?: any) => void,
progress: (progress: number) => void
) => void
);
/**
* Accepts a function that gets `instance.progress` as an argument and is
* called for every progress event.
*
* @throws {TypeError}
*/
onProgress(cb: (progress: number) => void): void;
}
export = PProgress;
+31
View File
@@ -0,0 +1,31 @@
import PProgress = require("p-progress");
new PProgress(async (resolve, reject, progress) => {
try {
await Promise.resolve("sindresorhus.com");
progress(0.5);
await Promise.resolve("ava.li");
progress(1);
resolve();
} catch (e) {
reject(e);
}
}).onProgress(progress => {
progress;
});
PProgress.all(
[
() => Promise.resolve("sindresorhus.com"),
() => Promise.resolve("ava.li"),
() => Promise.resolve(),
() => Promise.resolve(1)
],
{ concurrency: 2 }
).then(result => {
const str: string = result[0];
const str2: string = result[1];
const num: number = result[3];
});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"p-progress-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

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