From f70bcf9a0ef640915ad4324b23396f28e2803ddc Mon Sep 17 00:00:00 2001 From: Christian Kittelmann Date: Tue, 27 Sep 2016 12:54:43 +0200 Subject: [PATCH 1/9] vue: fixed definition for activate() in ComponentOption --- vue/vue-tests.ts | 5 +++++ vue/vue.d.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/vue/vue-tests.ts b/vue/vue-tests.ts index 48d8d91683..a15c3e49c1 100644 --- a/vue/vue-tests.ts +++ b/vue/vue-tests.ts @@ -88,6 +88,11 @@ namespace TestGlobalAPI { }, init: function() {} }); + Vue.component("component", { + activate: function(callback: Function) { + callback(); + } + }); var transition = Vue.transition("transition"); Vue.transition("transition", transition); Vue.transition("transition", { diff --git a/vue/vue.d.ts b/vue/vue.d.ts index a335ee63d1..d65a50da63 100644 --- a/vue/vue.d.ts +++ b/vue/vue.d.ts @@ -96,7 +96,7 @@ declare namespace vuejs { detached?(): void; beforeDestroy?(): void; destroyed?(): void; - activate?(): void; + activate?(callback: Function): void; directives?: { [key: string]: (DirectiveOption | Function) }; elementDirectives?: { [key: string]: (DirectiveOption | Function) }; filters?: { [key: string]: (Function | FilterOption) }; From 9fadbac5f835d7ad1b0b2d7241e25bf2c8c33d72 Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Wed, 28 Sep 2016 11:28:19 -0400 Subject: [PATCH 2/9] Implemented cheap-ruler definition --- cheap-ruler/cheap-ruler-tests.ts | 60 ++++++++ cheap-ruler/cheap-ruler.d.ts | 226 +++++++++++++++++++++++++++++++ 2 files changed, 286 insertions(+) create mode 100644 cheap-ruler/cheap-ruler-tests.ts create mode 100644 cheap-ruler/cheap-ruler.d.ts diff --git a/cheap-ruler/cheap-ruler-tests.ts b/cheap-ruler/cheap-ruler-tests.ts new file mode 100644 index 0000000000..67388e52fd --- /dev/null +++ b/cheap-ruler/cheap-ruler-tests.ts @@ -0,0 +1,60 @@ +/// + +import * as cheapRuler from 'cheap-ruler' + +// -- Fixtures -- +const unit = 'miles' +const lineString: GeoJSON.Feature = { + "type": "Feature", + "properties": {}, + "geometry": { + "type": "LineString", + "coordinates": [ + [-77.031669, 38.878605], + [-77.029609, 38.881946], + [-77.020339, 38.884084], + [-77.025661, 38.885821], + [-77.021884, 38.889563], + [-77.019824, 38.892368] + ] + } +} +const line = lineString.geometry.coordinates +const polygon = [[ + [-67.031, 50.458], [-67.031, 50.534], [-66.929, 50.534], + [-66.929, 50.458], [-67.031, 50.458] +]] +const points = [ + [-67.031, 50.458], [-67.031, 50.534], + [-66.929, 50.534], [-66.929, 50.458] +] + +// -- Test initiators -- +cheapRuler(35.05) +cheapRuler(35.05, 'miles') +cheapRuler(35.05, unit) +cheapRuler.fromTile(1567, 12) +cheapRuler.fromTile(1567, 12, 'miles') +cheapRuler.fromTile(1567, 12, unit) + +// -- Test units -- +cheapRuler.units +cheapRuler.units.miles +cheapRuler.units.kilometers +50 * cheapRuler.units.yards / cheapRuler.units.meters + +// -- Test cheapRuler -- +const ruler = cheapRuler(35.05, 'kilometers') + +console.log(ruler.distance([30.5, 50.5], [30.51, 50.49])) +ruler.bearing([30.5, 50.5], [30.51, 50.49]) +ruler.destination([30.5, 50.5], 0.1, 90) +ruler.lineDistance(points) +ruler.area(polygon) +ruler.along(line, 2.5) +ruler.pointOnLine(line, [-67.04, 50.5]).point +ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line) +ruler.lineSliceAlong(10, 20, line) +ruler.bufferPoint([30.5, 50.5], 0.01) +ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2) +ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]) \ No newline at end of file diff --git a/cheap-ruler/cheap-ruler.d.ts b/cheap-ruler/cheap-ruler.d.ts new file mode 100644 index 0000000000..97ad51730e --- /dev/null +++ b/cheap-ruler/cheap-ruler.d.ts @@ -0,0 +1,226 @@ +// Type definitions for cheap-ruler 2.4.1 +// Project: https://github.com/mapbox/cheap-ruler +// Definitions by: Denis Carriere +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "cheap-ruler" { + interface TemplateUnits { + kilometers: number + miles: number + nauticalmiles: number + meters: number + metres: number + yards: number + feet: number + inches: number + } + interface InterfacePointOnLine { + point: Array + index: number + t: number + } + class CheapRuler { + /** + * Given two points of the form [longitude, latitude], returns the distance. + * + * @name distance + * @param {Array} a point [longitude, latitude] + * @param {Array} b point [longitude, latitude] + * @returns {number} distance + * @example + * var distance = ruler.distance([30.5, 50.5], [30.51, 50.49]); + * //=distance + */ + distance(a: Array, b: Array): number; + + /** + * Returns the bearing between two points in angles. + * + * @name bearing + * @param {Array} a point [longitude, latitude] + * @param {Array} b point [longitude, latitude] + * @returns {number} bearing + * @example + * var bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]); + * //=bearing + */ + bearing(a: Array, b: Array): number; + + /** + * Returns a new point given distance and bearing from the starting point. + * + * @name destination + * @param {Array} p point [longitude, latitude] + * @param {number} dist distance + * @param {number} bearing + * @returns {Array} point [longitude, latitude] + * @example + * var point = ruler.destination([30.5, 50.5], 0.1, 90); + * //=point + */ + destination(p: Array, dist: number, bearing: number): Array; + + /** + * Given a line (an array of points), returns the total line distance. + * + * @name lineDistance + * @param {Array>} points [longitude, latitude] + * @returns {number} total line distance + * @example + * var length = ruler.lineDistance([ + * [-67.031, 50.458], [-67.031, 50.534], + * [-66.929, 50.534], [-66.929, 50.458] + * ]); + * //=length + */ + lineDistance(points: Array>): number; + + /** + * Given a polygon (an array of rings, where each ring is an array of points), returns the area. + * + * @name area + * @param {Array>>} polygon + * @returns {number} area value in the specified units (square kilometers by default) + * @example + * var area = ruler.area([[ + * [-67.031, 50.458], [-67.031, 50.534], [-66.929, 50.534], + * [-66.929, 50.458], [-67.031, 50.458] + * ]]); + * //=area + */ + area(polygon: Array>>): number; + + /** + * Returns the point at a specified distance along the line. + * + * @name along + * @param {Array>} line + * @param {number} dist distance + * @returns {Array} point [longitude, latitude] + * @example + * var point = ruler.along(line, 2.5); + * //=point + */ + along(line: Array>, dist: number): Array + + /** + * Returns an object of the form {point, index} where point is closest point on the line from the given point, and index is the start index of the segment with the closest point. + * + * @pointOnLine + * @param {Array>} line + * @param {Array} p point [longitude, latitude] + * @returns {Object} {point, index} + * @example + * var point = ruler.pointOnLine(line, [-67.04, 50.5]).point; + * //=point + */ + pointOnLine(line: Array>, p: Array): InterfacePointOnLine + + /** + * Returns a part of the given line between the start and the stop points (or their closest points on the line). + * + * @name lineSlice + * @param {Array} start point [longitude, latitude] + * @param {Array} stop point [longitude, latitude] + * @param {Array>} line + * @returns {Array>} line part of a line + * @example + * var line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1); + * //=line2 + */ + lineSlice(start: Array, stop: Array, line: Array>): Array> + + /** + * Returns a part of the given line between the start and the stop points indicated by distance along the line. + * + * @name lineSliceAlong + * @param {number} start distance + * @param {number} stop distance + * @param {Array>} line + * @returns {Array>} line part of a line + * @example + * var line2 = ruler.lineSliceAlong(10, 20, line1); + * //=line2 + */ + lineSliceAlong(start: number, stop: number, line: Array>): Array> + + /** + * Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance. + * + * @name bufferPoint + * @param {Array} p point [longitude, latitude] + * @param {number} buffer + * @returns {Array} box object ([w, s, e, n]) + * @example + * var bbox = ruler.bufferPoint([30.5, 50.5], 0.01); + * //=bbox + */ + bufferPoint(p: Array, buffer: number): Array + + /** + * Given a bounding box, returns the box buffered by a given distance. + * + * @name bufferBBox + * @param {Array} box object ([w, s, e, n]) + * @param {number} buffer + * @returns {Array} box object ([w, s, e, n]) + * @example + * var bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2); + * //=bbox + */ + bufferBBox(bbox: Array, buffer: number): Array + + /** + * Returns true if the given point is inside in the given bounding box, otherwise false. + * + * @name insideBBox + * @param {Array} p point [longitude, latitude] + * @param {Array} box object ([w, s, e, n]) + * @returns {boolean} + * @example + * var inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]); + * //=inside + */ + insideBBox(p: Array, bbox: Array): boolean + } + /** + * A collection of very fast approximations to common geodesic measurements. Useful for performance-sensitive code that measures things on a city scale. + * + * @name cheapRuler + * @param {number} lat latitude + * @param {string} [units='kilometers'] + * @returns {Object} CheapRuler + * @example + * var ruler = cheapRuler(35.05, 'miles'); + * //=ruler + */ + function cheapRuler(lat: number, units?: string): CheapRuler; + namespace cheapRuler { + /** + * Multipliers for converting between units. + * + * @name units + * @example + * // convert 50 meters to yards + * 50 * cheapRuler.units.yards / cheapRuler.units.meters; + */ + const units: TemplateUnits + + /** + * Creates a ruler object from tile coordinates (y and z). Convenient in tile-reduce scripts. + * + * @name fromTile + * @param {number} y + * @param {number} z + * @param {string} [units='kilometers'] + * @returns {Object} CheapRuler + * @example + * var ruler = cheapRuler.fromTile(1567, 12); + * //=ruler + */ + function fromTile(y: number, z: number, units?: string) + } + export = cheapRuler +} \ No newline at end of file From 7898c8c4fabe1dc79bc68066478697f00f516f7e Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Wed, 28 Sep 2016 11:29:48 -0400 Subject: [PATCH 3/9] Remove GeoJSON dependency --- cheap-ruler/cheap-ruler.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/cheap-ruler/cheap-ruler.d.ts b/cheap-ruler/cheap-ruler.d.ts index 97ad51730e..dd0dcb9dbc 100644 --- a/cheap-ruler/cheap-ruler.d.ts +++ b/cheap-ruler/cheap-ruler.d.ts @@ -3,8 +3,6 @@ // Definitions by: Denis Carriere // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare module "cheap-ruler" { interface TemplateUnits { kilometers: number From 4f3c8528c27c42684adea93d5608bc9f90e9ac76 Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Wed, 28 Sep 2016 11:38:10 -0400 Subject: [PATCH 4/9] Cheap-ruler fixes - Removed GeoJSON from tests - Added return-type to fromTile --- cheap-ruler/cheap-ruler-tests.ts | 6 +++--- cheap-ruler/cheap-ruler.d.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cheap-ruler/cheap-ruler-tests.ts b/cheap-ruler/cheap-ruler-tests.ts index 67388e52fd..2a1bf6521d 100644 --- a/cheap-ruler/cheap-ruler-tests.ts +++ b/cheap-ruler/cheap-ruler-tests.ts @@ -4,7 +4,7 @@ import * as cheapRuler from 'cheap-ruler' // -- Fixtures -- const unit = 'miles' -const lineString: GeoJSON.Feature = { +const lineString = { "type": "Feature", "properties": {}, "geometry": { @@ -44,9 +44,9 @@ cheapRuler.units.kilometers 50 * cheapRuler.units.yards / cheapRuler.units.meters // -- Test cheapRuler -- -const ruler = cheapRuler(35.05, 'kilometers') +const ruler = cheapRuler(35.05) -console.log(ruler.distance([30.5, 50.5], [30.51, 50.49])) +ruler.distance([30.5, 50.5], [30.51, 50.49]) ruler.bearing([30.5, 50.5], [30.51, 50.49]) ruler.destination([30.5, 50.5], 0.1, 90) ruler.lineDistance(points) diff --git a/cheap-ruler/cheap-ruler.d.ts b/cheap-ruler/cheap-ruler.d.ts index dd0dcb9dbc..300af9ee5d 100644 --- a/cheap-ruler/cheap-ruler.d.ts +++ b/cheap-ruler/cheap-ruler.d.ts @@ -218,7 +218,7 @@ declare module "cheap-ruler" { * var ruler = cheapRuler.fromTile(1567, 12); * //=ruler */ - function fromTile(y: number, z: number, units?: string) + function fromTile(y: number, z: number, units?: string): CheapRuler; } export = cheapRuler } \ No newline at end of file From bf34b77b69fbba586273d101a3fb2538b1c080ea Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Wed, 28 Sep 2016 11:59:07 -0400 Subject: [PATCH 5/9] Update JSDocs cheap-ruler Update based on comments https://github.com/mapbox/cheap-ruler/pull/20 - Removed `{@name}` - Changed {Object} to {CheapRuler} --- cheap-ruler/cheap-ruler.d.ts | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/cheap-ruler/cheap-ruler.d.ts b/cheap-ruler/cheap-ruler.d.ts index 300af9ee5d..187b27ea82 100644 --- a/cheap-ruler/cheap-ruler.d.ts +++ b/cheap-ruler/cheap-ruler.d.ts @@ -23,7 +23,6 @@ declare module "cheap-ruler" { /** * Given two points of the form [longitude, latitude], returns the distance. * - * @name distance * @param {Array} a point [longitude, latitude] * @param {Array} b point [longitude, latitude] * @returns {number} distance @@ -36,7 +35,6 @@ declare module "cheap-ruler" { /** * Returns the bearing between two points in angles. * - * @name bearing * @param {Array} a point [longitude, latitude] * @param {Array} b point [longitude, latitude] * @returns {number} bearing @@ -49,7 +47,6 @@ declare module "cheap-ruler" { /** * Returns a new point given distance and bearing from the starting point. * - * @name destination * @param {Array} p point [longitude, latitude] * @param {number} dist distance * @param {number} bearing @@ -63,7 +60,6 @@ declare module "cheap-ruler" { /** * Given a line (an array of points), returns the total line distance. * - * @name lineDistance * @param {Array>} points [longitude, latitude] * @returns {number} total line distance * @example @@ -78,7 +74,6 @@ declare module "cheap-ruler" { /** * Given a polygon (an array of rings, where each ring is an array of points), returns the area. * - * @name area * @param {Array>>} polygon * @returns {number} area value in the specified units (square kilometers by default) * @example @@ -93,7 +88,6 @@ declare module "cheap-ruler" { /** * Returns the point at a specified distance along the line. * - * @name along * @param {Array>} line * @param {number} dist distance * @returns {Array} point [longitude, latitude] @@ -119,7 +113,6 @@ declare module "cheap-ruler" { /** * Returns a part of the given line between the start and the stop points (or their closest points on the line). * - * @name lineSlice * @param {Array} start point [longitude, latitude] * @param {Array} stop point [longitude, latitude] * @param {Array>} line @@ -133,7 +126,6 @@ declare module "cheap-ruler" { /** * Returns a part of the given line between the start and the stop points indicated by distance along the line. * - * @name lineSliceAlong * @param {number} start distance * @param {number} stop distance * @param {Array>} line @@ -147,7 +139,6 @@ declare module "cheap-ruler" { /** * Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance. * - * @name bufferPoint * @param {Array} p point [longitude, latitude] * @param {number} buffer * @returns {Array} box object ([w, s, e, n]) @@ -160,7 +151,6 @@ declare module "cheap-ruler" { /** * Given a bounding box, returns the box buffered by a given distance. * - * @name bufferBBox * @param {Array} box object ([w, s, e, n]) * @param {number} buffer * @returns {Array} box object ([w, s, e, n]) @@ -173,7 +163,6 @@ declare module "cheap-ruler" { /** * Returns true if the given point is inside in the given bounding box, otherwise false. * - * @name insideBBox * @param {Array} p point [longitude, latitude] * @param {Array} box object ([w, s, e, n]) * @returns {boolean} @@ -186,10 +175,9 @@ declare module "cheap-ruler" { /** * A collection of very fast approximations to common geodesic measurements. Useful for performance-sensitive code that measures things on a city scale. * - * @name cheapRuler * @param {number} lat latitude * @param {string} [units='kilometers'] - * @returns {Object} CheapRuler + * @returns {CheapRuler} * @example * var ruler = cheapRuler(35.05, 'miles'); * //=ruler @@ -199,7 +187,6 @@ declare module "cheap-ruler" { /** * Multipliers for converting between units. * - * @name units * @example * // convert 50 meters to yards * 50 * cheapRuler.units.yards / cheapRuler.units.meters; @@ -209,11 +196,10 @@ declare module "cheap-ruler" { /** * Creates a ruler object from tile coordinates (y and z). Convenient in tile-reduce scripts. * - * @name fromTile * @param {number} y * @param {number} z * @param {string} [units='kilometers'] - * @returns {Object} CheapRuler + * @returns {CheapRuler} * @example * var ruler = cheapRuler.fromTile(1567, 12); * //=ruler From f58fded0a8cf5deb7fb1b136685c49ec310e9a57 Mon Sep 17 00:00:00 2001 From: Sahin Kureta Date: Thu, 29 Sep 2016 05:17:54 +0300 Subject: [PATCH 6/9] Fixed type of onchallenge --- autobahn/autobahn.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autobahn/autobahn.d.ts b/autobahn/autobahn.d.ts index bb7a0c86ae..496738875e 100644 --- a/autobahn/autobahn.d.ts +++ b/autobahn/autobahn.d.ts @@ -211,7 +211,7 @@ declare namespace autobahn { retry_delay_jitter?: number; url?: string; protocols?: string[]; - onchallenge?: (session: Session, method: string, extra: any) => OnChallengeHandler; + onchallenge?: OnChallengeHandler; realm?: string; authmethods?: string[]; authid?: string; From 50d20cf6e684b76f26c55eff966735e2db985cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Verg=C3=A9?= Date: Wed, 28 Sep 2016 16:46:08 +0200 Subject: [PATCH 7/9] feat(CKEditor): Add missing typings for `focusManager` --- ckeditor/ckeditor-tests.ts | 19 +++++++++++++++++++ ckeditor/ckeditor.d.ts | 13 ++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ckeditor/ckeditor-tests.ts b/ckeditor/ckeditor-tests.ts index f7deb67069..bcf2a7807b 100644 --- a/ckeditor/ckeditor-tests.ts +++ b/ckeditor/ckeditor-tests.ts @@ -300,3 +300,22 @@ function test_adding_widget() { }); } } + +function test_focusManager() { + var textarea = document.createElement('textarea'); + var instance = CKEDITOR.replace(textarea); + var element = CKEDITOR.document.getById('myElement'); + + instance.focusManager.focus(); + instance.focusManager.focus(element); + instance.focusManager.lock(); + instance.focusManager.unlock(); + instance.focusManager.blur(); + instance.focusManager.blur(true); + instance.focusManager.add(element, true); + instance.focusManager.remove(element); + + var focusManager = new CKEDITOR.focusManager(instance); + var object: CKEDITOR.dom.domObject = focusManager.currentActive; + var bool: boolean = focusManager.hasFocus; +} diff --git a/ckeditor/ckeditor.d.ts b/ckeditor/ckeditor.d.ts index 60b6491407..b5009fa031 100644 --- a/ckeditor/ckeditor.d.ts +++ b/ckeditor/ckeditor.d.ts @@ -544,8 +544,19 @@ declare namespace CKEDITOR { } - interface focusManager { + class focusManager { + // Properties + currentActive: dom.domObject; + hasFocus: boolean; + // Methods + constructor(editor: editor); + focus(currentActive?: dom.element): void; + lock(): void; + unlock(): void; + blur(noDelay?: boolean): void; + add(element: dom.element, isCapture: boolean): void; + remove(element: dom.element): void; } interface keystrokeHandler { From 2b7104bab0b653ebd2f247b01d51c9a210e33198 Mon Sep 17 00:00:00 2001 From: Denis Carriere Date: Thu, 29 Sep 2016 07:57:54 -0400 Subject: [PATCH 8/9] Added type Point for simplicity Comments from @vladima --- cheap-ruler/cheap-ruler-tests.ts | 19 ++++---- cheap-ruler/cheap-ruler.d.ts | 80 +++++++++++++++++--------------- 2 files changed, 54 insertions(+), 45 deletions(-) diff --git a/cheap-ruler/cheap-ruler-tests.ts b/cheap-ruler/cheap-ruler-tests.ts index 2a1bf6521d..6e2a2d45e7 100644 --- a/cheap-ruler/cheap-ruler-tests.ts +++ b/cheap-ruler/cheap-ruler-tests.ts @@ -3,6 +3,9 @@ import * as cheapRuler from 'cheap-ruler' // -- Fixtures -- +const bbox = [30.5, 50.5, 31, 51] +const point1 = [30.5, 50.5] +const point2 = [30.51, 50.49] const unit = 'miles' const lineString = { "type": "Feature", @@ -46,15 +49,15 @@ cheapRuler.units.kilometers // -- Test cheapRuler -- const ruler = cheapRuler(35.05) -ruler.distance([30.5, 50.5], [30.51, 50.49]) -ruler.bearing([30.5, 50.5], [30.51, 50.49]) -ruler.destination([30.5, 50.5], 0.1, 90) +ruler.distance(point1, point2) +ruler.bearing(point1, point2) +ruler.destination(point1, 0.1, 90) ruler.lineDistance(points) ruler.area(polygon) ruler.along(line, 2.5) -ruler.pointOnLine(line, [-67.04, 50.5]).point -ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line) +ruler.pointOnLine(line, point1).point +ruler.lineSlice(point1, point2, line) ruler.lineSliceAlong(10, 20, line) -ruler.bufferPoint([30.5, 50.5], 0.01) -ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2) -ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]) \ No newline at end of file +ruler.bufferPoint(point1, 0.01) +ruler.bufferBBox(bbox, 0.2) +ruler.insideBBox(point1, bbox) \ No newline at end of file diff --git a/cheap-ruler/cheap-ruler.d.ts b/cheap-ruler/cheap-ruler.d.ts index 187b27ea82..91f417d490 100644 --- a/cheap-ruler/cheap-ruler.d.ts +++ b/cheap-ruler/cheap-ruler.d.ts @@ -4,6 +4,12 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "cheap-ruler" { + type BBox = [number, number, number, number] | number[] + type Point = [number, number] | number[] + type Line = Array + type Points = Array + type Polygon = Array> + interface TemplateUnits { kilometers: number miles: number @@ -15,7 +21,7 @@ declare module "cheap-ruler" { inches: number } interface InterfacePointOnLine { - point: Array + point: Point index: number t: number } @@ -23,44 +29,44 @@ declare module "cheap-ruler" { /** * Given two points of the form [longitude, latitude], returns the distance. * - * @param {Array} a point [longitude, latitude] - * @param {Array} b point [longitude, latitude] + * @param {Point} a point [longitude, latitude] + * @param {Point} b point [longitude, latitude] * @returns {number} distance * @example * var distance = ruler.distance([30.5, 50.5], [30.51, 50.49]); * //=distance */ - distance(a: Array, b: Array): number; + distance(a: Point, b: Point): number; /** * Returns the bearing between two points in angles. * - * @param {Array} a point [longitude, latitude] - * @param {Array} b point [longitude, latitude] + * @param {Point} a point [longitude, latitude] + * @param {Point} b point [longitude, latitude] * @returns {number} bearing * @example * var bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]); * //=bearing */ - bearing(a: Array, b: Array): number; + bearing(a: Point, b: Point): number; /** * Returns a new point given distance and bearing from the starting point. * - * @param {Array} p point [longitude, latitude] + * @param {Point} p point [longitude, latitude] * @param {number} dist distance * @param {number} bearing - * @returns {Array} point [longitude, latitude] + * @returns {Point} point [longitude, latitude] * @example * var point = ruler.destination([30.5, 50.5], 0.1, 90); * //=point */ - destination(p: Array, dist: number, bearing: number): Array; + destination(p: Point, dist: number, bearing: number): Point; /** * Given a line (an array of points), returns the total line distance. * - * @param {Array>} points [longitude, latitude] + * @param {Points} points [longitude, latitude] * @returns {number} total line distance * @example * var length = ruler.lineDistance([ @@ -69,12 +75,12 @@ declare module "cheap-ruler" { * ]); * //=length */ - lineDistance(points: Array>): number; + lineDistance(points: Points): number; /** * Given a polygon (an array of rings, where each ring is an array of points), returns the area. * - * @param {Array>>} polygon + * @param {Polygon} polygon * @returns {number} area value in the specified units (square kilometers by default) * @example * var area = ruler.area([[ @@ -83,94 +89,94 @@ declare module "cheap-ruler" { * ]]); * //=area */ - area(polygon: Array>>): number; + area(polygon: Polygon): number; /** * Returns the point at a specified distance along the line. * - * @param {Array>} line + * @param {Line} line * @param {number} dist distance - * @returns {Array} point [longitude, latitude] + * @returns {Point} point [longitude, latitude] * @example * var point = ruler.along(line, 2.5); * //=point */ - along(line: Array>, dist: number): Array + along(line: Line, dist: number): Point /** * Returns an object of the form {point, index} where point is closest point on the line from the given point, and index is the start index of the segment with the closest point. * * @pointOnLine - * @param {Array>} line - * @param {Array} p point [longitude, latitude] + * @param {Line} line + * @param {Point} p point [longitude, latitude] * @returns {Object} {point, index} * @example * var point = ruler.pointOnLine(line, [-67.04, 50.5]).point; * //=point */ - pointOnLine(line: Array>, p: Array): InterfacePointOnLine + pointOnLine(line: Line, p: Point): InterfacePointOnLine /** * Returns a part of the given line between the start and the stop points (or their closest points on the line). * - * @param {Array} start point [longitude, latitude] - * @param {Array} stop point [longitude, latitude] - * @param {Array>} line - * @returns {Array>} line part of a line + * @param {Point} start point [longitude, latitude] + * @param {Point} stop point [longitude, latitude] + * @param {Line} line + * @returns {Line} line part of a line * @example * var line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1); * //=line2 */ - lineSlice(start: Array, stop: Array, line: Array>): Array> + lineSlice(start: Point, stop: Point, line: Line): Line /** * Returns a part of the given line between the start and the stop points indicated by distance along the line. * * @param {number} start distance * @param {number} stop distance - * @param {Array>} line - * @returns {Array>} line part of a line + * @param {Line} line + * @returns {Line} line part of a line * @example * var line2 = ruler.lineSliceAlong(10, 20, line1); * //=line2 */ - lineSliceAlong(start: number, stop: number, line: Array>): Array> + lineSliceAlong(start: number, stop: number, line: Line): Line /** * Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance. * - * @param {Array} p point [longitude, latitude] + * @param {Point} p point [longitude, latitude] * @param {number} buffer - * @returns {Array} box object ([w, s, e, n]) + * @returns {BBox} box object ([w, s, e, n]) * @example * var bbox = ruler.bufferPoint([30.5, 50.5], 0.01); * //=bbox */ - bufferPoint(p: Array, buffer: number): Array + bufferPoint(p: Point, buffer: number): BBox /** * Given a bounding box, returns the box buffered by a given distance. * - * @param {Array} box object ([w, s, e, n]) + * @param {BBox} box object ([w, s, e, n]) * @param {number} buffer - * @returns {Array} box object ([w, s, e, n]) + * @returns {BBox} box object ([w, s, e, n]) * @example * var bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2); * //=bbox */ - bufferBBox(bbox: Array, buffer: number): Array + bufferBBox(bbox: BBox, buffer: number): BBox /** * Returns true if the given point is inside in the given bounding box, otherwise false. * - * @param {Array} p point [longitude, latitude] - * @param {Array} box object ([w, s, e, n]) + * @param {Point} p point [longitude, latitude] + * @param {Point} box object ([w, s, e, n]) * @returns {boolean} * @example * var inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]); * //=inside */ - insideBBox(p: Array, bbox: Array): boolean + insideBBox(p: Point, bbox: BBox): boolean } /** * A collection of very fast approximations to common geodesic measurements. Useful for performance-sensitive code that measures things on a city scale. From 2f74c100a1b567675c9cb374fc7039d5a5ce8f13 Mon Sep 17 00:00:00 2001 From: George Edwards Date: Thu, 29 Sep 2016 16:17:37 +0100 Subject: [PATCH 9/9] optional constructor for RecurrenceRule --- node-schedule/node-schedule.d.ts | 56 ++++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/node-schedule/node-schedule.d.ts b/node-schedule/node-schedule.d.ts index 5127eafb40..1b15f9c34c 100644 --- a/node-schedule/node-schedule.d.ts +++ b/node-schedule/node-schedule.d.ts @@ -13,7 +13,7 @@ declare module 'node-schedule' { * The callback executed by a Job */ export interface JobCallback { - ():void; + (): void; } /** @@ -25,7 +25,7 @@ declare module 'node-schedule' { /** * This Job's name. read-only. */ - name:string; + name: string; /** * Use the function scheduleJob() to create new Job objects. @@ -36,7 +36,7 @@ declare module 'node-schedule' { * @param {JobCallback|Function} job either this Job's callback or an optional callback function * @param {Function} callback optional callback that is executed right before the JobCallback */ - constructor(name: string|JobCallback, job?: JobCallback|Function, callback?: Function); + constructor(name: string | JobCallback, job?: JobCallback | Function, callback?: Function); /** * Adds an Invocation to this job. For internal use. @@ -44,7 +44,7 @@ declare module 'node-schedule' { * @param {Invocation} invokation * @return {boolean} whether the invocation could be added */ - trackInvocation(invokation:Invocation):boolean; + trackInvocation(invokation: Invocation): boolean; /** * removes an Invocation from this Job's tracking list. For internal use. @@ -52,69 +52,69 @@ declare module 'node-schedule' { * @param invocation {Invocation} * @return boolean whether the invocation was successful. Removing an Invocation that doesn't exist, returns false. */ - stopTrackingInvocation(invocation:Invocation):boolean; + stopTrackingInvocation(invocation: Invocation): boolean; /** * @internal * @return {number} the number of currently running instances of this Job. */ - triggeredJobs():number; + triggeredJobs(): number; /** * set the number of currently running Jobs. * @internal * @param triggeredJobs */ - setTriggeredJobs(triggeredJobs:number):void; + setTriggeredJobs(triggeredJobs: number): void; /** * cancel all pending Invocations of this Job. * @param reschedule {boolean} whether to reschedule the canceled Invocations. */ - cancel(reschedule?:boolean):boolean; + cancel(reschedule?: boolean): boolean; /** * cancel the next Invocation of this Job. * @param reschedule {boolean} whether to reschedule the canceled Invocation. * @return {boolean} whether cancelation was successful */ - cancelNext(reschedule?:boolean):boolean; + cancelNext(reschedule?: boolean): boolean; /** * Changes the scheduling information for this Job. * @param spec {RecurrenceRule|string|number} the * @return {boolean} whether the reschedule was successful */ - reschedule(spec:RecurrenceRule|string|number):boolean; + reschedule(spec: RecurrenceRule | string | number): boolean; /** * Returns the Date on which this Job will be run next. * @return {Date} */ - nextInvocation():Date; + nextInvocation(): Date; /** * @return Invocation[] a list of all pending Invocations */ - pendingInvocations():Invocation[]; + pendingInvocations(): Invocation[]; /** * run this Job immediately. */ - invoke():void; + invoke(): void; /** * schedule this Job to be run on the specified date. * @param date {Date} */ - runOnDate(date:Date): void; + runOnDate(date: Date): void; /** * set scheduling information * @param {Date|string|number} date * @public */ - schedule(date: Date|string|number): boolean; + schedule(date: Date | string | number): boolean; } /** @@ -160,7 +160,7 @@ declare module 'node-schedule' { * @public * @type {number|Array} */ - dayOfWeek: number|Array; + dayOfWeek: number | Array; /** * Hour. @@ -202,15 +202,15 @@ declare module 'node-schedule' { */ year: number; - constructor(year:number, - month:number, - date:number, - dayOfWeek:number|Array, - hour:number, - minute:number, - second:number); + constructor(year?: number, + month?: number, + date?: number, + dayOfWeek?: number | Array, + hour?: number, + minute?: number, + second?: number); - nextInvocationDate(base:Date):Date; + nextInvocationDate(base: Date): Date; } /** @@ -269,7 +269,7 @@ declare module 'node-schedule' { * @param {RecurrenceRule|Date|string} rule either the scheduling info or the JobCallback * @param {JobCallback} callback The callback to be executed on each invocation. */ - export function scheduleJob(name:string|RecurrenceRule|Date, rule: RecurrenceRule|Date|string|JobCallback, callback?: JobCallback): Job; + export function scheduleJob(name: string | RecurrenceRule | Date, rule: RecurrenceRule | Date | string | JobCallback, callback?: JobCallback): Job; /** * Changes the timing of a Job, canceling all pending invocations. @@ -278,12 +278,12 @@ declare module 'node-schedule' { * @param spec {JobCallback} the new timing for this Job * @return {Job} if the job could be rescheduled, {null} otherwise. */ - export function rescheduleJob(job:Job|string, spec:RecurrenceRule|Date|string):Job; + export function rescheduleJob(job: Job | string, spec: RecurrenceRule | Date | string): Job; /** * Dictionary of all Jobs, accessible by name. */ - export let scheduledJobs:{[jobName:string]:Job}; + export let scheduledJobs: { [jobName: string]: Job }; /** * Cancels the job. @@ -291,5 +291,5 @@ declare module 'node-schedule' { * @param {Job} job The job. * @returns {boolean} {true} if the job has been cancelled with success, otherwise, {false}. */ - export function cancelJob(job: Job|string): boolean; + export function cancelJob(job: Job | string): boolean; }