Skip to content

Commit

Permalink
function response declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
mapsam committed Oct 2, 2024
1 parent 6c9d26c commit 188ebe3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ export function getSiblings(tile: Tile): Tile[] {
* Get the 3 sibling tiles for a tile
*
* const tiles = getSiblings([5, 10, 10])
* //=tiles
* //=boolean
*/
export function hasSiblings(tile: Tile, tiles: Tile[]) {
export function hasSiblings(tile: Tile, tiles: Tile[]): boolean {
const siblings = getSiblings(tile);
for (var i = 0; i < siblings.length; i++) {
for (let i = 0; i < siblings.length; i++) {
if (!hasTile(tiles, siblings[i])) return false;
}
return true;
Expand All @@ -145,7 +145,7 @@ export function hasSiblings(tile: Tile, tiles: Tile[]) {
* hasTile(tiles, [0, 0, 5])
* //=boolean
*/
export function hasTile(tiles: Tile[], tile: Tile) {
export function hasTile(tiles: Tile[], tile: Tile): boolean {
for (let i = 0; i < tiles.length; i++) {
if (tilesEqual(tiles[i], tile)) return true;
}
Expand All @@ -158,7 +158,7 @@ export function hasTile(tiles: Tile[], tile: Tile) {
* tilesEqual([0, 1, 5], [0, 0, 5])
* //=boolean
*/
export function tilesEqual(tile1: Tile, tile2: Tile) {
export function tilesEqual(tile1: Tile, tile2: Tile): boolean {
return (
tile1[0] === tile2[0] && tile1[1] === tile2[1] && tile1[2] === tile2[2]
);
Expand All @@ -167,10 +167,10 @@ export function tilesEqual(tile1: Tile, tile2: Tile) {
/**
* Get the quadkey for a tile
*
* var quadkey = tileToQuadkey([0, 1, 5])
* const quadkey = tileToQuadkey([0, 1, 5])
* //=quadkey
*/
export function tileToQuadkey(tile: Tile) {
export function tileToQuadkey(tile: Tile): string {
let index = '';
for (let z = tile[2]; z > 0; z--) {
let b = 0;
Expand All @@ -185,10 +185,10 @@ export function tileToQuadkey(tile: Tile) {
/**
* Get the tile for a quadkey
*
* var tile = quadkeyToTile('00001033')
* const tile = quadkeyToTile('00001033')
* //=tile
*/
export function quadkeyToTile(quadkey: string) {
export function quadkeyToTile(quadkey: string): Tile {
let x = 0;
let y = 0;
const z = quadkey.length;
Expand All @@ -206,7 +206,7 @@ export function quadkeyToTile(quadkey: string) {
return [x, y, z];
}

function getBboxZoom(bbox: BBox) {
function getBboxZoom(bbox: BBox): number {
const MAX_ZOOM = 28;
for (let z = 0; z < MAX_ZOOM; z++) {
const mask = 1 << (32 - (z + 1));
Expand All @@ -224,7 +224,7 @@ function getBboxZoom(bbox: BBox) {
/**
* Get the smallest tile to cover a bbox
*
* var tile = bboxToTile([ -178, 84, -177, 85 ])
* const tile = bboxToTile([ -178, 84, -177, 85 ])
* //=tile
*/
export function bboxToTile(bboxCoords: BBox): Tile {
Expand Down
2 changes: 1 addition & 1 deletion test/bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const bbox2 = tilebelt.tileToBBOX(tile2);

const bench = new Benchmark('tilebelt');
bench
.createSuite('suite', { time: 1000 })
.createSuite('tilebelt', { time: 1000 })
.add('tileToGeoJSON#tile1', () => {
tilebelt.tileToGeoJSON(tile1);
})
Expand Down

0 comments on commit 188ebe3

Please sign in to comment.