Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Arda TANRIKULU
2017-09-07 17:03:19 -04:00
27 changed files with 1403 additions and 337 deletions

View File

@@ -30,6 +30,7 @@ expect(wrapper).to.have.ref("test");
expect(wrapper).to.be.selected();
expect(wrapper).to.have.tagName("div");
expect(wrapper).to.have.text("");
expect(wrapper).to.contain.text("");
expect(wrapper).to.have.type(Test);
expect(wrapper).to.have.value("test");
expect(wrapper).to.have.attr("test", "test");

View File

@@ -26,6 +26,12 @@ declare namespace Chai {
* @param code
*/
(selector: EnzymeSelector): Assertion;
/**
* Assert that the given wrapper has the supplied text:
* @param str
*/
text(str?: string): Assertion;
}
interface Assertion {
/**

View File

@@ -3,23 +3,18 @@
// Definitions by: Dave Taylor <http://davetayls.me>, Samira Bazuzi <https://github.com/bazuzi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = DOMPurify;
export as namespace DOMPurify;
declare var DOMPurify: DOMPurify;
export declare function sanitize(source: string | Node): string;
export declare function sanitize(source: string | Node, config: Config & { RETURN_DOM_FRAGMENT?: false; RETURN_DOM?: false; }): string;
export declare function sanitize(source: string | Node, config: Config & { RETURN_DOM_FRAGMENT: true; }): DocumentFragment;
export declare function sanitize(source: string | Node, config: Config & { RETURN_DOM: true; }): HTMLElement;
export declare function sanitize(source: string | Node, config: Config): string | HTMLElement | DocumentFragment;
export declare function addHook(hook: 'uponSanitizeElement', cb: (currentNode: Element, data: SanitizeElementHookEvent, config: Config) => void): void;
export declare function addHook(hook: 'uponSanitizeAttribute', cb: (currentNode: Element, data: SanitizeAttributeHookEvent, config: Config) => void): void;
export declare function addHook(hook: HookName, cb: (currentNode: Element, data: HookEvent, config: Config) => void): void;
interface DOMPurify {
sanitize(source: string | Node): string;
sanitize(source: string | Node, config: DOMPurifyConfig & { RETURN_DOM_FRAGMENT?: false; RETURN_DOM?: false; }): string;
sanitize(source: string | Node, config: DOMPurifyConfig & { RETURN_DOM_FRAGMENT: true; }): DocumentFragment;
sanitize(source: string | Node, config: DOMPurifyConfig & { RETURN_DOM: true; }): HTMLElement;
sanitize(source: string | Node, config: DOMPurifyConfig): string | HTMLElement | DocumentFragment;
addHook(hook: 'uponSanitizeElement', cb: (currentNode: Element, data: DOMPurifySanitizeElementHookEvent, config: DOMPurifyConfig) => void): void;
addHook(hook: 'uponSanitizeAttribute', cb: (currentNode: Element, data: DOMPurifySanitizeAttributeHookEvent, config: DOMPurifyConfig) => void): void;
addHook(hook: DOMPurifyHookName, cb: (currentNode: Element, data: DOMPurifyHookEvent, config: DOMPurifyConfig) => void): void;
}
interface DOMPurifyConfig {
interface Config {
ADD_ATTR?: string[];
ADD_TAGS?: string[];
ALLOW_DATA_ATTR?: boolean;
@@ -27,6 +22,7 @@ interface DOMPurifyConfig {
ALLOWED_TAGS?: string[];
FORBID_ATTR?: string[];
FORBID_TAGS?: string[];
FORCE_BODY?: boolean;
KEEP_CONTENT?: boolean;
RETURN_DOM?: boolean;
RETURN_DOM_FRAGMENT?: boolean;
@@ -36,7 +32,7 @@ interface DOMPurifyConfig {
WHOLE_DOCUMENT?: boolean;
}
type DOMPurifyHookName
type HookName
= 'beforeSanitizeElements'
| 'uponSanitizeElement'
| 'afterSanitizeElements'
@@ -47,17 +43,17 @@ type DOMPurifyHookName
| 'uponSanitizeShadowNode'
| 'afterSanitizeShadowDOM';
type DOMPurifyHookEvent
= DOMPurifySanitizeElementHookEvent
| DOMPurifySanitizeAttributeHookEvent
type HookEvent
= SanitizeElementHookEvent
| SanitizeAttributeHookEvent
| null;
interface DOMPurifySanitizeElementHookEvent {
interface SanitizeElementHookEvent {
tagName: string;
allowedTags: string[];
}
interface DOMPurifySanitizeAttributeHookEvent {
interface SanitizeAttributeHookEvent {
attrName: string;
attrValue: string;
keepAttr: boolean;

View File

@@ -1,6 +1,6 @@
// Type definitions for ej.web.all 15.3
// Project: http://help.syncfusion.com/js/typescript
// Definitions by: Syncfusion <https://github.com/syncfusion/>
// Definitions by: Syncfusion <https://github.com/syncfusion>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -8,7 +8,7 @@
/*!
* filename: ej.web.all.d.ts
* version : 15.3.0.26
* version : 15.3.0.29
* Copyright Syncfusion Inc. 2001 - 2017. All rights reserved.
* Use of this code is subject to the terms of our license.
* A copy of the current license can be obtained at any time by e-mailing
@@ -7791,7 +7791,7 @@ declare namespace ej {
*/
target?: string;
/** The title text to be displayed in the dialog header. In order to set title, you need to set showHeader as true since the title will be displayed in the dialog header.
/** The title text to be displayed in the dialog header. In order to set title, you need to set "showHeader" as true since the title will be displayed in the dialog header.
*/
title?: string;
@@ -16048,7 +16048,7 @@ declare namespace ej {
*/
autoHeight?: boolean;
/** This API holds configuration setting for paste clenaup behavior.
/** This API holds configuration setting for paste cleanup behavior.
* @Default {{ listConversion: false, cleanCSS: false, removeStyles: false, cleanElements: false }}
*/
pasteCleanupSettings?: PasteCleanupSettings;
@@ -27283,7 +27283,7 @@ declare namespace ej {
*/
format?: string;
/** Sets the opacity of the dispalyed tooltip
/** Sets the opacity of the displayed tooltip
* @Default {0.95}
*/
opacity?: number;
@@ -27949,6 +27949,11 @@ declare namespace ej {
*/
refreshControl(): void;
/** This function Destroy the PivotGrid widget all events bound using this._on will be unbind automatically and bring the control to pre-init state.
* @returns {void}
*/
destroy(): void;
/** This function returns the height of all rows and width each and every column.
* @returns {any}
*/
@@ -27957,7 +27962,7 @@ declare namespace ej {
/** This function creates the conditional formatting dialog to apply conditional formatting for PivotGrid control.
* @returns {void}
*/
createConditionalDialog(): void;
openConditionalFormattingDialog(): void;
/** This function saves the current report to the database/local storage.
* @returns {void}
@@ -28163,11 +28168,16 @@ declare namespace ej {
*/
enableColumnResizing?: boolean;
/** Allows the user to fit the width of the columns based on its content. This is only applicable for enableColumnResizing option.
/** Allows the user to fit the width of the column based on its maximum text width.
* @Default {false}
*/
resizeColumnsToFit?: boolean;
/** Allows the user to enable/disable the context menu of Pivot buttons in the PivotGrid.
* @Default {false}
*/
enableContextMenu?: boolean;
/** Allows the user to view large amount of data through virtual scrolling.
* @Default {false}
*/
@@ -28616,14 +28626,6 @@ declare namespace ej {
values?: any[];
}
export interface DataSourceColumnsGroupByDate {
/** Contains the collection of formatString to group item from the field.
* @Default {[]}
*/
interval?: any[];
}
export interface DataSourceColumn {
/** Allows the user to bind the item by using its unique name as field name.
@@ -28679,11 +28681,6 @@ declare namespace ej {
* @Default {null}
*/
filterItems?: DataSourceColumnsFilterItems;
/** Allows the user to group the field by date. This is applicable only when the format is set as &quot;date&quot;.
* @Default {{}}
*/
groupByDate?: DataSourceColumnsGroupByDate;
}
export interface DataSourceRowsAdvancedFilter {
@@ -28728,14 +28725,6 @@ declare namespace ej {
values?: any[];
}
export interface DataSourceRowsGroupByDate {
/** Contains the collection of formatString to group item from the field.
* @Default {[]}
*/
interval?: any[];
}
export interface DataSourceRow {
/** Allows the user to bind the item by using its unique name as field name.
@@ -28791,11 +28780,6 @@ declare namespace ej {
* @Default {null}
*/
filterItems?: DataSourceRowsFilterItems;
/** Allows the user to group the field by date. This is applicable only when the format is set as &quot;date&quot;.
* @Default {{}}
*/
groupByDate?: DataSourceRowsGroupByDate;
}
export interface DataSourceValuesMeasure {
@@ -29128,6 +29112,16 @@ declare namespace ej {
*/
drillThroughDataTable?: string;
/** Allows the user to set the custom name for the service method responsible for performing value sorting operation in PivotGrid.
* @Default {ValueSorting}
*/
valueSorting?: string;
/** Allows the user to set the custom name for the service method responsible for removing pivot button from GroupingBar/Field List.
* @Default {RemoveButton}
*/
removeButton?: string;
/** Allows the user to set the custom name for the service method responsible for write-back operation in OLAP Cube. This is only applicable in server-side component.
* @Default {WriteBack}
*/
@@ -29215,6 +29209,11 @@ declare namespace ej {
* @returns {void}
*/
refreshControl(): void;
/** This function Destroy the PivotSchemaDesigner widget all events bound using this._on will be unbind automatically and bring the control to pre-init state.
* @returns {void}
*/
destroy(): void;
}
export namespace PivotSchemaDesigner {
@@ -29269,7 +29268,7 @@ declare namespace ej {
/** Allows the user to set custom name for the methods at service-end, communicated during AJAX post.
* @Default {{}}
*/
serviceMethod?: ServiceMethod;
serviceMethods?: any;
/** Connects the service using the specified URL for any server updates.
* @Default {âœâ}
@@ -29372,39 +29371,6 @@ declare namespace ej {
showNamedSets?: boolean;
}
export interface ServiceMethod {
/** Allows the user to set the custom name for the service method responsible for getting the values for the tree-view inside filter dialog.
* @Default {FetchMembers}
*/
fetchMembers?: string;
/** Allows the user to set the custom name for the service method responsible for filtering operation in Field List.
* @Default {Filtering}
*/
filtering?: string;
/** Allows the user to set the custom name for the service method responsible for the server-side action, on expanding members in Field List.
* @Default {MemberExpanded}
*/
memberExpand?: string;
/** Allows the user to set the custom name for the service method responsible for the server-side action, on dropping a node into Field List.
* @Default {NodeDropped}
*/
nodeDropped?: string;
/** Allows the user to set the custom name for the service method responsible for the server-side action on changing the checked state of a node in Field List.
* @Default {NodeStateModified}
*/
nodeStateModified?: string;
/** Allows the user to set the custom name for the service method responsible for button removing operation in Field List.
* @Default {RemoveButton}
*/
removeButton?: string;
}
enum Layouts {
///To set the layout as same in the Excel.
@@ -29552,6 +29518,11 @@ declare namespace ej {
*/
refreshControl(): void;
/** This function Destroy the PivotChart widget all events bound using this._on will be unbind automatically and bring the control to pre-init state.
* @returns {void}
*/
destroy(): void;
/** Renders the control with the pivot engine obtained from olap cube.
* @returns {void}
*/
@@ -29648,6 +29619,11 @@ declare namespace ej {
*/
rotation?: number;
/** Allows the user to enable/disable the context menu options in the PivotChart.
* @Default {false}
*/
enableContextMenu?: boolean;
/** Allows the user to set custom name for the methods at service-end, communicated on AJAX post.
* @Default {{}}
*/
@@ -29675,6 +29651,10 @@ declare namespace ej {
*/
beforeServiceInvoke?(e: BeforeServiceInvokeEventArgs): void;
/** Triggers before Pivot Engine starts to populate.
*/
beforePivotEnginePopulate?(e: BeforePivotEnginePopulateEventArgs): void;
/** Triggers on performing drill up/down in PivotChart control.
*/
drillSuccess?(e: DrillSuccessEventArgs): void;
@@ -29741,6 +29721,13 @@ declare namespace ej {
element?: any;
}
export interface BeforePivotEnginePopulateEventArgs {
/** returns the current instance of PivotChart.
*/
chartObj?: any;
}
export interface DrillSuccessEventArgs {
/** returns the current instance of PivotChart.
@@ -30132,6 +30119,16 @@ declare namespace ej {
*/
refreshControl(): void;
/** Returns the control tab string that displays currently in PivotClient.
* @returns {void}
*/
getActiveTab(): void;
/** This function Destroy the PivotClient widget all events bound using this._on will be unbind automatically and bring the control to pre-init state.
* @returns {void}
*/
destroy(): void;
/** Returns the OlapReport string maintained along with the axis elements information.
* @returns {string}
*/
@@ -30186,6 +30183,11 @@ declare namespace ej {
*/
dataSource?: DataSource;
/** Enables the Drill-Through feature which retrieves the raw items that are used to create the specific cell in PivotGrid.
* @Default {false}
*/
enableDrillThrough?: boolean;
/** Allows the user to customize the widget's layout and appearance.
* @Default {{}}
*/
@@ -30196,7 +30198,7 @@ declare namespace ej {
*/
toolbarIconSettings?: ToolbarIconSettings;
/** Allows user to show unique name on pivotbutton.
/** Allows user to show unique name on pivot button.
* @Default {false}
*/
showUniqueNameOnPivotButton?: boolean;
@@ -30276,6 +30278,11 @@ declare namespace ej {
*/
isResponsive?: boolean;
/** Options to customize the size of the PivotClient control.
* @Default {Example:}
*/
size?: any;
/** Allows the user to set the localized language for the widget.
* @Default {en-US}
*/
@@ -30335,6 +30342,10 @@ declare namespace ej {
*/
treeMapLoad?(e: TreeMapLoadEventArgs): void;
/** Triggers while clicking value cells in PivotGrid.
*/
drillThrough?(e: DrillThroughEventArgs): void;
/** Triggers while we initiate loading of the widget.
*/
load?(e: LoadEventArgs): void;
@@ -30463,6 +30474,17 @@ declare namespace ej {
element?: any;
}
export interface DrillThroughEventArgs {
/** return the JSON records of the generated cells on drill-through operation.
*/
data?: any;
/** returns the HTML element of PivotClient.
*/
element?: any;
}
export interface LoadEventArgs {
/** returns the HTML element of PivotClient component.
@@ -31013,6 +31035,16 @@ declare namespace ej {
*/
loadReport?: string;
/** Allows the user to set the custom name for the service method responsible for remove a report collection from the database.
* @Default {RemoveReportFromDB}
*/
removeDBReport?: string;
/** Allows the user to set the custom name for the service method responsible for rename the report collection in the database.
* @Default {RenameReportInDB}
*/
renameDBReport?: string;
/** Allows the user to set the custom name for the service method responsible for retrieving the MDX query for the current report.
* @Default {GetMDXQuery}
*/
@@ -31067,6 +31099,16 @@ declare namespace ej {
* @Default {CalculatedMember}
*/
calculatedMember?: string;
/** Allows the user to set the custom name for the service method responsible for performing drill through operation.
* @Default {DrillThroughHierarchies}
*/
drillThroughHierarchies?: string;
/** Allows the user to set the custom name for the service method responsible for performing drill through operation in data table.
* @Default {DrillThroughDataTable}
*/
drillThroughDataTable?: string;
}
enum ClientExportMode {
@@ -31143,6 +31185,11 @@ declare namespace ej {
*/
renderControlFromJSON(): void;
/** This function Destroy the PivotGauge widget all events bound using this._on will be unbind automatically and bring the control to pre-init state.
* @returns {void}
*/
destroy(): void;
/** Returns the OlapReport string maintained along with the axis elements information.
* @returns {string}
*/
@@ -31598,6 +31645,11 @@ declare namespace ej {
*/
doAjaxPost(): void;
/** Performs an asynchronous HTTP (FullPost) submit.
* @returns {void}
*/
doPostBack(): void;
/** Returns the OlapReport string maintained along with the axis elements information.
* @returns {string}
*/
@@ -31632,6 +31684,11 @@ declare namespace ej {
* @returns {void}
*/
renderControlSuccess(): void;
/** This function Destroy the PivotTreemap widget all events bound using this._on will be unbind automatically and bring the control to pre-init state.
* @returns {void}
*/
destroy(): void;
}
export namespace PivotTreeMap {
@@ -40686,6 +40743,8 @@ declare namespace ej {
XLRibbon: Spreadsheet.XLRibbon;
XLScroll: Spreadsheet.XLScroll;
XLSearch: Spreadsheet.XLSearch;
XLSelection: Spreadsheet.XLSelection;
@@ -41339,6 +41398,15 @@ declare namespace ej {
updateRibbonIcons(): void;
}
export interface XLScroll {
/** This method is used to scroll the sheet content to the specified cell address in the Spreadsheet.
* @param {string} Pass the cell address that you want to scroll to it.
* @returns {void}
*/
scrollToCell(range: string): void;
}
export interface XLSearch {
/** This method is used to find and replace all data by workbook in the Spreadsheet.
@@ -44481,7 +44549,7 @@ declare namespace ej {
/** Returns the previous color of the signature.
*/
perviousColor?: string;
previousColor?: string;
/** Returns the current color of the signature.
*/
@@ -44841,6 +44909,12 @@ declare namespace ej {
* @returns {any}
*/
addToDictionary(customWord: string): any;
/** Retrieves the possible suggestion words for the error word passed as an argument.
* @param {string} Error word to get the suggestions
* @returns {any}
*/
getSuggestionWords(errorWord: string): any;
}
export namespace SpellCheck {
@@ -44893,6 +44967,11 @@ declare namespace ej {
*/
controlsToValidate?: string;
/** When set to true, allows sending Asynchronous ajax request for checking the spelling errors.
* @Default {true}
*/
enableAsync?: boolean;
/** Triggers on the success of AJAX call request.
*/
actionSuccess?(e: ActionSuccessEventArgs): void;
@@ -51357,7 +51436,7 @@ declare namespace ej.datavisualization {
*/
type?: string;
/** location - X and Y co-ordinate of the points with respect to chart area. axis - axis of the multilevellabels. multilevellabel - Multi level label details
/** location - X and Y co-ordinate of the points with respect to chart area. axis - axis of the multi level labels. multiLevelLabel - Multi level label details
*/
data?: any;
}
@@ -52537,7 +52616,7 @@ declare namespace ej.datavisualization {
/** Specifies the type of the trendline for the series.
* @Default {linear. See TrendlinesType}
*/
type?: string;
type?: ej.datavisualization.Chart.TrendlinesType|string;
/** Name for the trendlines that is to be displayed in the legend text.
* @Default {trendline}
@@ -52741,7 +52820,7 @@ declare namespace ej.datavisualization {
*/
dataSource?: any;
/** Specifies spline tension value for cardianal spline type. Value ranges from 0 to 1.
/** Specifies spline tension value for cardinal spline type. Value ranges from 0 to 1.
* @Default {0.5}
*/
cardinalSplineTension?: number;
@@ -57013,7 +57092,7 @@ declare namespace ej.datavisualization {
*/
dataSource?: any;
/** Specifies spline tension values for cardianal spline type.Value ranges from 0 to 1.
/** Specifies spline tension values for cardinal spline type.Value ranges from 0 to 1.
* @Default {0.5}
*/
cardinalSplineTension?: number;
@@ -57123,7 +57202,7 @@ declare namespace ej.datavisualization {
splitMode?: ej.datavisualization.Chart.SplitMode|string;
/** Quartile calculation has been performed in three different formulas to render the boxplot series .
* @Default {exclusive}
* @Default {exclusive.See BoxPlotMode}
*/
boxPlotMode?: ej.datavisualization.Chart.LabelPosition|string;
@@ -57944,6 +58023,20 @@ declare namespace ej.datavisualization {
Minus,
}
}
namespace Chart {
enum TrendlinesType {
//string
Linear,
//string
Exponential,
//string
Logarithmic,
//string
Power,
//string
Polynomial,
}
}
namespace Chart {
enum Mode {
//string
@@ -64669,22 +64762,22 @@ declare namespace ej.datavisualization {
*/
id?: string;
/** Sets the sourcenode of the connection data source item
/** Sets the source node of the connection data source item
* @Default {null}
*/
sourceNode?: string;
/** Sets the targetnode of the connection data source item
/** Sets the target node of the connection data source item
* @Default {null}
*/
targetNode?: string;
/** Sets the sourcepoint-x value of the connection data source item
/** Sets the sourcePointX value of the connection data source item
* @Default {null}
*/
sourcePointX?: string;
/** Sets the sourcePoint-y value of the connection data source item
/** Sets the sourcePointY value of the connection data source item
* @Default {null}
*/
sourcePointY?: string;
@@ -64704,7 +64797,7 @@ declare namespace ej.datavisualization {
*/
crudAction?: DataSourceSettingsConnectionDataSourceCrudAction;
/** Specifies the customfields to get the updated data from client side to the server side
/** Specifies the custom fields to get the updated data from client side to the server side
* @Default {[]}
*/
customFields?: any[];
@@ -64745,7 +64838,7 @@ declare namespace ej.datavisualization {
*/
crudAction?: DataSourceSettingsCrudAction;
/** Specifies the customfields to get the updated data from client side to the server side
/** Specifies the custom fields to get the updated data from client side to the server side
* @Default {[]}
*/
customFields?: any[];
@@ -69214,7 +69307,7 @@ declare namespace ej.datavisualization {
*/
format?: string;
/** Sets the opacity of the dispalyed tooltip
/** Sets the opacity of the displayed tooltip
* @Default {0.95}
*/
opacity?: number;
@@ -69885,7 +69978,7 @@ interface JQueryPromise<T> {
*/
cancel?: boolean;
}
interface JQueryDeferred<T> extends JQueryPromise<T> {
interface JQueryDeferred<T> {
/**
* Returns the cancel option value.
*/

View File

@@ -6,6 +6,7 @@
"no-consecutive-blank-lines": false,
"no-mergeable-namespace": false,
"no-padding": false,
"no-any-union": false,
"no-unnecessary-qualifier": false,
"strict-export-declare-modifiers": false
}

View File

@@ -1,5 +1,5 @@
// common
import { vec2, mat2, mat3, mat4, vec3, vec4, mat2d, quat } from "gl-matrix";
import { glMatrix, vec2, mat2, mat3, mat4, vec3, vec4, mat2d, quat } from "gl-matrix";
var outVal: number;
var outBool: boolean;
@@ -350,7 +350,18 @@ outQuat = quat.calculateW(outQuat, quatA);
outBool = quat.exactEquals(quatA, quatB);
outBool = quat.equals(quatA, quatB);
// glMatrix
outVal = glMatrix.RANDOM();
outVal = glMatrix.EPSILON;
outBool = glMatrix.ENABLE_SIMD;
outBool = glMatrix.SIMD_AVAILABLE;
outBool = glMatrix.USE_SIMD;
outBool = glMatrix.equals(1, 1);
outBool = glMatrix.equals(1, -1);
outVal = glMatrix.toRadian(10);
// common
import _glMatrix = require('gl-matrix/src/gl-matrix/common');
import _vec2 = require('gl-matrix/src/gl-matrix/vec2');
import _vec3 = require('gl-matrix/src/gl-matrix/vec3');
import _vec4 = require('gl-matrix/src/gl-matrix/vec4');
@@ -699,3 +710,13 @@ outQuat = _quat.fromMat3(outQuat, mat3A);
outQuat = _quat.calculateW(outQuat, quatA);
outBool = _quat.exactEquals(quatA, quatB);
outBool = _quat.equals(quatA, quatB);
// glMatrix common
outVal = _glMatrix.RANDOM();
outVal = _glMatrix.EPSILON;
outBool = _glMatrix.ENABLE_SIMD;
outBool = _glMatrix.SIMD_AVAILABLE;
outBool = _glMatrix.USE_SIMD;
outBool = _glMatrix.equals(1, 1);
outBool = _glMatrix.equals(1, -1);
outVal = _glMatrix.toRadian(10);

View File

@@ -1,10 +1,49 @@
// Type definitions for gl-matrix 2.2.2
// Type definitions for gl-matrix 2.3.2
// Project: https://github.com/toji/gl-matrix
// Definitions by: Mattijs Kneppers <https://github.com/mattijskneppers>, based on definitions by Tat <https://github.com/tatchx>
// Nikolay Babanov <https://github.com/nbabanov>
// Austin Martin <https://github.com/auzmartist>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'gl-matrix' {
// Global Utilities
export class glMatrix {
// Configuration constants
public static EPSILON: number;
public static ARRAY_TYPE: any;
public static RANDOM(): number;
public static ENABLE_SIMD: boolean;
// Compatibility detection
public static SIMD_AVAILABLE: boolean;
public static USE_SIMD: boolean;
/**
* Sets the type of array used when creating new vectors and matrices
*
* @param {any} type - Array type, such as Float32Array or Array
*/
public static setMatrixArrayType(type: any): void;
/**
* Convert Degree To Radian
*
* @param {number} a - Angle in Degrees
*/
public static toRadian(a: number): number;
/**
* Tests whether or not the arguments have approximately the same value, within an absolute
* or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
* than or equal to 1.0, and a relative tolerance is used for larger values)
*
* @param {number} a - The first number to test.
* @param {number} b - The second number to test.
* @returns {boolean} True if the numbers are approximately equal, false otherwise.
*/
public static equals(a: number, b: number): boolean;
}
// vec2
export class vec2 extends Float32Array {
private typeVec2: number;
@@ -3057,6 +3096,11 @@ declare module 'gl-matrix' {
}
}
declare module 'gl-matrix/src/gl-matrix/common' {
import { glMatrix } from 'gl-matrix';
export = glMatrix;
}
declare module 'gl-matrix/src/gl-matrix/vec2' {
import { vec2 } from 'gl-matrix';
export = vec2;

View File

@@ -173,3 +173,6 @@ got('todomvc.com', {
'user-agent': `my-module/ (https://github.com/username/my-module)`
}
});
got('https://httpbin.org/404')
.catch(err => err instanceof got.HTTPError && err.statusCode === 404);

92
types/got/index.d.ts vendored
View File

@@ -13,10 +13,59 @@ import * as nodeStream from 'stream';
export = got;
declare class RequestError extends StdError {
name: 'RequestError';
}
declare class ReadError extends StdError {
name: 'ReadError';
}
declare class ParseError extends StdError {
name: 'ParseError';
statusCode: number;
statusMessage: string;
}
declare class HTTPError extends StdError {
name: 'HTTPError';
statusCode: number;
statusMessage: string;
headers: http.IncomingHttpHeaders;
}
declare class MaxRedirectsError extends StdError {
name: 'MaxRedirectsError';
statusCode: number;
statusMessage: string;
redirectUrls: string[];
}
declare class UnsupportedProtocolError extends StdError {
name: 'UnsupportedProtocolError';
}
declare class StdError extends Error {
code?: string;
host?: string;
hostname?: string;
method?: string;
path?: string;
protocol?: string;
url?: string;
response?: any;
}
declare const got: got.GotFn &
Record<'get' | 'post' | 'put' | 'patch' | 'head' | 'delete', got.GotFn> &
{
stream: got.GotStreamFn & Record<'get' | 'post' | 'put' | 'patch' | 'head' | 'delete', got.GotStreamFn>
RequestError: typeof RequestError
ReadError: typeof ReadError
ParseError: typeof ParseError
HTTPError: typeof HTTPError
MaxRedirectsError: typeof MaxRedirectsError
UnsupportedProtocolError: typeof UnsupportedProtocolError
};
declare namespace got {
@@ -111,47 +160,4 @@ declare namespace got {
}
type GotError = RequestError | ReadError | ParseError | HTTPError | MaxRedirectsError | UnsupportedProtocolError;
interface RequestError extends StdError {
name: 'RequestError';
}
interface ReadError extends StdError {
name: 'ReadError';
}
interface ParseError extends StdError {
name: 'ParseError';
statusCode: number;
statusMessage: string;
}
interface HTTPError extends StdError {
name: 'HTTPError';
statusCode: number;
statusMessage: string;
headers: http.IncomingHttpHeaders;
}
interface MaxRedirectsError extends StdError {
name: 'MaxRedirectsError';
statusCode: number;
statusMessage: string;
redirectUrls: string[];
}
interface UnsupportedProtocolError extends StdError {
name: 'UnsupportedProtocolError';
}
interface StdError extends Error {
code?: string;
host?: string;
hostname?: string;
method?: string;
path?: string;
protocol?: string;
url?: string;
response?: any;
}
}

View File

@@ -575,7 +575,7 @@ declare namespace Highcharts {
* categories: ['Apples', 'Bananas', 'Oranges']
* @default null
*/
categories?: string[];
categories?: any[];
/**
* The highest allowed value for automatically computed axis extremes.
* @since 4.0
@@ -1994,6 +1994,8 @@ declare namespace Highcharts {
position?: string;
top?: string;
textOutline?: string;
textOverflow?: string;
whiteSpace?: string;
}
interface CreditsOptions {

View File

@@ -231,6 +231,8 @@ barStream = fooStream.map((x: Foo) => {
barStream = fooStream.pluck<Bar>(str);
fooStream = fooStream.ratelimit(3, 1000);
barStream = fooStream.reduce(bar, (memo: Bar, x: Foo) => {
return memo;
});
@@ -405,4 +407,4 @@ num = _.add(num, num);
numCurNum = _.add(num);
//missing not
//missing not

View File

@@ -765,6 +765,26 @@ declare namespace Highland {
*/
pluck<U>(prop: string): Stream<U>;
/**
* Limits number of values through the stream to a maximum of number of values
* per window. Errors are not limited but allowed to pass through as soon as
* they are read from the source.
*
* @id ratelimit
* @section Transforms
* @name Stream.ratelimit(num, ms)
* @param {Number} num - the number of operations to perform per window
* @param {Number} ms - the window of time to limit the operations in (in ms)
* @api public
*
* _([1, 2, 3, 4, 5]).ratelimit(2, 100);
*
* // after 0ms => 1, 2
* // after 100ms => 1, 2, 3, 4
* // after 200ms => 1, 2, 3, 4, 5
*/
ratelimit(num: number, ms: number): Stream<R>;
/**
* Boils down a Stream to a single value. The memo is the initial state
* of the reduction, and each successive step of it should be returned by

View File

@@ -15,7 +15,7 @@ declare module 'mongoose-simple-random' {
declare module "mongoose" {
interface Model<T extends Document> extends NodeJS.EventEmitter, ModelProperties {
findRandom(conditions: Object, projection?: Object | null, options?: Object | null, callback?: (err: any, res: T[]) => void)
findRandom(conditions: Object, projection?: Object | null, options?: Object | null, callback?: (err: any, res?: T[]) => void)
: void;
}
}

View File

@@ -1,118 +1,327 @@
// Type definitions for needle 1.4
// Type definitions for needle 2.0
// Project: https://github.com/tomas/needle
// Definitions by: San Chen <https://github.com/bigsan>, Niklas Mollenhauer <https://github.com/nikeee>
// Definitions by: San Chen <https://github.com/bigsan>, Niklas Mollenhauer <https://github.com/nikeee>, Matanel Sindilevich <https://github.com/sindilevich>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
declare module "needle" {
import * as http from 'http';
import * as Buffer from 'buffer';
import * as https from 'https';
namespace Needle {
interface NeedleResponse extends http.IncomingMessage {
body: any;
raw: Buffer;
bytes: number;
}
import * as http from 'http';
import * as Buffer from 'buffer';
import * as https from 'https';
type ReadableStream = NodeJS.ReadableStream;
type NeedleCallback = (error: Error, response: NeedleResponse, body: any) => void;
interface Cookies {
[name: string]: any;
}
type NeedleOptions = RequestOptions & ResponseOptions & RedirectOptions & https.RequestOptions;
interface RequestOptions {
open_timeout?: number;
read_timeout?: number;
/**
* Alias for open_timeout
*/
timeout?: number;
follow_max?: number;
/**
* Alias for follow_max
*/
follow?: number;
multipart?: boolean;
agent?: http.Agent | boolean;
proxy?: string;
headers?: {};
auth?: "auto" | "digest" | "basic";
json?: boolean;
// These properties are overwritten by those in the 'headers' field
cookies?: Cookies;
compressed?: boolean;
// Overwritten if present in the URI
username?: string;
password?: string;
accept?: string;
connection?: string;
user_agent?: string;
}
interface ResponseOptions {
decode_response?: boolean;
/**
* Alias for decode_response
*/
decode?: boolean;
parse_response?: boolean;
/**
* Alias for parse_response
*/
parse?: boolean;
parse_cookies?: boolean;
output?: string;
}
interface RedirectOptions {
follow_set_cookie?: boolean;
follow_set_referer?: boolean;
follow_keep_method?: boolean;
follow_if_same_host?: boolean;
follow_if_same_protocol?: boolean;
}
interface KeyValue {
[key: string]: any;
}
type BodyData = Buffer | KeyValue | NodeJS.ReadableStream | string | null;
interface NeedleStatic {
defaults(options: NeedleOptions): void;
head(url: string, callback?: NeedleCallback): ReadableStream;
head(url: string, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
get(url: string, callback?: NeedleCallback): ReadableStream;
get(url: string, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
post(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
post(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
put(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
put(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
patch(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
patch(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
delete(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
delete(url: string, data: BodyData, options?: NeedleOptions, callback ?: NeedleCallback): ReadableStream;
request(method: string, url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
request(method: string, url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
}
declare namespace core {
interface NeedleResponse extends http.IncomingMessage {
body: any;
raw: Buffer;
bytes: number;
}
const needle: Needle.NeedleStatic;
export = needle;
type ReadableStream = NodeJS.ReadableStream;
type NeedleCallback = (error: Error, response: NeedleResponse, body: any) => void;
interface Cookies {
[name: string]: any;
}
type NeedleOptions = RequestOptions & ResponseOptions & RedirectOptions & https.RequestOptions;
type NeedleReadonlyHttpVerbs = 'get' | 'head';
type NeedleReadWriteHttpVerbs = 'delete' | 'patch' | 'post' | 'put';
type NeedleHttpVerbs = NeedleReadonlyHttpVerbs | NeedleReadWriteHttpVerbs;
interface RequestOptions {
/**
* Returns error if connection takes longer than X milisecs to establish.
* Defaults to 10000 (10 secs). 0 means no timeout.
*/
open_timeout?: number;
/**
* Alias for open_timeout
*/
timeout?: number;
/**
* Returns error if data transfer takes longer than X milisecs,
* after connection is established. Defaults to 0 (no timeout).
*/
read_timeout?: number;
/**
* Number of redirects to follow. Defaults to 0.
*/
follow_max?: number;
/**
* Alias for follow_max
*/
follow?: number;
/**
* Enables multipart/form-data encoding. Defaults to false.
* Use it when uploading files.
*/
multipart?: boolean;
/**
* Uses an http.Agent of your choice, instead of the global, default one.
* Useful for tweaking the behaviour at the connection level, such as when doing tunneling.
*/
agent?: http.Agent | boolean;
/**
* Forwards request through HTTP(s) proxy.
* Eg. proxy: 'http://user:pass@proxy.server.com:3128'.
* For more advanced proxying/tunneling use a custom agent.
*/
proxy?: string;
/**
* Object containing custom HTTP headers for request.
*/
headers?: {};
/**
* Determines what to do with provided username/password.
* Options are auto, digest or basic (default).
* auto will detect the type of authentication depending on the response headers.
*/
auth?: "auto" | "digest" | "basic";
/**
* When true, sets content type to application/json and sends request body as JSON string,
* instead of a query string.
*/
json?: boolean;
/**
* When sending streams, this lets manually set the Content-Length header
* --if the stream's bytecount is known beforehand--,
* preventing ECONNRESET (socket hang up) errors on some servers that misbehave
* when receiving payloads of unknown size.
* Set it to 0 and Needle will get and set the stream's length,
* or leave unset for the default behavior,
* which is no Content-Length header for stream payloads.
*/
stream_length?: number;
// These properties are overwritten by those in the 'headers' field
/**
* Builds and sets a Cookie header from a { key: 'value' } object.
*/
cookies?: Cookies;
/**
* If true, sets 'Accept-Encoding' header to 'gzip,deflate',
* and inflates content if zipped.
* Defaults to false.
*/
compressed?: boolean;
// Overwritten if present in the URI
/**
* For HTTP basic auth.
*/
username?: string;
/**
* For HTTP basic auth. Requires username to be passed, but is optional.
*/
password?: string;
/**
* Sets 'Accept' HTTP header. Defaults to &#x2a;&#x2f;&#x2a;.
*/
accept?: string;
/**
* Sets 'Connection' HTTP header.
* Not set by default, unless running Node < 0.11.4
* in which case it defaults to close.
*/
connection?: string;
/**
* Sets the 'User-Agent' HTTP header.
* Defaults to Needle/{version} (Node.js {node_version}).
*/
user_agent?: string;
/**
* Sets the 'Content-Type' header.
* Unset by default, unless you're sending data
* in which case it's set accordingly to whatever is being sent
* (application/x-www-form-urlencoded, application/json or multipart/form-data).
* That is, of course, unless the option is passed,
* either here or through options.headers.
*/
content_type?: string;
}
interface ResponseOptions {
/**
* Whether to decode the text responses to UTF-8,
* if Content-Type header shows a different charset. Defaults to true.
*/
decode_response?: boolean;
/**
* Alias for decode_response
*/
decode?: boolean;
/**
* Whether to parse XML or JSON response bodies automagically.
* Defaults to true.
* You can also set this to 'xml' or 'json' in which case Needle
* will only parse the response if the content type matches.
*/
parse_response?: boolean;
/**
* Alias for parse_response
*/
parse?: boolean;
/**
* Whether to parse responses Set-Cookie header.
* Defaults to true.
* If parsed, response cookies will be available at resp.cookies.
*/
parse_cookies?: boolean;
/**
* Dump response output to file.
* This occurs after parsing and charset decoding is done.
*/
output?: string;
}
interface RedirectOptions {
/**
* Sends the cookies received in the set-cookie header
* as part of the following request.
* false by default.
*/
follow_set_cookie?: boolean;
/**
* Sets the 'Referer' header to the requested URI
* when following a redirect.
* false by default.
*/
follow_set_referer?: boolean;
/**
* If enabled, resends the request using the original verb
* instead of being rewritten to get with no data.
* false by default.
*/
follow_keep_method?: boolean;
/**
* When true, Needle will only follow redirects that point to the same host
* as the original request.
* false by default.
*/
follow_if_same_host?: boolean;
/**
* When true, Needle will only follow redirects that point to the same protocol
* as the original request.
* false by default.
*/
follow_if_same_protocol?: boolean;
}
interface KeyValue {
[key: string]: any;
}
type BodyData = Buffer | KeyValue | NodeJS.ReadableStream | string | null;
}
/**
* Calling needle() directly returns a Promise.
*
* Since needle 2.0
* @param method Designates an HTTP verb for the request.
*/
declare function needle(method: core.NeedleReadonlyHttpVerbs, url: string, options?: core.NeedleOptions): Promise<core.NeedleResponse>;
/**
* Calling needle() directly returns a Promise.
*
* Since needle 2.0
* @param method Designates an HTTP verb for the request.
* @param data May be null when issuing an HTTP DELETE request, but you need to explicity pass it.
*/
declare function needle(method: core.NeedleHttpVerbs, url: string, data: core.BodyData, options?: core.NeedleOptions): Promise<core.NeedleResponse>;
declare namespace needle {
type BodyData = core.BodyData;
type NeedleCallback = core.NeedleCallback;
type NeedleHttpVerbs = core.NeedleHttpVerbs;
export type NeedleOptions = core.NeedleOptions;
type ReadableStream = core.ReadableStream;
/**
* Lets override the defaults for all future requests.
*/
export function defaults(options: NeedleOptions): NeedleOptions;
/**
* Issues an HTTP HEAD request.
*/
export function head(url: string, callback?: NeedleCallback): ReadableStream;
/**
* Issues an HTTP HEAD request.
*/
export function head(url: string, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
/**
* Issues an HTTP GET request.
*/
export function get(url: string, callback?: NeedleCallback): ReadableStream;
/**
* Issues an HTTP GET request.
*/
export function get(url: string, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
/**
* Issues an HTTP POST request.
*/
export function post(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
/**
* Issues an HTTP POST request.
*/
export function post(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
/**
* Issues an HTTP PUT request.
*/
export function put(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
/**
* Issues an HTTP PUT request.
*/
export function put(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
/**
* Same behaviour as PUT.
*/
export function patch(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
/**
* Same behaviour as PUT.
*/
export function patch(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
/**
* Issues an HTTP DELETE request.
*/
function deleteFunc(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
/**
* Issues an HTTP DELETE request.
*/
function deleteFunc(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
// See https://github.com/Microsoft/TypeScript/issues/1784#issuecomment-258720219
export { deleteFunc as delete };
/**
* Generic request.
* This not only allows for flexibility, but also lets you perform a GET request with data,
* in which case will be appended to the request as a query string,
* unless you pass a json: true option.
* @param method Designates an HTTP verb for the request.
*/
export function request(method: NeedleHttpVerbs, url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
/**
* Generic request.
* This not only allows for flexibility, but also lets you perform a GET request with data,
* in which case will be appended to the request as a query string,
* unless you pass a json: true option.
* @param method Designates an HTTP verb for the request.
*/
export function request(method: NeedleHttpVerbs, url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
}
export = needle;

View File

@@ -2,24 +2,37 @@ import * as needle from "needle";
import * as fs from "fs";
function Usage() {
// using promises
needle('get', 'http://ifconfig.me/all.json')
.then((resp) => console.log(resp.body.ip_addr));
// using callback
needle.get('http://ifconfig.me/all.json', function (error, response) {
needle.get('http://ifconfig.me/all.json', (error, response) => {
if (!error)
console.log(response.body.ip_addr); // JSON decoding magic. :)
});
// using streams
var out: any; // = fs.createWriteStream('logo.png');
const out = fs.createWriteStream('file.txt');
needle.get('https://google.com/images/logo.png').pipe(out);
}
function ResponsePipeline() {
needle.get('http://stackoverflow.com/feeds', { compressed: true }, function (err, resp) {
// using promises
needle('get', 'http://stackoverflow.com/feeds', { compressed: true })
.then((resp) => {
console.log(resp.body); // this little guy won't be a Gzipped binary blob
// but a nice object containing all the latest entries
});
// using callback
needle.get('http://stackoverflow.com/feeds', { compressed: true }, (err, resp) => {
console.log(resp.body); // this little guy won't be a Gzipped binary blob
// but a nice object containing all the latest entries
});
var options = {
// using streams
const options = {
compressed: true,
follow: 5,
rejectUnauthorized: true
@@ -27,54 +40,69 @@ function ResponsePipeline() {
// in this case, we'll ask Needle to follow redirects (disabled by default),
// but also to verify their SSL certificates when connecting.
var stream = needle.get('https://backend.server.com/everything.html', options);
const stream = needle.get('https://backend.server.com/everything.html', options);
stream.on('readable', function () {
var data: any;
stream.on('readable', () => {
let data: any;
while (data = stream.read()) {
console.log(data.toString());
}
});
stream.on('end', function(err: any) {
stream.on('end', (err: any) => {
// if our request had an error, our 'end' event will tell us.
if (!err) console.log('Great success!');
})
});
}
function API_head() {
var options = {
open_timeout: 5000 // if we don't get a response in 5 seconds, boom.
};
// using promises
needle('head', 'https://my.backend.server.com')
.then((resp) => console.log('Yup, still alive.'))
.catch((err: Error) => console.log('Shoot! Something is wrong: ' + err.message));
needle.head('https://my.backend.server.com', function (err, resp) {
// using callback
needle.head('https://my.backend.server.com', (err, resp) => {
if (err) {
console.log('Shoot! Something is wrong: ' + err.message);
}
else {
} else {
console.log('Yup, still alive.');
}
});
}
function API_get() {
needle.get('google.com/search?q=syd+barrett', function (err, resp) {
// using promises
needle('get', 'google.com/search?q=syd+barrett')
.then((resp) => {
// if no http:// is found, Needle will automagically prepend it.
});
// using callback
needle.get('google.com/search?q=syd+barrett', (err, resp) => {
// if no http:// is found, Needle will automagically prepend it.
});
}
function API_post() {
var options = {
const options = {
headers: { 'X-Custom-Header': 'Bumbaway atuna' }
};
needle.post('https://my.app.com/endpoint', 'foo=bar', options, function (err, resp) {
// using promises
needle('post', 'https://my.app.com/endpoint', 'foo=bar', options)
.then((resp) => {
// you can pass params as a string or as an object.
});
// using callback
needle.post('https://my.app.com/endpoint', 'foo=bar', options, (err, resp) => {
// you can pass params as a string or as an object.
});
}
function API_put() {
var nested = {
const nested = {
params: {
are: {
also: 'supported'
@@ -82,87 +110,155 @@ function API_put() {
}
};
needle.put('https://api.app.com/v2', nested, function (err, resp) {
console.log('Got ' + resp.bytes + ' bytes.') // another nice treat from this handsome fella.
// using promises
needle('put', 'https://api.app.com/v2', nested)
.then((resp) => {
console.log(`Got ${resp.bytes} bytes.`); // another nice treat from this handsome fella.
});
// using callback
needle.put('https://api.app.com/v2', nested, (err, resp) => {
console.log(`Got ${resp.bytes} bytes.`); // another nice treat from this handsome fella.
});
}
function API_delete() {
var options = {
const options = {
username: 'fidelio',
password: 'x'
};
needle.delete('https://api.app.com/messages/123', null, options, function (err, resp) {
// using promises
needle('delete', 'https://api.app.com/messages/123', null, options)
.then((resp) => {
// in this case, data may be null, but you need to explicity pass it.
});
// using callback
needle.delete('https://api.app.com/messages/123', null, options, (err, resp) => {
// in this case, data may be null, but you need to explicity pass it.
});
}
function API_request() {
var params = {
const params = {
q: 'a very smart query',
page: 2,
};
needle.request('get', 'forum.com/search', params, function (err, resp) {
if (!err && resp.statusCode == 200)
// using promises
needle('get', 'forum.com/search', params)
.then((resp) => {
if (resp.statusCode === 200)
console.log(resp.body); // here you go, mister.
});
needle('get', 'forum.com/search', params, { json: true })
.then((resp) => {
if (resp.statusCode === 200) console.log('It worked!');
});
// using callback
needle.request('get', 'forum.com/search', params, (err, resp) => {
if (!err && resp.statusCode === 200)
console.log(resp.body); // here you go, mister.
});
needle.request('get', 'forum.com/search', params, { json: true }, function(err, resp) {
if (resp.statusCode == 200) console.log('It worked!');
needle.request('get', 'forum.com/search', params, { json: true }, (err, resp) => {
if (resp.statusCode === 200) console.log('It worked!');
});
}
function HttpGetWithBasicAuth() {
needle.get('https://api.server.com', { username: 'you', password: 'secret' }, function(err, resp) {
// using promises
needle('get', 'https://api.server.com', { username: 'you', password: 'secret' })
.then((resp) => {
// used HTTP auth
});
needle('get', 'https://username:password@api.server.com')
.then((resp) => {
// used HTTP auth from URL
});
// using callback
needle.get('https://api.server.com', { username: 'you', password: 'secret' }, (err, resp) => {
// used HTTP auth
});
needle.get('https://username:password@api.server.com', function(err, resp) {
needle.get('https://username:password@api.server.com', (err, resp) => {
// used HTTP auth from URL
});
}
function DigestAuth() {
needle.get('other.server.com', { username: 'you', password: 'secret', auth: 'digest' }, function(err, resp, body) {
// using promises
needle('get', 'other.server.com', { username: 'you', password: 'secret', auth: 'digest' })
.then((resp) => {
// needle prepends 'http://' to your URL, if missing
});
// using callback
needle.get('other.server.com', { username: 'you', password: 'secret', auth: 'digest' }, (err, resp, body) => {
// needle prepends 'http://' to your URL, if missing
});
}
function CustomAcceptHeaderDeflate() {
var options = {
const options: needle.NeedleOptions = {
compressed: true,
follow: 10,
accept: 'application/vnd.github.full+json'
}
};
needle.get('api.github.com/users/tomas', options, function(err, resp, body) {
// using promises
needle('get', 'api.github.com/users/tomas', options)
.then((resp) => {
// body will contain a JSON.parse(d) object
// if parsing fails, you'll simply get the original body
});
// using callback
needle.get('api.github.com/users/tomas', options, (err, resp, body) => {
// body will contain a JSON.parse(d) object
// if parsing fails, you'll simply get the original body
});
}
function Various() {
// using promises
needle('get', 'https://news.ycombinator.com/rss')
.then((resp) => {
// if xml2js is installed, you'll get a nice object containing the nodes in the RSS
});
needle('get', 'http://upload.server.com/tux.png', { output: '/tmp/tux.png' })
.then((resp) => {
// you can dump any response to a file, not only binaries.
});
needle('get', 'http://search.npmjs.org', { proxy: 'http://localhost:1234' })
.then((resp) => {
// request passed through proxy
});
needle.get('https://news.ycombinator.com/rss', function(err, resp, body) {
// using callback
needle.get('https://news.ycombinator.com/rss', (err, resp, body) => {
// if xml2js is installed, you'll get a nice object containing the nodes in the RSS
});
needle.get('http://upload.server.com/tux.png', { output: '/tmp/tux.png' }, function(err, resp, body) {
needle.get('http://upload.server.com/tux.png', { output: '/tmp/tux.png' }, (err, resp, body) => {
// you can dump any response to a file, not only binaries.
});
needle.get('http://search.npmjs.org', { proxy: 'http://localhost:1234' }, function(err, resp, body) {
needle.get('http://search.npmjs.org', { proxy: 'http://localhost:1234' }, (err, resp, body) => {
// request passed through proxy
});
// using streams
const stream1 = needle.get('http://www.as35662.net/100.log');
stream1.on('readable', function() {
stream1.on('readable', () => {
let chunk: any;
while (chunk = stream1.read()) {
console.log('got data: ', chunk);
}
});
const stream2 = needle.get('http://jsonplaceholder.typicode.com/db', { parse: true });
stream2.on('readable', function() {
stream2.on('readable', () => {
let node: any;
// our stream2 will only emit a single JSON root node.
@@ -170,43 +266,54 @@ function Various() {
console.log('got data: ', node);
}
});
/*
// Sample omitted, no JSONStream
needle.get('http://jsonplaceholder.typicode.com/db', { parse: true })
.pipe(new JSONStream.parse('posts.*.title'))
.on('data', function (obj) {
console.log('got post title: %s', obj);
});
*/
}
function FileUpload() {
var data = {
const data = {
foo: 'bar',
image: { file: '/home/tomas/linux.png', content_type: 'image/png' }
};
needle.post('http://my.other.app.com', data, { multipart: true }, function(err, resp, body) {
// using promises
needle('post', 'http://my.other.app.com', data, { multipart: true })
.then((resp) => {
// needle will read the file and include it in the form-data as binary
});
needle('put', 'https://api.app.com/v2', fs.createReadStream('myfile.txt'))
.then((resp) => {
// stream content is uploaded verbatim
});
// using callback
needle.post('http://my.other.app.com', data, { multipart: true }, (err, resp, body) => {
// needle will read the file and include it in the form-data as binary
});
needle.put('https://api.app.com/v2', fs.createReadStream('myfile.txt'), function(err, resp, body) {
needle.put('https://api.app.com/v2', fs.createReadStream('myfile.txt'), (err, resp, body) => {
// stream content is uploaded verbatim
});
}
function Multipart() {
var buffer = fs.readFileSync('/path/to/package.zip');
const buffer = fs.readFileSync('/path/to/package.zip');
var data = {
const data = {
zip_file: {
buffer: buffer,
buffer,
filename: 'mypackage.zip',
content_type: 'application/octet-stream'
}
}
};
needle.post('http://somewhere.com/over/the/rainbow', data, { multipart: true }, function(err, resp, body) {
// using promises
needle('post', 'http://somewhere.com/over/the/rainbow', data, { multipart: true })
.then((resp) => {
// if you see, when using buffers we need to pass the filename for the multipart body.
// you can also pass a filename when using the file path method, in case you want to override
// the default filename to be received on the other end.
});
// using callback
needle.post('http://somewhere.com/over/the/rainbow', data, { multipart: true }, (err, resp, body) => {
// if you see, when using buffers we need to pass the filename for the multipart body.
// you can also pass a filename when using the file path method, in case you want to override
// the default filename to be received on the other end.
@@ -214,15 +321,23 @@ function Multipart() {
}
function MultipartContentType() {
var data = {
const data = {
token: 'verysecret',
payload: {
value: JSON.stringify({ title: 'test', version: 1 }),
content_type: 'application/json'
}
}
};
needle.post('http://test.com/', data, { timeout: 5000, multipart: true }, function(err, resp, body) {
// using promises
needle('post', 'http://test.com/', data, { timeout: 5000, multipart: true })
.then((resp) => {
// in this case, if the request takes more than 5 seconds
// the callback will return a [Socket closed] error
});
// using callback
needle.post('http://test.com/', data, { timeout: 5000, multipart: true }, (err, resp, body) => {
// in this case, if the request takes more than 5 seconds
// the callback will return a [Socket closed] error
});

7
types/needle/tslint.json Normal file
View File

@@ -0,0 +1,7 @@
{
"extends": "dtslint/dt.json",
"rules": {
"no-conditional-assignment": false,
"strict-export-declare-modifiers": false
}
}

118
types/needle/v1/index.d.ts vendored Normal file
View File

@@ -0,0 +1,118 @@
// Type definitions for needle 1.4
// Project: https://github.com/tomas/needle
// Definitions by: San Chen <https://github.com/bigsan>, Niklas Mollenhauer <https://github.com/nikeee>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
declare module "needle" {
import * as http from 'http';
import * as Buffer from 'buffer';
import * as https from 'https';
namespace Needle {
interface NeedleResponse extends http.IncomingMessage {
body: any;
raw: Buffer;
bytes: number;
}
type ReadableStream = NodeJS.ReadableStream;
type NeedleCallback = (error: Error, response: NeedleResponse, body: any) => void;
interface Cookies {
[name: string]: any;
}
type NeedleOptions = RequestOptions & ResponseOptions & RedirectOptions & https.RequestOptions;
interface RequestOptions {
open_timeout?: number;
read_timeout?: number;
/**
* Alias for open_timeout
*/
timeout?: number;
follow_max?: number;
/**
* Alias for follow_max
*/
follow?: number;
multipart?: boolean;
agent?: http.Agent | boolean;
proxy?: string;
headers?: {};
auth?: "auto" | "digest" | "basic";
json?: boolean;
// These properties are overwritten by those in the 'headers' field
cookies?: Cookies;
compressed?: boolean;
// Overwritten if present in the URI
username?: string;
password?: string;
accept?: string;
connection?: string;
user_agent?: string;
}
interface ResponseOptions {
decode_response?: boolean;
/**
* Alias for decode_response
*/
decode?: boolean;
parse_response?: boolean;
/**
* Alias for parse_response
*/
parse?: boolean;
parse_cookies?: boolean;
output?: string;
}
interface RedirectOptions {
follow_set_cookie?: boolean;
follow_set_referer?: boolean;
follow_keep_method?: boolean;
follow_if_same_host?: boolean;
follow_if_same_protocol?: boolean;
}
interface KeyValue {
[key: string]: any;
}
type BodyData = Buffer | KeyValue | NodeJS.ReadableStream | string | null;
interface NeedleStatic {
defaults(options: NeedleOptions): void;
head(url: string, callback?: NeedleCallback): ReadableStream;
head(url: string, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
get(url: string, callback?: NeedleCallback): ReadableStream;
get(url: string, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
post(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
post(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
put(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
put(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
patch(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
patch(url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
delete(url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
delete(url: string, data: BodyData, options?: NeedleOptions, callback ?: NeedleCallback): ReadableStream;
request(method: string, url: string, data: BodyData, callback?: NeedleCallback): ReadableStream;
request(method: string, url: string, data: BodyData, options?: NeedleOptions, callback?: NeedleCallback): ReadableStream;
}
}
const needle: Needle.NeedleStatic;
export = needle;
}

View File

@@ -0,0 +1,229 @@
import * as needle from "needle";
import * as fs from "fs";
function Usage() {
// using callback
needle.get('http://ifconfig.me/all.json', function (error, response) {
if (!error)
console.log(response.body.ip_addr); // JSON decoding magic. :)
});
// using streams
var out: any; // = fs.createWriteStream('logo.png');
needle.get('https://google.com/images/logo.png').pipe(out);
}
function ResponsePipeline() {
needle.get('http://stackoverflow.com/feeds', { compressed: true }, function (err, resp) {
console.log(resp.body); // this little guy won't be a Gzipped binary blob
// but a nice object containing all the latest entries
});
var options = {
compressed: true,
follow: 5,
rejectUnauthorized: true
};
// in this case, we'll ask Needle to follow redirects (disabled by default),
// but also to verify their SSL certificates when connecting.
var stream = needle.get('https://backend.server.com/everything.html', options);
stream.on('readable', function () {
var data: any;
while (data = stream.read()) {
console.log(data.toString());
}
});
stream.on('end', function(err: any) {
// if our request had an error, our 'end' event will tell us.
if (!err) console.log('Great success!');
})
}
function API_head() {
var options = {
open_timeout: 5000 // if we don't get a response in 5 seconds, boom.
};
needle.head('https://my.backend.server.com', function (err, resp) {
if (err) {
console.log('Shoot! Something is wrong: ' + err.message);
}
else {
console.log('Yup, still alive.');
}
});
}
function API_get() {
needle.get('google.com/search?q=syd+barrett', function (err, resp) {
// if no http:// is found, Needle will automagically prepend it.
});
}
function API_post() {
var options = {
headers: { 'X-Custom-Header': 'Bumbaway atuna' }
};
needle.post('https://my.app.com/endpoint', 'foo=bar', options, function (err, resp) {
// you can pass params as a string or as an object.
});
}
function API_put() {
var nested = {
params: {
are: {
also: 'supported'
}
}
};
needle.put('https://api.app.com/v2', nested, function (err, resp) {
console.log('Got ' + resp.bytes + ' bytes.') // another nice treat from this handsome fella.
});
}
function API_delete() {
var options = {
username: 'fidelio',
password: 'x'
};
needle.delete('https://api.app.com/messages/123', null, options, function (err, resp) {
// in this case, data may be null, but you need to explicity pass it.
});
}
function API_request() {
var params = {
q: 'a very smart query',
page: 2,
};
needle.request('get', 'forum.com/search', params, function (err, resp) {
if (!err && resp.statusCode == 200)
console.log(resp.body); // here you go, mister.
});
needle.request('get', 'forum.com/search', params, { json: true }, function(err, resp) {
if (resp.statusCode == 200) console.log('It worked!');
});
}
function HttpGetWithBasicAuth() {
needle.get('https://api.server.com', { username: 'you', password: 'secret' }, function(err, resp) {
// used HTTP auth
});
needle.get('https://username:password@api.server.com', function(err, resp) {
// used HTTP auth from URL
});
}
function DigestAuth() {
needle.get('other.server.com', { username: 'you', password: 'secret', auth: 'digest' }, function(err, resp, body) {
// needle prepends 'http://' to your URL, if missing
});
}
function CustomAcceptHeaderDeflate() {
var options = {
compressed: true,
follow: 10,
accept: 'application/vnd.github.full+json'
}
needle.get('api.github.com/users/tomas', options, function(err, resp, body) {
// body will contain a JSON.parse(d) object
// if parsing fails, you'll simply get the original body
});
}
function Various() {
needle.get('https://news.ycombinator.com/rss', function(err, resp, body) {
// if xml2js is installed, you'll get a nice object containing the nodes in the RSS
});
needle.get('http://upload.server.com/tux.png', { output: '/tmp/tux.png' }, function(err, resp, body) {
// you can dump any response to a file, not only binaries.
});
needle.get('http://search.npmjs.org', { proxy: 'http://localhost:1234' }, function(err, resp, body) {
// request passed through proxy
});
const stream1 = needle.get('http://www.as35662.net/100.log');
stream1.on('readable', function() {
let chunk: any;
while (chunk = stream1.read()) {
console.log('got data: ', chunk);
}
});
const stream2 = needle.get('http://jsonplaceholder.typicode.com/db', { parse: true });
stream2.on('readable', function() {
let node: any;
// our stream2 will only emit a single JSON root node.
while (node = stream2.read()) {
console.log('got data: ', node);
}
});
/*
// Sample omitted, no JSONStream
needle.get('http://jsonplaceholder.typicode.com/db', { parse: true })
.pipe(new JSONStream.parse('posts.*.title'))
.on('data', function (obj) {
console.log('got post title: %s', obj);
});
*/
}
function FileUpload() {
var data = {
foo: 'bar',
image: { file: '/home/tomas/linux.png', content_type: 'image/png' }
};
needle.post('http://my.other.app.com', data, { multipart: true }, function(err, resp, body) {
// needle will read the file and include it in the form-data as binary
});
needle.put('https://api.app.com/v2', fs.createReadStream('myfile.txt'), function(err, resp, body) {
// stream content is uploaded verbatim
});
}
function Multipart() {
var buffer = fs.readFileSync('/path/to/package.zip');
var data = {
zip_file: {
buffer: buffer,
filename: 'mypackage.zip',
content_type: 'application/octet-stream'
}
}
needle.post('http://somewhere.com/over/the/rainbow', data, { multipart: true }, function(err, resp, body) {
// if you see, when using buffers we need to pass the filename for the multipart body.
// you can also pass a filename when using the file path method, in case you want to override
// the default filename to be received on the other end.
});
}
function MultipartContentType() {
var data = {
token: 'verysecret',
payload: {
value: JSON.stringify({ title: 'test', version: 1 }),
content_type: 'application/json'
}
}
needle.post('http://test.com/', data, { timeout: 5000, multipart: true }, function(err, resp, body) {
// in this case, if the request takes more than 5 seconds
// the callback will return a [Socket closed] error
});
}

View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"needle": ["needle/v1"]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"needle-tests.ts"
]
}

18
types/picturefill/index.d.ts vendored Normal file
View File

@@ -0,0 +1,18 @@
// Type definitions for picturefill 3.0
// Project: https://scottjehl.github.io/picturefill/
// Definitions by: Alexander Azarov <https://github.com/alaz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Picturefill {
type ElementNullable = Element | null;
interface EvaluateArg {
reevaluate?: boolean;
elements: NodeList | ElementNullable[];
}
}
declare function picturefill(arg?: Picturefill.EvaluateArg): void;
export = picturefill;
export as namespace picturefill;

View File

@@ -0,0 +1,17 @@
function test_elements() {
// no args
picturefill();
// Element[]
picturefill({elements: [ document.getElementById('#id') ]});
// NodeList
picturefill({elements: document.querySelectorAll('img')});
}
function test_optional() {
picturefill({
elements: [],
reevaluate: true
});
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"dom",
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"picturefill-tests.ts"
]
}

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}

View File

@@ -17,6 +17,7 @@ export interface StickyProps {
topOffset?: number;
bottomOffset?: number;
onStickyStateChange?(isSticky: boolean): void;
disableCompensation?: boolean;
}
export const Sticky: React.ComponentClass<StickyProps>;

View File

@@ -1,6 +1,8 @@
// Type definitions for redux-actions 1.2
// Type definitions for redux-actions 2.2
// Project: https://github.com/acdlite/redux-actions
// Definitions by: Jack Hsu <https://github.com/jaysoo>, Alex Gorbatchev <https://github.com/alexgorbatchev>
// Definitions by: Jack Hsu <https://github.com/jaysoo>,
// Alex Gorbatchev <https://github.com/alexgorbatchev>,
// Alec Hill <https://github.com/alechill>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace ReduxActions;
@@ -25,7 +27,7 @@ export interface ReducerMap<State, Payload> {
}
export interface ReducerMapMeta<State, Payload, Meta> {
[actionType: string]: Reducer<State, Payload> | ReducerNextThrow<State, Payload>;
[actionType: string]: ReducerMeta<State, Payload, Meta> | ReducerNextThrowMeta<State, Payload, Meta>;
}
export interface ReducerNextThrow<State, Payload> {
@@ -93,9 +95,33 @@ export function createAction<Payload>(
export function createAction<Payload, Meta>(
actionType: string,
payloadCreator: (...args: any[]) => Payload,
metaCreator: (...args: any[]) => Meta
): (...args: any[]) => ActionMeta<Payload, Meta>;
payloadCreator: ActionFunctionAny<Payload>,
metaCreator: ActionFunctionAny<Meta>
): ActionFunctionAny<ActionMeta<Payload, Meta>>;
export function createAction<Payload, Meta, Arg1>(
actionType: string,
payloadCreator: ActionFunction1<Arg1, Payload>,
metaCreator: ActionFunction1<Arg1, Meta>
): ActionFunction1<Arg1, ActionMeta<Payload, Meta>>;
export function createAction<Payload, Meta, Arg1, Arg2>(
actionType: string,
payloadCreator: ActionFunction2<Arg1, Arg2, Payload>,
metaCreator: ActionFunction2<Arg1, Arg2, Meta>
): ActionFunction2<Arg1, Arg2, ActionMeta<Payload, Meta>>;
export function createAction<Payload, Meta, Arg1, Arg2, Arg3>(
actionType: string,
payloadCreator: ActionFunction3<Arg1, Arg2, Arg3, Payload>,
metaCreator: ActionFunction3<Arg1, Arg2, Arg3, Meta>
): ActionFunction3<Arg1, Arg2, Arg3, ActionMeta<Payload, Meta>>;
export function createAction<Payload, Meta, Arg1, Arg2, Arg3, Arg4>(
actionType: string,
payloadCreator: ActionFunction4<Arg1, Arg2, Arg3, Arg4, Payload>,
metaCreator: ActionFunction4<Arg1, Arg2, Arg3, Arg4, Meta>
): ActionFunction4<Arg1, Arg2, Arg3, Arg4, ActionMeta<Payload, Meta>>;
export function handleAction<State, Payload>(
actionType: string | ActionFunctions<Payload>,
@@ -119,6 +145,11 @@ export function handleActions<State, Payload>(
initialState: State
): Reducer<State, Payload>;
export function handleActions<State, Payload, Meta>(
reducerMap: ReducerMapMeta<State, Payload, Meta>,
initialState: State
): ReducerMeta<State, Payload, Meta>;
export function combineActions(...actionTypes: Array<ActionFunctions<any> | string>): string;
export interface ActionMap<Payload, Meta> {

View File

@@ -89,26 +89,100 @@ const typedActionHandler = ReduxActions.handleAction<TypedState, TypedPayload>(
{value: 1}
);
typedState = typedActionHandler({ value: 0 }, typedIncrementAction());
const actionNoArgs = typedIncrementAction();
actionNoArgs.payload.increase = 1;
const typedIncrementByActionWithMeta: (value: number) => ReduxActions.ActionMeta<TypedPayload, MetaType> =
ReduxActions.createAction<TypedPayload, MetaType>(
'INCREMENT_BY',
amount => ({ increase: amount }),
amount => ({ remote: true })
typedState = typedActionHandler({ value: 0 }, actionNoArgs);
const typedIncrementAction1TypedArg: (value: number) =>
ReduxActions.Action<TypedPayload> = ReduxActions.createAction<TypedPayload, number>(
'INCREMENT',
amount => ({ increase: amount })
);
const typedActionHandlerWithReduceMap = ReduxActions.handleAction<TypedState, TypedPayload>(
const actionFrom1Arg = typedIncrementAction1TypedArg(10);
actionFrom1Arg.payload.increase === 10;
const typedIncrementAction2TypedArgs: (numericAmount: number, stringAmount: string) =>
ReduxActions.Action<TypedPayload> = ReduxActions.createAction<TypedPayload, number, string>(
'INCREMENT',
(numericAmount, stringAmount) => ({ increase: numericAmount + parseInt(stringAmount, 10) })
);
const actionFrom2Args = typedIncrementAction2TypedArgs(10, '100');
actionFrom1Arg.payload.increase === 110;
const typedActionHandlerReducerMap = ReduxActions.handleActions<TypedState, TypedPayload>(
{
INCREMENT: (state: TypedState, action: ReduxActions.Action<TypedPayload>) => ({ value: state.value + 1 })
},
{value: 1}
);
typedState = typedActionHandlerReducerMap({ value: 0 }, actionFrom1Arg);
const typedIncrementByActionWithMetaAnyArgs: (...args: any[]) => ReduxActions.ActionMeta<TypedPayload, MetaType> =
ReduxActions.createAction<TypedPayload, MetaType>(
'INCREMENT_BY',
amount => ({ increase: amount }),
(_, remote) => ({ remote })
);
const actionMetaFromAnyArgs = typedIncrementByActionWithMetaAnyArgs(10, true, 'nic', 'cage');
actionMetaFromAnyArgs.payload.increase === 10;
actionMetaFromAnyArgs.meta.remote;
const typedActionHandlerWithMeta = ReduxActions.handleAction<TypedState, TypedPayload, MetaType>(
'INCREMENT_BY', {
next(state: TypedState, action: ReduxActions.Action<TypedPayload>) {
return { value: state.value + action.payload.increase };
next(state: TypedState, action: ReduxActions.ActionMeta<TypedPayload, MetaType>) {
return action.meta.remote ? state : { value: state.value + action.payload.increase };
},
throw(state: TypedState) { return state; }
},
{value: 1}
);
typedState = typedActionHandlerWithReduceMap({ value: 0 }, typedIncrementByActionWithMeta(10));
typedState = typedActionHandlerWithMeta({ value: 0 }, typedIncrementByActionWithMetaAnyArgs(10));
const typedActionHandlerReducerMetaMap = ReduxActions.handleActions<TypedState, TypedPayload, MetaType>(
{
INCREMENT_BY: {
next(state: TypedState, action: ReduxActions.ActionMeta<TypedPayload, MetaType>) {
return action.meta.remote ? state : { value: state.value + action.payload.increase };
},
throw(state: TypedState) { return state; }
}
},
{value: 1}
);
typedState = typedActionHandlerReducerMetaMap({ value: 0 }, actionMetaFromAnyArgs);
const typedActionWithMeta1TypedArg: (value: number) => ReduxActions.ActionMeta<TypedPayload, MetaType> =
ReduxActions.createAction<TypedPayload, MetaType, number>(
'INCREMENT_BY',
amount => ({ increase: amount }),
amount => ({ remote: true })
);
const actionMetaFrom1Arg = typedActionWithMeta1TypedArg(10);
actionMetaFrom1Arg.payload.increase === 10;
actionMetaFrom1Arg.meta.remote;
typedState = typedActionHandlerReducerMetaMap({ value: 0 }, actionMetaFrom1Arg);
const typedActionWithMeta2TypedArgs: (value: number, remote: boolean) => ReduxActions.ActionMeta<TypedPayload, MetaType> =
ReduxActions.createAction<TypedPayload, MetaType, number, boolean>(
'INCREMENT_BY',
(amount, remote) => ({ increase: amount }),
(amount, remote) => ({ remote })
);
const actionMetaFrom2Args = typedActionWithMeta2TypedArgs(10, true);
actionMetaFrom2Args.payload.increase === 10;
actionMetaFrom2Args.meta.remote;
typedState = typedActionHandlerReducerMetaMap({ value: 0 }, actionMetaFrom2Args);
const act0 = ReduxActions.createAction('ACTION0');
act0().payload === null;

View File

@@ -1,6 +1,7 @@
// Type definitions for webpack (module API) 1.13
// Project: https://github.com/webpack/webpack
// Definitions by: use-strict <https://github.com/use-strict>
// rhonsby <https://github.com/rhonsby>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
@@ -60,7 +61,7 @@ declare namespace __WebpackModuleApi {
loaded: boolean;
parent: any;
children: any[];
hot: Hot;
hot?: Hot;
}
type ModuleId = string|number;