From 65f47d2f205330d559e14d5577aa05bcdbf8a809 Mon Sep 17 00:00:00 2001 From: Magnus Gustafsson Date: Sun, 2 Feb 2014 00:16:19 +0000 Subject: [PATCH 1/3] Added type definitions for EasyStar.js 0.1.6 --- easystarjs/README.md | 61 ++++++++++++++++++++++++++++++++++ easystarjs/easystarjs-tests.ts | 47 ++++++++++++++++++++++++++ easystarjs/easystarjs.d.ts | 34 +++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100755 easystarjs/README.md create mode 100755 easystarjs/easystarjs-tests.ts create mode 100755 easystarjs/easystarjs.d.ts diff --git a/easystarjs/README.md b/easystarjs/README.md new file mode 100755 index 000000000..0f3b110f2 --- /dev/null +++ b/easystarjs/README.md @@ -0,0 +1,61 @@ +easystarjs.d.ts +=========== + +This is a typescript definitions file for EasyStar.js located here: https://github.com/prettymuchbryce/easystarjs +Main site: http://easystarjs.com/ + +Basic Usage +========== + +Import Statements +----------------- + +Reference the easystarjs.d.ts file in your project and include the following import statement + +```typescript +/// + +// Include the following import +import EasyStar = require("easystarjs"); +``` + +See tests for further details on how to use this library. + +Change Log +========== + +1.0 2014/02/02 +--------------- +* First version for EasyStar.js 0.1.6 + + +License +======= + +easystarjs.d.ts Copyright (c) 2014 Magnus Gustafsson http://github.com/borundin/easystarjs.d.ts +This definitions file is for EasyStar.js -> + https://github.com/prettymuchbryce/easystarjs + + + +EasyStar.js Copyright (c) 2012-2013 Bryce Neal + +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/easystarjs/easystarjs-tests.ts b/easystarjs/easystarjs-tests.ts new file mode 100755 index 000000000..a63d4ea0f --- /dev/null +++ b/easystarjs/easystarjs-tests.ts @@ -0,0 +1,47 @@ +/// + +// For node.js compile using: tsc --module commonjs easystarjs-tests.ts +// then run using: node easystarjs-tests.js +import EasyStar = require('easystarjs'); + +var test = new EasyStar.js(); + +test.setGrid([ + [0, 0, 0, 1, 0], + [0, 0, 0, 1, 0], + [0, 0, 1, 1, 0], + [0, 0, 0, 0, 0], + [0, 0, 0, 1, 0] +]); +test.setAcceptableTiles([0]); +test.setIterationsPerCalculation(1000); +test.findPath(2, 0, 4, 4, function (path: EasyStar.Position[]) +{ + if (path == null) + { + console.log("No path found!"); + return; + } + for (var i = 0; i < path.length; i++) + { + var pos = path[i]; + console.log("%d, %d", pos.x, pos.y); + } +}); + +test.calculate(); + +/* +Should log: + +2, 0 +2, 1 +1, 1 +1, 2 +1, 3 +2, 3 +3, 3 +4, 3 +4, 4 + +*/ \ No newline at end of file diff --git a/easystarjs/easystarjs.d.ts b/easystarjs/easystarjs.d.ts new file mode 100755 index 000000000..7640b1a8b --- /dev/null +++ b/easystarjs/easystarjs.d.ts @@ -0,0 +1,34 @@ +// Type definitions for EasyStar.js 0.1.6 +// Project: http://easystarjs.com/ +// Definitions by: Magnus Gustafsson +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/* +easystarjs.d.ts may be freely distributed under the MIT license. +*/ + +declare module "easystarjs" +{ + class js + { + new (): js; + setGrid(grid: number[][]): void; + setAcceptableTiles(tiles: number[]): void; + findPath(startX: number, startY: number, endX: number, endY: number, callback: (path: Position[]) => void): void; + calculate(): void; + setIterationsPerCalculation(iterations: number): void; + avoidAdditionalPoint(x: number, y: number): void; + stopAvoidingAdditionalPoint(x: number, y: number): void; + stopAvoidingAllAdditionalPoints(): void; + enableDiagonals(): void; + disableDiagonals(): void; + setTileCost(tileType: number, multiplicativeCost: number): void; + } + + interface Position + { + x: number; + y: number; + } +} + + \ No newline at end of file From fdee518da72cfe0f2729ed5256437de3ce0111fb Mon Sep 17 00:00:00 2001 From: Magnus Gustafsson Date: Sun, 2 Feb 2014 00:56:27 +0000 Subject: [PATCH 2/3] Removed wrong copy/paste url from README --- easystarjs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easystarjs/README.md b/easystarjs/README.md index 0f3b110f2..4066f9b37 100755 --- a/easystarjs/README.md +++ b/easystarjs/README.md @@ -32,7 +32,7 @@ Change Log License ======= -easystarjs.d.ts Copyright (c) 2014 Magnus Gustafsson http://github.com/borundin/easystarjs.d.ts +easystarjs.d.ts Copyright (c) 2014 Magnus Gustafsson This definitions file is for EasyStar.js -> https://github.com/prettymuchbryce/easystarjs From 5e8c4eee7caff334ba7e23f66b66f2620de54c11 Mon Sep 17 00:00:00 2001 From: Magnus Gustafsson Date: Thu, 6 Feb 2014 22:57:08 +0000 Subject: [PATCH 3/3] Removed local README file and added contributor to global README --- README.md | 1 + easystarjs/README.md | 61 -------------------------------------------- 2 files changed, 1 insertion(+), 61 deletions(-) delete mode 100755 easystarjs/README.md diff --git a/README.md b/README.md index ab4a8cdae..5a392b2ac 100755 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ List of Definitions * [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton)) * [dust](http://linkedin.github.com/dustjs) (by [Marcelo Dezem](https://github.com/mdezem)) * [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [EasyStar](http://easystarjs.com/) (by [Magnus Gustafsson](https://github.com/Borundin)) * [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) (by [François de Campredon](https://github.com/fdecampredon/)) diff --git a/easystarjs/README.md b/easystarjs/README.md deleted file mode 100755 index 4066f9b37..000000000 --- a/easystarjs/README.md +++ /dev/null @@ -1,61 +0,0 @@ -easystarjs.d.ts -=========== - -This is a typescript definitions file for EasyStar.js located here: https://github.com/prettymuchbryce/easystarjs -Main site: http://easystarjs.com/ - -Basic Usage -========== - -Import Statements ------------------ - -Reference the easystarjs.d.ts file in your project and include the following import statement - -```typescript -/// - -// Include the following import -import EasyStar = require("easystarjs"); -``` - -See tests for further details on how to use this library. - -Change Log -========== - -1.0 2014/02/02 ---------------- -* First version for EasyStar.js 0.1.6 - - -License -======= - -easystarjs.d.ts Copyright (c) 2014 Magnus Gustafsson -This definitions file is for EasyStar.js -> - https://github.com/prettymuchbryce/easystarjs - - - -EasyStar.js Copyright (c) 2012-2013 Bryce Neal - -The MIT License (MIT) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file