Merge remote-tracking branch 'refs/remotes/DefinitelyTyped/master'

This commit is contained in:
springbov
2016-03-31 11:31:36 -06:00
63 changed files with 6690 additions and 1698 deletions
@@ -0,0 +1,60 @@
/// <reference path="match-media.d.ts" />
var myApp = angular.module('testModule', ['matchMedia']);
myApp.controller('TestController', ($log: angular.ILogService,
$scope: angular.IScope,
screenSize: angular.matchmedia.IScreenSize) => {
var fnCallback = (result: boolean) => {
$log.info(`Result: ${result}`);
}
// '.isRetina' examples
if(screenSize.isRetina) {
$log.info("Retina screen detected")
}
// '.is(...)' examples
var res = screenSize.is(["xs", "sm"]);
fnCallback(res);
res = screenSize.is("xs, lg")
fnCallback(res);
// '.on(...)' examples
res = screenSize.on(["xs", "sm"], fnCallback);
fnCallback(res);
res = screenSize.on("xs, lg", fnCallback);
fnCallback(res);
res = screenSize.on(["xs", "sm"], fnCallback, $scope);
fnCallback(res);
res = screenSize.on("xs, lg", fnCallback, $scope);
fnCallback(res);
// '.onChange(...)' examples
res = screenSize.onChange($scope, ["xs", "sm"], fnCallback);
fnCallback(res);
res = screenSize.onChange($scope, "xs, lg", fnCallback);
fnCallback(res);
// '.when(...)' examples
res = screenSize.when(["xs", "sm"], fnCallback);
fnCallback(res);
res = screenSize.when("xs, lg", fnCallback);
fnCallback(res);
res = screenSize.when(["xs", "sm"], fnCallback, $scope);
fnCallback(res);
res = screenSize.when("xs, lg", fnCallback, $scope);
fnCallback(res);
});
+30
View File
@@ -0,0 +1,30 @@
// Type definitions for Angular matchMedia 0.6.0 (angular.matchMedia module)
// Project: https://github.com/jacopotarantino/angular-match-media
// Definitions by: Joao Monteiro <https://github.com/jpmnteiro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare namespace angular.matchmedia {
interface IScreenSize {
// Returns a value indicating if the current device has a retina screen
isRetina: boolean;
is(list: Array<string> | string): boolean;
// Executes the callback function on window resize with the match truthiness as the first argument.
// Returns the current match truthiness.
// The 'scope' parameter is optional. If it's not passed in, '$rootScope' is used.
on(list: Array<string> | string, callback: (result: boolean) => void, scope?: angular.IScope): boolean;
// Executes the callback function ONLY when the match differs from previous match.
// Returns the current match truthiness.
// The 'scope' parameter is required for cleanup reasons (destroy event).
onChange(scope: angular.IScope, list: Array<string> | string, callback: (result: boolean) => void): boolean;
// Executes the callback only when inside of the particular screensize.
// The 'scope' parameter is optional. If it's not passed in, '$rootScope' is used.
when(list: Array<string> | string, callback: (result: boolean) => void, scope?: angular.IScope): boolean;
}
}
+19 -19
View File
@@ -45,7 +45,7 @@ declare namespace angular {
specificity(): number;
resolveComponent(): Promise<ComponentInstruction>;
resolveComponent(): IPromise<ComponentInstruction>;
/**
* converts the instruction into a URL string
@@ -87,20 +87,20 @@ declare namespace angular {
* Called by the Router to instantiate a new component during the commit phase of a navigation.
* This method in turn is responsible for calling the `routerOnActivate` hook of its child.
*/
activate(nextInstruction: ComponentInstruction): Promise<any>;
activate(nextInstruction: ComponentInstruction): IPromise<any>;
/**
* Called by the {@link Router} during the commit phase of a navigation when an outlet
* reuses a component between different routes.
* This method in turn is responsible for calling the `routerOnReuse` hook of its child.
*/
reuse(nextInstruction: ComponentInstruction): Promise<any>;
reuse(nextInstruction: ComponentInstruction): IPromise<any>;
/**
* Called by the {@link Router} when an outlet disposes of a component's contents.
* This method in turn is responsible for calling the `routerOnDeactivate` hook of its child.
*/
deactivate(nextInstruction: ComponentInstruction): Promise<any>;
deactivate(nextInstruction: ComponentInstruction): IPromise<any>;
/**
* Called by the {@link Router} during recognition phase of a navigation.
@@ -110,7 +110,7 @@ declare namespace angular {
* This method delegates to the child component's `routerCanDeactivate` hook if it exists,
* and otherwise resolves to true.
*/
routerCanDeactivate(nextInstruction: ComponentInstruction): Promise<boolean>;
routerCanDeactivate(nextInstruction: ComponentInstruction): IPromise<boolean>;
/**
* Called by the {@link Router} during recognition phase of a navigation.
@@ -122,7 +122,7 @@ declare namespace angular {
* Otherwise, this method delegates to the child component's `routerCanReuse` hook if it exists,
* or resolves to true if the hook is not present.
*/
routerCanReuse(nextInstruction: ComponentInstruction): Promise<boolean>;
routerCanReuse(nextInstruction: ComponentInstruction): IPromise<boolean>;
}
interface RouteRegistry {
@@ -140,7 +140,7 @@ declare namespace angular {
* Given a URL and a parent component, return the most specific instruction for navigating
* the application into the state specified by the url
*/
recognize(url: string, ancestorInstructions: Instruction[]): Promise<Instruction>;
recognize(url: string, ancestorInstructions: Instruction[]): IPromise<Instruction>;
/**
* Given a normalized list with component names and params like: `['user', {id: 3 }]`
@@ -197,14 +197,14 @@ declare namespace angular {
*
* You probably don't need to use this unless you're writing a reusable component.
*/
registerPrimaryOutlet(outlet: RouterOutlet): Promise<boolean>;
registerPrimaryOutlet(outlet: RouterOutlet): IPromise<boolean>;
/**
* Register an outlet to notified of auxiliary route changes.
*
* You probably don't need to use this unless you're writing a reusable component.
*/
registerAuxOutlet(outlet: RouterOutlet): Promise<boolean>;
registerAuxOutlet(outlet: RouterOutlet): IPromise<boolean>;
/**
* Given an instruction, returns `true` if the instruction is currently active,
@@ -224,7 +224,7 @@ declare namespace angular {
* ]);
* ```
*/
config(definitions: RouteDefinition[]): Promise<any>;
config(definitions: RouteDefinition[]): IPromise<any>;
/**
* Navigate based on the provided Route Link DSL. It's preferred to navigate with this method
@@ -238,7 +238,7 @@ declare namespace angular {
* ```
* See the {@link RouterLink} directive for more.
*/
navigate(linkParams: any[]): Promise<any>;
navigate(linkParams: any[]): IPromise<any>;
/**
* Navigate to a URL. Returns a promise that resolves when navigation is complete.
@@ -247,19 +247,19 @@ declare namespace angular {
* If the given URL begins with a `/`, router will navigate absolutely.
* If the given URL does not begin with `/`, the router will navigate relative to this component.
*/
navigateByUrl(url: string, _skipLocationChange?: boolean): Promise<any>;
navigateByUrl(url: string, _skipLocationChange?: boolean): IPromise<any>;
/**
* Navigate via the provided instruction. Returns a promise that resolves when navigation is
* complete.
*/
navigateByInstruction(instruction: Instruction,
_skipLocationChange?: boolean): Promise<any>;
_skipLocationChange?: boolean): IPromise<any>;
/**
* Updates this router and all descendant routers according to the given instruction
*/
commit(instruction: Instruction, _skipLocationChange?: boolean): Promise<any>;
commit(instruction: Instruction, _skipLocationChange?: boolean): IPromise<any>;
/**
* Subscribe to URL updates from the router
@@ -269,18 +269,18 @@ declare namespace angular {
/**
* Removes the contents of this router's outlet and all descendant outlets
*/
deactivate(instruction: Instruction): Promise<any>;
deactivate(instruction: Instruction): IPromise<any>;
/**
* Given a URL, returns an instruction representing the component graph
*/
recognize(url: string): Promise<Instruction>;
recognize(url: string): IPromise<Instruction>;
/**
* Navigates to either the last URL successfully navigated to, or the last URL requested if the
* router has yet to successfully navigate.
*/
renavigate(): Promise<any>;
renavigate(): IPromise<any>;
/**
* Generate an `Instruction` based on the provided Route Link DSL.
@@ -364,7 +364,7 @@ declare namespace angular {
* {@example router/ts/can_deactivate/can_deactivate_example.ts region='routerCanDeactivate'}
*/
interface CanDeactivate {
$routerCanDeactivate(next?: ComponentInstruction, prev?: ComponentInstruction): boolean | Promise<boolean>;
$routerCanDeactivate(next?: ComponentInstruction, prev?: ComponentInstruction): boolean | IPromise<boolean>;
}
/**
@@ -407,7 +407,7 @@ declare namespace angular {
* {@example router/ts/reuse/reuse_example.ts region='reuseCmp'}
*/
interface CanReuse {
$routerCanReuse(next?: angular.ComponentInstruction, prev?: angular.ComponentInstruction): boolean | Promise<boolean>;
$routerCanReuse(next?: angular.ComponentInstruction, prev?: angular.ComponentInstruction): boolean | IPromise<boolean>;
}
/**
+5
View File
@@ -1845,6 +1845,11 @@ declare namespace angular {
controller(name: string): any;
injector(): any;
scope(): IScope;
/**
* Overload for custom scope interfaces
*/
scope<T extends IScope>(): T;
isolateScope(): IScope;
inheritedData(key: string, value: any): JQuery;
+1 -1
View File
@@ -192,7 +192,7 @@ file.upload('cdvfile://localhost/persistent/path/to/downloads/',
console.error('Failed with exception ' + err.exception);
}
},
{ headers: null, httpMethod: "PUT" },
{ headers: {"X-Email": "user@mail.com", 'X-Token': "asdf3w234"}, httpMethod: "PUT" },
true);
file.abort();
+1 -1
View File
@@ -93,7 +93,7 @@ interface FileUploadOptions {
/** Whether to upload the data in chunked streaming mode. Defaults to true. */
chunkedMode?: boolean;
/** A map of header name/header values. Use an array to specify more than one value. */
headers?: Object[];
headers?: Object;
}
/** Optional parameters for download method. */
+15
View File
@@ -0,0 +1,15 @@
/// <reference path="dotenv.d.ts" />
import dotenv = require('dotenv');
dotenv.config({
silent: true
});
dotenv.config({
path: '.env'
})
dotenv.config({
encoding: 'utf8'
})
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for dotenv 2.0.0
// Project: https://github.com/motdotla/dotenv
// Definitions by: Jussi Kinnula <https://github.com/jussikinnula/>
// Definitions: https://github.com/jussikinnula/DefinitelyTyped
interface dotenvOptions {
silent?: boolean;
path?: string;
encoding?: string;
}
declare module 'dotenv' {
export function config(options?: dotenvOptions): boolean;
}
+7
View File
@@ -0,0 +1,7 @@
/// <reference path="./evaporate.d.ts" />
function test_upload() {
var evaporate = new Evaporate({});
var uploadId = evaporate.add({});
evaporate.cancel(uploadId);
}
+13
View File
@@ -0,0 +1,13 @@
// Type definitions for EvaporateJS
// Project: https://github.com/TTLabs/EvaporateJS
// Definitions by: Andrew Kuklewicz <https://github.com/kookster/>, Chris Rhoden <https://github.com/chrisrhoden>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Evaporate {
cancel(id:string): boolean;
constructor(config:any);
add(config:any): string;
}
declare module 'evaporate' {
export = Evaporate;
}
+8 -8
View File
@@ -88,16 +88,16 @@ interface RowData {
interface MyCellProps extends CellProps {
rowIndex?: number;
field: string;
data: RowData[];
myData: RowData[];
}
class MyTextCell extends React.Component<MyCellProps, {}> {
render(): React.ReactElement<any> {
const {rowIndex, field, data} = this.props;
const {rowIndex, field, myData} = this.props;
return (
<Cell {...this.props}>
{data[rowIndex][field]}
<Cell {...this.props} className="text-cell">
{myData[rowIndex][field]}
</Cell>
);
}
@@ -105,11 +105,11 @@ class MyTextCell extends React.Component<MyCellProps, {}> {
class MyLinkCell extends React.Component<MyCellProps, {}> {
render(): React.ReactElement<any> {
const {rowIndex, field, data} = this.props;
const link: string = data[rowIndex][field];
const {rowIndex, field, myData} = this.props;
const link: string = myData[rowIndex][field];
return (
<Cell {...this.props}>
<Cell {...this.props} className="link-cell">
<a href={link}>{link}</a>
</Cell>
);
@@ -150,7 +150,7 @@ class MyTable4 extends React.Component<{}, MyTable4State> {
header={<Cell>{field}</Cell>}
cell={
<MyTextCell
data={this.state.tableData}
myData={this.state.tableData}
field={field}
/>
}
+2 -2
View File
@@ -458,11 +458,11 @@ declare namespace FixedDataTable {
* />
* );
*/
export interface CellProps {
export interface CellProps extends __React.HTMLAttributes {
/**
* The row index of the cell.
*/
rowIndex?: number
rowIndex?: number;
/**
* Outer height of the cell.
+5 -1
View File
@@ -6,6 +6,10 @@ function dateOnly() {
fromnow( '2015-12-31' );
}
function dateObjectOnly() {
fromnow( new Date() );
}
function maxChunks() {
fromnow( '2015-12-31', {
maxChunks: 12
@@ -22,4 +26,4 @@ function useAnd() {
fromnow( '2015-12-31', {
useAnd: true
});
}
}
+2 -2
View File
@@ -12,13 +12,13 @@ declare namespace FromNow {
export interface FromNowStatic {
/**
* Get readable time differences from now vs past or future dates.
* @param {string} date
* @param {string|Date} date
* @param {object} [opts]
* @param {number} [opts.maxChucks=10]
* @param {boolean} [opts.useAgo=false]
* @param {boolean} [opts.useAnd=false]
*/
(date: string, opts?: FromNowOpts): string
(date: string|Date, opts?: FromNowOpts): string
}
}
+2 -1
View File
@@ -166,7 +166,8 @@ declare module "fs-extra-promise" {
export function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher;
export function exists(path: string, callback?: (exists: boolean) => void): void;
export function existsSync(path: string): boolean;
export function ensureDir(path: string, cb: (err: Error) => void): void;
export function ensureDir(path: string, cb: (err: Error) => void): void;
export function ensureDirSync(path: string): void;
export interface OpenOptions {
encoding?: string;
+9 -1
View File
@@ -127,13 +127,21 @@ declare namespace gapi.auth {
}
declare namespace gapi.client {
/**
* Loads the client library interface to a particular API. If a callback is not provided, a promise is returned.
* @param name The name of the API to load.
* @param version The version of the API to load.
* @return promise The promise that get's resolved after the request is finished.
*/
export function load(name: string, version: string): Promise<void>
/**
* Loads the client library interface to a particular API. The new API interface will be in the form gapi.client.api.collection.method.
* @param name The name of the API to load.
* @param version The version of the API to load
* @param callback the function that is called once the API interface is loaded
*/
export function load(name: string, version: string, callback?: () => any): void;
export function load(name: string, version: string, callback: () => any): void;
/**
* Creates a HTTP request for making RESTful requests.
* An object encapsulating the various arguments for this method.
+2 -2
View File
@@ -1,6 +1,6 @@
/// <reference path="./geojson.d.ts" />
var featureCollection: GeoJSON.FeatureCollection = {
var featureCollection: GeoJSON.FeatureCollection<any> = {
type: "FeatureCollection",
features: [
{
@@ -54,7 +54,7 @@ var featureCollection: GeoJSON.FeatureCollection = {
}
}
var feature: GeoJSON.Feature = {
var feature: GeoJSON.Feature<GeoJSON.Polygon> = {
type: "Feature",
bbox: [-180.0, -90.0, 180.0, 90.0],
geometry: {
+4 -4
View File
@@ -90,9 +90,9 @@ declare namespace GeoJSON {
/***
* http://geojson.org/geojson-spec.html#feature-objects
*/
export interface Feature extends GeoJsonObject
export interface Feature<T extends GeometryObject> extends GeoJsonObject
{
geometry: GeometryObject;
geometry: T;
properties: any;
id?: string;
}
@@ -100,9 +100,9 @@ declare namespace GeoJSON {
/***
* http://geojson.org/geojson-spec.html#feature-collection-objects
*/
export interface FeatureCollection extends GeoJsonObject
export interface FeatureCollection<T extends GeometryObject> extends GeoJsonObject
{
features: Feature[];
features: Feature<T>[];
}
/***
Vendored
+3
View File
@@ -9,6 +9,9 @@ declare module "gm" {
import stream = require('stream');
function m(image: string): m.State;
function m(stream:NodeJS.ReadableStream, image?: string): m.State;
function m(buffer:Buffer, image?: string): m.State;
function m(width:number, height:number, color?:string): m.State;
namespace m {
export interface ClassOptions {
+4 -1
View File
@@ -1638,7 +1638,10 @@ declare namespace google.maps {
}
/***** Events *****/
export interface MapsEventListener { }
export interface MapsEventListener {
/** Removes the listener. Equivalent to calling google.maps.event.removeListener(listener). */
remove(): void;
}
export class event {
/**
@@ -1,10 +1,23 @@
///<reference path="i18next-sprintf-postprocessor.d.ts"/>
///<reference path="./i18next-sprintf-postprocessor.d.ts"/>
import * as i18next from "i18next";
import sprintf from "i18next-sprintf-postprocessor";
import * as sprintfA from "i18next-sprintf-postprocessor";
import sprintfB from "i18next-sprintf-postprocessor/dist/commonjs";
function initTest() {
const i18nextOptions = {};
i18next.use(sprintf).init(i18nextOptions);
i18next.init({ overloadTranslationOptionHandler: sprintf.overloadTranslationOptionHandler });
i18next
.use(sprintfA)
.use(sprintfB)
.init(i18nextOptions);
i18next
.init({ overloadTranslationOptionHandler: sprintfA.overloadTranslationOptionHandler });
i18next
.init({ overloadTranslationOptionHandler: sprintfB.overloadTranslationOptionHandler });
}
function tTest() {
i18next.t('interpolationTest1', 'a', 'b', 'c', 'd');
i18next.t('interpolationTest3', 'z');
i18next.t('interpolationTest4', 0);
}
@@ -3,29 +3,32 @@
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference path="../express/express.d.ts"/>
///<reference path="../i18next/i18next-2.0.17.d.ts"/>
///<reference path="../i18next/i18next.d.ts"/>
declare namespace I18next {
interface I18nextOptions extends i18nextSprintfPostProcessor.I18nextOptions {}
}
declare namespace i18nextSprintfPostProcessor {
interface I18nextOptions {
overloadTranslationOptionHandler?(args: Array<any>): void;
process?(value: any, key: string, options: Object): void;
}
interface I18n {
t(key: string, ...args: any[]): string;
}
}
declare module "i18next-sprintf-postprocessor" {
import i18next = require("i18next");
interface i18nextSprintfPostProcessor {
(): any;
process(value: any, key: string, options: Object): void;
overloadTranslationOptionHandler(args: Array<any>): void;
interface I18nextSprintfPostProcessor {
name: string;
type: string;
process(value: any, key: string, options: any): any;
overloadTranslationOptionHandler(args: string[]): {
postProcess: "sprintf",
sprintf: string[]
};
}
var sprintf: i18nextSprintfPostProcessor;
var sprintf: I18nextSprintfPostProcessor;
export = sprintf;
}
declare module "i18next-sprintf-postprocessor/dist/commonjs" {
import sprintf = require("i18next-sprintf-postprocessor");
export default sprintf;
}
-3
View File
@@ -5,10 +5,7 @@
// Sources: https://github.com/jamuhl/i18next/
/// <reference path="../express/express.d.ts" />
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="../i18next-express-middleware/i18next-express-middleware.d.ts" />
/// <reference path="../i18next-sprintf-postprocessor/i18next-sprintf-postprocessor.d.ts" />
declare namespace I18next {
export interface I18nextStatic {}
+1 -1
View File
@@ -280,7 +280,7 @@ declare namespace Handsontable {
/**
* Setting to true enables the autoColumnSize plugin, which makes sure each column gets enough space to show its content.
*/
autoColumnSize?: boolean;
autoColumnSize?: boolean | Object;
/**
* Setting to true enables the observeChanges plugin, which automatically renders the table when a change in the data source is observed.
+3482
View File
File diff suppressed because it is too large Load Diff
+52
View File
@@ -0,0 +1,52 @@
// Type definitions for jsen (JSON Sentinel)
// Project: https://github.com/bugventure/jsen
// Definitions by: Vladimir Đokić <https://github.com/vladeck/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module Jsen {
export interface JsenFormats {
[key: string]: string | RegExp | Function;
}
export interface JsenSettings {
missing$Ref?: boolean;
greedy?: boolean;
formats?: JsenFormats;
schemas?: any;
}
export interface JsenBuildSettings {
copy?: boolean;
additionalProperties?: boolean;
}
export interface JsenValidator {
(data?: any): boolean;
build(initial?: any, options?: JsenBuildSettings): any;
errors: JsenValidateError[];
}
export interface JsenValidateError {
path: string;
keyword: string;
message?: string;
}
export interface JsenUnique {
(array: any[]): boolean;
findIndex(array: any[], value: any, comparator: (obj1: any, obj2: any) => boolean): number;
}
export interface JsenMain {
(schema?: any, options?: JsenSettings): JsenValidator;
clone(data: any): any;
equal(a: any, b: any): boolean;
unique: JsenUnique;
}
}
declare module "jsen" {
var _jsen: Jsen.JsenMain;
export = _jsen;
}
+4 -4
View File
@@ -2000,11 +2000,11 @@ declare namespace L {
export function closestPointOnSegment(p: Point, p1: Point, p2: Point): Point;
/**
* Clips the segment a to b by rectangular bounds (modifying the segment points
* directly!). Used by Leaflet to only show polyline points that are on the screen
* or near, increasing performance.
* Clips the segment a to b by rectangular bounds. Used by Leaflet to only show
* polyline points that are on the screen or near, increasing performance. Returns
* either false or a length-2 array of clipped points.
*/
export function clipSegment(a: Point, b: Point, bounds: Bounds): void;
export function clipSegment(a: Point, b: Point, bounds: Bounds): Point[] | boolean;
}
}
+123 -25
View File
@@ -5003,13 +5003,6 @@ namespace TestReject {
}
}
result = <number>_.sample([1, 2, 3, 4]);
result = <number[]>_.sample([1, 2, 3, 4], 2);
result = <_.LoDashImplicitWrapper<number>>_([1, 2, 3, 4]).sample();
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).sample(2);
result = <number>_([1, 2, 3, 4]).sample().value();
result = <number[]>_([1, 2, 3, 4]).sample(2).value();
// _.select
namespace TestSelect {
let array: TResult[];
@@ -5108,6 +5101,78 @@ namespace TestSelect {
}
}
// _.sample
namespace TestSample {
let array: string[];
let list: _.List<string>;
let dictionary: _.Dictionary<string>;
let numericDictionary: _.NumericDictionary<string>;
{
let result: string;
result = _.sample('abc');
result = _.sample(array);
result = _.sample(list);
result = _.sample(dictionary);
result = _.sample(numericDictionary);
result = _.sample<{a: string}, string>({a: 'foo'});
result = _.sample<string>({a: 'foo'});
result = _('abc').sample();
result = _(array).sample();
result = _(list).sample<string>();
result = _(dictionary).sample<string>();
result = _(numericDictionary).sample<string>();
result = _({a: 'foo'}).sample<string>();
}
{
let result: string[];
result = _.sample('abc', 42);
result = _.sample(array, 42);
result = _.sample(list, 42);
result = _.sample(dictionary, 42);
result = _.sample(numericDictionary, 42);
result = _.sample<{a: string}, string>({a: 'foo'}, 42);
result = _.sample<string>({a: 'foo'}, 42);
}
{
let result: _.LoDashImplicitArrayWrapper<string>;
result = _('abc').sample(42);
result = _(array).sample(42);
result = _(list).sample<string>(42);
result = _(dictionary).sample<string>(42);
result = _(numericDictionary).sample<string>(42);
result = _({a: 'foo'}).sample<string>(42);
}
{
let result: _.LoDashExplicitWrapper<string>;
result = _('abc').chain().sample();
result = _(array).chain().sample<_.LoDashExplicitWrapper<string>>();
result = _(list).chain().sample<_.LoDashExplicitWrapper<string>>();
result = _(dictionary).chain().sample<_.LoDashExplicitWrapper<string>>();
result = _(numericDictionary).chain().sample<_.LoDashExplicitWrapper<string>>();
result = _({a: 'foo'}).chain().sample<_.LoDashExplicitWrapper<string>>();
}
{
let result: _.LoDashExplicitArrayWrapper<string>;
result = _('abc').chain().sample(42);
result = _(array).chain().sample(42);
result = _(list).chain().sample<string>(42);
result = _(dictionary).chain().sample<string>(42);
result = _(numericDictionary).chain().sample<string>(42);
result = _({a: 'foo'}).chain().sample<string>(42);
}
}
// _.shuffle
namespace TestShuffle {
let array: TResult[];
@@ -6097,20 +6162,42 @@ namespace TestFlowRight {
// _.memoize
namespace TestMemoize {
var testMemoizedFunction: _.MemoizedFunction;
var cache = <_.MapCache>testMemoizedFunction.cache;
interface TestMemoizedResultFn extends _.MemoizedFunction {
{
let memoizedFunction: _.MemoizedFunction;
let cache: _.MapCache = memoizedFunction.cache;
}
interface MemoizedResultFn extends _.MemoizedFunction {
(a1: string, a2: number): boolean;
}
var testMemoizeFn = (a1: string, a2: number) => a1.length > a2;
var testMemoizeResolverFn = (a1: string, a2: number) => a1 + a2;
var result: TestMemoizedResultFn;
result = _.memoize(testMemoizeFn);
result = _.memoize(testMemoizeFn, testMemoizeResolverFn);
result = _(testMemoizeFn).memoize().value();
result = _(testMemoizeFn).memoize(testMemoizeResolverFn).value();
result('foo', 1);
result.cache.get('foo1');
let memoizeFn: (a1: string, a2: number) => boolean;
let memoizeResolverFn: (a1: string, a2: number) => string;
{
let result: MemoizedResultFn;
result = _.memoize(memoizeFn);
result = _.memoize(memoizeFn, memoizeResolverFn);
result('foo', 1);
result.cache.get('foo1');
}
{
let result: _.LoDashImplicitObjectWrapper<MemoizedResultFn>;
result = _(memoizeFn).memoize();
result = _(memoizeFn).memoize(memoizeResolverFn);
}
{
let result: _.LoDashExplicitObjectWrapper<MemoizedResultFn>;
result = _(memoizeFn).chain().memoize();
result = _(memoizeFn).chain().memoize(memoizeResolverFn);
}
_.memoize.Cache = {
delete: key => false,
get: key => undefined,
@@ -10270,12 +10357,23 @@ namespace TestMixin {
}
// _.noConflict
{
let result: typeof _;
result = _.noConflict();
result = _(42).noConflict();
result = _<any>([]).noConflict();
result = _({}).noConflict();
namespace TestNoConflict {
{
let result: typeof _;
result = _.noConflict();
result = _(42).noConflict();
result = _<any>([]).noConflict();
result = _({}).noConflict();
}
{
let result: _.LoDashExplicitObjectWrapper<typeof _>;
result = _(42).chain().noConflict();
result = _<any>([]).chain().noConflict();
result = _({}).chain().noConflict();
}
}
// _.noop
+150 -50
View File
@@ -8008,56 +8008,6 @@ declare module _ {
reject<W, T>(predicate: W): LoDashExplicitArrayWrapper<T>;
}
//_.sample
interface LoDashStatic {
/**
* Retrieves a random element or n random elements from a collection.
* @param collection The collection to sample.
* @return Returns the random sample(s) of collection.
**/
sample<T>(collection: Array<T>): T;
/**
* @see _.sample
**/
sample<T>(collection: List<T>): T;
/**
* @see _.sample
**/
sample<T>(collection: Dictionary<T>): T;
/**
* @see _.sample
* @param n The number of elements to sample.
**/
sample<T>(collection: Array<T>, n: number): T[];
/**
* @see _.sample
* @param n The number of elements to sample.
**/
sample<T>(collection: List<T>, n: number): T[];
/**
* @see _.sample
* @param n The number of elements to sample.
**/
sample<T>(collection: Dictionary<T>, n: number): T[];
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.sample
**/
sample(n: number): LoDashImplicitArrayWrapper<T>;
/**
* @see _.sample
**/
sample(): LoDashImplicitWrapper<T>;
}
//_.select
interface LoDashStatic {
/**
@@ -8217,6 +8167,141 @@ declare module _ {
select<W, T>(predicate: W): LoDashExplicitArrayWrapper<T>;
}
//_.sample
interface LoDashStatic {
/**
* Gets a random element or n random elements from a collection.
*
* @param collection The collection to sample.
* @return Returns the random sample(s) of collection.
*/
sample<T>(
collection: List<T>|Dictionary<T>|NumericDictionary<T>,
n: number
): T[];
/**
* @see _.sample
*/
sample<O extends Object, T>(
collection: O,
n: number
): T[];
/**
* @see _.sample
*/
sample<T>(
collection: Object,
n: number
): T[];
/**
* @see _.sample
*/
sample<T>(
collection: List<T>|Dictionary<T>|NumericDictionary<T>
): T;
/**
* @see _.sample
*/
sample<O extends Object, T>(
collection: O
): T;
/**
* @see _.sample
*/
sample<T>(
collection: Object
): T;
}
interface LoDashImplicitWrapper<T> {
/**
* @see _.sample
*/
sample(
n: number
): LoDashImplicitArrayWrapper<string>;
/**
* @see _.sample
*/
sample(): string;
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.sample
*/
sample(
n: number
): LoDashImplicitArrayWrapper<T>;
/**
* @see _.sample
*/
sample(): T;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.sample
*/
sample<T>(
n: number
): LoDashImplicitArrayWrapper<T>;
/**
* @see _.sample
*/
sample<T>(): T;
}
interface LoDashExplicitWrapper<T> {
/**
* @see _.sample
*/
sample(
n: number
): LoDashExplicitArrayWrapper<string>;
/**
* @see _.sample
*/
sample(): LoDashExplicitWrapper<string>;
}
interface LoDashExplicitArrayWrapper<T> {
/**
* @see _.sample
*/
sample(
n: number
): LoDashExplicitArrayWrapper<T>;
/**
* @see _.sample
*/
sample<TWrapper>(): TWrapper;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.sample
*/
sample<T>(
n: number
): LoDashExplicitArrayWrapper<T>;
/**
* @see _.sample
*/
sample<TWrapper>(): TWrapper;
}
//_.shuffle
interface LoDashStatic {
/**
@@ -9735,6 +9820,7 @@ declare module _ {
* storing the result based on the arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with
* the this binding of the memoized function.
*
* @param func The function to have its output memoized.
* @param resolver The function to resolve the cache key.
* @return Returns the new memoizing function.
@@ -9752,6 +9838,13 @@ declare module _ {
memoize(resolver?: Function): LoDashImplicitObjectWrapper<T & MemoizedFunction>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.memoize
*/
memoize(resolver?: Function): LoDashExplicitObjectWrapper<T & MemoizedFunction>;
}
//_.modArgs
interface LoDashStatic {
/**
@@ -15430,6 +15523,13 @@ declare module _ {
noConflict(): typeof _;
}
interface LoDashExplicitWrapperBase<T, TWrapper> {
/**
* @see _.noConflict
*/
noConflict(): LoDashExplicitObjectWrapper<typeof _>;
}
//_.noop
interface LoDashStatic {
/**
+146 -24
View File
@@ -5042,14 +5042,103 @@ namespace TestReject {
}
// _.sample
result = <number>_.sample([1, 2, 3, 4]);
result = <_.LoDashImplicitWrapper<number>>_([1, 2, 3, 4]).sample();
result = <number>_([1, 2, 3, 4]).sample().value();
namespace TestSample {
let array: string[];
let list: _.List<string>;
let dictionary: _.Dictionary<string>;
let numericDictionary: _.NumericDictionary<string>;
{
let result: string;
result = _.sample('abc');
result = _.sample(array);
result = _.sample(list);
result = _.sample(dictionary);
result = _.sample(numericDictionary);
result = _.sample<{a: string}, string>({a: 'foo'});
result = _.sample<string>({a: 'foo'});
result = _('abc').sample();
result = _(array).sample();
result = _(list).sample<string>();
result = _(dictionary).sample<string>();
result = _(numericDictionary).sample<string>();
result = _({a: 'foo'}).sample<string>();
}
{
let result: _.LoDashExplicitWrapper<string>;
result = _('abc').chain().sample();
result = _(array).chain().sample<_.LoDashExplicitWrapper<string>>();
result = _(list).chain().sample<_.LoDashExplicitWrapper<string>>();
result = _(dictionary).chain().sample<_.LoDashExplicitWrapper<string>>();
result = _(numericDictionary).chain().sample<_.LoDashExplicitWrapper<string>>();
result = _({a: 'foo'}).chain().sample<_.LoDashExplicitWrapper<string>>();
}
}
// _.sampleSize
result = <number[]>_.sampleSize([1, 2, 3, 4], 2);
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).sampleSize(2);
result = <number[]>_([1, 2, 3, 4]).sampleSize(2).value();
namespace TestSampleSize {
let array: string[];
let list: _.List<string>;
let dictionary: _.Dictionary<string>;
let numericDictionary: _.NumericDictionary<string>;
{
let result: string[];
result = _.sampleSize('abc');
result = _.sampleSize('abc', 42);
result = _.sampleSize(array);
result = _.sampleSize(array, 42);
result = _.sampleSize(list);
result = _.sampleSize(list, 42);
result = _.sampleSize(dictionary);
result = _.sampleSize(dictionary, 42);
result = _.sampleSize(numericDictionary);
result = _.sampleSize(numericDictionary, 42);
result = _.sampleSize<{a: string}, string>({a: 'foo'});
result = _.sampleSize<{a: string}, string>({a: 'foo'}, 42);
result = _.sampleSize<string>({a: 'foo'});
result = _.sampleSize<string>({a: 'foo'}, 42);
}
{
let result: _.LoDashImplicitArrayWrapper<string>;
result = _('abc').sampleSize();
result = _('abc').sampleSize(42);
result = _(array).sampleSize();
result = _(array).sampleSize(42);
result = _(list).sampleSize<string>();
result = _(list).sampleSize<string>(42);
result = _(dictionary).sampleSize<string>();
result = _(dictionary).sampleSize<string>(42);
result = _(numericDictionary).sampleSize<string>();
result = _(numericDictionary).sampleSize<string>(42);
result = _({a: 'foo'}).sampleSize<string>();
result = _({a: 'foo'}).sampleSize<string>(42);
}
{
let result: _.LoDashExplicitArrayWrapper<string>;
result = _('abc').chain().sampleSize();
result = _('abc').chain().sampleSize(42);
result = _(array).chain().sampleSize();
result = _(array).chain().sampleSize(42);
result = _(list).chain().sampleSize<string>();
result = _(list).chain().sampleSize<string>(42);
result = _(dictionary).chain().sampleSize<string>();
result = _(dictionary).chain().sampleSize<string>(42);
result = _(numericDictionary).chain().sampleSize<string>();
result = _(numericDictionary).chain().sampleSize<string>(42);
result = _({a: 'foo'}).chain().sampleSize<string>();
result = _({a: 'foo'}).chain().sampleSize<string>(42);
}
}
// _.shuffle
namespace TestShuffle {
@@ -5977,20 +6066,42 @@ namespace TestFlowRight {
// _.memoize
namespace TestMemoize {
var testMemoizedFunction: _.MemoizedFunction;
var cache = <_.MapCache>testMemoizedFunction.cache;
interface TestMemoizedResultFn extends _.MemoizedFunction {
{
let memoizedFunction: _.MemoizedFunction;
let cache: _.MapCache = memoizedFunction.cache;
}
interface MemoizedResultFn extends _.MemoizedFunction {
(a1: string, a2: number): boolean;
}
var testMemoizeFn = (a1: string, a2: number) => a1.length > a2;
var testMemoizeResolverFn = (a1: string, a2: number) => a1 + a2;
var result: TestMemoizedResultFn;
result = _.memoize(testMemoizeFn);
result = _.memoize(testMemoizeFn, testMemoizeResolverFn);
result = _(testMemoizeFn).memoize().value();
result = _(testMemoizeFn).memoize(testMemoizeResolverFn).value();
result('foo', 1);
result.cache.get('foo1');
let memoizeFn: (a1: string, a2: number) => boolean;
let memoizeResolverFn: (a1: string, a2: number) => string;
{
let result: MemoizedResultFn;
result = _.memoize(memoizeFn);
result = _.memoize(memoizeFn, memoizeResolverFn);
result('foo', 1);
result.cache.get('foo1');
}
{
let result: _.LoDashImplicitObjectWrapper<MemoizedResultFn>;
result = _(memoizeFn).memoize();
result = _(memoizeFn).memoize(memoizeResolverFn);
}
{
let result: _.LoDashExplicitObjectWrapper<MemoizedResultFn>;
result = _(memoizeFn).chain().memoize();
result = _(memoizeFn).chain().memoize(memoizeResolverFn);
}
_.memoize.Cache = {
delete: key => false,
get: key => undefined,
@@ -11506,12 +11617,23 @@ namespace TestMixin {
}
// _.noConflict
{
let result: typeof _;
result = _.noConflict();
result = _(42).noConflict();
result = _<any>([]).noConflict();
result = _({}).noConflict();
namespace TestNoConflict {
{
let result: typeof _;
result = _.noConflict();
result = _(42).noConflict();
result = _<any>([]).noConflict();
result = _({}).noConflict();
}
{
let result: _.LoDashExplicitObjectWrapper<typeof _>;
result = _(42).chain().noConflict();
result = _<any>([]).chain().noConflict();
result = _({}).chain().noConflict();
}
}
// _.noop
+134 -41
View File
@@ -8981,77 +8981,155 @@ declare module _ {
//_.sample
interface LoDashStatic {
/**
* Gets a random element from `collection`.
* Gets a random element from collection.
*
* @static
* @memberOf _
* @category Collection
* @param {Array|Object} collection The collection to sample.
* @returns {*} Returns the random element.
* @example
*
* _.sample([1, 2, 3, 4]);
* // => 2
* @param collection The collection to sample.
* @return Returns the random element.
*/
sample<T>(collection: Array<T>): T;
sample<T>(
collection: List<T>|Dictionary<T>|NumericDictionary<T>
): T;
/**
* @see _.sample
**/
sample<T>(collection: List<T>): T;
* @see _.sample
*/
sample<O extends Object, T>(
collection: O
): T;
/**
* @see _.sample
**/
sample<T>(collection: Dictionary<T>): T;
* @see _.sample
*/
sample<T>(
collection: Object
): T;
}
interface LoDashImplicitWrapper<T> {
/**
* @see _.sample
*/
sample(): string;
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.sample
**/
sample(): LoDashImplicitWrapper<T>;
*/
sample(): T;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.sample
*/
sample<T>(): T;
}
interface LoDashExplicitWrapper<T> {
/**
* @see _.sample
*/
sample(): LoDashExplicitWrapper<string>;
}
interface LoDashExplicitArrayWrapper<T> {
/**
* @see _.sample
*/
sample<TWrapper>(): TWrapper;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.sample
*/
sample<TWrapper>(): TWrapper;
}
//_.sampleSize
interface LoDashStatic {
/**
* Gets `n` random elements from `collection`.
* Gets n random elements at unique keys from collection up to the size of collection.
*
* @static
* @memberOf _
* @category Collection
* @param {Array|Object} collection The collection to sample.
* @param {number} [n=0] The number of elements to sample.
* @returns {Array} Returns the random elements.
* @example
*
* _.sampleSize([1, 2, 3, 4], 2);
* // => [3, 1]
* @param collection The collection to sample.
* @param n The number of elements to sample.
* @return Returns the random elements.
*/
sampleSize<T>(collection: Array<T>, n: number): T[];
sampleSize<T>(
collection: List<T>|Dictionary<T>|NumericDictionary<T>,
n?: number
): T[];
/**
* @see _.sampleSize
**/
sampleSize<T>(collection: List<T>, n: number): T[];
* @see _.sampleSize
*/
sampleSize<O extends Object, T>(
collection: O,
n?: number
): T[];
/**
* @see _.sampleSize
**/
sampleSize<T>(collection: Dictionary<T>, n: number): T[];
* @see _.sampleSize
*/
sampleSize<T>(
collection: Object,
n?: number
): T[];
}
interface LoDashImplicitWrapper<T> {
/**
* @see _.sampleSize
*/
sampleSize(
n?: number
): LoDashImplicitArrayWrapper<string>;
}
interface LoDashImplicitArrayWrapper<T> {
/**
* @see _.sampleSize
**/
sampleSize(n: number): LoDashImplicitArrayWrapper<T>;
*/
sampleSize(
n?: number
): LoDashImplicitArrayWrapper<T>;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.sampleSize
**/
sampleSize(): LoDashImplicitWrapper<T>;
*/
sampleSize<T>(
n?: number
): LoDashImplicitArrayWrapper<T>;
}
interface LoDashExplicitWrapper<T> {
/**
* @see _.sampleSize
*/
sampleSize(
n?: number
): LoDashExplicitArrayWrapper<string>;
}
interface LoDashExplicitArrayWrapper<T> {
/**
* @see _.sampleSize
*/
sampleSize(
n?: number
): LoDashExplicitArrayWrapper<T>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.sampleSize
*/
sampleSize<T>(
n?: number
): LoDashExplicitArrayWrapper<T>;
}
//_.shuffle
@@ -10467,6 +10545,7 @@ declare module _ {
* storing the result based on the arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is coerced to a string and used as the cache key. The func is invoked with
* the this binding of the memoized function.
*
* @param func The function to have its output memoized.
* @param resolver The function to resolve the cache key.
* @return Returns the new memoizing function.
@@ -10484,6 +10563,13 @@ declare module _ {
memoize(resolver?: Function): LoDashImplicitObjectWrapper<T & MemoizedFunction>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.memoize
*/
memoize(resolver?: Function): LoDashExplicitObjectWrapper<T & MemoizedFunction>;
}
//_.overArgs (was _.modArgs)
interface LoDashStatic {
/**
@@ -18614,6 +18700,13 @@ declare module _ {
noConflict(): typeof _;
}
interface LoDashExplicitWrapperBase<T, TWrapper> {
/**
* @see _.noConflict
*/
noConflict(): LoDashExplicitObjectWrapper<typeof _>;
}
//_.noop
interface LoDashStatic {
/**
+4 -16
View File
@@ -35,22 +35,10 @@ interface MomentTimezone {
(date: number, timezone: string): moment.Moment;
(date: number[], timezone: string): moment.Moment;
(date: string, timezone: string): moment.Moment;
(date: string, format: string, timezone: string): moment.Moment;
(date: string, format: string, strict: boolean, timezone: string): moment.Moment;
(date: string, format: string, language: string, timezone: string): moment.Moment;
(date: string, format: string, language: string, strict: boolean, timezone: string): moment.Moment;
(date: string, formats: string[], timezone: string): moment.Moment;
(date: string, formats: string[], strict: boolean, timezone: string): moment.Moment;
(date: string, formats: string[], language: string, timezone: string): moment.Moment;
(date: string, formats: string[], language: string, strict: boolean, timezone: string): moment.Moment;
(date: string, specialFormat: () => void, timezone: string): moment.Moment;
(date: string, specialFormat: () => void, strict: boolean, timezone: string): moment.Moment;
(date: string, specialFormat: () => void, language: string, timezone: string): moment.Moment;
(date: string, specialFormat: () => void, language: string, strict: boolean, timezone: string): moment.Moment;
(date: string, formatsIncludingSpecial: any[], timezone: string): moment.Moment;
(date: string, formatsIncludingSpecial: any[], strict: boolean, timezone: string): moment.Moment;
(date: string, formatsIncludingSpecial: any[], language: string, timezone: string): moment.Moment;
(date: string, formatsIncludingSpecial: any[], language: string, strict: boolean, timezone: string): moment.Moment;
(date: string, format: moment.MomentFormatSpecification, timezone: string): moment.Moment;
(date: string, format: moment.MomentFormatSpecification, strict: boolean, timezone: string): moment.Moment;
(date: string, format: moment.MomentFormatSpecification, language: string, timezone: string): moment.Moment;
(date: string, format: moment.MomentFormatSpecification, language: string, strict: boolean, timezone: string): moment.Moment;
(date: Date, timezone: string): moment.Moment;
(date: moment.Moment, timezone: string): moment.Moment;
(date: Object, timezone: string): moment.Moment;
+9 -9
View File
@@ -571,6 +571,12 @@ declare namespace moment {
yy: any;
}
interface MomentBuiltinFormat {
__momentBuiltinFormatBrand: any;
}
type MomentFormatSpecification = string | MomentBuiltinFormat | (string | MomentBuiltinFormat)[];
interface MomentStatic {
version: string;
fn: Moment;
@@ -578,14 +584,8 @@ declare namespace moment {
(): Moment;
(date: number): Moment;
(date: number[]): Moment;
(date: string, format?: string, strict?: boolean): Moment;
(date: string, format?: string, language?: string, strict?: boolean): Moment;
(date: string, formats: string[], strict?: boolean): Moment;
(date: string, formats: string[], language?: string, strict?: boolean): Moment;
(date: string, specialFormat: () => void, strict?: boolean): Moment;
(date: string, specialFormat: () => void, language?: string, strict?: boolean): Moment;
(date: string, formatsIncludingSpecial: any[], strict?: boolean): Moment;
(date: string, formatsIncludingSpecial: any[], language?: string, strict?: boolean): Moment;
(date: string, format?: MomentFormatSpecification, strict?: boolean): Moment;
(date: string, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment;
(date: Date): Moment;
(date: Moment): Moment;
(date: Object): Moment;
@@ -675,7 +675,7 @@ declare namespace moment {
/**
* Constant used to enable explicit ISO_8601 format parsing.
*/
ISO_8601(): void;
ISO_8601: MomentBuiltinFormat;
defaultFormat: string;
}
+1 -1
View File
@@ -642,7 +642,7 @@ declare module "mongodb" {
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeOrderedBulkOp
initializeOrderedBulkOp(options: CollectionOptions): OrderedBulkOperation;
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#initializeUnorderedBulkOp
initializeUnorderedBulkOp(options: CollectionOptions): OrderedBulkOperation;
initializeUnorderedBulkOp(options: CollectionOptions): UnorderedBulkOperation;
//http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#insertMany
insertMany(docs: Object[], callback: MongoCallback<InsertWriteOpResult>): void
insertMany(docs: Object[], options?: CollectionInsertManyOptions): Promise<InsertWriteOpResult>;
+51
View File
@@ -0,0 +1,51 @@
/// <reference path="ng-facebook.d.ts" />
{
let $facebookProvider: angular.ngFacebook.IFacebookProvider;
$facebookProvider
.setAppId("764262530321266")
.setPermissions(["email", "user_friends"])
.setPermissions("user_friends")
.setCustomInit({
xfbml: true
})
.setVersion("v2.2");
let appId: string = $facebookProvider.getAppId();
let version: string = $facebookProvider.getVersion();
let permissions: string = $facebookProvider.getPermissions();
let customInit: any = $facebookProvider.getCustomInit();
}
{
let $facebook: angular.ngFacebook.IFacebookService;
let customInit: FBInitParams = $facebook.config<FBInitParams>("customInit");
let version: string = $facebook.config<string>("version");
let appId: string = $facebook.config<string>("appId");
$facebook.init();
$facebook.setCache("key1", 123);
$facebook.setCache<{ prop1: number }>("key2", { prop1: 456 });
let cache: number = $facebook.getCache<number>("key");
$facebook.clearCache();
let isConnected: boolean = $facebook.isConnected();
let authResponse: {} = $facebook.getAuthResponse();
$facebook.getLoginStatus().then(status => { });
$facebook.getLoginStatus(true).then(status => { });
$facebook.logout().then(() => { });
$facebook.login().then(() => { });
$facebook.api("/me").then(user => { });
$facebook.api("/me", "get");
$facebook.api("/me", { param: 1 });
$facebook.api("/me", "get", { param: 1 });
$facebook.cachedApi("'/me/friends").then(friends => { });
}
+46
View File
@@ -0,0 +1,46 @@
// Type definitions for ng-facebook
// Project: https://github.com/GoDisco/ngFacebook
// Definitions by: Crevil <https://github.com/Crevil>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
/// <reference path="../fbsdk/fbsdk.d.ts" />
declare namespace angular.ngFacebook {
interface IFacebookProvider {
setAppId(appId: string): IFacebookProvider;
getAppId(): string;
setVersion(version: string): IFacebookProvider;
getVersion(): string;
setPermissions(permissions: string|Array<string>): IFacebookProvider;
getPermissions(): string;
setCustomInit(customInit: FBInitParams): IFacebookProvider;
getCustomInit(): FBInitParams;
}
interface IFacebookService {
config<T extends string|number|FBInitParams>(property: string): T;
init(): void;
setCache<T>(attr: string, val: T): void;
getCache<T>(attr: string): T;
clearCache(): void;
isConnected(): boolean;
getAuthResponse(): {};
getLoginStatus(force?: boolean): angular.IPromise<{}>;
login(permissions?: string, rerequest?: boolean): angular.IPromise<{}>;
logout(): angular.IPromise<void>;
ui(params: FBUIParams): angular.IPromise<any>;
api(path: string): angular.IPromise<{}>;
api(path: string, method: string): angular.IPromise<{}>;
api(path: string, params: Object): angular.IPromise<{}>;
api(path: string, method: string, params: Object): angular.IPromise<{}>;
cachedApi(path: string): angular.IPromise<any>;
}
}
+2 -1
View File
@@ -3,8 +3,9 @@
// Definitions by: Ryan McNamara <https://github.com/ryan10132>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../flowjs/flowjs.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
declare namespace ng.flow {
declare namespace angular.flow {
interface IFlowFactory {
create(options?: flowjs.IFlowOptions): flowjs.IFlow;
}
+52 -1
View File
@@ -16,6 +16,7 @@ import * as path from "path";
import * as readline from "readline";
import * as childProcess from "child_process";
import * as os from "os";
import * as vm from "vm";
// Specifically test buffer module regression.
import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer";
@@ -32,7 +33,8 @@ assert.notDeepStrictEqual({ x: { y: "3" } }, { x: { y: 3 } }, "uses === comparat
assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT");
assert.doesNotThrow(() => {
if (false) { throw "a hammer at your face"; }
const b = false;
if (b) { throw "a hammer at your face"; }
}, undefined, "What the...*crunch*");
////////////////////////////////////////////////////
@@ -679,3 +681,52 @@ namespace os_tests {
result = os.networkInterfaces();
}
}
////////////////////////////////////////////////////
/// vm tests : https://nodejs.org/api/vm.html
////////////////////////////////////////////////////
namespace vm_tests {
{
const sandbox = {
animal: 'cat',
count: 2
};
const context = vm.createContext(sandbox);
console.log(vm.isContext(context));
const script = new vm.Script('count += 1; name = "kitty"');
for (let i = 0; i < 10; ++i) {
script.runInContext(context);
}
console.log(util.inspect(sandbox));
vm.runInNewContext('count += 1; name = "kitty"', sandbox);
console.log(util.inspect(sandbox));
}
{
const sandboxes = [{}, {}, {}];
const script = new vm.Script('globalVar = "set"');
sandboxes.forEach((sandbox) => {
script.runInNewContext(sandbox);
script.runInThisContext();
});
console.log(util.inspect(sandboxes));
var localVar = 'initial value';
vm.runInThisContext('localVar = "vm";');
console.log(localVar);
}
{
const Debug = vm.runInDebugContext('Debug');
Debug.scripts().forEach(function(script: any) { console.log(script.name); });
}
}
+27 -8
View File
@@ -932,15 +932,34 @@ declare module "readline" {
declare module "vm" {
export interface Context { }
export interface Script {
runInThisContext(): void;
runInNewContext(sandbox?: Context): void;
export interface ScriptOptions {
filename?: string;
lineOffset?: number;
columnOffset?: number;
displayErrors?: boolean;
timeout?: number;
cachedData?: Buffer;
produceCachedData?: boolean;
}
export function runInThisContext(code: string, filename?: string): void;
export function runInNewContext(code: string, sandbox?: Context, filename?: string): void;
export function runInContext(code: string, context: Context, filename?: string): void;
export function createContext(initSandbox?: Context): Context;
export function createScript(code: string, filename?: string): Script;
export interface RunningScriptOptions {
filename?: string;
lineOffset?: number;
columnOffset?: number;
displayErrors?: boolean;
timeout?: number;
}
export class Script {
constructor(code: string, options?: ScriptOptions);
runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any;
runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any;
runInThisContext(options?: RunningScriptOptions): any;
}
export function createContext(sandbox?: Context): Context;
export function isContext(sandbox: Context): boolean;
export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any;
export function runInDebugContext(code: string): any;
export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any;
export function runInThisContext(code: string, options?: RunningScriptOptions): any;
}
declare module "child_process" {
+1
View File
@@ -23,6 +23,7 @@ OracleDB.getConnection(
console.error(err.message); return;
}
console.log(result.rows);
console.log(result.rows[0].department_id); // when outFormet is OBJECT
}
);
}
+1 -1
View File
@@ -93,7 +93,7 @@ declare module 'oracledb' {
/** Metadata information - just columns names for now. */
metaData?: Array<IMetaData>;
/** When not using ResultSet, query results comes here. */
rows?: Array<Array<any>> | Array<Object>;
rows?: Array<Array<any>> | Array<any>;
/** When using ResultSet, query results comes here. */
resultSet?: IResultSet;
}
+36
View File
@@ -0,0 +1,36 @@
/// <reference path="passport-jwt.d.ts" />
/// <reference path="../passport/passport.d.ts" />
'use strict';
import {Strategy as JwtStrategy, ExtractJwt, StrategyOptions} from 'passport-jwt';
import {Request} from 'express';
import * as passport from 'passport';
let opts: StrategyOptions = {
jwtFromRequest: ExtractJwt.fromAuthHeader(),
secretOrKey: 'secret',
issuer: "accounts.example.com",
audience: "example.org"
};
passport.use(new JwtStrategy(opts, function(jwt_payload, done) {
findUser({id: jwt_payload.sub}, function(err, user) {
if (err) {
return done(err, false);
}
if (user) {
done(null, user);
} else {
done(null, false, {message: 'foo'});
// or you could create a new account
}
});
}));
opts.jwtFromRequest = ExtractJwt.fromHeader('x-api-key');
opts.jwtFromRequest = ExtractJwt.fromBodyField('field_name');
opts.jwtFromRequest = ExtractJwt.fromUrlQueryParameter('param_name');
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('param_name');
opts.jwtFromRequest = (req: Request) => { return req.query.token; };
declare function findUser(condition: {id: string}, callback: (error: any, user :any) => void): void;
+50
View File
@@ -0,0 +1,50 @@
// Type definitions for passport-jwt 2.0
// Project: https://github.com/themikenicholson/passport-jwt
// Definitions by: TANAKA Koichi <https://github.com/mugeso/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../passport-strategy/passport-strategy.d.ts" />
/// <reference path="../express/express.d.ts" />
declare module 'passport-jwt' {
import {Strategy as PassportStrategy} from 'passport-strategy';
import {Request} from 'express';
export class Strategy extends PassportStrategy {
constructor(opt: StrategyOptions, verify: VerifyCallback);
constructor(opt: StrategyOptions, verify: VerifyCallbackWithRequest);
}
export interface StrategyOptions {
secretOrKey: string;
jwtFromRequest: JwtFromRequestFunction;
issuer?: string;
audience?: string;
algorithms?: string[];
ignoreExpiration?: boolean;
passReqToCallback?: boolean;
}
export interface VerifyCallback {
(payload: any, done: VerifiedCallback): void;
}
export interface VerifyCallbackWithRequest {
(req: Request, payload: any, done: VerifiedCallback): void;
}
export interface VerifiedCallback {
(error: any, user?: any, info?: any): void;
}
export interface JwtFromRequestFunction {
(req: Request): string;
}
export namespace ExtractJwt {
export function fromHeader(header_name: string): JwtFromRequestFunction;
export function fromBodyField(field_name: string): JwtFromRequestFunction;
export function fromUrlQueryParameter(param_name: string): JwtFromRequestFunction;
export function fromAuthHeaderWithScheme(auth_scheme: string): JwtFromRequestFunction;
export function fromAuthHeader(): JwtFromRequestFunction;
}
}
+18
View File
@@ -0,0 +1,18 @@
/// <reference path="password-hash.d.ts" />
'use strict';
import {generate, verify, isHashed} from 'password-hash';
let password = 'raw-password';
let hashed: string;
hashed = generate(password);
hashed = generate(password, {algorithm: 'sha256'});
hashed = generate(password, {saltLength: 10});
hashed = generate(password, {iterations: 11});
hashed = generate(password, {algorithm: 'sha512', saltLength: 9, iterations: 11});
let isOk: boolean;
isOk = verify(password, hashed);
isOk = isHashed(password);
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for password-hash 1.2.x
// Project: https://github.com/davidwood/node-password-hash
// Definitions by: TANAKA Koichi <https://github.com/mugeso/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'password-hash' {
export function generate(password: string, options?: Options): string;
export function verify(password: string, hashedPassword: string): boolean;
export function isHashed(password: string): boolean;
export interface Options {
algorithm?: string;
saltLength?: number;
iterations?: number;
}
}
+1 -1
View File
@@ -8,7 +8,7 @@
interface Polyline {
decode(string: string, precision?: number): number[][];
encode(coordinate: number[][], precision?: number): string;
fromGeoJSON(geojson: GeoJSON.LineString | GeoJSON.Feature, precision?: number): string;
fromGeoJSON(geojson: GeoJSON.LineString | GeoJSON.Feature<GeoJSON.LineString>, precision?: number): string;
}
declare var polyline: Polyline;
+198 -168
View File
@@ -1,212 +1,242 @@
/// <reference path="./protractor-http-mock.d.ts" />
function TestConfig() {
function TestConfig() {
mock.config = {
rootDirectory: 'root',
protractorConfig: 'protractor.conf.js'
};
rootDirectory: "root",
protractorConfig: "protractor.conf.js"
};
}
function TestCtorOverloads() {
let noParam: mock.ProtractorHttpMock = mock();
let noParam: mock.ProtractorHttpMock = mock();
let emptyArray: mock.ProtractorHttpMock = mock([]);
let mockFiles: mock.ProtractorHttpMock = mock(['mock1', 'mock2']);
let skipDefaults: mock.ProtractorHttpMock = mock([], true);
let mockFiles: mock.ProtractorHttpMock = mock(["mock1", "mock2"]);
let skipDefaults: mock.ProtractorHttpMock = mock([], true);
let del: mock.requests.Delete<number> = {
request: {
path: 'path',
method: 'DELETE'
},
response: {
status: 400,
data: 1
}
};
let put: mock.requests.Put<number> = {
request: {
path: 'path',
method: 'PUT'
},
response: {
status: 400,
data: 1
}
};
let mocks: mock.ProtractorHttpMock = mock([del, put]);
let del: mock.requests.Delete<number> = {
request: {
path: "path",
method: "DELETE"
},
response: {
status: 400,
data: 1
}
};
let put: mock.requests.Put<number> = {
request: {
path: "path",
method: "PUT"
},
response: {
status: 400,
data: 1
}
};
let mocks: mock.ProtractorHttpMock = mock([del, put]);
}
function TestTeardown() {
mock.teardown();
mock.teardown();
}
function TestRequestsMade() {
let values: Array<mock.ReceivedRequest>;
mock.requestsMade().then(v => values = v);
let values: Array<mock.ReceivedRequest>;
mock.requestsMade().then(v => values = v);
}
function TestClearRequests() {
let promiseValue: boolean;
mock.clearRequests().then(value => {
promiseValue = value;
});
let promiseValue: boolean;
mock.clearRequests().then(value => {
promiseValue = value;
});
}
function TestDynamicAdd() {
let put: mock.requests.Put<number> = {
request: {
path: "path",
method: "PUT"
},
response: {
status: 400,
data: 1
}
};
let resolved: boolean;
mock.add([put]).then(r => resolved = r);
}
function TestDyanmicRemove() {
let put: mock.requests.Put<number> = {
request: {
path: "path",
method: "PUT"
},
response: {
status: 400,
data: 1
}
};
let resolved: boolean;
mock.remove([put]).then(r => resolved = r);
}
function TestGetRequestDefinitions() {
let getMinium: mock.requests.Get<number> = {
request: {
path: 'path',
method: 'GET'
},
response: {
data: 1,
status: 500
}
};
let getMinium: mock.requests.Get<number> = {
request: {
path: "path",
method: "GET"
},
response: {
data: 1,
status: 500
}
};
let getParams: mock.requests.Get<number> = {
request: {
path: 'path',
method: 'GET',
params: {
param1: 'param1',
param2: 2
}
},
response: {
data: 1,
status: 500
}
};
let getParams: mock.requests.Get<number> = {
request: {
path: "path",
method: "GET",
params: {
param1: "param1",
param2: 2
}
},
response: {
data: 1,
status: 500
}
};
let post: mock.requests.Post<number> = {
request: {
path: 'path',
method: 'POST'
},
response: {
data: 1,
status: 500
}
};
let post: mock.requests.Post<number> = {
request: {
path: "path",
method: "POST"
},
response: {
data: 1,
status: 500
}
};
let getQueryString: mock.requests.Get<number> = {
request: {
path: 'path',
method: 'GET',
queryString: {
query1: 'query1',
query2: 2
}
},
response: {
data: 1,
status: 500
}
};
let getQueryString: mock.requests.Get<number> = {
request: {
path: "path",
method: "GET",
queryString: {
query1: "query1",
query2: 2
}
},
response: {
data: 1,
status: 500
}
};
let getHeaders: mock.requests.Get<number> = {
request: {
path: 'path',
method: 'GET',
headers: {
head1: 'head1',
head2: 'head2'
}
},
response: {
data: 1,
status: 500
}
};
let getHeaders: mock.requests.Get<number> = {
request: {
path: "path",
method: "GET",
headers: {
head1: "head1",
head2: "head2"
}
},
response: {
data: 1,
status: 500
}
};
}
function TestPostRequestDefinitions() {
let post: mock.requests.Post<number> = {
request: {
path: 'path',
method: 'POST'
},
response: {
data: 1,
status: 500
}
};
let post: mock.requests.Post<number> = {
request: {
path: "path",
method: "POST"
},
response: {
data: 1,
status: 500
}
};
let postData: mock.requests.PostData<number, string> = {
request: {
path: 'path',
method: 'POST',
data: 'data'
},
response: {
data: 1,
status: 500
}
};
let postData: mock.requests.PostData<number, string> = {
request: {
path: "path",
method: "POST",
data: "data"
},
response: {
data: 1,
status: 500
}
};
}
function TestHeadRequestDefinitions() {
let head: mock.requests.Head<number> = {
request: {
path: 'path',
method: 'HEAD'
},
response: {
status: 500,
data: 1
}
};
let head: mock.requests.Head<number> = {
request: {
path: "path",
method: "HEAD"
},
response: {
status: 500,
data: 1
}
};
}
function TestDeleteRequestDefinitions() {
let del: mock.requests.Delete<number> = {
request: {
path: 'path',
method: 'DELETE'
},
response: {
status: 500,
data: 1
}
};
let del: mock.requests.Delete<number> = {
request: {
path: "path",
method: "DELETE"
},
response: {
status: 500,
data: 1
}
};
}
function TestPutRequestDefinitions() {
let put: mock.requests.Put<number> = {
request: {
path: 'path',
method: 'PUT'
},
response: {
status: 500,
data: 1
}
};
let put: mock.requests.Put<number> = {
request: {
path: "path",
method: "PUT"
},
response: {
status: 500,
data: 1
}
};
}
function TestPatchRequestDefinitions() {
let patch: mock.requests.Patch<number> = {
request: {
path: 'path',
method: 'PATCH'
},
response: {
status: 500,
data: 1
}
};
let patch: mock.requests.Patch<number> = {
request: {
path: "path",
method: "PATCH"
},
response: {
status: 500,
data: 1
}
};
}
function TestJsonpRequestDefinitions() {
let jsonp: mock.requests.Jsonp<number> = {
request: {
path: 'path',
method: 'JSONP'
},
response: {
status: 500,
data: 1
}
};
let jsonp: mock.requests.Jsonp<number> = {
request: {
path: "path",
method: "JSONP"
},
response: {
status: 500,
data: 1
}
};
}
+33 -10
View File
@@ -57,6 +57,24 @@ declare namespace mock {
*/
protractorConfig?: string;
};
/**
* Add mock dynamically.
* Returns a promise that will be resolved with a true boolean
* when mocks have been added.
*
* @param mocks An array of mock modules to load into the application.
*/
add<T>(mocks: Array<requests.BaseRequest<T>>): webdriver.promise.Promise<boolean>;
/**
* Remove mock dynamically.
* Returns a promise that will be resolved with a true boolean
* when mocks have been removed.
*
* @param mocks An array of mock modules to remove from the application.
*/
remove<T>(mocks: Array<requests.BaseRequest<T>>): webdriver.promise.Promise<boolean>;
}
/**
@@ -68,12 +86,17 @@ declare namespace mock {
}
namespace requests {
/**
* Request methods type
*/
type Method = "GET" | "POST" | "DELETE" | "PUT" | "HEAD" | "PATCH" | "JSONP";
/**
* Base request mock used for all mocks.
*/
interface BaseRequest<TResponse> {
request: {
method: string;
method: Method;
path: string;
};
response: {
@@ -87,7 +110,7 @@ declare namespace mock {
*/
interface Get<TResponse> extends BaseRequest<TResponse> {
request: {
method: string;
method: Method;
path: string;
params?: Object;
queryString?: Object;
@@ -107,7 +130,7 @@ declare namespace mock {
interface PostData<TResponse, TPayload> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
method: Method;
data: TPayload;
};
response: {
@@ -122,7 +145,7 @@ declare namespace mock {
interface Post<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
method: Method;
};
response: {
status: number;
@@ -136,7 +159,7 @@ declare namespace mock {
interface Head<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
method: Method;
};
response: {
status: number;
@@ -150,7 +173,7 @@ declare namespace mock {
interface Delete<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
method: Method;
};
response: {
status: number;
@@ -164,7 +187,7 @@ declare namespace mock {
interface Put<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
method: Method;
};
response: {
status: number;
@@ -178,7 +201,7 @@ declare namespace mock {
interface Patch<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
method: Method;
};
response: {
status: number;
@@ -192,7 +215,7 @@ declare namespace mock {
interface Jsonp<TResponse> extends BaseRequest<TResponse> {
request: {
path: string;
method: string;
method: Method;
};
response: {
status: number;
@@ -204,6 +227,6 @@ declare namespace mock {
declare var mock: mock.ProtractorHttpMock;
declare module 'protractor-http-mock' {
declare module "protractor-http-mock" {
export = mock;
}
+1
View File
@@ -4,6 +4,7 @@ import qs = require('query-string');
qs.stringify({ foo: 'bar' });
qs.stringify({ foo: 'bar', bar: 'baz' });
qs.stringify({ foo: 'bar' }, {strict: false})
qs.parse('?foo=bar');
qs.parse('#foo=bar');
+1 -1
View File
@@ -16,7 +16,7 @@ declare module "query-string" {
*
* @param obj
*/
export function stringify(obj: any): string;
export function stringify(obj: any, options?: {strict: boolean}): string;
/**
* Extract a query string from a URL that can be passed into .parse().
+14 -5
View File
@@ -18,15 +18,23 @@ declare namespace ReactRouter {
type Component = React.ReactType
type EnterHook = (nextState: RouterState, replaceState: RedirectFunction, callback?: Function) => any
type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: Function) => void
type LeaveHook = () => any
type LeaveHook = () => void
type ChangeHook = (prevState: RouterState, nextState: RouterState, replace: RedirectFunction, callback: Function) => void;
type Params = Object
type Params = { [param: string]: string }
type ParseQueryString = (queryString: H.QueryString) => H.Query
type RedirectFunction = (state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query) => void
interface RedirectFunction {
(location: H.LocationDescriptor): void;
/**
* @deprecated `replaceState(state, pathname, query) is deprecated; Use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated
*/
(state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query): void;
}
type RouteComponent = Component
@@ -98,7 +106,7 @@ declare namespace ReactRouter {
activeStyle?: React.CSSProperties
activeClassName?: string
onlyActiveOnIndex?: boolean
to: RoutePattern
to: RoutePattern | H.LocationDescriptor
query?: H.Query
state?: H.LocationState
}
@@ -138,6 +146,7 @@ declare namespace ReactRouter {
getComponents?: (location: H.Location, cb: (error: any, components?: RouteComponents) => void) => void
onEnter?: EnterHook
onLeave?: LeaveHook
onChange?: ChangeHook
getIndexRoute?: (location: H.Location, cb: (error: any, indexRoute: RouteConfig) => void) => void
getChildRoutes?: (location: H.Location, cb: (error: any, childRoutes: RouteConfig) => void) => void
}
+15 -3
View File
@@ -24,7 +24,7 @@ declare namespace SignalR {
name: string;
supportsKeepAlive(): boolean;
send(connection: SignalR.Connection, data: any): void;
start(connection: SignalR.Connection, onSuccess: () => void, onFailed: (error?: any) => void): void;
start(connection: SignalR.Connection, onSuccess: () => void, onFailed: (error?: ConnectionError) => void): void;
reconnect(connection: SignalR.Connection): void;
lostConnection(connection: SignalR.Connection): void;
stop(connection: SignalR.Connection): void;
@@ -169,6 +169,18 @@ declare namespace SignalR {
protocol: string;
host: string;
}
interface ConnectionErrorContext {
readyState: number;
responseText: string;
status: number;
statusText: string;
}
interface ConnectionError extends Error {
context: ConnectionErrorContext;
transport?: string;
}
interface Connection {
clientProtocol: string;
@@ -256,7 +268,7 @@ declare namespace SignalR {
*
* @param calback A callback function to execute when an error occurs on the connection
*/
error(callback: (error: Error) => void): Connection;
error(callback: (error: ConnectionError) => void): Connection;
/**
* Adds a callback that will be invoked when the client disconnects
@@ -306,7 +318,7 @@ declare namespace SignalR {
hub: Hub.Connection;
lastError: any;
lastError: ConnectionError;
resources: Resources;
}
}
+76 -61
View File
@@ -212,23 +212,23 @@
ok( b.distanceToPoint( new THREE.Vector2( -2, -2 ) ) == Math.sqrt( 2 ), "Passed!" );
});
test( "isIntersectionBox", function() {
test( "intersectsBox", function() {
var a = new THREE.Box2( zero2.clone(), zero2.clone() );
var b = new THREE.Box2( zero2.clone(), one2.clone() );
var c = new THREE.Box2( one2.clone().negate(), one2.clone() );
ok( a.isIntersectionBox( a ), "Passed!" );
ok( a.isIntersectionBox( b ), "Passed!" );
ok( a.isIntersectionBox( c ), "Passed!" );
ok( a.intersectsBox( a ), "Passed!" );
ok( a.intersectsBox( b ), "Passed!" );
ok( a.intersectsBox( c ), "Passed!" );
ok( b.isIntersectionBox( a ), "Passed!" );
ok( c.isIntersectionBox( a ), "Passed!" );
ok( b.isIntersectionBox( c ), "Passed!" );
ok( b.intersectsBox( a ), "Passed!" );
ok( c.intersectsBox( a ), "Passed!" );
ok( b.intersectsBox( c ), "Passed!" );
b.translate( new THREE.Vector2( 2, 2 ) );
ok( ! a.isIntersectionBox( b ), "Passed!" );
ok( ! b.isIntersectionBox( a ), "Passed!" );
ok( ! b.isIntersectionBox( c ), "Passed!" );
ok( ! a.intersectsBox( b ), "Passed!" );
ok( ! b.intersectsBox( a ), "Passed!" );
ok( ! b.intersectsBox( c ), "Passed!" );
});
test( "intersect", function() {
@@ -468,23 +468,23 @@
ok( b.distanceToPoint( new THREE.Vector3( -2, -2, -2 ) ) == Math.sqrt( 3 ), "Passed!" );
});
test( "isIntersectionBox", function() {
test( "intersectsBox", function() {
var a = new THREE.Box3( zero3.clone(), zero3.clone() );
var b = new THREE.Box3( zero3.clone(), one3.clone() );
var c = new THREE.Box3( one3.clone().negate(), one3.clone() );
ok( a.isIntersectionBox( a ), "Passed!" );
ok( a.isIntersectionBox( b ), "Passed!" );
ok( a.isIntersectionBox( c ), "Passed!" );
ok( a.intersectsBox( a ), "Passed!" );
ok( a.intersectsBox( b ), "Passed!" );
ok( a.intersectsBox( c ), "Passed!" );
ok( b.isIntersectionBox( a ), "Passed!" );
ok( c.isIntersectionBox( a ), "Passed!" );
ok( b.isIntersectionBox( c ), "Passed!" );
ok( b.intersectsBox( a ), "Passed!" );
ok( c.intersectsBox( a ), "Passed!" );
ok( b.intersectsBox( c ), "Passed!" );
b.translate( new THREE.Vector3( 2, 2, 2 ) );
ok( ! a.isIntersectionBox( b ), "Passed!" );
ok( ! b.isIntersectionBox( a ), "Passed!" );
ok( ! b.isIntersectionBox( c ), "Passed!" );
ok( ! a.intersectsBox( b ), "Passed!" );
ok( ! b.intersectsBox( a ), "Passed!" );
ok( ! b.intersectsBox( c ), "Passed!" );
});
test( "getBoundingSphere", function() {
@@ -1149,7 +1149,8 @@
var a = new THREE.Matrix3();
ok( a.determinant() == 1, "Passed!" );
var b = new THREE.Matrix3( 0, 1, 2, 3, 4, 5, 6, 7, 8 );
var b = new THREE.Matrix3();
b.set(0, 1, 2, 3, 4, 5, 6, 7, 8);
ok( b.elements[0] == 0 );
ok( b.elements[1] == 3 );
ok( b.elements[2] == 6 );
@@ -1164,7 +1165,8 @@
});
test( "copy", function() {
var a = new THREE.Matrix3( 0, 1, 2, 3, 4, 5, 6, 7, 8 );
var a = new THREE.Matrix3();
a.set(0, 1, 2, 3, 4, 5, 6, 7, 8);
var b = new THREE.Matrix3().copy( a );
ok( matrixEquals3( a, b ), "Passed!" );
@@ -1191,7 +1193,8 @@
});
test( "identity", function() {
var b = new THREE.Matrix3( 0, 1, 2, 3, 4, 5, 6, 7, 8 );
var b = new THREE.Matrix3();
b.set(0, 1, 2, 3, 4, 5, 6, 7, 8);
ok( b.elements[0] == 0 );
ok( b.elements[1] == 3 );
ok( b.elements[2] == 6 );
@@ -1210,7 +1213,8 @@
});
test( "multiplyScalar", function() {
var b = new THREE.Matrix3( 0, 1, 2, 3, 4, 5, 6, 7, 8 );
var b = new THREE.Matrix3();
b.set(0, 1, 2, 3, 4, 5, 6, 7, 8);
ok( b.elements[0] == 0 );
ok( b.elements[1] == 3 );
ok( b.elements[2] == 6 );
@@ -1252,8 +1256,10 @@
test( "getInverse", function() {
var identity = new THREE.Matrix4();
var a = new THREE.Matrix4();
var b = new THREE.Matrix3( 0, 0, 0, 0, 0, 0, 0, 0, 0 );
var c = new THREE.Matrix4( 0, 0, 0, 0, 0, 0, 0, 0, 0 );
var b = new THREE.Matrix3();
b.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
var c = new THREE.Matrix4();
c.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
ok( ! matrixEquals3( a, b ), "Passed!" );
b.getInverse( a, false );
@@ -1299,7 +1305,8 @@
var b = a.clone().transpose();
ok( matrixEquals3( a, b ), "Passed!" );
b = new THREE.Matrix3( 0, 1, 2, 3, 4, 5, 6, 7, 8 );
b = new THREE.Matrix3();
b.set(0, 1, 2, 3, 4, 5, 6, 7, 8);
var c = b.clone().transpose();
ok( ! matrixEquals3( b, c ), "Passed!" );
c.transpose();
@@ -1307,7 +1314,8 @@
});
test( "clone", function() {
var a = new THREE.Matrix3( 0, 1, 2, 3, 4, 5, 6, 7, 8 );
var a = new THREE.Matrix3();
a.set(0, 1, 2, 3, 4, 5, 6, 7, 8);
var b = a.clone();
ok( matrixEquals3( a, b ), "Passed!" );
@@ -1337,7 +1345,8 @@
var a = new THREE.Matrix4();
ok( a.determinant() == 1, "Passed!" );
var b = new THREE.Matrix4( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
var b = new THREE.Matrix4();
b.set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
ok( b.elements[0] == 0 );
ok( b.elements[1] == 4 );
ok( b.elements[2] == 8 );
@@ -1359,7 +1368,8 @@
});
test( "copy", function() {
var a = new THREE.Matrix4( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
var a = new THREE.Matrix4();
a.set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
var b = new THREE.Matrix4().copy( a );
ok( matrixEquals4( a, b ), "Passed!" );
@@ -1393,7 +1403,8 @@
});
test( "identity", function() {
var b = new THREE.Matrix4( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
var b = new THREE.Matrix4();
b.set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
ok( b.elements[0] == 0 );
ok( b.elements[1] == 4 );
ok( b.elements[2] == 8 );
@@ -1419,7 +1430,8 @@
});
test( "multiplyScalar", function() {
var b = new THREE.Matrix4( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
var b = new THREE.Matrix4();
b.set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
ok( b.elements[0] == 0 );
ok( b.elements[1] == 4 );
ok( b.elements[2] == 8 );
@@ -1475,8 +1487,8 @@
var identity = new THREE.Matrix4();
var a = new THREE.Matrix4();
var b = new THREE.Matrix4( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
var c = new THREE.Matrix4( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
var b = new THREE.Matrix4().set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var c = new THREE.Matrix4().set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
ok( ! matrixEquals4( a, b ), "Passed!" );
b.getInverse( a, false );
@@ -1561,7 +1573,8 @@
var b = a.clone().transpose();
ok( matrixEquals4( a, b ), "Passed!" );
b = new THREE.Matrix4( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
b = new THREE.Matrix4();
b.set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
var c = b.clone().transpose();
ok( ! matrixEquals4( b, c ), "Passed!" );
c.transpose();
@@ -1569,7 +1582,8 @@
});
test( "clone", function() {
var a = new THREE.Matrix4( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 );
var a = new THREE.Matrix4();
a.set(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
var b = a.clone();
ok( matrixEquals4( a, b ), "Passed!" );
@@ -1773,23 +1787,23 @@
var a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 0 );
var l1 = new THREE.Line3( new THREE.Vector3( -10, 0, 0 ), new THREE.Vector3( 10, 0, 0 ) );
ok( a.isIntersectionLine( l1 ), "Passed!" );
ok( a.intersectsLine( l1 ), "Passed!" );
ok( a.intersectLine( l1 ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), -3 );
ok( a.isIntersectionLine( l1 ), "Passed!" );
ok( a.intersectsLine( l1 ), "Passed!" );
ok( a.intersectLine( l1 ).equals( new THREE.Vector3( 3, 0, 0 ) ), "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), -11 );
ok( ! a.isIntersectionLine( l1 ), "Passed!" );
ok( ! a.intersectsLine( l1 ), "Passed!" );
ok( a.intersectLine( l1 ) === undefined, "Passed!" );
a = new THREE.Plane( new THREE.Vector3( 1, 0, 0 ), 11 );
ok( ! a.isIntersectionLine( l1 ), "Passed!" );
ok( ! a.intersectsLine( l1 ), "Passed!" );
ok( a.intersectLine( l1 ) === undefined, "Passed!" );
});
@@ -2136,7 +2150,7 @@
ok( d === 0, "Passed!" );
});
test( "isIntersectionSphere", function() {
test( "intersectsSphere", function() {
var a = new THREE.Ray( one3.clone(), new THREE.Vector3( 0, 0, 1 ) );
var b = new THREE.Sphere( zero3, 0.5 );
var c = new THREE.Sphere( zero3, 1.5 );
@@ -2144,11 +2158,11 @@
var e = new THREE.Sphere( two3, 0.1 );
var f = new THREE.Sphere( two3, 1 );
ok( ! a.isIntersectionSphere( b ), "Passed!" );
ok( ! a.isIntersectionSphere( c ), "Passed!" );
ok( a.isIntersectionSphere( d ), "Passed!" );
ok( ! a.isIntersectionSphere( e ), "Passed!" );
ok( ! a.isIntersectionSphere( f ), "Passed!" );
ok( ! a.intersectsSphere( b ), "Passed!" );
ok( ! a.intersectsSphere( c ), "Passed!" );
ok( a.intersectsSphere( d ), "Passed!" );
ok( ! a.intersectsSphere( e ), "Passed!" );
ok( ! a.intersectsSphere( f ), "Passed!" );
});
test( "intersectSphere", function() {
@@ -2210,28 +2224,28 @@
});
test( "isIntersectionPlane", function() {
test( "intersectsPlane", function() {
var a = new THREE.Ray( one3.clone(), new THREE.Vector3( 0, 0, 1 ) );
// parallel plane in front of the ray
var b = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), one3.clone().sub( new THREE.Vector3( 0, 0, -1 ) ) );
ok( a.isIntersectionPlane( b ), "Passed!" );
ok( a.intersectsPlane( b ), "Passed!" );
// parallel plane coincident with origin
var c = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), one3.clone().sub( new THREE.Vector3( 0, 0, 0 ) ) );
ok( a.isIntersectionPlane( c ), "Passed!" );
ok( a.intersectsPlane( c ), "Passed!" );
// parallel plane behind the ray
var d = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 0, 0, 1 ), one3.clone().sub( new THREE.Vector3( 0, 0, 1 ) ) );
ok( ! a.isIntersectionPlane( d ), "Passed!" );
ok( ! a.intersectsPlane( d ), "Passed!" );
// perpendical ray that overlaps exactly
var e = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 1, 0, 0 ), one3 );
ok( a.isIntersectionPlane( e ), "Passed!" );
ok( a.intersectsPlane( e ), "Passed!" );
// perpendical ray that doesn't overlap
var f = new THREE.Plane().setFromNormalAndCoplanarPoint( new THREE.Vector3( 1, 0, 0 ), zero3 );
ok( ! a.isIntersectionPlane( f ), "Passed!" );
ok( ! a.intersectsPlane( f ), "Passed!" );
});
test( "intersectPlane", function() {
@@ -2327,32 +2341,32 @@
var a = new THREE.Ray( new THREE.Vector3( -2, 0, 0 ), new THREE.Vector3( 1, 0, 0) );
//ray should intersect box at -1,0,0
ok( a.isIntersectionBox(box) === true, "Passed!" );
ok( a.intersectsBox(box) === true, "Passed!" );
ok( a.intersectBox(box).distanceTo( new THREE.Vector3( -1, 0, 0 ) ) < TOL, "Passed!" );
var b = new THREE.Ray( new THREE.Vector3( -2, 0, 0 ), new THREE.Vector3( -1, 0, 0) );
//ray is point away from box, it should not intersect
ok( b.isIntersectionBox(box) === false, "Passed!" );
ok( b.intersectsBox(box) === false, "Passed!" );
ok( b.intersectBox(box) === null, "Passed!" );
var c = new THREE.Ray( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 1, 0, 0) );
// ray is inside box, should return exit point
ok( c.isIntersectionBox(box) === true, "Passed!" );
ok( c.intersectsBox(box) === true, "Passed!" );
ok( c.intersectBox(box).distanceTo( new THREE.Vector3( 1, 0, 0 ) ) < TOL, "Passed!" );
var d = new THREE.Ray( new THREE.Vector3( 0, 2, 1 ), new THREE.Vector3( 0, -1, -1).normalize() );
//tilted ray should intersect box at 0,1,0
ok( d.isIntersectionBox(box) === true, "Passed!" );
ok( d.intersectsBox(box) === true, "Passed!" );
ok( d.intersectBox(box).distanceTo( new THREE.Vector3( 0, 1, 0 ) ) < TOL, "Passed!" );
var e = new THREE.Ray( new THREE.Vector3( 1, -2, 1 ), new THREE.Vector3( 0, 1, 0).normalize() );
//handle case where ray is coplanar with one of the boxes side - box in front of ray
ok( e.isIntersectionBox(box) === true, "Passed!" );
ok( e.intersectsBox(box) === true, "Passed!" );
ok( e.intersectBox(box).distanceTo( new THREE.Vector3( 1, -1, 1 ) ) < TOL, "Passed!" );
var f = new THREE.Ray( new THREE.Vector3( 1, -2, 0 ), new THREE.Vector3( 0, -1, 0).normalize() );
//handle case where ray is coplanar with one of the boxes side - box behind ray
ok( f.isIntersectionBox(box) === false, "Passed!" );
ok( f.intersectsBox(box) === false, "Passed!" );
ok( f.intersectBox(box) == null, "Passed!" );
});
@@ -3527,13 +3541,14 @@
test( "setAxisAngleFromRotationMatrix", function() {
var TOL = 1e-9;
var r = new THREE.Matrix4().makeRotationZ(Math.PI / 2);
// not sure what to do here since THREE.Vector4().setAxisAngleFromRotationMatrix() only accept Matrix3s
/*var r = new THREE.Matrix4().makeRotationZ(Math.PI / 2);
var v = new THREE.Vector4().setAxisAngleFromRotationMatrix(r);
ok( v.x == 0, "Passed!" );
ok( v.y == 0, "Passed!" );
ok( v.z == 1, "Passed!" );
ok( Math.abs(v.w - Math.PI / 2) < TOL, "Passed!" );
ok( Math.abs(v.w - Math.PI / 2) < TOL, "Passed!" );*/
});
};
@@ -186,8 +186,6 @@
var clipBones = geometry.animations[0];
mixer = new THREE.AnimationMixer( mesh );
mixer.addAction( new THREE.AnimationAction( clipMorpher ) );
mixer.addAction( new THREE.AnimationAction( clipBones ) );
}
function initGUI() {
@@ -130,7 +130,6 @@
scene.add( mesh );
var mixer = new THREE.AnimationMixer( mesh );
mixer.addAction( new THREE.AnimationAction( geometry.animations[ 0 ] ).warpToDuration( 1 ) );
mixers.push( mixer );
} );
+1 -1
View File
@@ -62,7 +62,7 @@
materials.push(new THREE.MeshLambertMaterial({ color: 0xdddddd }));
materials.push(new THREE.MeshPhongMaterial({ color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.SmoothShading, map: texture, transparent: true }));
materials.push(new THREE.MeshNormalMaterial({ shading: THREE.SmoothShading }));
materials.push(new THREE.MeshNormalMaterial({}));
materials.push(new THREE.MeshBasicMaterial({ color: 0xffaa00, wireframe: true }));
materials.push(new THREE.MeshDepthMaterial());
+1 -1
View File
@@ -35,7 +35,7 @@ THE SOFTWARE.
/// <reference path="./tests/webgl/webgl_interactive_cubes.ts" />
/// <reference path="./tests/webgl/webgl_interactive_raycasting_points.ts" />
/// <reference path="./tests/webgl/webgl_lensflares.ts" />
/// <reference path="./tests/webgl/webgl_lights_heimsphere.ts" />
/// <reference path="./tests/webgl/webgl_lights_hemisphere.ts" />
/// <reference path="./tests/webgl/webgl_lines_colors.ts" />
/// <reference path="./tests/webgl/webgl_loader_awd.ts" />
/// <reference path="./tests/webgl/webgl_materials.ts" />
+1423 -1135
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -441,11 +441,11 @@ var value = "oak";
var filtered = turf.filter(features, key, value);
// -- Test random --
var points = turf.random('points', 100, {
var randomPoints = turf.random('points', 100, {
bbox: [-70, 40, -60, 60]
});
var points = turf.random('points', 100, {
var randomPoints = turf.random('points', 100, {
bbox: [-70, 40, -60, 60],
num_vertices: 2,
max_radial_length: 10
@@ -455,7 +455,7 @@ var points = turf.random('points', 100, {
var filtered = turf.remove(points, 'marker-color', '#00f');
// -- Test sample --
var points = turf.random('points', 1000);
var randomPoints = turf.random('points', 1000);
var sample = turf.sample(points, 10);
///////////////////////////////////////////
+59 -59
View File
@@ -18,7 +18,7 @@ declare namespace turf {
* @param aggregations An array of aggregation objects
* @returns Polygons with properties listed based on outField values in aggregations
*/
function aggregate(polygons: GeoJSON.FeatureCollection, points: GeoJSON.FeatureCollection, aggregations: Array<{aggregation: string, inField: string, outField: string}>): GeoJSON.FeatureCollection;
function aggregate(polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>, points: GeoJSON.FeatureCollection<GeoJSON.Point>, aggregations: Array<{aggregation: string, inField: string, outField: string}>): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Calculates the average value of a field for a set of points within a set of polygons.
@@ -28,7 +28,7 @@ declare namespace turf {
* @param outField The field in polygons to put results of the averages
* @returns Polygons with the value of outField set to the calculated averages
*/
function average(polygons: GeoJSON.FeatureCollection, points: GeoJSON.FeatureCollection, field: string, outField: string): GeoJSON.FeatureCollection;
function average(polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>, points: GeoJSON.FeatureCollection<GeoJSON.Point>, field: string, outField: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Takes a set of points and a set of polygons and calculates the number of points that fall within the set of polygons.
@@ -37,7 +37,7 @@ declare namespace turf {
* @param countField A field to append to the attributes of the Polygon features representing Point counts
* @returns Polygons with countField appended
*/
function count(polygons: GeoJSON.FeatureCollection, points: GeoJSON.FeatureCollection, countField: string): GeoJSON.FeatureCollection;
function count(polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>, points: GeoJSON.FeatureCollection<GeoJSON.Point>, countField: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Calculates the standard deviation value of a field for a set of points within a set of polygons.
@@ -47,7 +47,7 @@ declare namespace turf {
* @param outField The field to append to polygons representing deviation
* @returns Polygons with appended field representing deviation
*/
function deviation(polygons: GeoJSON.FeatureCollection, points: GeoJSON.FeatureCollection, inField: string, outField: string): GeoJSON.FeatureCollection;
function deviation(polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>, points: GeoJSON.FeatureCollection<GeoJSON.Point>, inField: string, outField: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Calculates the maximum value of a field for a set of points within a set of polygons.
@@ -57,7 +57,7 @@ declare namespace turf {
* @param outField The field in which to store results
* @returns Polygons with properties listed as outField values
*/
function max(polygons: GeoJSON.FeatureCollection, points: GeoJSON.FeatureCollection, inField: string, outField: string): GeoJSON.FeatureCollection;
function max(polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>, points: GeoJSON.FeatureCollection<GeoJSON.Point>, inField: string, outField: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Calculates the median value of a field for a set of points within a set of polygons.
@@ -67,7 +67,7 @@ declare namespace turf {
* @param outField The field in which to store results
* @returns Polygons with properties listed as outField values
*/
function median(polygons: GeoJSON.FeatureCollection, points: GeoJSON.FeatureCollection, inField: string, outField: string): GeoJSON.FeatureCollection;
function median(polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>, points: GeoJSON.FeatureCollection<GeoJSON.Point>, inField: string, outField: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Calculates the minimum value of a field for a set of points within a set of polygons.
@@ -77,7 +77,7 @@ declare namespace turf {
* @param outField The field in which to store results
* @returns Polygons with properties listed as outField values
*/
function min(polygons: GeoJSON.FeatureCollection, points: GeoJSON.FeatureCollection, inField: string, outField: string): GeoJSON.FeatureCollection;
function min(polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>, points: GeoJSON.FeatureCollection<GeoJSON.Point>, inField: string, outField: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Calculates the sum of a field for a set of points within a set of polygons.
@@ -87,7 +87,7 @@ declare namespace turf {
* @param outField The field in which to store results
* @returns Polygons with properties listed as outField
*/
function sum(polygons: GeoJSON.FeatureCollection, points: GeoJSON.FeatureCollection, inField: string, outField: string): GeoJSON.FeatureCollection;
function sum(polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>, points: GeoJSON.FeatureCollection<GeoJSON.Point>, inField: string, outField: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Calculates the variance value of a field for a set of points within a set of polygons.
@@ -97,7 +97,7 @@ declare namespace turf {
* @param outField The field in which to store results
* @returns Polygons with properties listed as outField
*/
function variance(polygons: GeoJSON.FeatureCollection, points: GeoJSON.FeatureCollection, inField: string, outField: string): GeoJSON.FeatureCollection;
function variance(polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>, points: GeoJSON.FeatureCollection<GeoJSON.Point>, inField: string, outField: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
//////////////////////////////////////////////////////
// Measurement
@@ -110,21 +110,21 @@ declare namespace turf {
* @param [units=miles] 'miles', 'kilometers', 'radians' or 'degrees'
* @returns Point along the line
*/
function along(line: GeoJSON.Feature, distance: number, units?: string): GeoJSON.Feature;
function along(line: GeoJSON.Feature<GeoJSON.LineString>, distance: number, units?: string): GeoJSON.Feature<GeoJSON.Point>;
/**
* Takes one or more features and returns their area in square meters.
* @param input Input features
* @returns Area in square meters
*/
function area(input: GeoJSON.Feature | GeoJSON.FeatureCollection): number;
function area(input: GeoJSON.Feature<any> | GeoJSON.FeatureCollection<any>): number;
/**
* Takes a bbox and returns an equivalent polygon.
* @param bbox An Array of bounding box coordinates in the form: [xLow, yLow, xHigh, yHigh]
* @returns A Polygon representation of the bounding box
*/
function bboxPolygon(bbox: Array<number>): GeoJSON.Feature;
function bboxPolygon(bbox: Array<number>): GeoJSON.Feature<GeoJSON.Polygon>;
/**
* Takes two points and finds the geographic bearing between them.
@@ -132,14 +132,14 @@ declare namespace turf {
* @param end Ending point
* @returns Bearing in decimal degrees
*/
function bearing(start: GeoJSON.Feature, end: GeoJSON.Feature): number;
function bearing(start: GeoJSON.Feature<GeoJSON.Point>, end: GeoJSON.Feature<GeoJSON.Point>): number;
/**
* Takes a FeatureCollection and returns the absolute center point of all features.
* @param features Input features
* @returns A Point feature at the absolute center point of all input features
*/
function center(features: GeoJSON.FeatureCollection): GeoJSON.Feature;
function center(features: GeoJSON.FeatureCollection<any>): GeoJSON.Feature<GeoJSON.Point>;
/**
* Takes one or more features and calculates the centroid using the arithmetic mean of all vertices.
@@ -147,7 +147,7 @@ declare namespace turf {
* @param features Input features
* @returns The centroid of the input features
*/
function centroid(features: GeoJSON.Feature | GeoJSON.FeatureCollection): GeoJSON.Feature;
function centroid(features: GeoJSON.Feature<any> | GeoJSON.FeatureCollection<any>): GeoJSON.Feature<GeoJSON.Point>;
/**
* Takes a Point and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees.
@@ -158,7 +158,7 @@ declare namespace turf {
* @param units 'miles', 'kilometers', 'radians', or 'degrees'
* @returns Destination point
*/
function destination(start: GeoJSON.Feature, distance: number, bearing: number, units: string): GeoJSON.Feature;
function destination(start: GeoJSON.Feature<GeoJSON.Point>, distance: number, bearing: number, units: string): GeoJSON.Feature<GeoJSON.Point>;
/**
* Calculates the distance between two points in degress, radians, miles, or kilometers.
@@ -168,21 +168,21 @@ declare namespace turf {
* @param [units=kilometers] 'miles', 'kilometers', 'radians', or 'degrees'
* @returns Distance between the two points
*/
function distance(from: GeoJSON.Feature, to: GeoJSON.Feature, units?: string): number;
function distance(from: GeoJSON.Feature<GeoJSON.Point>, to: GeoJSON.Feature<GeoJSON.Point>, units?: string): number;
/**
* Takes any number of features and returns a rectangular Polygon that encompasses all vertices.
* @param fc Input features
* @returns A rectangular Polygon feature that encompasses all vertices
*/
function envelope(fc: GeoJSON.FeatureCollection): GeoJSON.Feature;
function envelope(fc: GeoJSON.FeatureCollection<any>): GeoJSON.Feature<GeoJSON.Polygon>;
/**
* Takes a set of features, calculates the extent of all input features, and returns a bounding box.
* @param input Input features
* @returns The bounding box of input given as an array in WSEN order (west, south, east, north)
*/
function extent(input: GeoJSON.Feature | GeoJSON.FeatureCollection): Array<number>;
function extent(input: GeoJSON.Feature<any> | GeoJSON.FeatureCollection<any>): Array<number>;
/**
* Takes a line and measures its length in the specified units.
@@ -190,7 +190,7 @@ declare namespace turf {
* @param units 'miles', 'kilometers', 'radians', or 'degrees'
* @returns Length of the input line
*/
function lineDistance(line: GeoJSON.Feature, units: string): number;
function lineDistance(line: GeoJSON.Feature<GeoJSON.LineString>, units: string): number;
/**
* Takes two points and returns a point midway between them.
@@ -198,7 +198,7 @@ declare namespace turf {
* @param pt2 Second point
* @returns A point midway between pt1 and pt2
*/
function midpoint(pt1: GeoJSON.Feature, pt2: GeoJSON.Feature): GeoJSON.Feature;
function midpoint(pt1: GeoJSON.Feature<GeoJSON.Point>, pt2: GeoJSON.Feature<GeoJSON.Point>): GeoJSON.Feature<GeoJSON.Point>;
/**
* Takes a feature and returns a Point guaranteed to be on the surface of the feature. Given a Polygon, the point will be in the area of the polygon.
@@ -206,7 +206,7 @@ declare namespace turf {
* @param input Any feature or set of features
* @returns A point on the surface of input
*/
function pointOnSurface(input: GeoJSON.Feature | GeoJSON.FeatureCollection): GeoJSON.Feature;
function pointOnSurface(input: GeoJSON.Feature<any> | GeoJSON.FeatureCollection<any>): GeoJSON.Feature<any>;
/**
* Takes a bounding box and returns a new bounding box with a size expanded or contracted by a factor of X.
@@ -235,7 +235,7 @@ declare namespace turf {
* @param [sharpness=0.85] A measure of how curvy the path should be between splines
* @returns Curved line
*/
function bezier(line: GeoJSON.Feature, resolution?: number, sharpness?: number): GeoJSON.Feature;
function bezier(line: GeoJSON.Feature<GeoJSON.LineString>, resolution?: number, sharpness?: number): GeoJSON.Feature<GeoJSON.LineString>;
/**
* Calculates a buffer for input features for a given radius. Units supported are miles, kilometers, and degrees.
@@ -244,7 +244,7 @@ declare namespace turf {
* @param units 'miles', 'kilometers', 'radians', or 'degrees'
* @returns Buffered features
*/
function buffer(feature: GeoJSON.Feature | GeoJSON.FeatureCollection, distance: number, units: string): GeoJSON.Feature | GeoJSON.FeatureCollection;
function buffer(feature: GeoJSON.Feature<any> | GeoJSON.FeatureCollection<any>, distance: number, units: string): GeoJSON.FeatureCollection<GeoJSON.Polygon> | GeoJSON.FeatureCollection<GeoJSON.MultiPolygon> | GeoJSON.Polygon | GeoJSON.MultiPolygon;
/**
* Takes a set of points and returns a concave hull polygon. Internally, this implements a Monotone chain algorithm.
@@ -253,14 +253,14 @@ declare namespace turf {
* @param units Used for maxEdge distance (miles or kilometers)
* @returns A concave hull
*/
function concave(points: GeoJSON.FeatureCollection, maxEdge: number, units: string): GeoJSON.Feature;
function concave(points: GeoJSON.FeatureCollection<GeoJSON.Point>, maxEdge: number, units: string): GeoJSON.Feature<GeoJSON.Polygon>;
/**
* Takes a set of points and returns a convex hull polygon. Internally this uses the convex-hull module that implements a monotone chain hull.
* @param input Input points
* @returns A convex hull
*/
function convex(input: GeoJSON.FeatureCollection): GeoJSON.Feature;
function convex(input: GeoJSON.FeatureCollection<GeoJSON.Point>): GeoJSON.Feature<GeoJSON.Polygon>;
/**
* Finds the difference between two polygons by clipping the second polygon from the first.
@@ -268,7 +268,7 @@ declare namespace turf {
* @param poly2 Polygon feature to difference from poly1
* @returns A Polygon feature showing the area of poly1 excluding the area of poly2
*/
function difference(poly1: GeoJSON.Feature, poly2: GeoJSON.Feature): GeoJSON.Feature;
function difference(poly1: GeoJSON.Feature<GeoJSON.Polygon>, poly2: GeoJSON.Feature<GeoJSON.Polygon>): GeoJSON.Feature<GeoJSON.Polygon>;
/**
* Takes two polygons and finds their intersection.
@@ -279,7 +279,7 @@ declare namespace turf {
* if poly1 and poly2 do not overlap, returns undefined;
* if poly1 and poly2 share a border, a MultiLineString of the locations where their borders are shared
*/
function intersect(poly1: GeoJSON.Feature, poly2: GeoJSON.Feature): GeoJSON.Feature;
function intersect(poly1: GeoJSON.Feature<GeoJSON.Polygon>, poly2: GeoJSON.Feature<GeoJSON.Polygon>): GeoJSON.Feature<GeoJSON.Polygon | GeoJSON.MultiLineString> | typeof undefined;
/**
* Takes a set of polygons and returns a single merged polygon feature.
@@ -287,7 +287,7 @@ declare namespace turf {
* @param fc Input polygons
* @returns Merged polygon or multipolygon
*/
function merge(fc: GeoJSON.FeatureCollection): GeoJSON.Feature;
function merge(fc: GeoJSON.FeatureCollection<GeoJSON.Polygon>): GeoJSON.Feature<GeoJSON.Polygon | GeoJSON.MultiPolygon>;
/**
* Takes a LineString or Polygon and returns a simplified version.
@@ -297,7 +297,7 @@ declare namespace turf {
* @param highQuality Whether or not to spend more time to create a higher-quality simplification with a different algorithm
* @returns A simplified feature
*/
function simplify(feature: GeoJSON.Feature | GeoJSON.FeatureCollection | GeoJSON.GeometryCollection, tolerance: number, highQuality: boolean): GeoJSON.Feature | GeoJSON.FeatureCollection | GeoJSON.GeometryCollection;
function simplify(feature: GeoJSON.Feature<any> | GeoJSON.FeatureCollection<any> | GeoJSON.GeometryCollection, tolerance: number, highQuality: boolean): GeoJSON.Feature<any> | GeoJSON.FeatureCollection<any> | GeoJSON.GeometryCollection;
/**
* Takes two polygons and returns a combined polygon.
@@ -306,7 +306,7 @@ declare namespace turf {
* @param poly2 Another input polygon
* @returns A combined Polygon or MultiPolygon feature
*/
function union(poly1: GeoJSON.Feature, poly2: GeoJSON.Feature): GeoJSON.Feature;
function union(poly1: GeoJSON.Feature<GeoJSON.Polygon>, poly2: GeoJSON.Feature<GeoJSON.Polygon>): GeoJSON.Feature<GeoJSON.Polygon | GeoJSON.MultiPolygon>;
//////////////////////////////////////////////////////
// Misc
@@ -317,28 +317,28 @@ declare namespace turf {
* @param fc A FeatureCollection of any type
* @returns A FeatureCollection of corresponding type to input
*/
function combine(fc: GeoJSON.FeatureCollection): GeoJSON.FeatureCollection;
function combine(fc: GeoJSON.FeatureCollection<any>): GeoJSON.FeatureCollection<any>;
/**
* Takes a feature or set of features and returns all positions as points.
* @param input Input features
* @returns Points representing the exploded input features
*/
function explode(input: GeoJSON.Feature | GeoJSON.FeatureCollection): GeoJSON.FeatureCollection;
function explode(input: GeoJSON.Feature<any> | GeoJSON.FeatureCollection<any>): GeoJSON.FeatureCollection<GeoJSON.Point>;
/**
* Takes input features and flips all of their coordinates from [x, y] to [y, x].
* @param input Input features
* @returns A feature or set of features of the same type as input with flipped coordinates
*/
function flip(input: GeoJSON.Feature | GeoJSON.FeatureCollection): GeoJSON.Feature | GeoJSON.FeatureCollection;
function flip(input: GeoJSON.Feature<any> | GeoJSON.FeatureCollection<any>): GeoJSON.Feature<any> | GeoJSON.FeatureCollection<any>;
/**
* Takes a polygon and returns points at all self-intersections.
* @param polygon Input polygon
* @returns Self-intersections
*/
function kinks(polygon: GeoJSON.Feature): GeoJSON.FeatureCollection;
function kinks(polygon: GeoJSON.Feature<GeoJSON.Polygon>): GeoJSON.FeatureCollection<GeoJSON.Point>;
/**
* Takes a line, a start Point, and a stop point and returns the line in between those points.
@@ -347,7 +347,7 @@ declare namespace turf {
* @param line Line to slice
* @returns Sliced line
*/
function lineSlice(point1: GeoJSON.Feature, point2: GeoJSON.Feature, line: GeoJSON.Feature): GeoJSON.Feature;
function lineSlice(point1: GeoJSON.Feature<GeoJSON.Point>, point2: GeoJSON.Feature<GeoJSON.Point>, line: GeoJSON.Feature<GeoJSON.LineString>): GeoJSON.Feature<GeoJSON.LineString>;
/**
* Takes a Point and a LineString and calculates the closest Point on the LineString.
@@ -355,7 +355,7 @@ declare namespace turf {
* @param point Point to snap from
* @returns Closest point on the line to point
*/
function pointOnLine(line: GeoJSON.Feature, point: GeoJSON.Feature): GeoJSON.Feature;
function pointOnLine(line: GeoJSON.Feature<GeoJSON.LineString>, point: GeoJSON.Feature<GeoJSON.Point>): GeoJSON.Feature<GeoJSON.Point>;
//////////////////////////////////////////////////////
// Helper
@@ -366,7 +366,7 @@ declare namespace turf {
* @param features Input features
* @returns A FeatureCollection of input features
*/
function featurecollection(features: Array<GeoJSON.Feature>): GeoJSON.FeatureCollection;
function featurecollection(features: Array<GeoJSON.Feature<any>>): GeoJSON.FeatureCollection<any>;
/**
* Creates a LineString based on a coordinate array. Properties can be added optionally.
@@ -374,7 +374,7 @@ declare namespace turf {
* @param [properties] An Object of key-value pairs to add as properties
* @returns A LineString feature
*/
function linestring(coordinates: Array<Array<number>>, properties?: any): GeoJSON.Feature;
function linestring(coordinates: Array<Array<number>>, properties?: any): GeoJSON.Feature<GeoJSON.LineString>;
/**
* Takes coordinates and properties (optional) and returns a new Point feature.
@@ -382,7 +382,7 @@ declare namespace turf {
* @param [properties] An Object of key-value pairs to add as properties
* @returns A Point feature
*/
function point(coordinates: Array<number>, properties?: any): GeoJSON.Feature;
function point(coordinates: Array<number>, properties?: any): GeoJSON.Feature<GeoJSON.Point>;
/**
* Takes an array of LinearRings and optionally an Object with properties and returns a Polygon feature.
@@ -390,7 +390,7 @@ declare namespace turf {
* @param [properties] An Object of key-value pairs to add as properties
* @returns A Polygon feature
*/
function polygon(rings: Array<Array<Array<number>>>, properties?: any): GeoJSON.Feature;
function polygon(rings: Array<Array<Array<number>>>, properties?: any): GeoJSON.Feature<GeoJSON.Polygon>;
//////////////////////////////////////////////////////
// Data
@@ -403,7 +403,7 @@ declare namespace turf {
* @param value The value of that property on which to filter
* @returns A filtered collection with only features that match input key and value
*/
function filter(features: GeoJSON.FeatureCollection, key: string, value: string): GeoJSON.FeatureCollection;
function filter(features: GeoJSON.FeatureCollection<any>, key: string, value: string): GeoJSON.FeatureCollection<any>;
/**
* Generates random GeoJSON data, including Points and Polygons, for testing and experimentation.
@@ -415,7 +415,7 @@ declare namespace turf {
* - The total number of decimal degrees longitude or latitude that a polygon can extent outwards to from its center. Default is 10.
* @returns Generated random features
*/
function random(type?: string, count?: number, options?: {bbox?: Array<number>; num_vertices?: number; max_radial_length?: number;}): GeoJSON.FeatureCollection;
function random(type?: string, count?: number, options?: {bbox?: Array<number>; num_vertices?: number; max_radial_length?: number;}): GeoJSON.FeatureCollection<any>;
/**
* Takes a FeatureCollection of any type, a property, and a value and returns a FeatureCollection with features matching that property-value pair removed.
@@ -424,7 +424,7 @@ declare namespace turf {
* @param value The value to remove
* @returns The resulting FeatureCollection without features that match the property-value pair
*/
function remove(features: GeoJSON.FeatureCollection, property: string, value: string): GeoJSON.FeatureCollection;
function remove(features: GeoJSON.FeatureCollection<any>, property: string, value: string): GeoJSON.FeatureCollection<any>;
/**
* Takes a FeatureCollection and returns a FeatureCollection with given number of features at random.
@@ -432,7 +432,7 @@ declare namespace turf {
* @param n Number of features to select
* @returns A FeatureCollection with n features
*/
function sample(features: GeoJSON.FeatureCollection, n: number): GeoJSON.FeatureCollection;
function sample(features: GeoJSON.FeatureCollection<any>, n: number): GeoJSON.FeatureCollection<any>;
//////////////////////////////////////////////////////
// Interpolation
@@ -445,7 +445,7 @@ declare namespace turf {
* @param units Used in calculating cellWidth ('miles' or 'kilometers')
* @returns A hexagonal grid
*/
function hexGrid(bbox: Array<number>, cellWidth: number, units: string): GeoJSON.FeatureCollection;
function hexGrid(bbox: Array<number>, cellWidth: number, units: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Takes points with z-values and an array of value breaks and generates isolines.
@@ -455,7 +455,7 @@ declare namespace turf {
* @param breaks Where to draw contours
* @returns Isolines
*/
function isolines(points: GeoJSON.FeatureCollection, z: string, resolution: number, breaks: Array<number>): GeoJSON.FeatureCollection;
function isolines(points: GeoJSON.FeatureCollection<GeoJSON.Point>, z: string, resolution: number, breaks: Array<number>): GeoJSON.FeatureCollection<GeoJSON.LineString>;
/**
* Takes a triangular plane as a Polygon and a Point within that triangle and returns the z-value at that point.
@@ -464,7 +464,7 @@ declare namespace turf {
* @param triangle A Polygon feature with three vertices
* @returns The z-value for interpolatedPoint
*/
function planepoint(interpolatedPoint: GeoJSON.Feature, triangle: GeoJSON.Feature): number;
function planepoint(interpolatedpoint: GeoJSON.Feature<GeoJSON.Point>, triangle: GeoJSON.Feature<GeoJSON.Polygon>): number;
/**
* Takes a bounding box and a cell depth and returns a set of points in a grid.
@@ -473,7 +473,7 @@ declare namespace turf {
* @param units Used in calculating cellWidth ('miles' or 'kilometers')
* @returns Grid of points
*/
function pointGrid(extent: Array<number>, cellWidth: number, units: string): GeoJSON.FeatureCollection;
function pointGrid(extent: Array<number>, cellWidth: number, units: string): GeoJSON.FeatureCollection<GeoJSON.Point>;
/**
* Takes a bounding box and a cell depth and returns a set of square polygons in a grid.
@@ -482,7 +482,7 @@ declare namespace turf {
* @param units Used in calculating cellWidth ('miles' or 'kilometers')
* @returns Grid of polygons
*/
function squareGrid(extent: Array<number>, cellWidth: number, units: string): GeoJSON.FeatureCollection;
function squareGrid(extent: Array<number>, cellWidth: number, units: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Takes a set of points and the name of a z-value property and creates a Triangulated Irregular Network, or a TIN for short, returned as a collection of Polygons.
@@ -492,7 +492,7 @@ declare namespace turf {
* @param [propertyName] Name of the property from which to pull z values This is optional: if not given, then there will be no extra data added to the derived triangles.
* @returns TIN output
*/
function tin(points: GeoJSON.FeatureCollection, propertyName?: string): GeoJSON.FeatureCollection;
function tin(points: GeoJSON.FeatureCollection<GeoJSON.Point>, propertyName?: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
/**
* Takes a bounding box and a cell depth and returns a set of triangular polygons in a grid.
@@ -501,7 +501,7 @@ declare namespace turf {
* @param units Used in calculating cellWidth ('miles' or 'kilometers')
* @returns Grid of triangles
*/
function triangleGrid(extent: Array<number>, cellWidth: number, units: string): GeoJSON.FeatureCollection;
function triangleGrid(extent: Array<number>, cellWidth: number, units: string): GeoJSON.FeatureCollection<GeoJSON.Polygon>;
//////////////////////////////////////////////////////
// Joins
@@ -514,7 +514,7 @@ declare namespace turf {
* @param polygon Input polygon or multipolygon
* @returns true if the Point is inside the Polygon; false if the Point is not inside the Polygon
*/
function inside(point: GeoJSON.Feature, polygon: GeoJSON.Feature): boolean;
function inside(point: GeoJSON.Feature<GeoJSON.Point>, polygon: GeoJSON.Feature<GeoJSON.Polygon>): boolean;
/**
* Takes a set of points and a set of polygons and performs a spatial join.
@@ -524,7 +524,7 @@ declare namespace turf {
* @param containingPolyId Property in points in which to store joined property from polygons
* @returns Points with containingPolyId property containing values from polyId
*/
function tag(points: GeoJSON.FeatureCollection, polygons: GeoJSON.FeatureCollection, polyId: string, containingPolyId: string): GeoJSON.FeatureCollection;
function tag(points: GeoJSON.FeatureCollection<GeoJSON.Point>, polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>, polyId: string, containingPolyId: string): GeoJSON.FeatureCollection<GeoJSON.Point>;
/**
* Takes a set of points and a set of polygons and returns the points that fall within the polygons.
@@ -532,7 +532,7 @@ declare namespace turf {
* @param polygons Input polygons
* @returns Points that land within at least one polygon
*/
function within(points: GeoJSON.FeatureCollection, polygons: GeoJSON.FeatureCollection): GeoJSON.FeatureCollection;
function within(points: GeoJSON.FeatureCollection<GeoJSON.Point>, polygons: GeoJSON.FeatureCollection<GeoJSON.Polygon>): GeoJSON.FeatureCollection<GeoJSON.Point>;
//////////////////////////////////////////////////////
// Classification
@@ -545,7 +545,7 @@ declare namespace turf {
* @param numberOfBreaks Number of classes in which to group the data
* @returns The break number for each class plus the minimum and maximum values
*/
function jenks(input: GeoJSON.FeatureCollection, field: string, numberOfBreaks: number): Array<number>;
function jenks(input: GeoJSON.FeatureCollection<any>, field: string, numberOfBreaks: number): Array<number>;
/**
* Takes a reference point and a set of points and returns the point from the set closest to the reference.
@@ -553,7 +553,7 @@ declare namespace turf {
* @param against Input point set
* @returns The closest point in the set to the reference point
*/
function nearest(point: GeoJSON.Feature, against: GeoJSON.FeatureCollection): GeoJSON.Feature;
function nearest(point: GeoJSON.Feature<GeoJSON.Point>, against: GeoJSON.FeatureCollection<GeoJSON.Point>): GeoJSON.Feature<GeoJSON.Point>;
/**
* Takes a FeatureCollection, a property name, and a set of percentiles and returns a quantile array.
@@ -562,7 +562,7 @@ declare namespace turf {
* @param percentiles An Array of percentiles on which to calculate quantile values
* @returns An array of the break values
*/
function quantile(input: GeoJSON.FeatureCollection, field: string, percentiles: Array<number>): Array<number>;
function quantile(input: GeoJSON.FeatureCollection<any>, field: string, percentiles: Array<number>): Array<number>;
/**
* Takes a FeatureCollection, an input field, an output field, and an array of translations and outputs an identical FeatureCollection with the output field property populated.
@@ -572,5 +572,5 @@ declare namespace turf {
* @param translations An array of translations
* @returns A FeatureCollection with identical geometries to input but with outField populated.
*/
function reclass(input: GeoJSON.FeatureCollection, inField: string, outField: string, translations: Array<any>): GeoJSON.FeatureCollection;
function reclass(input: GeoJSON.FeatureCollection<any>, inField: string, outField: string, translations: Array<any>): GeoJSON.FeatureCollection<any>;
}
+119
View File
@@ -0,0 +1,119 @@
/// <reference path="wampy.d.ts" />
/// <reference path="../node/node.d.ts" />
import Wampy from 'wampy';
var ws = new Wampy('http://wamp.router.url', {realm: 'WAMPRealm'});
ws.options();
ws.options({
reconnectInterval: 1000,
maxRetries: 999,
onConnect: function () { console.log('Yahoo! We are online!'); },
onClose: function () { console.log('See you next time!'); },
onError: function () { console.log('Breakdown happened'); },
onReconnect: function () { console.log('Reconnecting...'); }
});
ws.connect();
ws.connect('/my-socket-path');
ws.connect('wss://socket.server.com:5000/ws');
var id: number = ws.getSessionId();
ws.disconnect();
ws.abort();
ws.subscribe('system.monitor.update', function (data) {
console.log('Received system.monitor.update event!');
})
.subscribe('client.message', function (data) {
console.log('Received client.message event!');
});
var f1 = function () { console.log('Subscribe processing!'); };
ws.unsubscribe('subscribed.topic', f1);
ws.unsubscribe('chat.message.received');
ws.call('get.server.time', null, {
onSuccess: function (stime) {
console.log('RPC successfully called');
console.log('Server time is ' + stime);
},
onError: function (err) {
console.log('RPC call failed with error ' + err);
}
});
ws.publish('system.monitor.update');
ws.getOpStatus();
ws.publish('user.logged.in');
ws.publish('chat.message.received', 'user message');
ws.publish('chat.message.received', ['user message1', 'user message2']);
ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 });
ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 }, {
onSuccess: function () { console.log('User successfully modified'); }
});
ws.publish('user.modified', { field1: 'field1', field2: true, field3: 123 }, {
onSuccess: function () { console.log('User successfully modified'); },
onError: function (err) { console.log('User modification failed', err); }
});
ws.publish('chat.message.received', ['Private message'], null, { eligible: 123456789 });
ws.call('server.time', null, function (data) { console.log('Server time is ' + data[0]); });
ws.call('start.migration', null, {
onSuccess: function (data) {
console.log('RPC successfully called');
},
onError: function (err) {
console.log('RPC call failed!',err);
}
});
ws.call('restore.backup', { backupFile: 'backup.zip' }, {
onSuccess: function (data) {
console.log('Backup successfully restored');
},
onError: function (err) {
console.log('Restore failed!',err);
}
});
ws.call('start.migration', null, {
onSuccess: function (data) {
console.log('RPC successfully called');
},
onError: function (err) {
console.log('RPC call failed!',err);
}
});
var status = ws.getOpStatus();
ws.cancel(status.reqId);
var sqrt_f = function (x: number) { return x*x; };
ws.register('sqrt.value', sqrt_f);
ws.register('sqrt.value', {
rpc: sqrt_f,
onSuccess: function (data) {
console.log('RPC successfully registered');
},
onError: function (err) {
console.log('RPC registration failed!',err);
}
});
ws.unregister('sqrt.value');
ws.unregister('sqrt.value', {
onSuccess: function (data) {
console.log('RPC successfully unregistered');
},
onError: function (err) {
console.log('RPC unregistration failed!',err);
}
});
+93
View File
@@ -0,0 +1,93 @@
// Type definitions for wampy.js v2.0.1
// Project: https://github.com/KSDaemon/wampy.js
// Definitions by: Konstantin Burkalev <https://github.com/KSDaemon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "wampy" {
interface WampyOptions {
autoReconnect?: boolean;
reconnectInterval?: number;
maxRetries?: number;
transportEncoding?: string;
realm?: string;
helloCustomDetails?: any;
onConnect?: () => void;
onClose?: () => void;
onError?: () => void;
onReconnect?: () => void;
ws?: any;
msgpackCoder?: any;
}
interface WampyOpStatus {
code: number;
description: string;
reqId?: number;
}
interface SuccessErrorCallbacksHash {
onSuccess?: (data: any) => void;
onError?: (err: string) => void;
}
interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash {
onEvent: (data: any) => void;
}
interface RegisterCallbacksHash extends SuccessErrorCallbacksHash {
rpc: (data: any) => any;
}
interface CallSuccessErrorCallbacksHash {
onSuccess: (data: any) => any;
onError?: (err: string) => void;
}
interface AdvancedOptions {
exclude?: number | number[];
eligible?: number | number[];
exclude_me?: boolean;
disclose_me?: boolean;
}
interface CallAdvancedOptions extends AdvancedOptions {
receive_progress?: boolean;
}
interface CancelAdvancedOptions {
mode?: "skip" | "kill" | "killnowait";
}
interface Wampy {
options(opts?: WampyOptions): WampyOptions | Wampy;
getOpStatus(): WampyOpStatus;
getSessionId(): number;
connect(url?: string): Wampy;
disconnect(): Wampy;
abort(): Wampy;
subscribe(topicURI: string, callbacks: (((data: any) => void) | SubscribeCallbacksHash)): Wampy;
unsubscribe(topicURI: string, callbacks?: (((data: any) => void) | SubscribeCallbacksHash)): Wampy;
publish(topicURI: string,
payload?: any,
callbacks?: SuccessErrorCallbacksHash,
advancedOptions?: AdvancedOptions): Wampy;
call(topicURI: string,
payload?: any,
callbacks?: (((data: any) => void) | CallSuccessErrorCallbacksHash),
advancedOptions?: CallAdvancedOptions): Wampy;
cancel(reqId: number,
callbacks?: ((() => void) | SuccessErrorCallbacksHash),
advancedOptions?: CancelAdvancedOptions): Wampy;
register(topicURI: string, callbacks: (((data: any) => any) | RegisterCallbacksHash)): Wampy;
unregister(topicURI: string, callbacks?: ((() => void) | SuccessErrorCallbacksHash)): Wampy;
}
interface WampyInstance {
new(url?: string, options?: WampyOptions): Wampy;
}
var wampy: WampyInstance;
export default wampy;
}
+5
View File
@@ -188,6 +188,10 @@ interface MediaStreamAudioSourceNode extends AudioNode {
}
interface MediaStreamAudioDestinationNode extends AudioNode {
stream: MediaStream;
}
interface AudioBuffer {
copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void;
@@ -202,4 +206,5 @@ interface AudioContext {
suspend(): Promise<void>;
resume(): Promise<void>;
close(): Promise<void>;
createMediaStreamDestination(): MediaStreamAudioDestinationNode;
}