From 291f88988c156676458523a84c0dfec7cf2d8e10 Mon Sep 17 00:00:00 2001 From: Sergey Gerasimov Date: Thu, 9 Jan 2014 08:51:27 +0400 Subject: [PATCH 1/4] hashset definitions --- hashset/hashset-tests.ts | 36 ++++++++++++++++++++++++++++++++++++ hashset/hashset.d.ts | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 hashset/hashset-tests.ts create mode 100644 hashset/hashset.d.ts diff --git a/hashset/hashset-tests.ts b/hashset/hashset-tests.ts new file mode 100644 index 000000000..fda2e4d1a --- /dev/null +++ b/hashset/hashset-tests.ts @@ -0,0 +1,36 @@ +/// + +class Point { + constructor(public x: number, public y: number) { + } +} + +function hashPoint(p: Point) { + return "Point:" + p.x + "," + p.y; +} + +function pointsEqual(p1: Point, p2: Point) { + return p1.x === p2.x && p1.y === p2.y; +} + +var points = new HashSet({ hashCode: hashPoint, equals: pointsEqual }); + +points.add(new Point(1, 2)); +points.add(new Point(2, 3)); +points.add(new Point(1, 2)); +points.add(new Point(6, 5)); + +alert(points.size()); // Alerts 3 + +var otherPoints = new HashSet({ hashCode: hashPoint, equals: pointsEqual }); + +otherPoints.add(new Point(4, 4)); +otherPoints.add(new Point(7, 9)); +otherPoints.add(new Point(2, 3)); +otherPoints.add(new Point(6, 5)); + +var intersection = points.intersection(otherPoints); + +alert(intersection.contains(new Point(2, 3))); // Alerts true +alert(intersection.contains(new Point(7, 9))); // Alerts false +alert(intersection.size()); // Alerts 2 diff --git a/hashset/hashset.d.ts b/hashset/hashset.d.ts new file mode 100644 index 000000000..cca5af535 --- /dev/null +++ b/hashset/hashset.d.ts @@ -0,0 +1,38 @@ +// Type definitions for jshashset 3.0 +// Project: http://www.timdown.co.uk/jshashtable/jshashset.html +// Definitions by: Sergey Gerasimov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface IHashSet +{ + add(value: TValue): void; + addAll(arr: TValue[]): void; + contains(value: TValue): boolean; + + clear(): void; + isEmpty(): boolean; values(): TValue[]; + + remove(value: TValue): void; + size(): number; + + clone(): IHashSet; + + isSubsetOf(set: IHashSet): boolean; + intersection(set: IHashSet): IHashSet; + union(set: IHashSet): IHashSet; + complement(set: IHashSet): IHashSet; +} + +interface IHashSetStatic { + new (): IHashSet; + new (options: IHashtableOptions): IHashSet; + new (hashCode?: (value: TValue) => any, equals?: (value1: TValue, value2: TValue) => boolean): IHashSet; +} + +declare var HashSet: IHashSetStatic; + +declare module "hashset" { + export = HashSet; +} \ No newline at end of file From a58a98133215bda769d85e47649dbb12874a6342 Mon Sep 17 00:00:00 2001 From: sergey-gerasimov Date: Thu, 9 Jan 2014 12:29:17 +0400 Subject: [PATCH 2/4] some info added --- README.md | 2 ++ hashset/hashset.d.ts | 2 +- hashtable/hashtable.d.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e41a79bca..c43e6394a 100755 --- a/README.md +++ b/README.md @@ -94,6 +94,8 @@ List of Definitions * [Google Url Shortener](https://developers.google.com/url-shortener/) (by [Frank M](https://github.com/sgtfrankieboy)) * [Hammer.js](http://eightmedia.github.com/hammer.js/) (by [Boris Yankov](https://github.com/borisyankov)) * [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [HashSet](http://www.timdown.co.uk/jshashtable/jshashset.html) (by [Sergey Gerasimov](https://github.com/gerich-home)) +* [Hashtable](http://www.timdown.co.uk/jshashtable/) (by [Sergey Gerasimov](https://github.com/gerich-home)) * [Highcharts](http://www.highcharts.com/) (by [damianog](https://github.com/damianog)) * [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee)) * [History.js](https://github.com/browserstate/history.js) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/hashset/hashset.d.ts b/hashset/hashset.d.ts index cca5af535..fedf7381a 100644 --- a/hashset/hashset.d.ts +++ b/hashset/hashset.d.ts @@ -1,6 +1,6 @@ // Type definitions for jshashset 3.0 // Project: http://www.timdown.co.uk/jshashtable/jshashset.html -// Definitions by: Sergey Gerasimov +// Definitions by: Sergey Gerasimov // Definitions: https://github.com/borisyankov/DefinitelyTyped /// diff --git a/hashtable/hashtable.d.ts b/hashtable/hashtable.d.ts index 1a5ac47b9..fbc0f219a 100644 --- a/hashtable/hashtable.d.ts +++ b/hashtable/hashtable.d.ts @@ -1,6 +1,6 @@ // Type definitions for jshashtable 3.0 // Project: http://www.timdown.co.uk/jshashtable/ -// Definitions by: Sergey Gerasimov +// Definitions by: Sergey Gerasimov // Definitions: https://github.com/borisyankov/DefinitelyTyped interface IHashtable From 40adcdd3adf8d61d3fee48fd435e2e52285ccc27 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 9 Jan 2014 13:35:13 +0000 Subject: [PATCH 3/4] jQuery: offsetWidth, offsetHeight, position JSDoc removed invalid overloads, added JSDoc, changed position to use JQueryCoordinates. Added position test suite. --- jquery/jquery-tests.ts | 18 ++++++++++++------ jquery/jquery.d.ts | 17 ++++++++++++++--- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index e8b11f182..35a954e95 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1802,16 +1802,22 @@ function test_innerWidth() { function test_outerHeight() { var p = $("p:first"); - $("p:last").text("outerHeight:" + p.outerHeight(true)); - p.outerHeight(p.outerHeight() * 2).outerHeight(); - p.outerHeight(p.outerHeight() * 2, true).outerHeight(); + $("p:last").text( + "outerHeight:" + p.outerHeight() + + " , outerHeight( true ):" + p.outerHeight(true)); } function test_outerWidth() { var p = $("p:first"); - $("p:last").text("outerWidth:" + p.outerWidth(true)); - p.outerWidth(p.outerWidth() * 2).outerWidth(); - p.outerWidth(p.outerWidth() * 2, true).outerWidth(); + $("p:last").text( + "outerWidth:" + p.outerWidth() + + " , outerWidth( true ):" + p.outerWidth(true)); +} + +function test_position() { + var p = $("p:first"); + var position = p.position(); + $("p:last").text("left: " + position.left + ", top: " + position.top); } function test_insertAfter() { diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index e0018f654..01e75e118 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1048,13 +1048,24 @@ interface JQuery { */ offset(func: (index: number, coords: JQueryCoordinates) => JQueryCoordinates): JQuery; + /** + * Get the current computed height for the first element in the set of matched elements, including padding, border, and optionally margin. Returns an integer (without "px") representation of the value or null if called on an empty set of elements. + * + * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation. + */ outerHeight(includeMargin?: boolean): number; - outerHeight(value: number, includeMargin?: boolean): JQuery; + /** + * Get the current computed width for the first element in the set of matched elements, including padding and border. + * + * @param includeMargin A Boolean indicating whether to include the element's margin in the calculation. + */ outerWidth(includeMargin?: boolean): number; - outerWidth(value: number, includeMargin?: boolean): JQuery; - position(): { top: number; left: number; }; + /** + * Get the current coordinates of the first element in the set of matched elements, relative to the offset parent. + */ + position(): JQueryCoordinates; scrollLeft(): number; scrollLeft(value: number): JQuery; From 8bda915f3766026c53cb91be99ae5587632bd8e0 Mon Sep 17 00:00:00 2001 From: bolkhovsky Date: Thu, 9 Jan 2014 18:06:50 +0400 Subject: [PATCH 4/4] fix methods accessors --- openlayers/openlayers.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openlayers/openlayers.d.ts b/openlayers/openlayers.d.ts index ea489bc12..ba9f6baea 100644 --- a/openlayers/openlayers.d.ts +++ b/openlayers/openlayers.d.ts @@ -611,7 +611,7 @@ declare module OpenLayers { * openlayers.org homepage: * http://trac.openlayers.org/wiki/SettingZoomLevels */ - private initResolutions(): void; + initResolutions(): void; /** * Method: resolutionsFromScales @@ -635,7 +635,7 @@ declare module OpenLayers { * Returns: * {Array({Number})} Array of resolutions. */ - private calculateResolutions(props: Object): number[]; + calculateResolutions(props: Object): number[]; /** * APIMethod: getResolution @@ -760,7 +760,7 @@ declare module OpenLayers { * Returns: * {Integer} the z-index of this layer */ - private getZIndex(): number; + getZIndex(): number; /** * Method: setZIndex @@ -768,7 +768,7 @@ declare module OpenLayers { * Parameters: * zIndex - {Integer} */ - private setZIndex(zIndex: number): void; + setZIndex(zIndex: number): void; /** * Method: adjustBounds @@ -781,7 +781,7 @@ declare module OpenLayers { * Parameters: * bounds - {} */ - private adjustBounds(bounds: Bounds): Bounds; + adjustBounds(bounds: Bounds): Bounds; static CLASS_NAME: string; }