Merge remote-tracking branch 'DefinitelyTyped/master'

This commit is contained in:
John McLaughlin
2017-08-08 14:19:26 +07:00
180 changed files with 5845 additions and 4697 deletions
+18
View File
@@ -1,11 +1,23 @@
{
"packages": [
{
"libraryName": "ag-grid",
"typingsPackageName": "ag-grid",
"sourceRepoURL": "https://github.com/ceolter/ag-grid",
"asOfVersion": "3.2.0"
},
{
"libraryName": "ajv",
"typingsPackageName": "ajv",
"sourceRepoURL": "https://github.com/epoberezkin/ajv",
"asOfVersion": "1.0.0"
},
{
"libraryName": "angular-ui-router-default",
"typingsPackageName": "angular-ui-router-default",
"sourceRepoURL": "https://github.com/nonplus/angular-ui-router-default",
"asOfVersion": "0.0.5"
},
{
"libraryName": "antd",
"typingsPackageName": "antd",
@@ -60,6 +72,12 @@
"sourceRepoURL": "http://www.babylonjs.com/",
"asOfVersion": "2.4.1"
},
{
"libraryName": "base64url",
"typingsPackageName": "base64url",
"sourceRepoURL": "https://github.com/brianloveswords/base64url",
"asOfVersion": "2.0.0"
},
{
"libraryName": "BigInteger.js",
"typingsPackageName": "big-integer",
-136
View File
@@ -1,136 +0,0 @@
checkGridOptions(<ag.grid.GridOptions>{});
checkColDef(<ag.grid.ColDef>{});
function checkGridOptions(gridOptions: ag.grid.GridOptions): void {
gridOptions.virtualPaging = true;
gridOptions.toolPanelSuppressPivot = true;
gridOptions.toolPanelSuppressValues = true;
gridOptions.rowsAlreadyGrouped = true;
gridOptions.suppressRowClickSelection = true;
gridOptions.suppressCellSelection = true;
gridOptions.sortingOrder = ['asc','desc'];
gridOptions.suppressMultiSort = true;
gridOptions.suppressHorizontalScroll = true;
gridOptions.unSortIcon = true;
gridOptions.rowHeight = 0;
gridOptions.rowBuffer = 0;
gridOptions.enableColResize = true;
gridOptions.enableCellExpressions = true;
gridOptions.enableSorting = true;
gridOptions.enableServerSideSorting = true;
gridOptions.enableFilter = true;
gridOptions.enableServerSideFilter = true;
gridOptions.colWidth = 0;
gridOptions.suppressMenuHide = true;
gridOptions.singleClickEdit = true;
gridOptions.debug = true;
gridOptions.icons = {};
gridOptions.angularCompileRows = true;
gridOptions.angularCompileFilters = true;
gridOptions.angularCompileHeaders = true;
gridOptions.localeText = {};
gridOptions.localeTextFunc = function() {}
gridOptions.suppressScrollLag = true;
gridOptions.groupSuppressAutoColumn = true;
gridOptions.groupSelectsChildren = true;
gridOptions.groupHidePivotColumns = true;
gridOptions.groupIncludeFooter = true;
gridOptions.groupUseEntireRow = true;
gridOptions.groupSuppressRow = true;
gridOptions.groupSuppressBlankHeader = true;
gridOptions.forPrint = true;
gridOptions.groupColumnDef = {};
gridOptions.context = {};
gridOptions.rowStyle = {color: 'red'};
gridOptions.rowClass = 'green';
gridOptions.groupDefaultExpanded = false;
gridOptions.slaveGrids = [];
gridOptions.rowSelection = 'single';
gridOptions.rowDeselection = true;
gridOptions.rowData = [];
gridOptions.floatingTopRowData = [];
gridOptions.floatingBottomRowData = [];
gridOptions.showToolPanel = true;
gridOptions.groupKeys = ['a','b']
gridOptions.groupAggFields = ['a','b']
gridOptions.columnDefs = [];
gridOptions.datasource = {};
gridOptions.pinnedColumnCount = 0;
gridOptions.groupHeaders = true;
gridOptions.headerHeight = 0;
gridOptions.groupRowInnerRenderer = function(params) {};
gridOptions.groupRowRenderer = {};
gridOptions.isScrollLag = function() {return true;}
gridOptions.isExternalFilterPresent = function() { return true; };
gridOptions.doesExternalFilterPass = function(node: ag.grid.RowNode) { return false; };
gridOptions.getRowStyle = function() {};
gridOptions.getRowClass = function() {};
gridOptions.headerCellRenderer = function() {};
gridOptions.groupAggFunction = function(nodes: any[]) {};
gridOptions.onReady = function(api: any) {};
gridOptions.onModelUpdated = function() {};
gridOptions.onCellClicked = function(params) {};
gridOptions.onCellDoubleClicked = function(params) {};
gridOptions.onCellContextMenu = function(params) {};
gridOptions.onCellValueChanged = function(params) {};
gridOptions.onCellFocused = function(params) {};
gridOptions.onRowSelected = function(params) {};
gridOptions.onSelectionChanged = function() {};
gridOptions.onBeforeFilterChanged = function() {};
gridOptions.onAfterFilterChanged = function() {};
gridOptions.onFilterModified = function() {};
gridOptions.onBeforeSortChanged = function() {};
gridOptions.onAfterSortChanged = function() {};
gridOptions.onVirtualRowRemoved = function(params) {};
gridOptions.onRowClicked = function(params) {};
gridOptions.api = null;
gridOptions.columnApi = null;
}
function checkColDef(colDef: ag.grid.ColDef): void {
colDef.sort = 'test';
colDef.sortedAt = 0;
colDef.sortingOrder = ['asc','desc'];
colDef.headerName = 'test';
colDef.field = 'test';
colDef.headerValueGetter = 'test';
colDef.colId = 'test';
colDef.hide = true;
colDef.headerTooltip = 'test';
colDef.valueGetter = 'test';
colDef.headerCellRenderer = {};
colDef.headerClass = 'test';
colDef.width = 0;
colDef.minWidth = 0;
colDef.maxWidth = 0;
colDef.cellClass = 'test';
colDef.cellStyle = {color: 'test'};
colDef.cellRenderer = function() {};
colDef.floatingCellRenderer = function() {};
colDef.aggFunc = 'test';
colDef.comparator = function() {};
colDef.checkboxSelection = true;
colDef.suppressMenu = true;
colDef.suppressSorting = true;
colDef.unSortIcon = true;
colDef.suppressSizeToFit = true;
colDef.suppressResize = true;
colDef.headerGroup = 'test';
colDef.headerGroupShow = 'test';
colDef.editable = true;
colDef.newValueHandler = function() {};
colDef.volatile = true;
colDef.template = 'test';
colDef.templateUrl = 'test';
colDef.filter = 'test';
colDef.filterParams = {};
colDef.onCellValueChanged = function() {};
colDef.onCellClicked = function() {};
colDef.onCellDoubleClicked = function() {};
colDef.onCellContextMenu = function() {};
colDef.cellClassRules = {};
}
-1991
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,9 @@
import AggregateError = require('aggregate-error');
const err = new AggregateError([new Error('foo'), 'bar']);
for (const el of Array.from(err)) {
let err: Error = el;
}
throw err;
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for aggregate-error 1.0
// Project: https://github.com/sindresorhus/aggregate-error#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = AggregateError;
declare class AggregateError extends Error implements Iterable<Error> {
constructor(errors: Iterable<Error | string>);
[Symbol.iterator](): Iterator<Error>;
}
@@ -1,17 +1,12 @@
{
"files": [
"index.d.ts",
"ag-grid-tests.ts"
],
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -19,5 +14,9 @@
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}
},
"files": [
"index.d.ts",
"aggregate-error-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+3
View File
@@ -61,6 +61,9 @@ declare module 'angular' {
controllerAs(controllerAs?: string): T;
parent(parent?: string | Element | JQuery): T; // default: root node
ariaLabel(ariaLabel: string): T;
openFrom(from: string | Element | Event | { top: number, left: number }): T;
closeTo(to: string | Element | { top: number, left: number }): T;
multiple(multiple: boolean): T;
}
// tslint:disable-next-line no-empty-interface
@@ -1,39 +0,0 @@
import * as angular from "angular";
angular.module("test", [
"ui.router",
"ui.router.default"
])
.config(function($stateProvider: angular.ui.IStateProvider) {
$stateProvider
.state('concrete', {
// no abstract or default
})
.state('string', {
abstract: true,
default: 'concrete'
})
.state('func_str', {
abstract: true,
default: function($rootScope): string { return $rootScope.test; }
})
.state('func_promise', {
abstract: true,
default: function($q: ng.IQService): ng.IPromise<string> {
return $q.when("concrete");
}
})
.state('injection_str', {
abstract: true,
default: ["$rootScope", function($rootScope) {
return $rootScope.test;
}]
})
.state('injection_promise', {
abstract: true,
default: ["$q", function($q: ng.IQService) {
return $q.when("concrete");
}]
})
;
});
-20
View File
@@ -1,20 +0,0 @@
// Type definitions for angular-ui-router-default 0.5
// Project: https://github.com/nonplus/angular-ui-router-default
// Definitions by: Stepan Riha <https://github.com/nonplus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as aur from "angular-ui-router";
declare module "angular" {
namespace ui {
export type StateDefaultSpecifier = string
| ((...args: any[]) => string)
| ((...args: any[]) => ng.IPromise<string>)
| (string | ((...args: any[]) => string))[]
| (string | ((...args: any[]) => ng.IPromise<string>))[];
interface IState {
default?: StateDefaultSpecifier
}
}
}
+26
View File
@@ -0,0 +1,26 @@
import { unlessProduction, isDevelopment, isTest, isProduction, getEnv, setEnv } from 'asenv';
import { equal, throws } from 'assert';
// Test isDevelopment()
setEnv('development');
equal(getEnv(), 'development', 'Should return be true');
equal(isDevelopment(), true, 'NODE_ENV should be "development"');
equal(isTest(), false, 'NODE_ENV should be "development"');
equal(isProduction(), false, 'NODE_ENV should be "development"');
equal(unlessProduction(() => true), true, "Shound return true");
// Test isTest()
setEnv('test');
equal(getEnv(), 'test', 'Should return be true');
equal(isDevelopment(), false, 'NODE_ENV should be "test"');
equal(isTest(), true, 'NODE_ENV should be "test"');
equal(isProduction(), false, 'NODE_ENV should be "test"');
equal(unlessProduction(() => true), true, "Shound return true");
// Test isProduction()
setEnv('production');
equal(getEnv(), 'production', 'Should return be true');
equal(isDevelopment(), false, 'NODE_ENV should be "production"');
equal(isTest(), false, 'NODE_ENV should be "production"');
equal(isProduction(), true, 'NODE_ENV should be "production"');
equal(unlessProduction(() => true), false, "Shound return false");
+18
View File
@@ -0,0 +1,18 @@
// Type definitions for asenv 1.1
// Project: https://github.com/a-labo/asenv#readme
// Definitions by: Remisery <https://github.com/remisery>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export function getEnv(): string;
export function isDevelopment(): boolean;
export function isProduction(): boolean;
export function isTest(): boolean;
export function setEnv(env: string): void;
export function unlessProduction(handle: () => any): any;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"asenv-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+2 -2
View File
@@ -98,9 +98,9 @@ export class Scope {
bindingIdentifierEquals(name: string, node: Node): boolean;
getBinding(name: string): Binding;
getBinding(name: string): Binding | undefined;
getOwnBinding(name: string): Binding;
getOwnBinding(name: string): Binding | undefined;
getBindingIdentifier(name: string): t.Identifier;
+1 -1
View File
@@ -2,4 +2,4 @@ import * as base64js from "base64-js";
base64js.byteLength(""); // $ExpectType number
base64js.toByteArray(""); // $ExpectType Uint8Array
base64js.fromByteArray(new Uint8Array(0)); // $ExpectTpe string
base64js.fromByteArray(new Uint8Array(0)); // $ExpectType string
-24
View File
@@ -1,24 +0,0 @@
import * as base64url from "base64url";
// default
let str = base64url("some value");
str = base64url("some value", "hex");
str = base64url(new Buffer("some value"));
// encode
str = base64url.encode("some value");
str = base64url.encode("some value", "hex");
str = base64url.encode(new Buffer("some value"));
// decode
str = base64url.decode("ADA=");
str = base64url.decode("ADA=", "binary");
// toBase64
str = base64url.toBase64("ADA=");
str = base64url.toBase64(new Buffer("ADA=", "base64"));
// fromBase64
str = base64url.fromBase64("ADA=");
let buf = base64url.toBase64("ADA=");
-72
View File
@@ -1,72 +0,0 @@
// Type definitions for base64url v2.0.0
// Project: https://github.com/brianloveswords/base64url
// Definitions by: Stepan Miroshin <https://github.com/microshine>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference types="node" />
/**
* For encoding and decoding base64url!
* v2.0.0
*/
/**
* Encoding type
*/
declare type Encoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "utf16le" | "base64" | "binary" | "hex"
interface IBase64Url {
/**
* Encode input to base64url
* @param {string} input Incoming input
* @param {Encoding} encoding Default 'utf8'
* @return {string}
*/
(input: string, encoding?: Encoding): string;
/**
* Encode input to base64url
* @param {Buffer} input Incoming value
*/
(inout: Buffer): string;
/**
* Encode input to base64url
*
* @param {string} input Incoming input
* @param {Encoding} encoding Default 'utf8'
* @returns {string}
*/
encode(input: string, encoding?: Encoding): string;
/**
* Encode input to base64url
* @param {Buffer} input Incoming value
*/
encode(input: Buffer): string;
/**
* Convert a base64url encoded string into a raw string.
* @param {string} base64url base64url encoded string
* @param {Encoding} encoding Encoding defaults to 'utf8'
* @returns {string}
*/
decode(base64url: string, encoding?: string): string;
/**
* Convert a base64url encoded string to a base64 encoded string
* @param {string | Buffer} base64url base64url encoded value
* @returns {string}
*/
toBase64(base64url: string | Buffer): string;
/**
* Convert a base64 encoded string to a base64url encoded string
* @param {string} base64 encoded string
* @returns {string}
*/
fromBase64(base64: string): string;
/**
* Convert a base64url encoded string to a Buffer
* @param {string} base64url encoded string
* @returns {Buffer}
*/
toBuffer(base64url: string): Buffer;
}
declare const base64url: IBase64Url;
export = base64url;
+232 -234
View File
@@ -1,248 +1,246 @@
import * as CanvasJS from "canvasjs";
namespace CanvasJS.Tests {
// Column Chart
var columnChart = new CanvasJS.Chart("chartContainer",
{
title: {
text: "Top Oil Reserves",
},
axisY: {
title: "Reserves(MMbbl)"
},
legend: {
verticalAlign: "bottom",
horizontalAlign: "center"
},
theme: "theme2",
data: [
{
type: "column",
showInLegend: true,
legendMarkerColor: "grey",
legendText: "MMbbl = one million barrels",
dataPoints: [
{ y: 297571, label: "Venezuela" },
{ y: 267017, label: "Saudi" },
{ y: 175200, label: "Canada" },
{ y: 154580, label: "Iran" },
{ y: 116000, label: "Russia" },
{ y: 97800, label: "UAE" },
{ y: 20682, label: "US" },
{ y: 20350, label: "China" }
]
}
]
});
columnChart.render();
// Line Chart
var lineChart = new CanvasJS.Chart("chartContainer",
{
theme: "theme2",
title: {
text: "Earthquakes - per month"
},
axisX: {
valueFormatString: "MMM",
interval: 1,
intervalType: "month"
},
axisY: {
includeZero: false
},
data: [
{
type: "line",
//lineThickness: 3,
dataPoints: [
{ x: new Date(2012, 0, 1), y: 450 },
{ x: new Date(2012, 1, 1), y: 414 },
{ x: new Date(2012, 2, 1), y: 520, indexLabel: "highest", markerColor: "red", markerType: "triangle" },
{ x: new Date(2012, 3, 1), y: 460 },
{ x: new Date(2012, 4, 1), y: 450 },
{ x: new Date(2012, 5, 1), y: 500 },
{ x: new Date(2012, 6, 1), y: 480 },
{ x: new Date(2012, 7, 1), y: 480 },
{ x: new Date(2012, 8, 1), y: 410, indexLabel: "lowest", markerColor: "DarkSlateGrey", markerType: "cross" },
{ x: new Date(2012, 9, 1), y: 500 },
{ x: new Date(2012, 10, 1), y: 480 },
{ x: new Date(2012, 11, 1), y: 510 }
]
}
]
});
lineChart.render();
// Spline Chart
var splineChart = new CanvasJS.Chart("chartContainer",
{
theme: "theme2",
title: {
text: "Game of Thrones, Viewers of the first airing on HBO"
},
axisY: {
includeZero: false,
// suffix: " k",
valueFormatString: "#,,.",
suffix: " mn"
},
toolTip: {
shared: true
},
data: [
{
type: "spline",
showInLegend: true,
name: "Season 2",
// markerSize: 0,
// color: "rgba(54,158,173,.6)",
dataPoints: [
{ label: "Ep. 1", y: 3858000 },
{ label: "Ep. 2", y: 3759000 },
{ label: "Ep. 3", y: 3766000 },
{ label: "Ep. 4", y: 3654000 },
{ label: "Ep. 5", y: 3903000 },
{ label: "Ep. 6", y: 3879000 },
{ label: "Ep. 7", y: 3694000 },
{ label: "Ep. 8", y: 3864000 },
{ label: "Ep. 9", y: 3384000 },
{ label: "Ep. 10", y: 4200000 }
]
},
{
type: "spline",
showInLegend: true,
// markerSize: 0,
name: "Season 1",
dataPoints: [
{ label: "Ep. 1", y: 2220000 },
{ label: "Ep. 2", y: 2200000 },
{ label: "Ep. 3", y: 2440000 },
{ label: "Ep. 4", y: 2450000 },
{ label: "Ep. 5", y: 2580000 },
{ label: "Ep. 6", y: 2440000 },
{ label: "Ep. 7", y: 2400000 },
{ label: "Ep. 8", y: 2720000 },
{ label: "Ep. 9", y: 2660000 },
{ label: "Ep. 10", y: 3040000 }
]
}
],
legend: {
cursor: "pointer",
itemclick: function (e) {
if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
}
else {
e.dataSeries.visible = true;
}
splineChart.render();
}
},
});
splineChart.render();
// Bar Chart
var barChart = new CanvasJS.Chart("chartContainer", {
// Column Chart
let columnChart = new CanvasJS.Chart("chartContainer",
{
title: {
text: "Fortune Global 500 Companies by Country"
},
axisX: {
interval: 1,
gridThickness: 0,
labelFontSize: 10,
labelFontStyle: "normal",
labelFontWeight: "normal",
labelFontFamily: "Lucida Sans Unicode"
text: "Top Oil Reserves",
},
axisY: {
interlacedColor: "rgba(1,77,101,.2)",
gridColor: "rgba(1,77,101,.1)"
title: "Reserves(MMbbl)"
},
legend: {
verticalAlign: "bottom",
horizontalAlign: "center"
},
theme: "theme2",
data: [
{
type: "bar",
name: "companies",
axisYType: "secondary",
color: "#014D65",
type: "column",
showInLegend: true,
legendMarkerColor: "grey",
legendText: "MMbbl = one million barrels",
dataPoints: [
{ y: 5, label: "Sweden" },
{ y: 6, label: "Taiwan" },
{ y: 7, label: "Russia" },
{ y: 8, label: "Spain" },
{ y: 8, label: "Brazil" },
{ y: 8, label: "India" },
{ y: 9, label: "Italy" },
{ y: 9, label: "Australia" },
{ y: 12, label: "Canada" },
{ y: 13, label: "South Korea" },
{ y: 13, label: "Netherlands" },
{ y: 15, label: "Switzerland" },
{ y: 28, label: "Britain" },
{ y: 32, label: "Germany" },
{ y: 32, label: "France" },
{ y: 68, label: "Japan" },
{ y: 73, label: "China" },
{ y: 132, label: "US" }
{ y: 297571, label: "Venezuela" },
{ y: 267017, label: "Saudi" },
{ y: 175200, label: "Canada" },
{ y: 154580, label: "Iran" },
{ y: 116000, label: "Russia" },
{ y: 97800, label: "UAE" },
{ y: 20682, label: "US" },
{ y: 20350, label: "China" }
]
}
]
});
barChart.render();
columnChart.render();
let option = columnChart.get("title");
columnChart.print();
columnChart.exportChart({ format: "jpg" });
columnChart.destroy();
columnChart.axisX[0].convertPixelToValue(20);
columnChart.toolTip.get("text");
// Pie Chart
var pieChart = new CanvasJS.Chart("chartContainer",
{
title: {
text: "Desktop Search Engine Market Share, Dec-2012"
},
legend: {
verticalAlign: "center",
horizontalAlign: "left",
fontSize: 20,
fontFamily: "Helvetica"
},
theme: "theme2",
data: [
{
type: "pie",
indexLabelFontFamily: "Garamond",
indexLabelFontSize: 20,
indexLabel: "{label} {y}%",
startAngle: -20,
showInLegend: true,
toolTipContent: "{legendText} {y}%",
dataPoints: [
{ y: 83.24, legendText: "Google", label: "Google" },
{ y: 8.16, legendText: "Yahoo!", label: "Yahoo!" },
{ y: 4.67, legendText: "Bing", label: "Bing" },
{ y: 1.67, legendText: "Baidu", label: "Baidu" },
{ y: 0.98, legendText: "Others", label: "Others" }
]
}
]
});
pieChart.render();
addColorSet("MyColorSet", [
"123456",
"blue",
"red",
"orange"
]);
addCultureInfo("js", {
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
// Line Chart
let lineChart = new CanvasJS.Chart("chartContainer",
{
theme: "theme2",
title: {
text: "Earthquakes - per month"
},
axisX: {
valueFormatString: "MMM",
interval: 1,
intervalType: "month"
},
axisY: {
includeZero: false
},
data: [
{
type: "line",
// lineThickness: 3,
dataPoints: [
{ x: new Date(2012, 0, 1), y: 450 },
{ x: new Date(2012, 1, 1), y: 414 },
{ x: new Date(2012, 2, 1), y: 520, indexLabel: "highest", markerColor: "red", markerType: "triangle" },
{ x: new Date(2012, 3, 1), y: 460 },
{ x: new Date(2012, 4, 1), y: 450 },
{ x: new Date(2012, 5, 1), y: 500 },
{ x: new Date(2012, 6, 1), y: 480 },
{ x: new Date(2012, 7, 1), y: 480 },
{ x: new Date(2012, 8, 1), y: 410, indexLabel: "lowest", markerColor: "DarkSlateGrey", markerType: "cross" },
{ x: new Date(2012, 9, 1), y: 500 },
{ x: new Date(2012, 10, 1), y: 480 },
{ x: new Date(2012, 11, 1), y: 510 }
]
}
]
});
}
lineChart.render();
// Spline Chart
let splineChart = new CanvasJS.Chart("chartContainer",
{
theme: "theme2",
title: {
text: "Game of Thrones, Viewers of the first airing on HBO"
},
axisY: {
includeZero: false,
// suffix: " k",
valueFormatString: "#,,.",
suffix: " mn"
},
toolTip: {
shared: true
},
data: [
{
type: "spline",
showInLegend: true,
name: "Season 2",
// markerSize: 0,
// color: "rgba(54,158,173,.6)",
dataPoints: [
{ label: "Ep. 1", y: 3858000 },
{ label: "Ep. 2", y: 3759000 },
{ label: "Ep. 3", y: 3766000 },
{ label: "Ep. 4", y: 3654000 },
{ label: "Ep. 5", y: 3903000 },
{ label: "Ep. 6", y: 3879000 },
{ label: "Ep. 7", y: 3694000 },
{ label: "Ep. 8", y: 3864000 },
{ label: "Ep. 9", y: 3384000 },
{ label: "Ep. 10", y: 4200000 }
]
},
{
type: "spline",
showInLegend: true,
// markerSize: 0,
name: "Season 1",
dataPoints: [
{ label: "Ep. 1", y: 2220000 },
{ label: "Ep. 2", y: 2200000 },
{ label: "Ep. 3", y: 2440000 },
{ label: "Ep. 4", y: 2450000 },
{ label: "Ep. 5", y: 2580000 },
{ label: "Ep. 6", y: 2440000 },
{ label: "Ep. 7", y: 2400000 },
{ label: "Ep. 8", y: 2720000 },
{ label: "Ep. 9", y: 2660000 },
{ label: "Ep. 10", y: 3040000 }
]
}
],
legend: {
cursor: "pointer",
itemclick: (e) => {
if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
} else {
e.dataSeries.visible = true;
}
splineChart.render();
}
},
});
splineChart.render();
// Bar Chart
let barChart = new CanvasJS.Chart("chartContainer", {
title: {
text: "Fortune Global 500 Companies by Country"
},
axisX: {
interval: 1,
gridThickness: 0,
labelFontSize: 10,
labelFontStyle: "normal",
labelFontWeight: "normal",
labelFontFamily: "Lucida Sans Unicode"
},
axisY: {
interlacedColor: "rgba(1,77,101,.2)",
gridColor: "rgba(1,77,101,.1)"
},
data: [
{
type: "bar",
name: "companies",
axisYType: "secondary",
color: "#014D65",
dataPoints: [
{ y: 5, label: "Sweden" },
{ y: 6, label: "Taiwan" },
{ y: 7, label: "Russia" },
{ y: 8, label: "Spain" },
{ y: 8, label: "Brazil" },
{ y: 8, label: "India" },
{ y: 9, label: "Italy" },
{ y: 9, label: "Australia" },
{ y: 12, label: "Canada" },
{ y: 13, label: "South Korea" },
{ y: 13, label: "Netherlands" },
{ y: 15, label: "Switzerland" },
{ y: 28, label: "Britain" },
{ y: 32, label: "Germany" },
{ y: 32, label: "France" },
{ y: 68, label: "Japan" },
{ y: 73, label: "China" },
{ y: 132, label: "US" }
]
}
]
});
barChart.render();
// Pie Chart
let pieChart = new CanvasJS.Chart("chartContainer",
{
title: {
text: "Desktop Search Engine Market Share, Dec-2012"
},
legend: {
verticalAlign: "center",
horizontalAlign: "left",
fontSize: 20,
fontFamily: "Helvetica"
},
theme: "theme2",
data: [
{
type: "pie",
indexLabelFontFamily: "Garamond",
indexLabelFontSize: 20,
indexLabel: "{label} {y}%",
startAngle: -20,
showInLegend: true,
toolTipContent: "{legendText} {y}%",
dataPoints: [
{ y: 83.24, legendText: "Google", label: "Google" },
{ y: 8.16, legendText: "Yahoo!", label: "Yahoo!" },
{ y: 4.67, legendText: "Bing", label: "Bing" },
{ y: 1.67, legendText: "Baidu", label: "Baidu" },
{ y: 0.98, legendText: "Others", label: "Others" }
]
}
]
});
pieChart.render();
CanvasJS.addColorSet("MyColorSet", [
"123456",
"blue",
"red",
"orange"
]);
CanvasJS.addCultureInfo("js", {
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
});
CanvasJS.formatNumber(20);
CanvasJS.formatDate(new Date());
+1423 -722
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -19,4 +19,4 @@
"index.d.ts",
"canvasjs-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+7 -1
View File
@@ -39,7 +39,7 @@ chai.request(app)
chai.request(app)
.get('/search')
.query({name: 'foo', limit: 10});
.query({ name: 'foo', limit: 10 });
chai.request(app)
.put('/user/me')
@@ -98,3 +98,9 @@ function test1() {
}
when(chai.request(app).get('/')).done(() => console.log('success'), () => console.log('failure'));
Promise.resolve(1)
.then(val => chai.request(app).get(`/user/${val}`))
.then(res => {
chai.expect(res).to.have.status(200);
});
+6 -4
View File
@@ -1,8 +1,10 @@
// Type definitions for chai-http 3.0
// Project: https://github.com/chaijs/chai-http
// Definitions by: Wim Looman <https://github.com/Nemo157>
// Liam Jones <https://github.com/G1itcher>
// Liam Jones <https://github.com/G1itcher>
// Federico Caselli <https://github.com/CaselIT>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />
/// <reference types="chai" />
@@ -60,9 +62,9 @@ declare global {
end(callback?: (err: any, res: Response) => void): FinishedRequest;
}
interface FinishedRequest {
then(success?: (res: Response) => void, failure?: (err: any) => void): FinishedRequest;
catch(failure?: (err: any) => void): FinishedRequest;
interface FinishedRequest<T = Response>{
then<TR1 = T, TR2 = void>(success?: (res: T) => TR1 | PromiseLike<TR1>, failure?: (err: any) => TR2 | PromiseLike<TR2>): FinishedRequest<TR1>;
catch(failure?: (err: any) => void): FinishedRequest<T>;
}
interface Agent {
+1 -1
View File
@@ -7366,7 +7366,7 @@ declare namespace chrome.webRequest {
interface WebRedirectionResponseEvent extends _WebResponseHeadersEvent<WebRedirectionResponseDetails> {}
interface WebAuthenticationChallengeEvent extends chrome.events.Event<(details: WebAuthenticationChallengeDetails, callback?: (response: BlockingResponse) => void) => void> {
addListener(callback: (details: WebAuthenticationChallengeDetails) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
addListener(callback: (details: WebAuthenticationChallengeDetails, callback?: (response: BlockingResponse) => void) => void, filter?: RequestFilter, opt_extraInfoSpec?: string[]): void;
}
interface WebResponseErrorEvent extends _WebResponseHeadersEvent<WebResponseErrorDetails> {}
+268 -77
View File
@@ -54,18 +54,29 @@ let mixedOrUndefinedExtent: [d3Array.Primitive | NumCoercible, d3Array.Primitive
let dateOrUndefinedExtent: [Date, Date] | [undefined, undefined];
let numbersArray = [10, 20, 30, 40, 50];
const numbersOrUndefinedArray = [10, 20, undefined, null, 40, 50];
const stringyNumbersArray = ['10', '20', '30', '40', '50'];
const numericArray = [new NumCoercible(10), new NumCoercible(20), new NumCoercible(30), new NumCoercible(40), new NumCoercible(50)];
const dateArray = [new Date(2016, 6, 1), new Date(2016, 7, 30), new Date(2015, 3, 15)];
const mixedObjectArray = [
let numbersOrUndefinedArray = [10, 20, undefined, null, 40, 50];
let stringyNumbersArray = ['10', '20', '30', '40', '50'];
let numericArray = [new NumCoercible(10), new NumCoercible(20), new NumCoercible(30), new NumCoercible(40), new NumCoercible(50)];
let dateArray = [new Date(2016, 6, 1), new Date(2016, 7, 30), new Date(2015, 3, 15)];
let mixedObjectArray = [
new MixedObject(10, new Date(2016, 6, 1)),
new MixedObject(20, new Date(2016, 7, 30)),
new MixedObject(30, new Date(2015, 3, 15)),
new MixedObject(40, new Date(2014, 3, 15)),
new MixedObject(50, new Date(2017, 4, 15))
];
const mixedObjectOrUndefinedArray = [...mixedObjectArray, undefined];
let mixedObjectOrUndefinedArray = [...mixedObjectArray, undefined];
let typedArray = Uint8Array.from(numbersArray);
let readonlyNumbersArray = numbersArray as ReadonlyArray<number>;
let readonlyNumbersOrUndefinedArray = numbersOrUndefinedArray as ReadonlyArray<number>;
let readonlyStringyNumbersArray = stringyNumbersArray as ReadonlyArray<string>;
let readonlyNumericArray = numericArray as ReadonlyArray<NumCoercible>;
let readonlyDateArray = dateArray as ReadonlyArray<Date>;
let readonlyMixedObjectArray = mixedObjectArray as ReadonlyArray<MixedObject>;
let readonlyMixedObjectOrUndefinedArray = mixedObjectOrUndefinedArray as ReadonlyArray<MixedObject>;
function accessorMixedObjectToNum(datum: MixedObject, index: number, array: MixedObject[]): number {
return datum.num;
@@ -104,6 +115,14 @@ strOrUndefined = d3Array.max(stringyNumbersArray);
numericOrUndefined = d3Array.max(numericArray);
dateOrUndefined = d3Array.max(dateArray);
// ArrayLike test cases
numOrUndefined = d3Array.max(typedArray);
numOrUndefined = d3Array.max(readonlyNumbersOrUndefinedArray);
strOrUndefined = d3Array.max(readonlyStringyNumbersArray);
numericOrUndefined = d3Array.max(readonlyNumericArray);
dateOrUndefined = d3Array.max(readonlyDateArray);
// with accessors
numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNum);
@@ -112,6 +131,7 @@ numericOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNumeric)
dateOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToDate);
numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNumOrUndefined);
strOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToStrOrUndefined);
numOrUndefined = d3Array.max(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// min() -----------------------------------------------------------------------
@@ -122,6 +142,14 @@ strOrUndefined = d3Array.min(stringyNumbersArray);
numericOrUndefined = d3Array.min(numericArray);
dateOrUndefined = d3Array.min(dateArray);
// ArrayLike test cases
numOrUndefined = d3Array.min(typedArray);
numOrUndefined = d3Array.min(readonlyNumbersOrUndefinedArray);
strOrUndefined = d3Array.min(readonlyStringyNumbersArray);
numericOrUndefined = d3Array.min(readonlyNumericArray);
dateOrUndefined = d3Array.min(readonlyDateArray);
// with accessors
numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNum);
@@ -130,6 +158,7 @@ numericOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumeric)
dateOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToDate);
numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumOrUndefined);
strOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToStrOrUndefined);
numOrUndefined = d3Array.max(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// extent() --------------------------------------------------------------------
@@ -140,6 +169,14 @@ strOrUndefinedExtent = d3Array.extent(stringyNumbersArray);
numericOrUndefinedExtent = d3Array.extent(numericArray);
dateOrUndefinedExtent = d3Array.extent(dateArray);
// ArrayLike test cases
numOrUndefinedExtent = d3Array.extent(typedArray);
numOrUndefinedExtent = d3Array.extent(readonlyNumbersOrUndefinedArray);
strOrUndefinedExtent = d3Array.extent(readonlyStringyNumbersArray);
numericOrUndefinedExtent = d3Array.extent(readonlyNumericArray);
dateOrUndefinedExtent = d3Array.extent(readonlyDateArray);
// with accessors
numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNum);
@@ -148,6 +185,7 @@ mixedOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToN
dateMixedOrUndefined = d3Array.extent(mixedObjectArray, accessorMixedObjectToDate);
numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNumOrUndefined);
strOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToStrOrUndefined);
numOrUndefinedExtent = d3Array.extent(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// mean() ----------------------------------------------------------------------
@@ -155,8 +193,14 @@ numOrUndefined = d3Array.mean(numbersArray);
numOrUndefined = d3Array.mean(numericArray);
numOrUndefined = d3Array.mean(numbersOrUndefinedArray);
numOrUndefined = d3Array.mean(typedArray);
numOrUndefined = d3Array.mean(readonlyNumbersOrUndefinedArray);
numOrUndefined = d3Array.mean(readonlyNumericArray);
numOrUndefined = d3Array.mean(readonlyNumbersOrUndefinedArray);
numOrUndefined = d3Array.mean(mixedObjectArray, accessorMixedObjectToNum);
numOrUndefined = d3Array.mean(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
numOrUndefined = d3Array.mean(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// median() --------------------------------------------------------------------
@@ -164,8 +208,14 @@ numOrUndefined = d3Array.median(numbersArray);
numOrUndefined = d3Array.median(numericArray);
numOrUndefined = d3Array.median(numbersOrUndefinedArray);
numOrUndefined = d3Array.median(typedArray);
numOrUndefined = d3Array.median(readonlyNumbersArray);
numOrUndefined = d3Array.median(readonlyNumericArray);
numOrUndefined = d3Array.median(readonlyNumbersOrUndefinedArray);
numOrUndefined = d3Array.median(mixedObjectArray, accessorMixedObjectToNum);
numOrUndefined = d3Array.median(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
numOrUndefined = d3Array.median(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// quantile() ------------------------------------------------------------------
@@ -173,8 +223,14 @@ numOrUndefined = d3Array.quantile(numbersArray, 0.5);
numOrUndefined = d3Array.quantile(numericArray, 0.5);
numOrUndefined = d3Array.quantile(numbersOrUndefinedArray, 0.5);
numOrUndefined = d3Array.quantile(typedArray, 0.5);
numOrUndefined = d3Array.quantile(readonlyNumbersArray, 0.5);
numOrUndefined = d3Array.quantile(readonlyNumericArray, 0.5);
numOrUndefined = d3Array.quantile(readonlyNumbersOrUndefinedArray, 0.5);
numOrUndefined = d3Array.quantile(mixedObjectArray, 0.5, accessorMixedObjectToNum);
numOrUndefined = d3Array.quantile(mixedObjectOrUndefinedArray, 0.5, accessorMixedObjectToNumOrUndefined);
numOrUndefined = d3Array.quantile(readonlyMixedObjectOrUndefinedArray, 0.5, accessorMixedObjectToNumOrUndefined);
// sum() -----------------------------------------------------------------------
@@ -182,8 +238,14 @@ numOrUndefined = d3Array.sum(numbersArray);
numOrUndefined = d3Array.sum(numericArray);
numOrUndefined = d3Array.sum(numbersOrUndefinedArray);
numOrUndefined = d3Array.sum(typedArray);
numOrUndefined = d3Array.sum(readonlyNumbersArray);
numOrUndefined = d3Array.sum(readonlyNumericArray);
numOrUndefined = d3Array.sum(readonlyNumbersOrUndefinedArray);
numOrUndefined = d3Array.sum(mixedObjectArray, accessorMixedObjectToNum);
numOrUndefined = d3Array.sum(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
numOrUndefined = d3Array.sum(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// deviation() -----------------------------------------------------------------
@@ -191,8 +253,14 @@ numOrUndefined = d3Array.deviation(numbersArray);
numOrUndefined = d3Array.deviation(numericArray);
numOrUndefined = d3Array.deviation(numbersOrUndefinedArray);
numOrUndefined = d3Array.deviation(typedArray);
numOrUndefined = d3Array.deviation(readonlyNumbersArray);
numOrUndefined = d3Array.deviation(readonlyNumericArray);
numOrUndefined = d3Array.deviation(readonlyNumbersOrUndefinedArray);
numOrUndefined = d3Array.deviation(mixedObjectArray, accessorMixedObjectToNum);
numOrUndefined = d3Array.deviation(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
numOrUndefined = d3Array.deviation(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// variance() ------------------------------------------------------------------
@@ -200,16 +268,29 @@ numOrUndefined = d3Array.variance(numbersArray);
numOrUndefined = d3Array.variance(numericArray);
numOrUndefined = d3Array.variance(numbersOrUndefinedArray);
numOrUndefined = d3Array.variance(typedArray);
numOrUndefined = d3Array.variance(readonlyNumbersArray);
numOrUndefined = d3Array.variance(readonlyNumericArray);
numOrUndefined = d3Array.variance(readonlyNumbersOrUndefinedArray);
numOrUndefined = d3Array.variance(mixedObjectArray, accessorMixedObjectToNum);
numOrUndefined = d3Array.variance(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
numOrUndefined = d3Array.variance(readonlyMixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined);
// -----------------------------------------------------------------------------
// Test Searching Arrays
// -----------------------------------------------------------------------------
numbersArray = [0, 2, 3, 4, 7, 8];
stringyNumbersArray = ['0', '2', '3', '4', '7', '8'];
dateArray = [new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)];
typedArray = Uint8Array.from(numbersArray);
// scan() ----------------------------------------------------------------------
numOrUndefined = d3Array.scan(numbersArray);
numOrUndefined = d3Array.scan(typedArray);
numOrUndefined = d3Array.scan(readonlyNumbersArray);
numOrUndefined = d3Array.scan(mixedObjectArray, (a, b) => {
const aElem: MixedObject = a;
@@ -217,53 +298,113 @@ numOrUndefined = d3Array.scan(mixedObjectArray, (a, b) => {
return a.num - b.num;
});
numOrUndefined = d3Array.scan(readonlyMixedObjectArray, (a, b) => {
const aElem: MixedObject = a;
const bElem: MixedObject = b;
return a.num - b.num;
});
numOrUndefined = d3Array.scan(mixedObjectOrUndefinedArray, (a, b) => {
const aElem: MixedObject | undefined = a;
const bElem: MixedObject | undefined = b;
return a && b ? a.num - b.num : NaN;
});
numOrUndefined = d3Array.scan(readonlyMixedObjectOrUndefinedArray, (a, b) => {
const aElem: MixedObject | undefined = a;
const bElem: MixedObject | undefined = b;
return a && b ? a.num - b.num : NaN;
});
// bisectLeft() ----------------------------------------------------------------
num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4);
num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4, 1);
num = d3Array.bisectLeft([0, 2, 3, 4, 7, 8], 4, 1, 4);
num = d3Array.bisectLeft(numbersArray, 4);
num = d3Array.bisectLeft(numbersArray, 4, 1);
num = d3Array.bisectLeft(numbersArray, 4, 1, 4);
num = d3Array.bisectLeft(['0', '2', '3', '4', '7', '8'], '21');
num = d3Array.bisectLeft(['0', '2', '3', '4', '7', '8'], '21', 1);
num = d3Array.bisectLeft(['0', '2', '3', '4', '7', '8'], '21', 1, 4);
num = d3Array.bisectLeft(stringyNumbersArray, '21');
num = d3Array.bisectLeft(stringyNumbersArray, '21', 1);
num = d3Array.bisectLeft(stringyNumbersArray, '21', 1, 4);
num = d3Array.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1));
num = d3Array.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1);
num = d3Array.bisectLeft([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2);
num = d3Array.bisectLeft(dateArray, new Date(2011, 2, 1));
num = d3Array.bisectLeft(dateArray, new Date(2011, 2, 1), 1);
num = d3Array.bisectLeft(dateArray, new Date(2011, 2, 1), 1, 2);
num = d3Array.bisectLeft(typedArray, 4);
num = d3Array.bisectLeft(typedArray, 4, 1);
num = d3Array.bisectLeft(typedArray, 4, 1, 4);
num = d3Array.bisectLeft(readonlyNumbersArray, 4);
num = d3Array.bisectLeft(readonlyNumbersArray, 4, 1);
num = d3Array.bisectLeft(readonlyNumbersArray, 4, 1, 4);
num = d3Array.bisectLeft(readonlyStringyNumbersArray, '21');
num = d3Array.bisectLeft(readonlyStringyNumbersArray, '21', 1);
num = d3Array.bisectLeft(readonlyStringyNumbersArray, '21', 1, 4);
num = d3Array.bisectLeft(readonlyDateArray, new Date(2011, 2, 1));
num = d3Array.bisectLeft(readonlyDateArray, new Date(2011, 2, 1), 1);
num = d3Array.bisectLeft(readonlyDateArray, new Date(2011, 2, 1), 1, 2);
// bisectRight() ---------------------------------------------------------------
num = d3Array.bisectRight([0, 2, 3, 4, 7, 8], 4);
num = d3Array.bisectRight([0, 2, 3, 4, 7, 8], 4, 1);
num = d3Array.bisectRight([0, 2, 3, 4, 7, 8], 4, 1, 4);
num = d3Array.bisectRight(numbersArray, 4);
num = d3Array.bisectRight(numbersArray, 4, 1);
num = d3Array.bisectRight(numbersArray, 4, 1, 4);
num = d3Array.bisectRight(['0', '2', '3', '4', '7', '8'], '21');
num = d3Array.bisectRight(['0', '2', '3', '4', '7', '8'], '21', 1);
num = d3Array.bisectRight(['0', '2', '3', '4', '7', '8'], '21', 1, 4);
num = d3Array.bisectRight(stringyNumbersArray, '21');
num = d3Array.bisectRight(stringyNumbersArray, '21', 1);
num = d3Array.bisectRight(stringyNumbersArray, '21', 1, 4);
num = d3Array.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1));
num = d3Array.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1);
num = d3Array.bisectRight([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2);
num = d3Array.bisectRight(dateArray, new Date(2011, 2, 1));
num = d3Array.bisectRight(dateArray, new Date(2011, 2, 1), 1);
num = d3Array.bisectRight(dateArray, new Date(2011, 2, 1), 1, 2);
num = d3Array.bisectRight(typedArray, 4);
num = d3Array.bisectRight(typedArray, 4, 1);
num = d3Array.bisectRight(typedArray, 4, 1, 4);
num = d3Array.bisectRight(readonlyNumbersArray, 4);
num = d3Array.bisectRight(readonlyNumbersArray, 4, 1);
num = d3Array.bisectRight(readonlyNumbersArray, 4, 1, 4);
num = d3Array.bisectRight(readonlyStringyNumbersArray, '21');
num = d3Array.bisectRight(readonlyStringyNumbersArray, '21', 1);
num = d3Array.bisectRight(readonlyStringyNumbersArray, '21', 1, 4);
num = d3Array.bisectRight(readonlyDateArray, new Date(2011, 2, 1));
num = d3Array.bisectRight(readonlyDateArray, new Date(2011, 2, 1), 1);
num = d3Array.bisectRight(readonlyDateArray, new Date(2011, 2, 1), 1, 2);
// bisect() --------------------------------------------------------------------
num = d3Array.bisect([0, 2, 3, 4, 7, 8], 4);
num = d3Array.bisect([0, 2, 3, 4, 7, 8], 4, 1);
num = d3Array.bisect([0, 2, 3, 4, 7, 8], 4, 1, 4);
num = d3Array.bisect(numbersArray, 4);
num = d3Array.bisect(numbersArray, 4, 1);
num = d3Array.bisect(numbersArray, 4, 1, 4);
num = d3Array.bisect(['0', '2', '3', '4', '7', '8'], '21');
num = d3Array.bisect(['0', '2', '3', '4', '7', '8'], '21', 1);
num = d3Array.bisect(['0', '2', '3', '4', '7', '8'], '21', 1, 4);
num = d3Array.bisect(stringyNumbersArray, '21');
num = d3Array.bisect(stringyNumbersArray, '21', 1);
num = d3Array.bisect(stringyNumbersArray, '21', 1, 4);
num = d3Array.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1));
num = d3Array.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1);
num = d3Array.bisect([new Date(2010, 1, 1), new Date(2011, 1, 1), new Date(2012, 1, 1), new Date(2013, 1, 1)], new Date(2011, 2, 1), 1, 2);
num = d3Array.bisect(dateArray, new Date(2011, 2, 1));
num = d3Array.bisect(dateArray, new Date(2011, 2, 1), 1);
num = d3Array.bisect(dateArray, new Date(2011, 2, 1), 1, 2);
num = d3Array.bisect(typedArray, 4);
num = d3Array.bisect(typedArray, 4, 1);
num = d3Array.bisect(typedArray, 4, 1, 4);
num = d3Array.bisect(readonlyNumbersArray, 4);
num = d3Array.bisect(readonlyNumbersArray, 4, 1);
num = d3Array.bisect(readonlyNumbersArray, 4, 1, 4);
num = d3Array.bisect(readonlyStringyNumbersArray, '21');
num = d3Array.bisect(readonlyStringyNumbersArray, '21', 1);
num = d3Array.bisect(readonlyStringyNumbersArray, '21', 1, 4);
num = d3Array.bisect(readonlyDateArray, new Date(2011, 2, 1));
num = d3Array.bisect(readonlyDateArray, new Date(2011, 2, 1), 1);
num = d3Array.bisect(readonlyDateArray, new Date(2011, 2, 1), 1, 2);
// bisector() ------------------------------------------------------------------
@@ -283,11 +424,19 @@ num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14)
num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14), 1);
num = mixedObjectDateBisectorObject.left(mixedObjectArray, new Date(2015, 3, 14), 3, 4);
num = mixedObjectDateBisectorObject.left(readonlyMixedObjectArray, new Date(2015, 3, 14));
num = mixedObjectDateBisectorObject.left(readonlyMixedObjectArray, new Date(2015, 3, 14), 1);
num = mixedObjectDateBisectorObject.left(readonlyMixedObjectArray, new Date(2015, 3, 14), 3, 4);
// bisect right
num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14));
num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14), 1);
num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14), 3, 4);
num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14));
num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14), 1);
num = mixedObjectDateBisectorObject.right(readonlyMixedObjectArray, new Date(2015, 3, 14), 3, 4);
// ascending() -----------------------------------------------------------------
num = d3Array.ascending(undefined, 20);
@@ -308,32 +457,44 @@ num = d3Array.descending(new Date(2016, 6, 13), new Date(2016, 6, 14));
// merge() ---------------------------------------------------------------------
let testArrays: MixedObject[][] = [
[
new MixedObject(10, new Date(2016, 6, 1)),
new MixedObject(20, new Date(2016, 7, 30)),
new MixedObject(30, new Date(2015, 3, 15)),
new MixedObject(40, new Date(2014, 3, 15)),
new MixedObject(50, new Date(2017, 4, 15))
],
[
new MixedObject(40, new Date(2016, 3, 1)),
new MixedObject(50, new Date(2016, 9, 30)),
]
let testArray1 = [
new MixedObject(10, new Date(2016, 6, 1)),
new MixedObject(20, new Date(2016, 7, 30)),
new MixedObject(30, new Date(2015, 3, 15)),
new MixedObject(40, new Date(2014, 3, 15)),
new MixedObject(50, new Date(2017, 4, 15))
];
let testArray2 = [
new MixedObject(40, new Date(2016, 3, 1)),
new MixedObject(50, new Date(2016, 9, 30)),
];
let testArrays: MixedObject[][] = [testArray1, testArray2];
let readonlyTestArray1 = testArray1 as ReadonlyArray<MixedObject>;
let readonlyTestArray2 = testArray2 as ReadonlyArray<MixedObject>;
let readonlyTestArrays = [testArray1, testArray2] as ReadonlyArray<ReadonlyArray<MixedObject>>;
let mergedArray: MixedObject[];
mergedArray = d3Array.merge(testArrays); // inferred type
mergedArray = d3Array.merge<MixedObject>(testArrays); // explicit type
// mergedArray = d3Array.merge<MixedObject>([[10, 40, 30], [15, 30]]); // fails, type mismatch
// mergedArray = d3Array.merge([testArray1, [15, 30]]); // fails, type mismatch
mergedArray = d3Array.merge(readonlyTestArrays); // inferred type
mergedArray = d3Array.merge<MixedObject>(readonlyTestArrays); // explicit type
// cross() ---------------------------------------------------------------------
let crossed: Array<[string, number]>;
crossed = d3Array.cross(['x', 'y'], [1, 2]);
crossed = d3Array.cross<string, number>(['x', 'y'], [1, 2]);
const chars = ['x', 'y'];
const nums = [1, 2];
crossed = d3Array.cross(chars, nums);
crossed = d3Array.cross<string, number>(chars, nums);
let strArray: string[] = d3Array.cross<number, number, string>([2, 3], [5, 6], (a, b) => (a + b) + 'px');
strArray = d3Array.cross([2, 3], [5, 6], (a, b) => {
@@ -342,6 +503,21 @@ strArray = d3Array.cross([2, 3], [5, 6], (a, b) => {
return (aa + bb) + 'px';
});
const readonlyChars = chars as ReadonlyArray<string>;
const readonlyNums = new Uint8Array(nums);
crossed = d3Array.cross(readonlyChars, readonlyNums);
crossed = d3Array.cross<string, number>(readonlyChars, readonlyNums);
strArray = d3Array.cross<number, number, string>([2, 3] as ReadonlyArray<number>, new Uint8ClampedArray([5, 6]), (a, b) => (a + b) + 'px');
strArray = d3Array.cross([2, 3] as ReadonlyArray<number>, new Uint8ClampedArray([5, 6]), (a, b) => {
const aa: number = a;
const bb: number = b;
return (aa + bb) + 'px';
});
d3Array.cross(new Uint8Array([1, 2, 3, 4, 5]), new Uint8Array([10, 20, 30, 40, 50]));
// pairs() ---------------------------------------------------------------------
let pairs: Array<[MixedObject, MixedObject]>;
@@ -355,10 +531,21 @@ numbersArray = d3Array.pairs(mergedArray, (a, b) => {
return bb.num - aa.num;
});
const readonlyMergedArray = mergedArray as ReadonlyArray<MixedObject>;
pairs = d3Array.pairs(readonlyMergedArray);
numbersArray = d3Array.pairs<MixedObject, number>(readonlyMergedArray, (a, b) => b.num - a.num);
numbersArray = d3Array.pairs(readonlyMergedArray, (a, b) => {
const aa: MixedObject = a;
const bb: MixedObject = b;
return bb.num - aa.num;
});
// permute() -------------------------------------------------------------------
// getting a permutation of array elements
mergedArray = d3Array.permute(mergedArray, [1, 0, 2, 5, 3, 4, 6]);
mergedArray = d3Array.permute(readonlyMergedArray, [1, 0, 2, 5, 3, 4, 6]);
// Getting an ordered array with object properties
@@ -380,10 +567,20 @@ numbersArray = d3Array.range(1, 10, 0.5);
// shuffle() -------------------------------------------------------------------
mergedArray = d3Array.shuffle(mergedArray);
mergedArray = d3Array.shuffle(mergedArray, 1);
mergedArray = d3Array.shuffle(mergedArray, 1, 3);
// mergedArray = d3Array.shuffle(readonlyMergedArray); // fails, shuffle mutates input array in-place
// Test each TypedArray explicitly. Can't use ArrayLike in this case because shuffle is mutable and ArrayLike would include ReadonlyArray
let resultInt8: Int8Array = d3Array.shuffle(new Int8Array(numbersArray));
let resultUint8: Uint8Array = d3Array.shuffle(new Uint8Array(numbersArray));
let resultUint8Clamped: Uint8ClampedArray = d3Array.shuffle(new Uint8ClampedArray(numbersArray));
let resultInt16: Int16Array = d3Array.shuffle(new Int16Array(numbersArray));
let resultUint6: Uint16Array = d3Array.shuffle(new Uint16Array(numbersArray));
let resultInt32: Int32Array = d3Array.shuffle(new Int32Array(numbersArray));
let resultUint32: Uint32Array = d3Array.shuffle(new Uint32Array(numbersArray));
let resultFloat32: Float32Array = d3Array.shuffle(new Float32Array(numbersArray));
let resultFloat64: Float64Array = d3Array.shuffle(new Float64Array(numbersArray));
// ticks() ---------------------------------------------------------------------
@@ -399,32 +596,13 @@ numDiff = d3Array.tickStep(1, 10, 5);
// transpose() -----------------------------------------------------------------
testArrays = d3Array.transpose([
[
new MixedObject(10, new Date(2016, 6, 1)),
new MixedObject(50, new Date(2017, 4, 15))
],
[
new MixedObject(40, new Date(2016, 3, 1)),
new MixedObject(50, new Date(2016, 9, 30)),
]
]);
testArrays = d3Array.transpose([testArray1, testArray2]);
testArrays = d3Array.transpose([readonlyTestArray1, readonlyTestArray2] as ReadonlyArray<ReadonlyArray<MixedObject>>);
// zip() -----------------------------------------------------------------------
testArrays = d3Array.zip(
[
new MixedObject(10, new Date(2016, 6, 1)),
new MixedObject(20, new Date(2016, 7, 30)),
new MixedObject(30, new Date(2015, 3, 15)),
new MixedObject(40, new Date(2014, 3, 15)),
new MixedObject(50, new Date(2017, 4, 15))
],
[
new MixedObject(40, new Date(2016, 3, 1)),
new MixedObject(50, new Date(2016, 9, 30)),
]
);
testArrays = d3Array.zip(testArray1, testArray2);
testArrays = d3Array.zip(readonlyTestArray1, readonlyTestArray2);
// -----------------------------------------------------------------------------
// Test Histogram
@@ -447,7 +625,7 @@ testHistogram = d3Array.histogram<MixedObject, Date>();
testHistogram = testHistogram.value((d, i, data) => {
const datum: MixedObject = d; // d is of type MixedObject
const index: number = i; // i is number
const array: MixedObject[] = data; // data is of type MixedObject[]
const array: ArrayLike<MixedObject> = data; // data is of type MixedObject[]
return datum.date;
});
@@ -496,8 +674,10 @@ testHistogram = testHistogram.thresholds(tScale.ticks(timeYear));
// Use histogram generator =====================================================
numbersArray = [-1, 0, 1, 1, 3, 20, 234];
let defaultBins: Array<d3Array.Bin<number, number>>;
defaultBins = defaultHistogram([-1, 0, 1, 1, 3, 20, 234]);
defaultBins = defaultHistogram(numbersArray);
let defaultBin: d3Array.Bin<number, number>;
defaultBin = defaultBins[0];
@@ -509,6 +689,7 @@ num = defaultBin.x1; // bin upper bound is number
let testBins: Array<d3Array.Bin<MixedObject, Date>>;
testBins = testHistogram(mixedObjectArray);
testBins = testHistogram(readonlyMixedObjectArray);
let testBin: d3Array.Bin<MixedObject, Date>;
testBin = testBins[0];
@@ -520,8 +701,18 @@ date = testBin.x1; // bin upper bound is Date
// Histogram Tresholds =========================================================
num = d3Array.thresholdFreedmanDiaconis([-1, 0, 1, 1, 3, 20, 234], -1, 234);
numbersArray = [-1, 0, 1, 1, 3, 20, 234];
typedArray = new Uint8Array(numbersArray);
readonlyNumbersArray = numbersArray as ReadonlyArray<number>;
num = d3Array.thresholdScott([-1, 0, 1, 1, 3, 20, 234], -1, 234);
num = d3Array.thresholdFreedmanDiaconis(numbersArray, -1, 234);
num = d3Array.thresholdFreedmanDiaconis(typedArray, -1, 234);
num = d3Array.thresholdFreedmanDiaconis(readonlyNumbersArray, -1, 234);
num = d3Array.thresholdSturges([-1, 0, 1, 1, 3, 20, 234]);
num = d3Array.thresholdScott(numbersArray, -1, 234);
num = d3Array.thresholdScott(typedArray, -1, 234);
num = d3Array.thresholdScott(readonlyNumbersArray, -1, 234);
num = d3Array.thresholdSturges(numbersArray);
num = d3Array.thresholdSturges(typedArray);
num = d3Array.thresholdSturges(readonlyNumbersArray);
+63 -54
View File
@@ -28,133 +28,133 @@ export interface Numeric {
/**
* Return the maximum value in the array of strings using natural order.
*/
export function max(array: string[]): string | undefined;
export function max(array: ArrayLike<string>): string | undefined;
/**
* Return the maximum value in the array of numbers using natural order.
*/
export function max<T extends Numeric>(array: T[]): T | undefined;
export function max<T extends Numeric>(array: ArrayLike<T>): T | undefined;
/**
* Return the maximum value in the array using natural order and a projection function to map values to strings.
*/
export function max<T>(array: T[], accessor: (datum: T, index: number, array: T[]) => string | undefined | null): string | undefined;
export function max<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => string | undefined | null): string | undefined;
/**
* Return the maximum value in the array using natural order and a projection function to map values to easily-sorted values.
*/
export function max<T, U extends Numeric>(array: T[], accessor: (datum: T, index: number, array: T[]) => U | undefined | null): U | undefined;
export function max<T, U extends Numeric>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => U | undefined | null): U | undefined;
/**
* Return the minimum value in the array using natural order.
*/
export function min(array: string[]): string | undefined;
export function min(array: ArrayLike<string>): string | undefined;
/**
* Return the minimum value in the array using natural order.
*/
export function min<T extends Numeric>(array: T[]): T | undefined;
export function min<T extends Numeric>(array: ArrayLike<T>): T | undefined;
/**
* Return the minimum value in the array using natural order.
*/
export function min<T>(array: T[], accessor: (datum: T, index: number, array: T[]) => string | undefined | null): string | undefined;
export function min<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => string | undefined | null): string | undefined;
/**
* Return the minimum value in the array using natural order.
*/
export function min<T, U extends Numeric>(array: T[], accessor: (datum: T, index: number, array: T[]) => U | undefined | null): U | undefined;
export function min<T, U extends Numeric>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => U | undefined | null): U | undefined;
/**
* Return the min and max simultaneously.
*/
export function extent(array: string[]): [string, string] | [undefined, undefined];
export function extent(array: ArrayLike<string>): [string, string] | [undefined, undefined];
/**
* Return the min and max simultaneously.
*/
export function extent<T extends Numeric>(array: T[]): [T, T] | [undefined, undefined];
export function extent<T extends Numeric>(array: ArrayLike<T>): [T, T] | [undefined, undefined];
/**
* Return the min and max simultaneously.
*/
export function extent<T>(array: T[], accessor: (datum: T, index: number, array: T[]) => string | undefined | null): [string, string] | [undefined, undefined];
export function extent<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => string | undefined | null): [string, string] | [undefined, undefined];
/**
* Return the min and max simultaneously.
*/
export function extent<T, U extends Numeric>(array: T[], accessor: (datum: T, index: number, array: T[]) => U | undefined | null): [U, U] | [undefined, undefined];
export function extent<T, U extends Numeric>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => U | undefined | null): [U, U] | [undefined, undefined];
/**
* Return the mean of an array of numbers
*/
export function mean<T extends Numeric>(array: Array<T | undefined | null>): number | undefined;
export function mean<T>(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number | undefined;
export function mean<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
export function mean<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
/**
* Return the median of an array of numbers
*/
export function median<T extends Numeric>(array: Array<T | undefined | null>): number | undefined;
export function median<T>(array: T[], accessor: (element: T, i: number, array: T[]) => number | undefined | null): number | undefined;
export function median<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
export function median<T>(array: ArrayLike<T>, accessor: (element: T, i: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
/**
* Returns the p-quantile of an array of numbers
*/
export function quantile<T extends Numeric>(array: Array<T | undefined | null>, p: number): number | undefined;
export function quantile<T>(array: T[], p: number, accessor: (element: T, i: number, array: T[]) => number | undefined | null): number | undefined;
export function quantile<T extends Numeric>(array: ArrayLike<T | undefined | null>, p: number): number | undefined;
export function quantile<T>(array: ArrayLike<T>, p: number, accessor: (element: T, i: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
/**
* Compute the sum of an array of numbers.
*/
export function sum<T extends Numeric>(array: Array<T | undefined | null>): number;
export function sum<T extends Numeric>(array: ArrayLike<T | undefined | null>): number;
/**
* Compute the sum of an array, using the given accessor to convert values to numbers.
*/
export function sum<T>(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number;
export function sum<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number;
/**
* Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array of numbers.
*/
export function deviation<T extends Numeric>(array: Array<T | undefined | null>): number | undefined;
export function deviation<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
/**
* Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array,
* using the given accessor to convert values to numbers.
*/
export function deviation<T>(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number | undefined;
export function deviation<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
/**
* Compute an unbiased estimator of the population variance of the given array of numbers.
*/
export function variance<T extends Numeric>(array: Array<T | undefined | null>): number | undefined;
export function variance<T extends Numeric>(array: ArrayLike<T | undefined | null>): number | undefined;
/**
* Compute an unbiased estimator of the population variance of the given array,
* using the given accessor to convert values to numbers.
*/
export function variance<T>(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number | undefined;
export function variance<T>(array: ArrayLike<T>, accessor: (datum: T, index: number, array: ArrayLike<T>) => number | undefined | null): number | undefined;
// --------------------------------------------------------------------------------------
// Searching Arrays
// --------------------------------------------------------------------------------------
export function scan(array: number[], comparator?: (a: number, b: number) => number): number | undefined;
export function scan<T>(array: T[], comparator: (a: T, b: T) => number): number | undefined;
export function scan(array: ArrayLike<number>, comparator?: (a: number, b: number) => number): number | undefined;
export function scan<T>(array: ArrayLike<T>, comparator: (a: T, b: T) => number): number | undefined;
export function bisectLeft(array: number[], x: number, lo?: number, hi?: number): number;
export function bisectLeft(array: string[], x: string, lo?: number, hi?: number): number;
export function bisectLeft(array: Date[], x: Date, lo?: number, hi?: number): number;
export function bisectLeft(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
export function bisectLeft(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
export function bisectLeft(array: ArrayLike<Date>, x: Date, lo?: number, hi?: number): number;
export function bisectRight(array: number[], x: number, lo?: number, hi?: number): number;
export function bisectRight(array: string[], x: string, lo?: number, hi?: number): number;
export function bisectRight(array: Date[], x: Date, lo?: number, hi?: number): number;
export function bisectRight(array: ArrayLike<number>, x: number, lo?: number, hi?: number): number;
export function bisectRight(array: ArrayLike<string>, x: string, lo?: number, hi?: number): number;
export function bisectRight(array: ArrayLike<Date>, x: Date, lo?: number, hi?: number): number;
export const bisect: typeof bisectRight;
export interface Bisector<T, U> {
left(array: T[], x: U, lo?: number, hi?: number): number;
right(array: T[], x: U, lo?: number, hi?: number): number;
left(array: ArrayLike<T>, x: U, lo?: number, hi?: number): number;
right(array: ArrayLike<T>, x: U, lo?: number, hi?: number): number;
}
export function bisector<T, U>(comparator: (a: T, b: U) => number): Bisector<T, U>;
@@ -184,7 +184,7 @@ export function descending(a: Primitive | undefined, b: Primitive | undefined):
* @param a First input array.
* @param b Second input array.
*/
export function cross<S, T>(a: S[], b: T[]): Array<[S, T]>;
export function cross<S, T>(a: ArrayLike<S>, b: ArrayLike<T>): Array<[S, T]>;
/**
* Returns the Cartesian product of the two arrays a and b.
@@ -195,12 +195,12 @@ export function cross<S, T>(a: S[], b: T[]): Array<[S, T]>;
* @param b Second input array.
* @param reducer A reducer function taking as input an element from "a" and "b" and returning a reduced value.
*/
export function cross<S, T, U>(a: S[], b: T[], reducer: (a: S, b: T) => U): U[];
export function cross<S, T, U>(a: ArrayLike<S>, b: ArrayLike<T>, reducer: (a: S, b: T) => U): U[];
/**
* Merges the specified arrays into a single array.
*/
export function merge<T>(arrays: T[][]): T[];
export function merge<T>(arrays: ArrayLike<ArrayLike<T>>): T[];
/**
* For each adjacent pair of elements in the specified array, returns a new array of tuples of elements i and i - 1.
@@ -208,7 +208,7 @@ export function merge<T>(arrays: T[][]): T[];
*
* @param array Array of input elements
*/
export function pairs<T>(array: T[]): Array<[T, T]>;
export function pairs<T>(array: ArrayLike<T>): Array<[T, T]>;
/**
* For each adjacent pair of elements in the specified array, in order, invokes the specified reducer function passing the element i and element i - 1.
* Returns the resulting array of pair-wise reduced elements.
@@ -217,17 +217,17 @@ export function pairs<T>(array: T[]): Array<[T, T]>;
* @param array Array of input elements
* @param reducer A reducer function taking as input to adjecent elements of the input array and returning a reduced value.
*/
export function pairs<T, U>(array: T[], reducer: (a: T, b: T) => U): U[];
export function pairs<T, U>(array: ArrayLike<T>, reducer: (a: T, b: T) => U): U[];
/**
* Given the specified array, return an array corresponding to the list of indices in 'keys'.
*/
export function permute<T>(array: { [key: number]: T }, keys: number[]): T[];
export function permute<T>(array: { [key: number]: T }, keys: ArrayLike<number>): T[];
/**
* Given the specified object, return an array corresponding to the list of property names in 'keys'.
*/
export function permute<T>(object: { [key: string]: T }, keys: string[]): T[];
export function permute<T>(object: { [key: string]: T }, keys: ArrayLike<string>): T[];
/**
* Generates a 0-based numeric sequence. The output range does not include 'stop'.
@@ -243,6 +243,15 @@ export function range(start: number, stop: number, step?: number): number[];
* Randomizes the order of the specified array using the Fisher–Yates shuffle.
*/
export function shuffle<T>(array: T[], lo?: number, hi?: number): T[];
export function shuffle(array: Int8Array, lo?: number, hi?: number): Int8Array;
export function shuffle(array: Uint8Array, lo?: number, hi?: number): Uint8Array;
export function shuffle(array: Uint8ClampedArray, lo?: number, hi?: number): Uint8ClampedArray;
export function shuffle(array: Int16Array, lo?: number, hi?: number): Int16Array;
export function shuffle(array: Uint16Array, lo?: number, hi?: number): Uint16Array;
export function shuffle(array: Int32Array, lo?: number, hi?: number): Int32Array;
export function shuffle(array: Uint32Array, lo?: number, hi?: number): Uint32Array;
export function shuffle(array: Float32Array, lo?: number, hi?: number): Float32Array;
export function shuffle(array: Float64Array, lo?: number, hi?: number): Float64Array;
/**
* Generate an array of approximately count + 1 uniformly-spaced, nicely-rounded values between start and stop (inclusive).
@@ -289,14 +298,14 @@ export function tickStep(start: number, stop: number, count: number): number;
/**
* Transpose a matrix provided in Array of Arrays format.
*/
export function transpose<T>(matrix: T[][]): T[][];
export function transpose<T>(matrix: ArrayLike<ArrayLike<T>>): T[][];
/**
* Returns an array of arrays, where the ith array contains the ith element from each of the argument arrays.
* The returned array is truncated in length to the shortest array in arrays. If arrays contains only a single array, the returned array
* contains one-element arrays. With no arguments, the returned array is empty.
*/
export function zip<T>(...arrays: T[][]): T[][];
export function zip<T>(...arrays: Array<ArrayLike<T>>): T[][];
// --------------------------------------------------------------------------------------
// Histogram
@@ -310,20 +319,20 @@ export interface Bin<Datum, Value extends number | Date> extends Array<Datum> {
/**
* Type definition for threshold generator which returns the count of recommended thresholds
*/
export type ThresholdCountGenerator = (values: number[], min?: number, max?: number) => number;
export type ThresholdCountGenerator = (values: ArrayLike<number>, min?: number, max?: number) => number;
/**
* Type definition for threshold generator which returns an array of recommended thresholds
*/
export type ThresholdArrayGenerator<Value extends number | Date> = (values: Value[], min?: Value, max?: Value) => Value[];
export type ThresholdArrayGenerator<Value extends number | Date> = (values: ArrayLike<Value>, min?: Value, max?: Value) => Value[];
export interface HistogramGenerator<Datum, Value extends number | Date> {
(data: Datum[]): Array<Bin<Datum, Value>>;
value(): (d: Datum, i: number, data: Datum[]) => Value;
value(valueAccessor: (d: Datum, i: number, data: Datum[]) => Value): this;
domain(): (values: Value[]) => [Value, Value];
(data: ArrayLike<Datum>): Array<Bin<Datum, Value>>;
value(): (d: Datum, i: number, data: ArrayLike<Datum>) => Value;
value(valueAccessor: (d: Datum, i: number, data: ArrayLike<Datum>) => Value): this;
domain(): (values: ArrayLike<Value>) => [Value, Value];
domain(domain: [Value, Value]): this;
domain(domainAccessor: (values: Value[]) => [Value, Value]): this;
domain(domainAccessor: (values: ArrayLike<Value>) => [Value, Value]): this;
thresholds(): ThresholdCountGenerator | ThresholdArrayGenerator<Value>;
/**
* Divide the domain uniformly into approximately count bins. IMPORTANT: This threshold
@@ -357,7 +366,7 @@ export interface HistogramGenerator<Datum, Value extends number | Date> {
* @param thresholds Array of threshold values used for binning. The elements must
* be of the same type as the materialized values of the histogram.
*/
thresholds(thresholds: Value[]): this;
thresholds(thresholds: ArrayLike<Value>): this;
/**
* Set a threshold accessor function, which returns the array of values to be used as
* thresholds in determining the bins.
@@ -379,8 +388,8 @@ export function histogram<Datum, Value extends number | Date>(): HistogramGenera
// Histogram Thresholds
// --------------------------------------------------------------------------------------
export function thresholdFreedmanDiaconis(values: number[], min: number, max: number): number; // of type ThresholdCountGenerator
export function thresholdFreedmanDiaconis(values: ArrayLike<number>, min: number, max: number): number; // of type ThresholdCountGenerator
export function thresholdScott(values: number[], min: number, max: number): number; // of type ThresholdCountGenerator
export function thresholdScott(values: ArrayLike<number>, min: number, max: number): number; // of type ThresholdCountGenerator
export function thresholdSturges(values: number[]): number; // of type ThresholdCountGenerator
export function thresholdSturges(values: ArrayLike<number>): number; // of type ThresholdCountGenerator
+2
View File
@@ -715,6 +715,8 @@ declare namespace Draft {
createEntity(type: DraftEntityType, mutability: DraftEntityMutability, data?: Object): ContentState;
getEntity(key: string): EntityInstance;
getLastCreatedEntityKey(): string;
mergeEntityData(key: string, toMerge: { [key: string]: any }): ContentState;
getBlockMap(): BlockMap;
getSelectionBefore(): SelectionState;
+3 -3
View File
@@ -63,8 +63,8 @@ declare namespace electronPackager {
OriginalFilename?: string;
ProductName?: string;
InternalName?: string;
"requested-execution-level": any;
"application-manifest": any;
"requested-execution-level"?: "asInvoker" | "highestAvailable" | "requireAdministrator";
"application-manifest"?: string;
}
/** Electron-packager Options. */
@@ -188,7 +188,7 @@ declare namespace electronPackager {
/**
* The URL protocol scheme(s) to associate the app with
*/
protocol?: string;
protocol?: string[];
/**
* The descriptive name(s) of the URL protocol scheme(s) specified via the protocol option.
* Maps to the CFBundleURLName metadata property.
+4
View File
@@ -1,4 +1,5 @@
import * as fetchMock from "fetch-mock";
import { MockResponse } from "fetch-mock";
fetchMock.mock("http://test.com", 200);
fetchMock.mock(/test\.com/, 200);
@@ -65,3 +66,6 @@ const myMatcher: fetchMock.MockMatcherFunction = (
url: string,
opts: fetchMock.MockRequest
) => true;
fetchMock.flush().then(resolved => resolved.forEach(console.log));
fetchMock.flush().catch(r => r);
+11 -2
View File
@@ -1,6 +1,9 @@
// Type definitions for fetch-mock 5.8
// Type definitions for fetch-mock 5.12
// Project: https://github.com/wheresrhys/fetch-mock
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>, Tamir Duberstein <https://github.com/tamird>, Risto Keravuori <https://github.com/merrywhether>
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Tamir Duberstein <https://github.com/tamird>
// Risto Keravuori <https://github.com/merrywhether>
// Chris Sinclair <https://github.com/chrissinclair>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -333,6 +336,12 @@ declare namespace fetchMock {
*/
reset(): this;
/**
* Returns a promise that resolves once all fetches handled by fetch-mock
* have resolved.
*/
flush(): Promise<MockResponse[]>;
/**
* Returns all calls to fetch, grouped by whether fetch-mock matched
* them or not.
+1
View File
@@ -70,6 +70,7 @@ declare namespace Flatpickr {
weekNumbers?: boolean;
wrap?: boolean;
locale?: string | Locale;
plugins?: any[];
}
interface Locale {
-100
View File
@@ -1,100 +0,0 @@
import { ReadStream } from "fs";
import { Channel, ChannelConfig } from "./channel";
import { File } from "./file";
import {
Acl,
ApiResponse,
UploadOptions
} from "./storage";
/**
* A bucket in the cloud.
*/
export class Bucket {
acl: Acl;
combine(sources: string[] | File[], destination: string [] | File[]): Promise<[File, ApiResponse]>;
create(config?: BucketConfig): Promise<[Bucket, ApiResponse]>;
createChannel(id: string, config: ChannelConfig): Promise<[Channel, ApiResponse]>;
delete(): Promise<[ApiResponse]>;
deleteFiles(query?: BucketQuery): Promise<void>;
exists(): Promise<[boolean]>;
file(name: string, options?: BucketFileOptions): File;
get(options?: BucketGetOptions): Promise<[Bucket, ApiResponse]>;
getFiles(query?: BucketQuery): Promise<[File[]]>;
getFilesStream(query?: BucketQuery): ReadStream;
getMetadata(): Promise<[BucketMetadata, ApiResponse]>;
id: string;
makePrivate(options?: BucketPrivacyOptions): Promise<[File[]]>;
makePublic(options?: BucketPrivacyOptions): Promise<[File[]]>;
metadata: BucketMetadata;
name: string;
setMetadata(metadata?: BucketMetadata): Promise<[ApiResponse]>;
upload(localPath: string, options?: UploadOptions): Promise<[File]>;
}
/**
* Bucket configuration.
*/
export interface BucketConfig {
coldline?: boolean;
dra?: boolean;
location?: string;
multiRegional?: boolean;
nearline?: boolean;
regional?: boolean;
versioning?: {
enabled?: boolean
};
}
/**
* Options for getting a file.
*/
export interface BucketFileOptions {
generation?: string | number;
}
/**
* Options for getting a bucket.
*/
export interface BucketGetOptions {
autoCreate?: boolean;
}
/**
* Bucket metadata.
*/
export interface BucketMetadata {
etag?: string;
id?: string;
kind?: string;
location?: string;
metageneration?: string;
name?: string;
projectNumber?: string;
selfLink?: string;
storageClass?: string;
timeCreated?: string;
updated?: string;
}
/**
* The options for making the bucket private.
*/
export interface BucketPrivacyOptions {
includeFiles?: boolean;
force?: boolean;
}
/**
* Query a bucket.
*/
export interface BucketQuery {
autoPaginate?: boolean;
delimiter?: string;
prefix?: string;
maxApiCalls?: number;
maxResults?: number;
pageToken?: string;
versions?: boolean;
}
-15
View File
@@ -1,15 +0,0 @@
import { ApiResponse } from "./storage";
/**
* This class allows you interact with Google Cloud Storage.
*/
export class Channel {
stop(): Promise<[ApiResponse]>;
}
/**
* Channel configuration.
*/
export interface ChannelConfig {
address: string;
}
-95
View File
@@ -1,95 +0,0 @@
import { ReadStream, WriteStream } from "fs";
import { Bucket } from "./bucket";
import {
Acl,
ApiResponse,
DownloadOptions,
ReadStreamOptions,
UploadOptions,
WriteStreamOptions
} from "./storage";
/**
* Options for specifying the content length range.
*/
export interface ContentLengthRange {
max?: number;
min?: number;
}
/**
* A file in the cloud.
*/
export class File {
acl: Acl;
copy(destination: string | Bucket | File): Promise<[File, ApiResponse]>;
createReadStream(options?: ReadStreamOptions): ReadStream;
createWriteStream(options?: WriteStreamOptions): WriteStream;
delete(): Promise<[ApiResponse]>;
download(options?: DownloadOptions): Promise<[string]>;
exists(): Promise<[boolean]>;
get(): Promise<[File, ApiResponse]>;
getMetadata(): Promise<[FileMetadata, ApiResponse]>;
getSignedPolicy(options?: SignedPolicyOptions): Promise<[SignedPolicy]>;
getSignedUrl(config?: SignedUrlConfig): Promise<[string]>;
makePrivate(options?: FilePrivateOptions): Promise<[ApiResponse]>;
makePublic(): Promise<[ApiResponse]>;
move(destination: string | Bucket | File): Promise<[File, ApiResponse]>;
name: string;
save(data: string, options?: WriteStreamOptions): Promise<void>;
setEncryptionKey(encryptionKey: string | Buffer): File;
setMetadata(metadata: FileMetadata): Promise<[ApiResponse]>;
}
/**
* File metadata.
*/
export interface FileMetadata {
contentType?: string;
}
/**
* Options when setting the file as private.
*/
export interface FilePrivateOptions {
strict?: boolean;
}
/**
* A signed policy allowing a user to upload a file with a POST.
*/
export interface SignedPolicy {
base64?: string;
signature?: string;
string?: string;
}
/**
* Options when obtaining the signed policy.
*/
export interface SignedPolicyOptions {
acl?: string;
contentLengthRange?: ContentLengthRange;
equals?: string[] | [string[]];
expires?: number | string;
max?: number;
min?: number;
startsWith?: string[] | [string[]];
successRedirect?: string;
successStatus?: string;
}
/**
* Options when obtaining a temporary signed URL for a file.
*/
export interface SignedUrlConfig {
action: string;
cname?: string;
contentMd5?: string;
contentType?: string;
expires?: number | string;
extensionHeaders?: {[key: string]: string};
promptSaveAs?: string;
responseDisposition?: string;
responseType?: string;
}
@@ -3,83 +3,83 @@ import * as fs from "fs";
// import Google Cloud Storage
import {
Acl,
Bucket,
Channel,
File,
ApiResponse,
BucketConfig,
BucketFileOptions,
BucketGetOptions,
BucketMetadata,
BucketPrivacyOptions,
BucketQuery,
ChannelConfig,
DownloadOptions,
FileMetadata,
FilePrivateOptions,
ReadStreamOptions,
SignedPolicy,
SignedPolicyOptions,
SignedUrlConfig,
WriteStreamOptions,
UploadOptions,
Storage
Acl,
Bucket,
Channel,
File,
ApiResponse,
BucketConfig,
BucketFileOptions,
BucketGetOptions,
BucketMetadata,
BucketPrivacyOptions,
BucketQuery,
ChannelConfig,
DownloadOptions,
FileMetadata,
FilePrivateOptions,
ReadStreamOptions,
SignedPolicy,
SignedPolicyOptions,
SignedUrlConfig,
WriteStreamOptions,
UploadOptions
} from "@google-cloud/storage";
import * as CloudStorage from "@google-cloud/storage";
/**
* Test the storage service.
* @class TestStorage
*/
export class TestStorage {
// constants
static BUCKET_CONFIG: BucketConfig = {
multiRegional: true
};
// constants
static BUCKET_CONFIG: BucketConfig = {
multiRegional: true
};
// import Storage class
static gcs: Storage = new Storage();
// import Storage class
static gcs = CloudStorage();
// the bucket
private buckets: Bucket[] = [];
// the bucket
private buckets: Bucket[] = [];
/**
* @constructor
*/
constructor() {
// nothing to do
}
/**
* @constructor
*/
constructor() {
// nothing to do
}
/**
* Returns the bucket.
* @method bucket
* @param {string} name
* @return {Bucket}
*/
bucket(name: string): Bucket {
return TestStorage.gcs.bucket(name);
}
/**
* Returns the bucket.
* @method bucket
* @param {string} name
* @return {Bucket}
*/
bucket(name: string): Bucket {
return TestStorage.gcs.bucket(name);
}
/**
* Create a new bucket.
* @param {string} name
* @param {BucketConfig} metadata
* @return {Promise<[Bucket, ApiResponse]>}
*/
createBucket(name: string, config?: BucketConfig): Promise<[Bucket, ApiResponse]> {
// overwrite default values with custom config
config = Object.assign(TestStorage.BUCKET_CONFIG, config);
/**
* Create a new bucket.
* @param {string} name
* @param {BucketConfig} metadata
* @return {Promise<[Bucket, ApiResponse]>}
*/
createBucket(name: string, config?: BucketConfig): Promise<[Bucket, ApiResponse]> {
// overwrite default values with custom config
config = Object.assign(TestStorage.BUCKET_CONFIG, config);
return TestStorage.gcs.createBucket(name, config);
}
return TestStorage.gcs.createBucket(name, config);
}
/**
* Query for buckets.
* @param {BucketQuery} query
*/
getBuckets(query?: BucketQuery): Promise<[Bucket[]]> {
return TestStorage.gcs.getBuckets(query);
}
/**
* Query for buckets.
* @param {BucketQuery} query
*/
getBuckets(query?: BucketQuery): Promise<[Bucket[]]> {
return TestStorage.gcs.getBuckets(query);
}
}
/**
@@ -87,143 +87,143 @@ export class TestStorage {
* @class TestBucket
*/
export class TestBucket {
// the bucket in the cloud
bucket: Bucket;
// the bucket in the cloud
bucket: Bucket;
/**
* Create a bucket.
* @param {BucketConfig} config
* @return {Promise<[Bucket, ApiResponse]>}
*/
create(config?: BucketConfig): Promise<[Bucket, ApiResponse]> {
return this.bucket.create(config);
}
/**
* Create a bucket.
* @param {BucketConfig} config
* @return {Promise<[Bucket, ApiResponse]>}
*/
create(config?: BucketConfig): Promise<[Bucket, ApiResponse]> {
return this.bucket.create(config);
}
/**
* Create a channel that will be notified when objects in this bucket changes.
* @method createChannel
* @param {string} id
* @param {ChannelConfig} config
* @return {Promise<[Channel, ApiResponse]>}
*/
createChannel(id: string, config: ChannelConfig): Promise<[Channel, ApiResponse]> {
return this.bucket.createChannel(id, config);
}
/**
* Create a channel that will be notified when objects in this bucket changes.
* @method createChannel
* @param {string} id
* @param {ChannelConfig} config
* @return {Promise<[Channel, ApiResponse]>}
*/
createChannel(id: string, config: ChannelConfig): Promise<[Channel, ApiResponse]> {
return this.bucket.createChannel(id, config);
}
/**
* Delete the bucket.
* @method delete
* @return {Promise<[ApiResponse]>}
*/
delete(): Promise<[ApiResponse]> {
return this.bucket.delete();
}
/**
* Delete the bucket.
* @method delete
* @return {Promise<[ApiResponse]>}
*/
delete(): Promise<[ApiResponse]> {
return this.bucket.delete();
}
/**
* Iterate over the bucket's files, calling file.delete() on each.
* @method deleteFiles
* @return {Promise<void>}
*/
deleteFiles(query?: BucketQuery): Promise<void> {
return this.bucket.deleteFiles(query);
}
/**
* Iterate over the bucket's files, calling file.delete() on each.
* @method deleteFiles
* @return {Promise<void>}
*/
deleteFiles(query?: BucketQuery): Promise<void> {
return this.bucket.deleteFiles(query);
}
/**
* Check if the bucket exists.
* @method exists
* @return {Promise<[boolean]>}
*/
exists(): Promise<[boolean]> {
return this.bucket.exists();
}
/**
* Check if the bucket exists.
* @method exists
* @return {Promise<[boolean]>}
*/
exists(): Promise<[boolean]> {
return this.bucket.exists();
}
/**
* Create a File object.
* @method file
* @param {string} name
* @param {BucketFileOptions} options
*/
file(name: string, options?: BucketFileOptions): File {
return this.bucket.file(name);
}
/**
* Create a File object.
* @method file
* @param {string} name
* @param {BucketFileOptions} options
*/
file(name: string, options?: BucketFileOptions): File {
return this.bucket.file(name);
}
/**
* Get a bucket if it exists.
* @method get
* @param {BucketGetOptions} options
*/
get(options?: BucketGetOptions): Promise<[Bucket, ApiResponse]> {
return this.bucket.get(options);
}
/**
* Get a bucket if it exists.
* @method get
* @param {BucketGetOptions} options
*/
get(options?: BucketGetOptions): Promise<[Bucket, ApiResponse]> {
return this.bucket.get(options);
}
/**
* Get File objects for the files currently in the bucket
* @method getFiles
* @param {BucketQuery} query
* @return {Promise<[File[]]>}
*/
getFiles(query?: BucketQuery): Promise<[File[]]> {
return this.bucket.getFiles(query);
}
/**
* Get File objects for the files currently in the bucket
* @method getFiles
* @param {BucketQuery} query
* @return {Promise<[File[]]>}
*/
getFiles(query?: BucketQuery): Promise<[File[]]> {
return this.bucket.getFiles(query);
}
/**
* Get File objects for the files currently in the bucket as a readable object stream.
* @method getFilesStream
* @param {BucketQuery} query
* @return {ReadStream}
*/
getFilesStream(query?: BucketQuery): fs.ReadStream {
return this.bucket.getFilesStream(query);
}
/**
* Get File objects for the files currently in the bucket as a readable object stream.
* @method getFilesStream
* @param {BucketQuery} query
* @return {ReadStream}
*/
getFilesStream(query?: BucketQuery): fs.ReadStream {
return this.bucket.getFilesStream(query);
}
/**
* Get the bucket's metadata.
* @method getMetadata
* @return {Promise<[BucketMetadata, ApiResponse]>}
*/
getMetadata(): Promise<[BucketMetadata, ApiResponse]> {
return this.bucket.getMetadata();
}
/**
* Get the bucket's metadata.
* @method getMetadata
* @return {Promise<[BucketMetadata, ApiResponse]>}
*/
getMetadata(): Promise<[BucketMetadata, ApiResponse]> {
return this.bucket.getMetadata();
}
/**
* Make the bucket listing private.
* @method makePrivate
* @param {} options
* @return Promise<[File[]]>
*/
makePrivate(options?: BucketPrivacyOptions): Promise<[File[]]> {
return this.bucket.makePrivate(options);
}
/**
* Make the bucket listing private.
* @method makePrivate
* @param {} options
* @return Promise<[File[]]>
*/
makePrivate(options?: BucketPrivacyOptions): Promise<[File[]]> {
return this.bucket.makePrivate(options);
}
/**
* Make the bucket publicly readable.
* @method makePublic
* @param {} options
* @return Promise<[File[]]>
*/
makePublic(options?: BucketPrivacyOptions): Promise<[File[]]> {
return this.bucket.makePublic(options);
}
/**
* Make the bucket publicly readable.
* @method makePublic
* @param {} options
* @return Promise<[File[]]>
*/
makePublic(options?: BucketPrivacyOptions): Promise<[File[]]> {
return this.bucket.makePublic(options);
}
/**
* Set the bucket's metadata.
* @method setMetadata
* @param {BucketMetadata} metadata
* @return {Promise<[ApiResponse]>}
*/
setMetadata(metadata?: BucketMetadata): Promise<[ApiResponse]> {
return this.bucket.setMetadata(metadata);
}
/**
* Set the bucket's metadata.
* @method setMetadata
* @param {BucketMetadata} metadata
* @return {Promise<[ApiResponse]>}
*/
setMetadata(metadata?: BucketMetadata): Promise<[ApiResponse]> {
return this.bucket.setMetadata(metadata);
}
/**
* Upload a file.
* @method upload
* @param {localPath} string
* @param {UploadOptions} options
*/
upload(localPath: string, options?: UploadOptions): Promise<[File]> {
return this.bucket.upload(localPath, options);
}
/**
* Upload a file.
* @method upload
* @param {localPath} string
* @param {UploadOptions} options
*/
upload(localPath: string, options?: UploadOptions): Promise<[File]> {
return this.bucket.upload(localPath, options);
}
}
/**
@@ -231,168 +231,168 @@ export class TestBucket {
* @class TestFile
*/
export class TestFile {
// the file in the cloud
file: File;
// the file in the cloud
file: File;
/**
* Copy this file to another file.
* By default, this will copy the file to the same bucket, but you can choose to copy it to another
* Bucket by providing a Bucket or File object or a URL starting with "gs:// ".
* @method copy
* @param {string} destination
* @return Promise<[File, ApiResponse]>
*/
/**
* Copy this file to another file.
* By default, this will copy the file to the same bucket, but you can choose to copy it to another
* Bucket by providing a Bucket or File object or a URL starting with "gs:// ".
* @method copy
* @param {string} destination
* @return Promise<[File, ApiResponse]>
*/
copy(destination: string | Bucket | File): Promise<[File, ApiResponse]> {
return this.file.copy(destination);
}
copy(destination: string | Bucket | File): Promise<[File, ApiResponse]> {
return this.file.copy(destination);
}
/**
* Create a readable stream to read the contents of the remote file.
* It can be piped to a writable stream or listened to for 'data' events to read a file's contents.
* @method createReadStream
* @param {ReadStreamOptions} options
* @return {ReadStream}
*/
createReadStream(options?: ReadStreamOptions): fs.ReadStream {
return this.file.createReadStream(options);
}
/**
* Create a readable stream to read the contents of the remote file.
* It can be piped to a writable stream or listened to for 'data' events to read a file's contents.
* @method createReadStream
* @param {ReadStreamOptions} options
* @return {ReadStream}
*/
createReadStream(options?: ReadStreamOptions): fs.ReadStream {
return this.file.createReadStream(options);
}
/**
* Create a writable stream to overwrite the contents of the file in your bucket.
* @method createWriteStream
* @param {WriteStreamOptions} options
* @return {WriteStream}
*/
createWriteStream(options?: WriteStreamOptions): fs.WriteStream {
return this.file.createWriteStream(options);
}
/**
* Create a writable stream to overwrite the contents of the file in your bucket.
* @method createWriteStream
* @param {WriteStreamOptions} options
* @return {WriteStream}
*/
createWriteStream(options?: WriteStreamOptions): fs.WriteStream {
return this.file.createWriteStream(options);
}
/**
* Delete the file.
* @method delete
* @return {Promise<[ApiResponse]>}
*/
delete(): Promise<[ApiResponse]> {
return this.file.delete();
}
/**
* Delete the file.
* @method delete
* @return {Promise<[ApiResponse]>}
*/
delete(): Promise<[ApiResponse]> {
return this.file.delete();
}
/**
* Convenience method to download a file into memory or to a local destination.
* @method download
* @param {DownloadOptions} options
* @return {Promise<[string]>}
*/
download(options?: DownloadOptions): Promise<[string]> {
return this.file.download(options);
}
/**
* Convenience method to download a file into memory or to a local destination.
* @method download
* @param {DownloadOptions} options
* @return {Promise<[string]>}
*/
download(options?: DownloadOptions): Promise<[string]> {
return this.file.download(options);
}
/**
* Check if the file exists.
* @method exists
* @return {Promise<[boolean]>}
*/
exists(): Promise<[boolean]> {
return this.file.exists();
}
/**
* Check if the file exists.
* @method exists
* @return {Promise<[boolean]>}
*/
exists(): Promise<[boolean]> {
return this.file.exists();
}
/**
* Get a file object and its metadata if it exists.
* @method get
* @return {Promise<[File, ApiResponse]>}
*/
get(): Promise<[File, ApiResponse]> {
return this.file.get();
}
/**
* Get a file object and its metadata if it exists.
* @method get
* @return {Promise<[File, ApiResponse]>}
*/
get(): Promise<[File, ApiResponse]> {
return this.file.get();
}
/**
* Get the file's metadata.
* @method getMetadata
* @return {Promise<[FileMetadata, ApiResponse]>}
*/
getMetadata(): Promise<[FileMetadata, ApiResponse]> {
return this.file.getMetadata();
}
/**
* Get the file's metadata.
* @method getMetadata
* @return {Promise<[FileMetadata, ApiResponse]>}
*/
getMetadata(): Promise<[FileMetadata, ApiResponse]> {
return this.file.getMetadata();
}
/**
* Get a signed policy document to allow a user to upload data with a POST request
* @method getSignedPolicy
* @param {SignedPolicyOptions} options
* @return {Promise<[SignedPolicy]>}
*/
getSignedPolicy(options?: SignedPolicyOptions): Promise<[SignedPolicy]> {
return this.file.getSignedPolicy(options);
}
/**
* Get a signed policy document to allow a user to upload data with a POST request
* @method getSignedPolicy
* @param {SignedPolicyOptions} options
* @return {Promise<[SignedPolicy]>}
*/
getSignedPolicy(options?: SignedPolicyOptions): Promise<[SignedPolicy]> {
return this.file.getSignedPolicy(options);
}
/**
* Get a signed URL to allow limited time access to the file
* @method getSignedUrl
* @param {SignedUrlConfig} config
* @return {Promise<[string]>}
*/
getSignedUrl(config?: SignedUrlConfig): Promise<[string]> {
return this.file.getSignedUrl(config);
}
/**
* Get a signed URL to allow limited time access to the file
* @method getSignedUrl
* @param {SignedUrlConfig} config
* @return {Promise<[string]>}
*/
getSignedUrl(config?: SignedUrlConfig): Promise<[string]> {
return this.file.getSignedUrl(config);
}
/**
* Make a file private to the project and remove all other permissions.
* @method makePrivate
* @param {FilePrivateOptions} options
* @return {Promise<[ApiResponse]>}
*/
makePrivate(options?: FilePrivateOptions): Promise<[ApiResponse]> {
return this.file.makePrivate(options);
}
/**
* Make a file private to the project and remove all other permissions.
* @method makePrivate
* @param {FilePrivateOptions} options
* @return {Promise<[ApiResponse]>}
*/
makePrivate(options?: FilePrivateOptions): Promise<[ApiResponse]> {
return this.file.makePrivate(options);
}
/**
* Set a file to be publicly readable and maintain all previous permissions.
* @method makePublic
* @return {Promise<[ApiResponse]>}
*/
makePublic(): Promise<[ApiResponse]> {
return this.file.makePublic();
}
/**
* Set a file to be publicly readable and maintain all previous permissions.
* @method makePublic
* @return {Promise<[ApiResponse]>}
*/
makePublic(): Promise<[ApiResponse]> {
return this.file.makePublic();
}
/**
* Move this file to another location.
* By default, this will move the file to the same bucket, but you can choose to move it to
* another Bucket by providing a Bucket or File object or a URL beginning with "gs:// ".
* @method move
* @param {string|Bucket|File} destination
* @return {Promise<[File, ApiResponse]>}
*/
move(destination: string | Bucket | File): Promise<[File, ApiResponse]> {
return this.file.move(destination);
}
/**
* Move this file to another location.
* By default, this will move the file to the same bucket, but you can choose to move it to
* another Bucket by providing a Bucket or File object or a URL beginning with "gs:// ".
* @method move
* @param {string|Bucket|File} destination
* @return {Promise<[File, ApiResponse]>}
*/
move(destination: string | Bucket | File): Promise<[File, ApiResponse]> {
return this.file.move(destination);
}
/**
* Write arbitrary data to a file.
* @param {string} data
* @param {WriteStreamOptions} options
* @return {Promise<void>}
*/
save(data: string, options?: WriteStreamOptions): Promise<void> {
return this.file.save(data);
}
/**
* Write arbitrary data to a file.
* @param {string} data
* @param {WriteStreamOptions} options
* @return {Promise<void>}
*/
save(data: string, options?: WriteStreamOptions): Promise<void> {
return this.file.save(data);
}
/**
* The Storage API allows you to use a custom key for server-side encryption.
* @param {string|Buffer} encryptionKey
* @return {File}
*/
setEncryptionKey(encryptionKey: string | Buffer): File {
return this.file.setEncryptionKey(encryptionKey);
}
/**
* The Storage API allows you to use a custom key for server-side encryption.
* @param {string|Buffer} encryptionKey
* @return {File}
*/
setEncryptionKey(encryptionKey: string | Buffer): File {
return this.file.setEncryptionKey(encryptionKey);
}
/**
* Merge the given metadata with the current remote file's metadata.
* This will set metadata if it was previously unset or update previously set metadata.
* To unset previously set metadata, set its value to null.
* @method setMetadata
* @param {FileMetadata} metadata
* @return {Promise<[ApiResponse]>}
*/
setMetadata(metadata: FileMetadata): Promise<[ApiResponse]> {
return this.file.setMetadata(metadata);
}
/**
* Merge the given metadata with the current remote file's metadata.
* This will set metadata if it was previously unset or update previously set metadata.
* To unset previously set metadata, set its value to null.
* @method setMetadata
* @param {FileMetadata} metadata
* @return {Promise<[ApiResponse]>}
*/
setMetadata(metadata: FileMetadata): Promise<[ApiResponse]> {
return this.file.setMetadata(metadata);
}
}
+337 -4
View File
@@ -5,7 +5,340 @@
/// <reference types="node" />
export * from "./bucket";
export * from "./channel";
export * from "./file";
export * from "./storage";
import { ReadStream, WriteStream } from "fs";
type PromiseLibrary<T> = () => PromiseLike<T>;
declare namespace Storage {
/**
* A bucket in the cloud.
*/
class Bucket {
constructor(storage: Storage, name: string);
acl: Storage.Acl;
combine(sources: string[] | File[], destination: string[] | File[]): Promise<[File, Storage.ApiResponse]>;
create(config?: BucketConfig): Promise<[Bucket, Storage.ApiResponse]>;
createChannel(id: string, config: ChannelConfig): Promise<[Channel, Storage.ApiResponse]>;
delete(): Promise<[Storage.ApiResponse]>;
deleteFiles(query?: BucketQuery): Promise<void>;
exists(): Promise<[boolean]>;
file(name: string, options?: BucketFileOptions): File;
get(options?: BucketGetOptions): Promise<[Bucket, Storage.ApiResponse]>;
getFiles(query?: BucketQuery): Promise<[File[]]>;
getFilesStream(query?: BucketQuery): ReadStream;
getMetadata(): Promise<[BucketMetadata, Storage.ApiResponse]>;
id: string;
makePrivate(options?: BucketPrivacyOptions): Promise<[File[]]>;
makePublic(options?: BucketPrivacyOptions): Promise<[File[]]>;
metadata: BucketMetadata;
name: string;
setMetadata(metadata?: BucketMetadata): Promise<[Storage.ApiResponse]>;
upload(localPath: string, options?: Storage.UploadOptions): Promise<[File]>;
}
/**
* Bucket configuration.
*/
interface BucketConfig {
coldline?: boolean;
dra?: boolean;
location?: string;
multiRegional?: boolean;
nearline?: boolean;
regional?: boolean;
versioning?: {
enabled?: boolean
};
}
/**
* Options for getting a file.
*/
interface BucketFileOptions {
generation?: string | number;
}
/**
* Options for getting a bucket.
*/
interface BucketGetOptions {
autoCreate?: boolean;
}
/**
* Bucket metadata.
*/
interface BucketMetadata {
etag?: string;
id?: string;
kind?: string;
location?: string;
metageneration?: string;
name?: string;
projectNumber?: string;
selfLink?: string;
storageClass?: string;
timeCreated?: string;
updated?: string;
}
/**
* The options for making the bucket private.
*/
interface BucketPrivacyOptions {
includeFiles?: boolean;
force?: boolean;
}
/**
* Query a bucket.
*/
interface BucketQuery {
autoPaginate?: boolean;
delimiter?: string;
prefix?: string;
maxApiCalls?: number;
maxResults?: number;
pageToken?: string;
versions?: boolean;
}
/**
* Options for specifying the content length range.
*/
interface ContentLengthRange {
max?: number;
min?: number;
}
/**
* A file in the cloud.
*/
class File {
constructor(bucket: Bucket, name: string, options?: BucketFileOptions);
acl: Acl;
copy(destination: string | Bucket | File): Promise<[File, ApiResponse]>;
createReadStream(options?: ReadStreamOptions): ReadStream;
createWriteStream(options?: WriteStreamOptions): WriteStream;
delete(): Promise<[ApiResponse]>;
download(options?: DownloadOptions): Promise<[Buffer]>;
exists(): Promise<[boolean]>;
get(): Promise<[File, ApiResponse]>;
getMetadata(): Promise<[FileMetadata, ApiResponse]>;
getSignedPolicy(options?: SignedPolicyOptions): Promise<[SignedPolicy]>;
getSignedUrl(config?: SignedUrlConfig): Promise<[string]>;
makePrivate(options?: FilePrivateOptions): Promise<[ApiResponse]>;
makePublic(): Promise<[ApiResponse]>;
move(destination: string | Bucket | File): Promise<[File, ApiResponse]>;
name: string;
save(data: string, options?: WriteStreamOptions): Promise<void>;
setEncryptionKey(encryptionKey: string | Buffer): File;
setMetadata(metadata: FileMetadata): Promise<[ApiResponse]>;
metadata?: FileMetadata;
}
/**
* File metadata.
*/
interface FileMetadata {
contentType?: string;
}
/**
* Options when setting the file as private.
*/
interface FilePrivateOptions {
strict?: boolean;
}
/**
* A signed policy allowing a user to upload a file with a POST.
*/
interface SignedPolicy {
base64?: string;
signature?: string;
string?: string;
}
/**
* Options when obtaining the signed policy.
*/
interface SignedPolicyOptions {
acl?: string;
contentLengthRange?: ContentLengthRange;
equals?: string[] | [string[]];
expires?: number | string;
max?: number;
min?: number;
startsWith?: string[] | [string[]];
successRedirect?: string;
successStatus?: string;
}
/**
* Options when obtaining a temporary signed URL for a file.
*/
interface SignedUrlConfig {
action: string;
cname?: string;
contentMd5?: string;
contentType?: string;
expires?: number | string;
extensionHeaders?: { [key: string]: string };
promptSaveAs?: string;
responseDisposition?: string;
responseType?: string;
}
/**
* Access control list for storage buckets and files.
*/
interface Acl extends AclActions {
default: AclEntity;
owners: AclEntity;
readers: AclEntity;
writers: AclEntity;
}
/**
* Actions that can be performed on all ACL entities, including the root Acl.
*/
interface AclActions {
add(options: AclOptions): Promise<[Acl, ApiResponse]>;
delete(options: AclOptions): Promise<[Acl, ApiResponse]>;
get(options: AclOptions): Promise<[Acl, ApiResponse]>;
update(options: AclOptions): Promise<[Acl, ApiResponse]>;
}
/**
* An object of convenience methods to add or delete reader ACL permissions for a given entity.
*/
interface AclEntity extends AclActions {
addAllAuthenticatedUsers(): Promise<[Acl, ApiResponse]>;
addAllUsers(): Promise<[Acl, ApiResponse]>;
addDomain(entity: string): Promise<[Acl, ApiResponse]>;
addGroup(entity: string): Promise<[Acl, ApiResponse]>;
addProject(entity: string): Promise<[Acl, ApiResponse]>;
addUser(entity: string): Promise<[Acl, ApiResponse]>;
deleteAllAuthenticatedUsers(): Promise<[Acl, ApiResponse]>;
deleteAllUsers(): Promise<[Acl, ApiResponse]>;
deleteDomain(entity: string): Promise<[Acl, ApiResponse]>;
deleteGroup(entity: string): Promise<[Acl, ApiResponse]>;
deleteProject(entity: string): Promise<[Acl, ApiResponse]>;
deleteUser(entity: string): Promise<[Acl, ApiResponse]>;
}
/**
* ACL options.
*/
interface AclOptions {
entity?: string;
role?: string;
generation?: number;
}
/**
* The response object.
*/
interface ApiResponse {
etag?: string;
id?: string;
kind?: string;
location?: string;
metageneration?: string;
name?: string;
projectNumber?: string;
selfLink?: string;
storageClass?: string;
timeCreated?: string;
updated?: string;
}
interface Credentials {
client_email?: string;
private_key?: string;
}
interface ConfigurationObject {
autoRetry?: boolean;
credentials?: Credentials;
email?: string;
keyFilename?: string;
maxRetries?: number;
projectId?: string;
promise?: PromiseLibrary<any>;
}
/**
* The options when downloading a file.
*/
interface DownloadOptions extends ReadStreamOptions {
destination?: string;
}
/**
* Options when reading a file stream.
*/
interface ReadStreamOptions {
end?: number;
start?: number;
validation?: string | boolean;
}
/**
* Options when uploading file to bucket.
*/
interface UploadOptions extends WriteStreamOptions {
destination?: string;
}
/**
* Options when writing to a file stream.
*/
interface WriteStreamOptions {
gzip?: boolean;
metadata?: FileMetadata;
offset?: number;
predefinedAcl?: string;
private?: boolean;
public?: boolean;
resumable?: boolean;
uri?: string;
validation?: string | boolean;
}
/**
* The Storage class allows you interact with Google Cloud Storage.
*/
class Storage {
constructor(config?: ConfigurationObject);
acl: Acl;
bucket(name: string | Bucket): Bucket;
channel(id: string, resourceId: string): Channel;
createBucket(name: string, metadata?: BucketConfig): Promise<[Bucket, ApiResponse]>;
getBuckets(query?: BucketQuery): Promise<[Bucket[]]>;
getBucketsStream(query?: BucketQuery): Promise<[ReadStream]>;
Channel: (storage: Storage, id: string, resourceId: string) => Channel;
File: (bucket: Bucket, name: string, opts: BucketFileOptions) => File;
Bucket: (storage: Storage, name: string) => Bucket;
}
/**
* This class allows you interact with Google Cloud Storage.
*/
class Channel {
constructor(storage: Storage, id: string, resourceId: string);
stop(): Promise<[Storage.ApiResponse]>;
}
/**
* Channel configuration.
*/
interface ChannelConfig {
address: string;
}
}
declare function Storage(config?: Storage.ConfigurationObject): Storage.Storage;
export = Storage;
-136
View File
@@ -1,136 +0,0 @@
import { ReadStream } from "fs";
import { Bucket, BucketConfig, BucketQuery } from "./bucket";
import { Channel } from "./channel";
import { FileMetadata } from "./file";
/**
* Access control list for storage buckets and files.
*/
export class Acl extends AclActions {
default: AclEntity;
owners: AclEntity;
readers: AclEntity;
writers: AclEntity;
}
/**
* Actions that can be performed on all ACL entities, including the root Acl.
*/
export class AclActions {
add(options: AclOptions): Promise<[Acl, ApiResponse]>;
delete(options: AclOptions): Promise<[Acl, ApiResponse]>;
get(options: AclOptions): Promise<[Acl, ApiResponse]>;
update(options: AclOptions): Promise<[Acl, ApiResponse]>;
}
/**
* An object of convenience methods to add or delete reader ACL permissions for a given entity.
*/
export class AclEntity extends AclActions {
addAllAuthenticatedUsers(): Promise<[Acl, ApiResponse]>;
addAllUsers(): Promise<[Acl, ApiResponse]>;
addDomain(entity: string): Promise<[Acl, ApiResponse]>;
addGroup(entity: string): Promise<[Acl, ApiResponse]>;
addProject(entity: string): Promise<[Acl, ApiResponse]>;
addUser(entity: string): Promise<[Acl, ApiResponse]>;
deleteAllAuthenticatedUsers(): Promise<[Acl, ApiResponse]>;
deleteAllUsers(): Promise<[Acl, ApiResponse]>;
deleteDomain(entity: string): Promise<[Acl, ApiResponse]>;
deleteGroup(entity: string): Promise<[Acl, ApiResponse]>;
deleteProject(entity: string): Promise<[Acl, ApiResponse]>;
deleteUser(entity: string): Promise<[Acl, ApiResponse]>;
}
/**
* ACL options.
*/
export interface AclOptions {
entity?: string;
role?: string;
generation?: number;
}
/**
* The response object.
*/
export interface ApiResponse {
etag?: string;
id?: string;
kind?: string;
location?: string;
metageneration?: string;
name?: string;
projectNumber?: string;
selfLink?: string;
storageClass?: string;
timeCreated?: string;
updated?: string;
}
export interface Credentials {
client_email?: string;
private_key?: string;
}
export interface ConfigurationObject {
autoRetry?: boolean;
credentials?: Credentials;
email?: string;
keyFilename?: string;
maxRetries?: number;
projectId?: string;
promise?: PromiseLibrary<any>;
}
/**
* The options when downloading a file.
*/
export interface DownloadOptions extends ReadStreamOptions {
destination?: string;
}
/**
* Options when reading a file stream.
*/
export interface ReadStreamOptions {
end?: number;
start?: number;
validation?: string | boolean;
}
/**
* Options when uploading file to bucket.
*/
export interface UploadOptions extends WriteStreamOptions {
destination?: string;
}
/**
* Options when writing to a file stream.
*/
export interface WriteStreamOptions {
gzip?: boolean;
metadata?: FileMetadata;
offset?: number;
predefinedAcl?: string;
private?: boolean;
public?: boolean;
resumable?: boolean;
uri?: string;
validation?: string | boolean;
}
/**
* The Storage class allows you interact with Google Cloud Storage.
*/
export class Storage {
constructor(options?: ConfigurationObject);
acl: Acl;
bucket(name: string|Bucket): Bucket;
channel(id: string, resourceId: string): Channel;
createBucket(name: string, metadata?: BucketConfig): Promise<[Bucket, ApiResponse]>;
getBuckets(query?: BucketQuery): Promise<[Bucket[]]>;
getBucketsStream(query?: BucketQuery): Promise<[ReadStream]>;
}
export type PromiseLibrary<T> = () => PromiseLike<T>;
+2 -2
View File
@@ -11,10 +11,10 @@
"typeRoots": [
"../"
],
"types" : [],
"paths":{
"@google-cloud/storage": ["google-cloud__storage"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
@@ -22,4 +22,4 @@
"index.d.ts",
"google-cloud__storage-tests.ts"
]
}
}
@@ -0,0 +1,8 @@
import { src, dest } from 'gulp';
import * as gulpModernizr from 'gulp-modernizr';
let s1 = gulpModernizr();
let s2 = gulpModernizr('filename.js', {});
let s3 = gulpModernizr({cache: false});
src('fixtures.js').pipe(s1).pipe(s2);
+79
View File
@@ -0,0 +1,79 @@
// Type definitions for gulp-modernizr 1.0
// Project: https://github.com/doctyper/gulp-modernizr
// Definitions by: remisery <https://github.com/remisery>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import stream = require('stream');
declare function GulpModernizr(parames?: GulpModernizr.Params): stream.Transform;
declare function GulpModernizr(file?: string, parames?: GulpModernizr.Params): stream.Transform;
declare namespace GulpModernizr {
interface Params {
/**
* Avoid unnecessary builds (see Caching section below)
*/
cache?: boolean;
/**
* Path to the build you're using for development.
*/
devFile?: string | false;
/**
* Path to save out the built file
*/
dest?: string | false;
/**
* Based on default settings on http://modernizr.com/download/
*/
options?: {
classPrefix: string;
enableJSClass: boolean;
enableClasses: boolean;
};
/**
* By default, source is uglified before saving
*/
uglify?: boolean;
/**
* Define any tests you want to explicitly include
*/
tests?: string[];
/**
* Useful for excluding any tests that this tool will match
* e.g. you use .notification class for notification elements,
* but don’t want the test for Notification API
*/
excludeTests?: string[];
/**
* By default, will crawl your project for references to Modernizr tests
* Set to false to disable
*/
crawl?: boolean;
/**
* Set to true to pass in buffers via the "files" parameter below
*/
useBuffers?: boolean;
/**
* By default, this task will crawl all *.js, *.css, *.scss files.
*/
files?: { src: string[] };
/**
* Have custom Modernizr tests? Add them here.
*/
customTests?: string[];
}
}
export = GulpModernizr;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"gulp-modernizr-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
@@ -0,0 +1,18 @@
import * as mustache from "gulp-mustache";
// noinspection ES6UnusedImports
import { Transform } from "stream";
mustache({ // $ExpectType Transform
msg: "Hello Gulp!"
});
mustache({ // $ExpectType Transform
msg: "Hello Gulp!",
nested_value: "I am nested.",
another_value: "1 2 3"
}, {}, {
some_inner_partial: "<p>{{nested_value}}</p>",
another_partial: "<div>{{another_value}}</div>"
});
mustache('your_json_file.json', {}, {}); // $ExpectType Transform
+27
View File
@@ -0,0 +1,27 @@
// Type definitions for gulp-mustache v 3.0
// Project: https://github.com/rogeriopvl/gulp-mustache
// Definitions by: Christopher Durham <cad97@cad97.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { Transform } from "stream";
declare namespace GulpMustache {
type View = Hash | string | undefined;
interface Hash {
[key: string]: string;
}
interface Options {
extension?: string;
tags?: ReadonlyArray<string> | undefined;
}
}
declare function GulpMustache(view: GulpMustache.View,
options?: GulpMustache.Options,
partials?: GulpMustache.Hash): Transform;
export = GulpMustache;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"gulp-mustache-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+8
View File
@@ -0,0 +1,8 @@
import { src, dest } from 'gulp';
import * as gulpPug from 'gulp-pug';
let s1 = gulpPug();
let s2 = gulpPug({});
let s3 = gulpPug({ basedir: '.' });
src('fixtures.js').pipe(s1).pipe(s2).pipe(s3);
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for gulp-pug 3.3
// Project: https://github.com/pugjs/gulp-pug#readme
// Definitions by: remisery <https://github.com/remisery>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import stream = require('stream');
import { Options } from 'pug';
declare function GulpPug(params?: GulpPug.Params): stream.Transform;
declare namespace GulpPug {
interface Params extends Options {
locals?: any;
data?: any;
client?: boolean;
pug?: any;
verbose?: boolean;
}
}
export = GulpPug;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"gulp-pug-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -6
View File
@@ -1,6 +1,3 @@
import * as gulp from 'gulp';
import * as size from 'gulp-size';
import * as debug from 'gulp-debug';
@@ -11,9 +8,8 @@ gulp.task('default', () =>
.pipe(gulp.dest('dist'))
);
gulp.task('default', () => {
var s = size();
let s = size();
return gulp.src('fixture.js')
.pipe(s)
@@ -21,6 +17,5 @@ gulp.task('default', () => {
.pipe(debug({title: 'Total size ' + s.prettySize}));
});
size();
size({showFiles: true, gzip: true});
+4 -2
View File
@@ -1,16 +1,18 @@
// Type definitions for gulp-size v1.2.3
// Type definitions for gulp-size 2.1
// Project: https://github.com/sindresorhus/gulp-size
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
// Remisery <https://github.com/remisery>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare namespace size {
interface Options {
showFiles?: boolean;
gzip?: boolean;
title?: string;
pretty?: boolean;
showTotal?: boolean;
}
interface SizeStream extends NodeJS.ReadWriteStream {
+2 -2
View File
@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -22,4 +22,4 @@
"index.d.ts",
"gulp-size-tests.ts"
]
}
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+18
View File
@@ -0,0 +1,18 @@
import * as UglifyJS from 'uglify-js';
import * as GulpUglify from 'gulp-uglify';
interface Composer {
(uglify: Uglify, log: Logger): typeof GulpUglify;
}
interface Uglify {
minify: typeof UglifyJS.minify;
}
interface Logger {
warn: typeof console.warn;
}
declare const composer: Composer;
export = composer;
+38 -5
View File
@@ -1,17 +1,19 @@
import * as gulp from 'gulp';
import * as uglify from 'gulp-uglify';
import pump = require('pump');
import uglifyjs = require('uglify-js');
import composer = require('gulp-uglify/composer');
gulp.task('compress', function() {
var tsResult = gulp.src('lib/*.ts')
gulp.task('compress', () => {
const tsResult = gulp.src('lib/*.ts')
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('compress2', function() {
var tsResult = gulp.src('lib/*.ts')
gulp.task('compress2', () => {
const tsResult = gulp.src('lib/*.ts')
.pipe(uglify({
mangle: false,
preserveComments: "some",
compress: false,
output: {
max_line_len: 300
@@ -19,3 +21,34 @@ gulp.task('compress2', function() {
}))
.pipe(gulp.dest('dist'));
});
gulp.task('compress', (cb) => {
pump([
gulp.src('lib/*.js'),
uglify(),
gulp.dest('dist')
],
cb
);
});
const minify = composer(uglifyjs, console);
gulp.task('compress', (cb) => {
// the same options as described above
const options = {};
pump([
gulp.src('lib/*.js'),
minify(options),
gulp.dest('dist')
],
cb
);
});
gulp.task('compress', () => {
return gulp.src('lib/*.js')
.pipe(minify())
.pipe(gulp.dest('dist'));
});
+2 -9
View File
@@ -1,6 +1,7 @@
// Type definitions for gulp-uglify
// Type definitions for gulp-uglify 3.0
// Project: https://github.com/terinjokes/gulp-uglify
// Definitions by: Christopher Haws <https://github.com/ChristopherHaws/>
// Leonard Thieu <https://github.com/leonard-thieu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
@@ -23,14 +24,6 @@ declare namespace GulpUglify {
* Pass an object to specify custom compressor options. Pass false to skip compression completely.
*/
compress?: UglifyJS.CompressorOptions | boolean;
/**
* A convenience option for options.output.comments. Defaults to preserving no comments.
* all - Preserve all comments in code blocks
* some - Preserve comments that start with a bang (!) or include a Closure Compiler directive (@preserve, @license, @cc_on)
* function - Specify your own comment preservation function. You will be passed the current node and the current comment and are expected to return either true or false.
*/
preserveComments?: string | ((node: any, comment: UglifyJS.Tokenizer) => boolean);
}
}
+3 -5
View File
@@ -6,20 +6,18 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"q": [ "q/v0" ]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"composer.d.ts",
"gulp-uglify-tests.ts"
]
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"callable-types": false
}
}
+16 -2
View File
@@ -1,6 +1,6 @@
// Type definitions for helmet
// Project: https://github.com/helmetjs/helmet
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>, Evan Hahn <https://github.com/EvanHahn>
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>, Evan Hahn <https://github.com/EvanHahn>, Elliot Blackburn <https://github.com/bluehatbrit>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import express = require('express');
@@ -19,7 +19,8 @@ declare namespace helmet {
ieNoOpen?: boolean,
noCache?: boolean,
noSniff?: boolean,
xssFilter?: boolean | IHelmetXssFilterConfiguration
xssFilter?: boolean | IHelmetXssFilterConfiguration,
expectCt?: boolean | IHelmetExpectCtConfiguration,
}
export interface IHelmetContentSecurityPolicyDirectiveFunction {
@@ -96,6 +97,12 @@ declare namespace helmet {
setOnOldIE?: boolean;
}
export interface IHelmetExpectCtConfiguration {
enforce?: boolean;
maxAge?: number;
reportUri?: string;
}
/**
* @summary Interface for helmet class.
* @interface
@@ -179,5 +186,12 @@ declare namespace helmet {
* @return {RequestHandler} The Request handler.
*/
xssFilter(options?: IHelmetXssFilterConfiguration): express.RequestHandler;
/**
* @summary Adds the "Expect-CT" header.
* @param {helmet.IHelmetExpectCtConfiguration} options
* @returns {e.RequestHandler}
*/
expectCt(options?: IHelmetExpectCtConfiguration): express.RequestHandler;
}
}
+5
View File
@@ -1455,6 +1455,11 @@ declare namespace Highcharts {
* @since 3.0.8
*/
drillup?(event: Event): void;
/**
* Fires after drilling up from all drilldown series.
* @since 4.2.4
*/
drillupall?(event: Event): void;
/**
* Fires when the chart is finished loading. One parameter, event, is passed to the function. This contains common
* event information based on jQuery or MooTools depending on which library is used as the base for Highcharts.
+1
View File
@@ -242,6 +242,7 @@ function test_ChartOptions() {
click: () => { },
drilldown: () => { },
drillup: () => { },
drillupall: () => { },
load: () => { },
redraw: () => { },
selection: () => { }
+17
View File
@@ -0,0 +1,17 @@
import * as express from 'express';
import * as hpp from 'hpp';
const app = express();
app.use(hpp());
app.use(hpp({
checkBody: true,
checkBodyOnlyForContentType: 'urlencoded',
checkQuery: true,
whitelist: ['foo', 'bar']
}));
app.use(hpp({
whitelist: 'foobar'
}));
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for hpp 0.2
// Project: https://github.com/analog-nico/hpp
// Definitions by: Michael Strobel <https://github.com/kryops>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as express from 'express';
declare namespace hpp {
interface Options {
checkBody?: boolean;
checkBodyOnlyForContentType?: string;
checkQuery?: boolean;
whitelist?: string | string[];
}
}
declare function hpp(options?: hpp.Options): express.RequestHandler;
export = hpp;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"hpp-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+8
View File
@@ -0,0 +1,8 @@
// Type definitions for is-url-superb 2.0
// Project: https://github.com/sindresorhus/is-url-superb
// Definitions by: Michael Strobel <https://github.com/kryops>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = isUrl;
declare function isUrl(str: string): boolean;
@@ -0,0 +1,5 @@
import isUrl = require('is-url-superb');
const url1: boolean = isUrl('http://todomvc.com');
const url2: boolean = isUrl('//todomvc.com');
const url3: boolean = isUrl('unicorn');
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"is-url-superb-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+52
View File
@@ -0,0 +1,52 @@
// Type definitions for iso-3166-2 0.6
// Project: https://github.com/olahol/iso-3166-2.js
// Definitions by: Matt Rollins <https://github.com/sicilica>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export type InfoOrEmptyRecord<T> = T | {};
export namespace CountryInfo {
interface Partial {
name: string;
sub: SubdivisionInfo.Map;
}
interface Full extends Partial {
code: string;
}
interface Map {
// full data if this country has been retrieved with country() at least once
[code: string]: Full | Partial;
}
}
export type CountryInfo = CountryInfo.Full;
export namespace SubdivisionInfo {
interface Partial {
type: string;
name: string;
}
interface Full extends Partial {
countryName: string;
countryCode: string;
code: string;
regionCode: string;
}
interface Map {
// full data if this subdivision has been retrieved with subdivision() at least once
[code: string]: Full | Partial;
}
}
export type SubdivisionInfo = SubdivisionInfo.Full;
export function subdivision(countryCodeOrFullSubdivisionCode: string, subdivisionCodeOrName?: string): InfoOrEmptyRecord<SubdivisionInfo>;
export function country(countryCodeOrName: string): InfoOrEmptyRecord<CountryInfo>;
export const data: CountryInfo.Map;
// map of alpha 3 codes to alpha 3 codes
export const codes: {
[alpha3: string]: string
};
+50
View File
@@ -0,0 +1,50 @@
import * as iso3166 from "iso-3166-2";
// subdivision() and country() return {} on failure, which is nearly impossible to separate from a valid response in TypeScript;
// until a PR can be accepted on the original repo, this workaround makes accessing the original type possible.
function wrap<T>(rawResult: T|{}): T|null {
if (Object.keys(rawResult).length)
return rawResult as T;
else
return null;
}
iso3166.subdivision("SE-O");
iso3166.subdivision("US-IN");
iso3166.subdivision("SWE", "O");
iso3166.subdivision("US", "Indiana");
const indiana = wrap(iso3166.subdivision("US-IN"));
if (indiana) {
const name: string = indiana.name;
const type: string = indiana.type;
const code: string = indiana.code;
const regionCode: string = indiana.regionCode;
const countryCode: string = indiana.countryCode;
const countryName: string = indiana.countryName;
}
iso3166.country("US");
iso3166.country("SE");
iso3166.country("SWE");
iso3166.country("United States");
iso3166.country("Sweden");
const sweden = wrap(iso3166.country("SE"));
if (sweden) {
const name: string = sweden.name;
const subNameO: string = sweden.sub["SE-O"].name;
const code: string = sweden.code;
}
const unitedStates = iso3166.data["US"];
{
const name: string = unitedStates.name;
const subNameIN: string = unitedStates.sub["US-IN"].name;
}
const alpha3 = "SWE";
const alpha2 = "SE";
const codesWork = (alpha2 === iso3166.codes[alpha3]);
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"iso-3166-2-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -1
View File
@@ -175,7 +175,7 @@ declare namespace jest {
type ProvidesCallback = (cb: DoneCallback) => any;
type Lifecycle = (fn: ProvidesCallback) => any;
type Lifecycle = (fn: ProvidesCallback, timeout?: number) => any;
/**
* Creates a test closure
+6
View File
@@ -480,6 +480,12 @@ describe('strictNullChecks', () => {
});
});
describe('beforeEach with timeout', () => {
beforeEach(() => {
// this shouldn't take more than a second
}, 1000);
});
class TestApi {
constructor() { }
testProp: boolean;
+8 -8
View File
@@ -3017,7 +3017,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* @see {@link https://api.jquery.com/after/}
* @since 1.0
*/
after(...contents: Array<JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery>): this;
after(...contents: Array<JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery<JQuery.Node>>): this;
/**
* Insert content, specified by the parameter, after each element in the set of matched elements.
*
@@ -3029,7 +3029,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* @since 1.4
* @since 1.10
*/
after(fn: (this: TElement, index: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery): this;
after(fn: (this: TElement, index: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery<JQuery.Node>): this;
/**
* Register a handler to be called when Ajax requests complete. This is an AjaxEvent.
*
@@ -3133,7 +3133,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* @see {@link https://api.jquery.com/append/}
* @since 1.0
*/
append(...contents: Array<JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery>): this;
append(...contents: Array<JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery<JQuery.Node>>): this;
/**
* Insert content, specified by the parameter, to the end of each element in the set of matched elements.
*
@@ -3144,7 +3144,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* @see {@link https://api.jquery.com/append/}
* @since 1.4
*/
append(fn: (this: TElement, index: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery): this;
append(fn: (this: TElement, index: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery<JQuery.Node>): this;
/**
* Insert every element in the set of matched elements to the end of the target.
*
@@ -3191,7 +3191,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* @see {@link https://api.jquery.com/before/}
* @since 1.0
*/
before(...contents: Array<JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery>): this;
before(...contents: Array<JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery<JQuery.Node>>): this;
/**
* Insert content, specified by the parameter, before each element in the set of matched elements.
*
@@ -3203,7 +3203,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* @since 1.4
* @since 1.10
*/
before(fn: (this: TElement, index: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery): this;
before(fn: (this: TElement, index: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery<JQuery.Node>): this;
// [bind() overloads] https://github.com/jquery/api.jquery.com/issues/1048
/**
* Attach a handler to an event for the elements.
@@ -4595,7 +4595,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* @see {@link https://api.jquery.com/prepend/}
* @since 1.0
*/
prepend(...contents: Array<JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery>): this;
prepend(...contents: Array<JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery<JQuery.Node>>): this;
/**
* Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
*
@@ -4606,7 +4606,7 @@ interface JQuery<TElement extends Node = HTMLElement> extends Iterable<TElement>
* @see {@link https://api.jquery.com/prepend/}
* @since 1.4
*/
prepend(fn: (this: TElement, index: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery): this;
prepend(fn: (this: TElement, index: number, html: string) => JQuery.htmlString | JQuery.TypeOrArray<JQuery.Node> | JQuery<JQuery.Node>): this;
/**
* Insert every element in the set of matched elements to the beginning of the target.
*
+8 -8
View File
@@ -5130,7 +5130,7 @@ function JQuery() {
function manipulation() {
function after() {
// $ExpectType JQuery<HTMLElement>
$('p').after('<p></p>', new Element(), new Text(), $('p'), [new Element(), new Text()]);
$('p').after('<p></p>', new Element(), new Text(), $('p').contents(), [new Element(), new Text()]);
// $ExpectType JQuery<HTMLElement>
$('p').after(function(index, html) {
@@ -5189,13 +5189,13 @@ function JQuery() {
// $ExpectType string
html;
return $('p');
return $('p').contents();
});
}
function append() {
// $ExpectType JQuery<HTMLElement>
$('p').append('<p></p>', new Element(), new Text(), $('p'), [new Element(), new Text()]);
$('p').append('<p></p>', new Element(), new Text(), $('p').contents(), [new Element(), new Text()]);
// $ExpectType JQuery<HTMLElement>
$('p').append(function(index, html) {
@@ -5254,7 +5254,7 @@ function JQuery() {
// $ExpectType string
html;
return $('p');
return $('p').contents();
});
// $ExpectType JQuery<HTMLElement>
@@ -5263,7 +5263,7 @@ function JQuery() {
function before() {
// $ExpectType JQuery<HTMLElement>
$('p').before('<p></p>', new Element(), new Text(), $('p'), [new Element(), new Text()]);
$('p').before('<p></p>', new Element(), new Text(), $('p').contents(), [new Element(), new Text()]);
// $ExpectType JQuery<HTMLElement>
$('p').before(function(index, html) {
@@ -5322,13 +5322,13 @@ function JQuery() {
// $ExpectType string
html;
return $('p');
return $('p').contents();
});
}
function prepend() {
// $ExpectType JQuery<HTMLElement>
$('p').prepend('<p></p>', new Element(), new Text(), $('p'), [new Element(), new Text()]);
$('p').prepend('<p></p>', new Element(), new Text(), $('p').contents(), [new Element(), new Text()]);
// $ExpectType JQuery<HTMLElement>
$('p').prepend(function(index, html) {
@@ -5387,7 +5387,7 @@ function JQuery() {
// $ExpectType string
html;
return $('p');
return $('p').contents();
});
}
+5 -3
View File
@@ -83,6 +83,8 @@ export interface SignCallback {
(err: Error, encoded: string): void;
}
export type Secret = string | Buffer | {key: string, passphrase: string}
/**
* Synchronously sign the given payload into a JSON Web Token string
* @param {String|Object|Buffer} payload - Payload to sign, could be an literal, buffer or string
@@ -90,7 +92,7 @@ export interface SignCallback {
* @param {SignOptions} [options] - Options for the signature
* @returns {String} The JSON Web Token string
*/
export declare function sign(payload: string | Buffer | object, secretOrPrivateKey: string | Buffer, options?: SignOptions): string;
export declare function sign(payload: string | Buffer | object, secretOrPrivateKey: Secret, options?: SignOptions): string;
/**
* Sign the given payload into a JSON Web Token string
@@ -99,8 +101,8 @@ export declare function sign(payload: string | Buffer | object, secretOrPrivateK
* @param {SignOptions} [options] - Options for the signature
* @param {Function} callback - Callback to get the encoded token on
*/
export declare function sign(payload: string | Buffer | object, secretOrPrivateKey: string | Buffer, callback: SignCallback): void;
export declare function sign(payload: string | Buffer | object, secretOrPrivateKey: string | Buffer, options: SignOptions, callback: SignCallback): void;
export declare function sign(payload: string | Buffer | object, secretOrPrivateKey: Secret, callback: SignCallback): void;
export declare function sign(payload: string | Buffer | object, secretOrPrivateKey: Secret, options: SignOptions, callback: SignCallback): void;
/**
* Synchronously verify given token using a secret or a public key to get a decoded token
+4
View File
@@ -36,6 +36,10 @@ token = jwt.sign(testObject, 'shhhhh', { keyid: "theKeyId"});
cert = fs.readFileSync('private.key'); // get private key
token = jwt.sign(testObject, cert, { algorithm: 'RS256'});
// sign with encrypted RSA SHA256 private key (only PEM encoding is supported)
const privKey: Buffer = fs.readFileSync('encrypted_private.key'); // get private key
const secret = {key: privKey.toString(), passphrase: 'keypwd'}
token = jwt.sign(testObject, secret, { algorithm: 'RS256' }); // the algorithm option is mandatory in this case
// sign asynchronously
jwt.sign(testObject, cert, { algorithm: 'RS256' }, function(err: Error, token: string) {
+1
View File
@@ -15,6 +15,7 @@ export class Client {
export class KafkaClient extends Client {
constructor(options?: KafkaClientOptions);
on(eventName: "ready", cb: () => any): this;
on(eventName: "reconnect", cb: () => void): this;
on(eventName: "error", cb: (error: any) => any): this;
connect(): void;
}
+35 -25
View File
@@ -11,6 +11,10 @@ declare namespace mapboxgl {
export function supported(options?: {failIfMajorPerformanceCaveat?: boolean}): boolean;
export function setRTLTextPlugin(pluginURL: string, callback: Function): void;
type LngLatLike = number[] | LngLat;
type LngLatBoundsLike = number[][] | LngLatLike[] | LngLatBounds;
type PointLike = number[] | Point;
/**
* Map
*/
@@ -35,7 +39,7 @@ declare namespace mapboxgl {
getBounds(): mapboxgl.LngLatBounds;
setMaxBounds(lnglatbounds?: mapboxgl.LngLatBounds | number[][]): this;
setMaxBounds(lnglatbounds?: LngLatBoundsLike): this;
setMinZoom(minZoom?: number): this;
@@ -45,11 +49,11 @@ declare namespace mapboxgl {
getMaxZoom(): number;
project(lnglat: mapboxgl.LngLat | number[]): mapboxgl.Point;
project(lnglat: LngLatLike): mapboxgl.Point;
unproject(point: mapboxgl.Point | number[]): mapboxgl.LngLat;
unproject(point: PointLike): mapboxgl.LngLat;
queryRenderedFeatures(pointOrBox?: mapboxgl.Point|number[]|mapboxgl.Point[]|number[][], parameters?: {layers?: string[], filter?: any[]}): GeoJSON.Feature<GeoJSON.GeometryObject>[];
queryRenderedFeatures(pointOrBox?: PointLike | PointLike[], parameters?: {layers?: string[], filter?: any[]}): GeoJSON.Feature<GeoJSON.GeometryObject>[];
querySourceFeatures(sourceID: string, parameters?: {sourceLayer?: string, filter?: any[]}): GeoJSON.Feature<GeoJSON.GeometryObject>[];
@@ -121,11 +125,11 @@ declare namespace mapboxgl {
getCenter(): mapboxgl.LngLat;
setCenter(center: LngLat|number[], eventData?: mapboxgl.EventData): this;
setCenter(center: LngLatLike, eventData?: mapboxgl.EventData): this;
panBy(offset: number[], options?: mapboxgl.AnimationOptions, eventData?: mapboxgl.EventData): this;
panTo(lnglat: mapboxgl.LngLat, options?: mapboxgl.AnimationOptions, eventdata?: mapboxgl.EventData): this;
panTo(lnglat: LngLatLike, options?: mapboxgl.AnimationOptions, eventdata?: mapboxgl.EventData): this;
getZoom(): number;
@@ -151,7 +155,7 @@ declare namespace mapboxgl {
setPitch(pitch: number, eventData?: EventData): this;
fitBounds(bounds: mapboxgl.LngLatBounds | number[][], options?: { linear?: boolean, easing?: Function, padding?: number | mapboxgl.PaddingOptions, offset?: Point|number[],maxZoom?: number }, eventData?: mapboxgl.EventData): this;
fitBounds(bounds: LngLatBoundsLike, options?: { linear?: boolean, easing?: Function, padding?: number | mapboxgl.PaddingOptions, offset?: PointLike, maxZoom?: number }, eventData?: mapboxgl.EventData): this;
jumpTo(options: mapboxgl.CameraOptions, eventData?: mapboxgl.EventData): this;
@@ -191,7 +195,7 @@ declare namespace mapboxgl {
boxZoom?: boolean;
/** initial map center */
center?: mapboxgl.LngLat | number[];
center?: LngLatLike;
/** Style class names with which to initialize the map */
classes?: string[];
@@ -223,7 +227,7 @@ declare namespace mapboxgl {
logoPosition?: boolean;
/** If set, the map is constrained to the given bounds. */
maxBounds?: mapboxgl.LngLatBounds | number[][];
maxBounds?: LngLatBoundsLike;
/** Maximum zoom of the map */
maxZoom?: number;
@@ -434,7 +438,7 @@ declare namespace mapboxgl {
getLngLat(): mapboxgl.LngLat;
setLngLat(lnglat: mapboxgl.LngLat | number[]): this;
setLngLat(lnglat: LngLatLike): this;
setText(text: string): this;
@@ -450,7 +454,7 @@ declare namespace mapboxgl {
anchor?: 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
offset?: number | Point | number[] | { [key:string]: Point | number[];};
offset?: number | PointLike | { [key:string]: PointLike;};
}
export interface Style {
@@ -613,16 +617,22 @@ declare namespace mapboxgl {
/** Return a LngLat as a string */
toString(): string;
static convert(input: number[]|mapboxgl.LngLat): mapboxgl.LngLat;
toBounds(radius: number): LngLatBounds;
static convert(input: LngLatLike): mapboxgl.LngLat;
}
/**
* LngLatBounds
*/
export class LngLatBounds {
sw: LngLat | number[];
ne: LngLat | number[];
constructor(sw?: LngLat, ne?: LngLat);
sw: LngLatLike;
ne: LngLatLike;
constructor(sw?: LngLatLike, ne?: LngLatLike);
setNorthEast(ne: LngLatLike): this;
setSouthWest(sw: LngLatLike): this;
/** Extend the bounds to include a given LngLat or LngLatBounds. */
extend(obj: mapboxgl.LngLat | mapboxgl.LngLatBounds): this;
@@ -661,7 +671,7 @@ declare namespace mapboxgl {
toString(): string;
/** Convert an array to a LngLatBounds object, or return an existing LngLatBounds object unchanged. */
static convert(input: mapboxgl.LngLatBounds | number[] | number[][]): mapboxgl.LngLatBounds;
static convert(input: LngLatBoundsLike): mapboxgl.LngLatBounds;
}
/**
@@ -710,11 +720,11 @@ declare namespace mapboxgl {
angleWithSep(x: number, y: number): number;
static convert(a: Array<number> | Point): Point;
static convert(a: PointLike): Point;
}
export class Marker {
constructor(element?: HTMLElement, options?: { offset?: Point | number[] });
constructor(element?: HTMLElement, options?: { offset?: PointLike });
addTo(map: Map): this;
@@ -722,7 +732,7 @@ declare namespace mapboxgl {
getLngLat(): LngLat;
setLngLat(lngLat: LngLat | number[]): this;
setLngLat(lngLat: LngLatLike): this;
setPopup(popup?: Popup): this;
@@ -807,7 +817,7 @@ declare namespace mapboxgl {
duration?: number;
easing?: Function;
/** point, origin of movement relative to map center */
offset?: Point | number[];
offset?: PointLike;
/** When set to false, no animation happens */
animate?: boolean;
}
@@ -817,7 +827,7 @@ declare namespace mapboxgl {
*/
export interface CameraOptions {
/** Map center */
center?: mapboxgl.LngLat | number[];
center?: LngLatLike;
/** Map zoom level */
zoom?: number;
/** Map rotation bearing in degrees counter-clockwise from north */
@@ -825,7 +835,7 @@ declare namespace mapboxgl {
/** Map angle in degrees at which the camera is looking at the ground */
pitch?: number;
/** If zooming, the zoom center (defaults to map center) */
around?: mapboxgl.LngLat | number[];
around?: LngLatLike;
}
/**
@@ -891,7 +901,7 @@ declare namespace mapboxgl {
metadata?: any;
ref?: string;
source?: string;
source?: string | VectorSource | RasterSource | GeoJSONSource | ImageSource | VideoSource | GeoJSONSourceRaw;
"source-layer"?: string;
@@ -959,10 +969,10 @@ declare namespace mapboxgl {
}
export interface LinePaint {
"line-opacity"?: number | StyleFunction;
"line-color"?: string| StyleFunction;
"line-color"?: string | StyleFunction;
"line-translate"?: number[];
"line-translate-anchor"?: "map" | "viewport";
"line-width"?: number;
"line-width"?: number | StyleFunction;
"line-gap-width"?: number | StyleFunction;
"line-offset"?: number | StyleFunction;
"line-blur"?: number | StyleFunction;
+248 -131
View File
@@ -1,9 +1,38 @@
// Type definitions for Marked
// Type definitions for Marked 0.3
// Project: https://github.com/chjj/marked
// Definitions by: William Orr <https://github.com/worr>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface MarkedStatic {
export as namespace marked;
export = marked;
/**
* Compiles markdown to HTML.
*
* @param src String of markdown source to be compiled
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
* @return String of compiled HTML
*/
declare function marked(src: string, callback: (error: any | undefined, parseResult: string) => void): string;
/**
* Compiles markdown to HTML.
*
* @param src String of markdown source to be compiled
* @param options Hash of options
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
* @return String of compiled HTML
*/
declare function marked(src: string, options?: marked.MarkedOptions, callback?: (error: any | undefined, parseResult: string) => void): string;
declare namespace marked {
/**
* @param src String of markdown source to be compiled
* @param options Hash of options
*/
function lexer(src: string, options?: MarkedOptions): TokensList;
/**
* Compiles markdown to HTML.
*
@@ -11,7 +40,7 @@ interface MarkedStatic {
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
* @return String of compiled HTML
*/
(src: string, callback: Function): string;
function parse(src: string, callback: (error: any | undefined, parseResult: string) => void): string;
/**
* Compiles markdown to HTML.
@@ -21,144 +50,232 @@ interface MarkedStatic {
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
* @return String of compiled HTML
*/
(src: string, options?: MarkedOptions, callback?: Function): string;
function parse(src: string, options?: MarkedOptions, callback?: (error: any | undefined, parseResult: string) => void): string;
/**
* @param src String of markdown source to be compiled
* @param src Tokenized source as array of tokens
* @param options Hash of options
*/
lexer(src: string, options?: MarkedOptions): any[];
/**
* Compiles markdown to HTML.
*
* @param src String of markdown source to be compiled
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
* @return String of compiled HTML
*/
parse(src: string, callback: Function): string;
/**
* Compiles markdown to HTML.
*
* @param src String of markdown source to be compiled
* @param options Hash of options
* @param callback Function called when the markdownString has been fully parsed when using async highlighting
* @return String of compiled HTML
*/
parse(src: string, options?: MarkedOptions, callback?: Function): string;
/**
* @param options Hash of options
*/
parser(src: any[], options?: MarkedOptions): string;
function parser(src: TokensList, options?: MarkedOptions): string;
/**
* Sets the default options.
*
* @param options Hash of options
*/
setOptions(options: MarkedOptions): MarkedStatic;
Renderer: {
new(): MarkedRenderer;
function setOptions(options: MarkedOptions): typeof marked;
class Renderer {
constructor(options?: MarkedOptions);
code(code: string, language: string, isEscaped: boolean): string;
blockquote(quote: string): string;
html(html: string): string;
heading(text: string, level: number, raw: string): string;
hr(): string;
list(body: string, ordered: boolean): string;
listitem(text: string): string;
paragraph(text: string): string;
table(header: string, body: string): string;
tablerow(content: string): string;
tablecell(content: string, flags: {
header: boolean;
align: 'center' | 'left' | 'right' | null;
}): string;
strong(text: string): string;
em(text: string): string;
codespan(code: string): string;
br(): string;
del(text: string): string;
link(href: string, title: string, text: string): string;
image(href: string, title: string, text: string): string;
text(text: string): string;
}
Parser: {
new(options: MarkedOptions): MarkedParser;
class Lexer {
rules: Rules;
tokens: TokensList;
constructor(options?: MarkedOptions);
lex(src: string): TokensList;
}
interface Rules {
[ruleName: string]: RegExp | Rules;
}
type TokensList = Token[] & {
links: {
[key: string]: { href: string; title: string; }
}
};
type Token =
Tokens.Space
| Tokens.Code
| Tokens.Heading
| Tokens.Table
| Tokens.Hr
| Tokens.BlockquoteStart
| Tokens.BlockquoteEnd
| Tokens.ListStart
| Tokens.LooseItemStart
| Tokens.ListItemStart
| Tokens.ListItemEnd
| Tokens.ListEnd
| Tokens.Paragraph
| Tokens.HTML
| Tokens.Text;
namespace Tokens {
interface Space {
type: 'space';
}
interface Code {
type: 'code';
lang?: string;
text: string;
}
interface Heading {
type: 'heading';
depth: number;
text: string;
}
interface Table {
type: 'table';
header: string[];
align: Array<'center' | 'left' | 'right' | null>;
cells: string[][];
}
interface Hr {
type: 'hr';
}
interface BlockquoteStart {
type: 'blockquote_start';
}
interface BlockquoteEnd {
type: 'blockquote_end';
}
interface ListStart {
type: 'list_start';
ordered: boolean;
}
interface LooseItemStart {
type: 'loose_item_start';
}
interface ListItemStart {
type: 'list_item_start';
}
interface ListItemEnd {
type: 'list_item_end';
}
interface ListEnd {
type: 'list_end';
}
interface Paragraph {
type: 'paragraph';
pre?: boolean;
text: string;
}
interface HTML {
type: 'html';
pre: boolean;
text: string;
}
interface Text {
type: 'text';
text: string;
}
}
interface MarkedOptions {
/**
* Type: object Default: new Renderer()
*
* An object containing functions to render tokens to HTML.
*/
renderer?: Renderer;
/**
* Enable GitHub flavored markdown.
*/
gfm?: boolean;
/**
* Enable GFM tables. This option requires the gfm option to be true.
*/
tables?: boolean;
/**
* Enable GFM line breaks. This option requires the gfm option to be true.
*/
breaks?: boolean;
/**
* Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
*/
pedantic?: boolean;
/**
* Sanitize the output. Ignore any HTML that has been input.
*/
sanitize?: boolean;
/**
* Optionally sanitize found HTML with a sanitizer function.
*/
sanitizer?(html: string): string;
/**
* Mangle autolinks (<email@domain.com>).
*/
mangle?: boolean;
/**
* Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
*/
smartLists?: boolean;
/**
* Shows an HTML error message when rendering fails.
*/
silent?: boolean;
/**
* A function to highlight code blocks. The function takes three arguments: code, lang, and callback.
*/
highlight?(code: string, lang: string, callback?: (error: any | undefined, code: string) => void): string;
/**
* Set the prefix for code block classes.
*/
langPrefix?: string;
/**
* Use "smart" typograhic punctuation for things like quotes and dashes.
*/
smartypants?: boolean;
/**
* Set the prefix for header tag ids.
*/
headerPrefix?: string;
/**
* Generate closing slash for self-closing tags (<br/> instead of <br>)
*/
xhtml?: boolean;
}
}
interface MarkedRenderer {
code(code: string, language: string): string;
blockquote(quote: string): string;
html(html: string): string;
heading(text: string, level: number, raw: string): string;
hr(): string;
list(body: string, ordered: boolean): string;
listitem(text: string): string;
paragraph(text: string): string;
table(header: string, body: string): string;
tablerow(content: string): string;
tablecell(content: string, flags: {
header: boolean,
align: string
}): string;
strong(text: string): string;
em(text: string): string;
codespan(code: string): string;
br(): string;
del(text: string): string;
link(href: string, title: string, text: string): string;
image(href: string, title: string, text: string): string;
text(text: string): string;
}
interface MarkedParser {
parse(source: any[]): string
}
interface MarkedOptions {
/**
* Type: object Default: new Renderer()
*
* An object containing functions to render tokens to HTML.
*/
renderer?: MarkedRenderer;
/**
* Enable GitHub flavored markdown.
*/
gfm?: boolean;
/**
* Enable GFM tables. This option requires the gfm option to be true.
*/
tables?: boolean;
/**
* Enable GFM line breaks. This option requires the gfm option to be true.
*/
breaks?: boolean;
/**
* Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
*/
pedantic?: boolean;
/**
* Sanitize the output. Ignore any HTML that has been input.
*/
sanitize?: boolean;
/**
* Use smarter list behavior than the original markdown. May eventually be default with the old behavior moved into pedantic.
*/
smartLists?: boolean;
/**
* Shows an HTML error message when rendering fails.
*/
silent?: boolean;
/**
* A function to highlight code blocks. The function takes three arguments: code, lang, and callback.
*/
highlight? (code: string, lang: string, callback?: Function): string;
/**
* Set the prefix for code block classes.
*/
langPrefix?: string;
/**
* Use "smart" typograhic punctuation for things like quotes and dashes.
*/
smartypants?: boolean;
}
declare module "marked" {
export = marked;
}
declare var marked: MarkedStatic;
+14 -11
View File
@@ -1,8 +1,6 @@
import * as marked from 'marked';
var options: MarkedOptions = {
const options: marked.MarkedOptions = {
gfm: true,
tables: true,
breaks: false,
@@ -10,8 +8,8 @@ var options: MarkedOptions = {
sanitize: true,
smartLists: true,
silent: false,
highlight: function (code: string, lang: string) {
return '';
highlight(code: string, lang: string) {
return '';
},
langPrefix: 'lang-',
smartypants: false,
@@ -19,10 +17,10 @@ var options: MarkedOptions = {
};
function callback() {
console.log('callback called');
console.log('callback called');
}
marked.setOptions(options);
const myOldMarked: typeof marked = marked.setOptions(options);
console.log(marked('i am using __markdown__.'));
console.log(marked('i am using __markdown__.', options));
@@ -34,11 +32,16 @@ console.log(marked.parse('i am using __markdown__.', options));
console.log(marked.parse('i am using __markdown__.', callback));
console.log(marked.parse('i am using __markdown__.', options, callback));
var text = 'something';
var tokens = marked.lexer(text, options);
const text = 'something';
const tokens: marked.TokensList = marked.lexer(text, options);
console.log(marked.parser(tokens));
var renderer = new marked.Renderer();
renderer.heading = function(text, level, raw) {
const lexer = new marked.Lexer(options);
const tokens2 = lexer.lex(text);
console.log(tokens2);
const re: RegExp | marked.Rules = lexer.rules['code'];
const renderer = new marked.Renderer();
renderer.heading = (text, level, raw) => {
return text + level.toString() + raw;
};
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5
View File
@@ -1234,6 +1234,7 @@ declare namespace __MaterialUI {
autoWidth?: boolean;
className?: string;
disabled?: boolean;
iconButton?: React.ReactNode;
iconStyle?: React.CSSProperties;
labelStyle?: React.CSSProperties;
listStyle?: React.CSSProperties;
@@ -1242,6 +1243,8 @@ declare namespace __MaterialUI {
onChange?(e: TouchTapEvent, index: number, menuItemValue: any): void;
onClose?(e: TouchTapEvent): void;
openImmediately?: boolean;
selectedMenuItemStyle?: React.CSSProperties;
selectionRenderer?(value: any, menuItem: any): void;
style?: React.CSSProperties;
underlineStyle?: React.CSSProperties;
value?: any;
@@ -1849,6 +1852,8 @@ declare namespace __MaterialUI {
autoFocus?: boolean;
min?: number;
max?: number;
maxlength?: string;
minlegnth?: string;
step?: number;
autoComplete?: string;
}
+42 -12
View File
@@ -1,23 +1,53 @@
// Type definitions for merge2 v0.3.6
// Type definitions for merge2 1.1
// Project: https://github.com/teambition/merge2
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
// Chigozirim C. <https://github.com/smac89>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { DuplexOptions } from 'stream';
interface IOptions {
end?: boolean;
objectMode?: boolean;
type StreamType = NodeJS.ReadableStream | Merge2Stream;
interface Merge2Stream extends NodeJS.ReadWriteStream {
/**
* @summary Add more streams to an existing merged stream
*
* @param {...(StreamType|StreamType[])} args streams to add
*
* @return The merged stream
*/
add(...args: Array<StreamType | StreamType[]>): Merge2Stream;
/**
* @summary It will emit 'queueDrain' when all streams merged.
* If you set end === false in options, this event give you a notice that
* you should add more streams to merge, or end the mergedStream.
*
* @param {string} event The 'queueDrain' event
*
* @return This stream
*/
on(event: 'queueDrain', callback: () => void): this;
}
interface IMerge2Stream extends NodeJS.ReadWriteStream {
add(...args: Array<NodeJS.ReadWriteStream | IMerge2Stream | Array<NodeJS.ReadWriteStream | IMerge2Stream | IOptions>>): IMerge2Stream;
}
/**
* @summary This function takes an arbitrary number of streams and returns a
* Merge2Stream.
*
* @description If a DuplexOption is specified, it has to be specified last in the
* argument list
*
* @see { @link https://github.com/teambition/merge2#api }
*
* @param {...(StreamType|StreamType[])} args StreamTypes
* @param {DuplexOptions} opts Optional DuplexOption to be specified last
*
* @return A merged duplex stream
*/
declare function IMerge2(...args: Array<StreamType | StreamType[] | DuplexOptions>): Merge2Stream;
interface IMerge2 {
(...args: Array<NodeJS.ReadWriteStream | IMerge2Stream | Array<NodeJS.ReadWriteStream | IMerge2Stream> | IOptions>): IMerge2Stream;
}
declare namespace IMerge2 {}
declare var _tmp: IMerge2;
export = _tmp;
export = IMerge2;
+17 -25
View File
@@ -1,8 +1,5 @@
import gulp = require('gulp');
import * as merge2 from "merge2";
import * as gulp from 'gulp';
import * as merge2 from 'merge2';
gulp.task('app-js', () =>
merge2(
@@ -21,44 +18,39 @@ gulp.task('app-js', () =>
.pipe(gulp.dest('static/dist/js/'))
);
const stream1 = gulp.src('*.html');
const stream2 = gulp.src('*.html');
const stream3 = gulp.src('*.html');
const stream4 = gulp.src('*.html');
const stream5 = gulp.src('*.html');
const stream6 = gulp.src('*.html');
const stream7 = gulp.src('*.html');
var stream1 = gulp.src('*.html');
var stream2 = gulp.src('*.html');
var stream3 = gulp.src('*.html');
var stream4 = gulp.src('*.html');
var stream5 = gulp.src('*.html');
var stream6 = gulp.src('*.html');
var stream7 = gulp.src('*.html');
var stream = merge2([stream1, stream2], stream3, {end: false})
//...
let stream = merge2([stream1, stream2], stream3, {end: false});
// ...
stream.add(stream4, stream5);
//..
// ..
stream.end();
// equal to merge2([stream1, stream2], stream3)
var stream = merge2();
stream = merge2();
stream.add([stream1, stream2]);
stream.add(stream3);
// merge order:
// 1. merge `stream1`;
// 2. merge `stream2` and `stream3` in parallel after `stream1` merged;
// 3. merge 'stream4' after `stream2` and `stream3` merged;
var stream = merge2(stream1, [stream2, stream3], stream4);
stream = merge2(stream1, [stream2, stream3], stream4);
// merge order:
// 1. merge `stream5` and `stream6` in parallel after `stream4` merged;
// 2. merge 'stream7' after `stream5` and `stream6` merged;
stream.add([stream5, stream6], stream7);
// nest merge
// equal to merge2(stream1, stream2, stream6, stream3, [stream4, stream5]);
var streamA = merge2(stream1, stream2);
var streamB = merge2(stream3, [stream4, stream5]);
var stream = merge2(streamA, streamB);
const streamA = merge2(stream1, stream2);
const streamB = merge2(stream3, [stream4, stream5]);
stream = merge2(streamA, streamB);
streamA.add(stream6);
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+2
View File
@@ -1,6 +1,7 @@
// Type definitions for Nightmare 1.6.5
// Project: https://github.com/segmentio/nightmare
// Definitions by: horiuchi <https://github.com/horiuchi/>
// Sam Yang <https://github.com/samyang-au>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -78,6 +79,7 @@ declare namespace Nightmare {
proxyAuth?: string;
cookiesFile?: string;
phantomPath?: string;
show?: boolean;
}
export interface IRequest {
+1
View File
@@ -318,3 +318,4 @@ new Nightmare()
.use(testTitle('test term'))
.run(done);
new Nightmare({show: true});
+5 -1
View File
@@ -63,10 +63,14 @@ export declare function createTransport(options?: directTransport.DirectOptions,
* Create an SMTP transporter
*/
export declare function createTransport(options?: smtpTransport.SmtpOptions, defaults?: Object): Transporter;
/**
* Create an SMTP transporter using a connection url
*/
export declare function createTransport(connectionUrl: string, defaults?: Object): Transporter;
/**
* Create an AWS SES transporter
*/
export declare function createTransport(options?: sesTransport.SesOptions, defaults?: Object): Transporter
export declare function createTransport(options?: sesTransport.SesOptions, defaults?: Object): Transporter;
/**
* Create a transporter from a given implementation
*/
+12
View File
@@ -10,6 +10,18 @@ var transporter: nodemailer.Transporter = nodemailer.createTransport({
}
});
// create reusable transporter object using SMTP connection url using default options
transporter = nodemailer.createTransport("smtps://gmail.user@gmail.com:userpass@gmail/?pool=true");
// create reusable transporter object using SMTP connection url and specify some options
transporter = nodemailer.createTransport("smtps://gmail.user@gmail.com:userpass@gmail/?pool=true",
{
from: 'sender@address',
headers: {
'My-Awesome-Header': '123'
}
});
// create reusable transporter object using SES transport and set default values for mail options.
transporter = nodemailer.createTransport({
SES: new AWS.SES()
+13 -13
View File
@@ -123,9 +123,9 @@ export interface NdArray<T = number> extends BaseNdArray<T> {
* Converts {NdArray} to a native JavaScript {Array}
*
*/
tolist(): T[];
tolist<LT = T>(): LT[];
valueOf(): T[];
valueOf<LT = T>(): LT[];
/**
* Stringify the array to make it readable in the console, by a human.
@@ -523,17 +523,17 @@ export namespace images {
*/
const moon: NdArray<number>;
}
function read(input: string): NdArray<Uint32Array>;
function save(img: NdArray<Uint32Array>, dest: string): void;
function resize(img: NdArray<Uint32Array>, height: number, width: number): NdArray<Uint32Array>;
function sat(img: NdArray<Uint32Array>): NdArray<Uint32Array>;
function ssat(img: NdArray<Uint32Array>): NdArray<Uint32Array>;
function sobel(img: NdArray<Uint32Array>): NdArray<Uint32Array>;
function scharr(img: NdArray<Uint32Array>): NdArray<Uint32Array>;
function areaSum(h0: number, w0: number, H: number, W: number, SAT: NdArray<Uint32Array>): number;
function areaValue(img: NdArray<Uint32Array>): number;
function rgb2gray(img: NdArray<Uint32Array>): NdArray<Uint32Array>;
function flip(img: NdArray<Uint32Array>): NdArray<Uint32Array>;
function read(input: string): NdArray<Uint8Array>;
function save<T = number>(img: NdArray<T>, dest: string): void;
function resize<T = number>(img: NdArray<T>, height: number, width: number): NdArray<Uint8Array>;
function sat<T = number>(img: NdArray<T>): NdArray<Uint32Array>;
function ssat<T = number>(img: NdArray<T>): NdArray<Uint32Array>;
function sobel<T = number>(img: NdArray<T>): NdArray<Float32Array>;
function scharr<T = number>(img: NdArray<T>): NdArray<Float32Array>;
function areaSum<T = number>(h0: number, w0: number, H: number, W: number, SAT: NdArray<T>): number;
function areaValue<T = number>(img: NdArray<T>): number;
function rgb2gray<T = number>(img: NdArray<T>): NdArray<Uint8Array>;
function flip<T = number, O = T>(img: NdArray<T>): NdArray<O>;
}
export function array<T = number>(arr: NjArray<T>, dtype?: BaseNdArray.DataType): NdArray<T>;
+2
View File
@@ -21,3 +21,5 @@ arr.transpose(1, 0, 2);
const b = nj.array([2, 3, 4]);
const c = nj.uint8([1, 2, 3]);
const d = nj.array<number[]>([[2], [3, 4]]);
+43
View File
@@ -0,0 +1,43 @@
// Type definitions for p-all 1.0
// Project: https://github.com/sindresorhus/p-all#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = pAll;
declare function pAll<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(
tasks: [PromiseFactory<T1>, PromiseFactory<T2>, PromiseFactory<T3>, PromiseFactory<T4>, PromiseFactory<T5>, PromiseFactory<T6>, PromiseFactory<T7>,
PromiseFactory<T8>, PromiseFactory<T9>, PromiseFactory<T10>],
options?: pAll.Options): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
declare function pAll<T1, T2, T3, T4, T5, T6, T7, T8, T9>(
tasks: [PromiseFactory<T1>, PromiseFactory<T2>, PromiseFactory<T3>, PromiseFactory<T4>, PromiseFactory<T5>, PromiseFactory<T6>, PromiseFactory<T7>,
PromiseFactory<T8>, PromiseFactory<T9>],
options?: pAll.Options): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
declare function pAll<T1, T2, T3, T4, T5, T6, T7, T8>(
tasks: [PromiseFactory<T1>, PromiseFactory<T2>, PromiseFactory<T3>, PromiseFactory<T4>, PromiseFactory<T5>, PromiseFactory<T6>, PromiseFactory<T7>,
PromiseFactory<T8>],
options?: pAll.Options): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
declare function pAll<T1, T2, T3, T4, T5, T6, T7>(
tasks: [PromiseFactory<T1>, PromiseFactory<T2>, PromiseFactory<T3>, PromiseFactory<T4>, PromiseFactory<T5>, PromiseFactory<T6>, PromiseFactory<T7>],
options?: pAll.Options): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
declare function pAll<T1, T2, T3, T4, T5, T6>(
tasks: [PromiseFactory<T1>, PromiseFactory<T2>, PromiseFactory<T3>, PromiseFactory<T4>, PromiseFactory<T5>, PromiseFactory<T6>],
options?: pAll.Options): Promise<[T1, T2, T3, T4, T5, T6]>;
declare function pAll<T1, T2, T3, T4, T5>(
tasks: [PromiseFactory<T1>, PromiseFactory<T2>, PromiseFactory<T3>, PromiseFactory<T4>, PromiseFactory<T5>],
options?: pAll.Options): Promise<[T1, T2, T3, T4, T5]>;
declare function pAll<T1, T2, T3, T4>(
tasks: [PromiseFactory<T1>, PromiseFactory<T2>, PromiseFactory<T3>, PromiseFactory<T4>],
options?: pAll.Options): Promise<[T1, T2, T3, T4]>;
declare function pAll<T1, T2, T3>(tasks: [PromiseFactory<T1>, PromiseFactory<T2>, PromiseFactory<T3>], options?: pAll.Options): Promise<[T1, T2, T3]>;
declare function pAll<T1, T2>(tasks: [PromiseFactory<T1>, PromiseFactory<T2>], options?: pAll.Options): Promise<[T1, T2]>;
declare function pAll<T1>(tasks: [PromiseFactory<T1>], options?: pAll.Options): Promise<[T1]>;
declare function pAll<TAll>(tasks: Iterable<PromiseFactory<TAll>> | Array<PromiseFactory<TAll>>, options?: pAll.Options): Promise<TAll[]>;
type PromiseFactory<T> = () => Promise<T> | PromiseLike<T>;
declare namespace pAll {
interface Options {
concurrency?: number;
}
}
+14
View File
@@ -0,0 +1,14 @@
import pAll = require('p-all');
const actions: [() => Promise<string>, () => Promise<string>, () => Promise<void>, () => Promise<number>] = [
() => Promise.resolve('sindresorhus.com'),
() => Promise.resolve('ava.li'),
() => Promise.resolve(),
() => Promise.resolve(1)
];
pAll(actions, {concurrency: 2}).then(result => {
let str: string = result[0];
let str2: string = result[1];
let num: number = result[3];
});
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"p-all-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