diff --git a/CHANGELOG.md b/CHANGELOG.md index 22f1f2f..2412970 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. This librar ## [Unreleased] ### Added - Added `h3GetFaces` binding (#54) +- Generate TypeScript definition file from jsdoc comments. (#55) ### Changed - Updated the core library to v3.5.0 (#52, #54) diff --git a/README.md b/README.md index c6a5aff..5db36a5 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ const coordinates = h3.h3SetToMultiPolygon(hexagons, true); * [.getRes0Indexes()](#module_h3.getRes0Indexes) ⇒ Array.<H3Index> * [.degsToRads(deg)](#module_h3.degsToRads) ⇒ Number * [.radsToDegs(rad)](#module_h3.radsToDegs) ⇒ Number + * [.H3Index](#module_h3.H3Index) : string * * * @@ -711,6 +712,14 @@ Convert radians to degrees | rad | Number | Value in radians | +* * * + + + +### h3.H3Index : string +64-bit hexidecimal string representation of an H3 index + + * * * diff --git a/lib/h3core.js b/lib/h3core.js index 52b5fcd..f270e9d 100644 --- a/lib/h3core.js +++ b/lib/h3core.js @@ -21,6 +21,12 @@ import C from '../out/libh3'; import BINDINGS from './bindings'; +/** + * 64-bit hexidecimal string representation of an H3 index + * @static + * @typedef {string} H3Index + */ + const H3 = {}; // Create the bound functions themselves diff --git a/package.json b/package.json index b7df177..36de5da 100644 --- a/package.json +++ b/package.json @@ -23,17 +23,19 @@ "unpkg": "dist/h3-js.umd.js", "module": "dist/h3-js.es.js", "es2015": "dist/h3-js.es.js", + "types": "dist/types.d.ts", "source": "lib/h3core.js", "scripts": { "build-update-h3": "bash scripts/update-h3.sh", "build-emscripten": "yarn build-update-h3 && yarn docker-emscripten", "build-docs": "jsdoc2md --global-index-format grouped --partial doc-files/scope.hbs --helper ./doc-files/insert-version.js --separators --template doc-files/README.tmpl.md lib/h3core.js > README.md", + "build-tsd": "jsdoc -t node_modules/tsd-jsdoc/dist -d console lib/h3core.js | sed 's/\"h3\"/\"h3-js\"/g' > dist/types.d.ts", "bundle-umd": "microbundle --name h3 --format=umd", "bundle-cjs": "microbundle --format=cjs --no-compress", "bundle-es": "microbundle --format=es --no-compress", "bundle-cjs-browser": "microbundle -o dist/browser --format=cjs --no-compress --alias ../out/libh3=$(printf '%q' \"$PWD\")/dist/libh3-browser", "bundle-es-browser": "microbundle -o dist/browser --format=es --no-compress --alias ../out/libh3=$(printf '%q' \"$PWD\")/dist/libh3-browser", - "dist": "yarn dist-clean && yarn docker-emscripten-browser && yarn bundle-umd && yarn bundle-cjs && yarn bundle-cjs-browser && yarn bundle-es && yarn bundle-es-browser", + "dist": "yarn dist-clean && yarn docker-emscripten-browser && yarn bundle-umd && yarn bundle-cjs && yarn bundle-cjs-browser && yarn bundle-es && yarn bundle-es-browser && yarn build-tsd", "dist-clean": "rm -rf dist", "rollup-test": "rollup test/index.js --file dist/test.js --sourcemap --format=cjs --external=tape,fs,path", "rollup-bindings": "rollup build/print-bindings.js --file dist/print-bindings.js --format cjs", @@ -75,7 +77,8 @@ "nyc": "^14.1.1", "prettier": "^1.12.1", "rollup": "^1.7.0", - "tape": "^4.8.0" + "tape": "^4.8.0", + "tsd-jsdoc": "^2.3.1" }, "engines": { "node": ">=4", diff --git a/yarn.lock b/yarn.lock index 1df9485..23b70cf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6699,6 +6699,13 @@ trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" +tsd-jsdoc@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/tsd-jsdoc/-/tsd-jsdoc-2.3.1.tgz#71e8507326de3ac730a5227206a0e49325d24708" + integrity sha512-zrgOVp4TXRYpBBiPa/fXOInlgijKlj4eCMvs1W/s2ssrZs+hYqLKGwpjDZ5trZK2E3XJoh1+JTUbvqhAK30oZg== + dependencies: + typescript "^3.2.1" + tslib@1.9.3, tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" @@ -6729,6 +6736,11 @@ typescript@>=2.8.3: version "3.3.4000" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.4000.tgz#76b0f89cfdbf97827e1112d64f283f1151d6adf0" +typescript@^3.2.1: + version "3.5.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977" + integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g== + typical@^2.4.2, typical@^2.6.0, typical@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/typical/-/typical-2.6.1.tgz#5c080e5d661cbbe38259d2e70a3c7253e873881d"