slippy-tile
Advanced tools
Comparing version 1.2.4 to 1.3.0
# Changelog | ||
## 1.3.0 - 2016-10-25 | ||
- Changed main function to `parse` | ||
- Reduce library file size 400% (268KB to 60KB) | ||
## 1.2.4 - 2016-10-21 | ||
@@ -4,0 +9,0 @@ |
15
index.js
"use strict"; | ||
const mercator = require('global-mercator'); | ||
const path = require('path'); | ||
const providerLookup = require(path.join(__dirname, 'providers')); | ||
exports.providers = require('./providers'); | ||
/** | ||
@@ -12,6 +11,6 @@ * Substitutes the given tile information [x,y,zoom] to the URL tile scheme. | ||
* @example | ||
* slippyTile([10, 15, 8], 'osm') | ||
* parse([10, 15, 8], 'osm') | ||
* //='https://c.tile.openstreetmap.org/8/10/15.png' | ||
*/ | ||
function slippyTile(tile, url) { | ||
function parse(tile, url) { | ||
const [x, y, zoom] = tile; | ||
@@ -40,3 +39,3 @@ const providerURL = provider(url); | ||
} | ||
exports.slippyTile = slippyTile; | ||
exports.parse = parse; | ||
// /** | ||
@@ -95,4 +94,4 @@ // * Downloads Tile | ||
const key = provider.toLowerCase().trim(); | ||
if (providerLookup[key] !== undefined) { | ||
return providerLookup[key].url; | ||
if (exports.providers[key]) { | ||
return exports.providers[key].url; | ||
} | ||
@@ -116,3 +115,3 @@ } | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = slippyTile; | ||
exports.default = parse; | ||
//# sourceMappingURL=index.js.map |
21
index.ts
import * as mercator from 'global-mercator' | ||
import * as path from 'path' | ||
export interface Provider { | ||
interface Provider { | ||
name: string | ||
@@ -14,3 +13,3 @@ categories: Array<string> | ||
interface Providers { | ||
[key: string]: Provider | ||
[index: string]: Provider | ||
} | ||
@@ -23,3 +22,3 @@ | ||
const providerLookup: Providers = require(path.join(__dirname, 'providers')) | ||
export const providers: Providers = require('./providers') | ||
@@ -38,6 +37,6 @@ /** | ||
* @example | ||
* slippyTile([10, 15, 8], 'osm') | ||
* parse([10, 15, 8], 'osm') | ||
* //='https://c.tile.openstreetmap.org/8/10/15.png' | ||
*/ | ||
export function slippyTile(tile: Tile, url: string) { | ||
export function parse (tile: Tile, url: string) { | ||
const [x, y, zoom] = tile | ||
@@ -110,7 +109,7 @@ const providerURL = provider(url) | ||
*/ | ||
export function provider(provider: string) { | ||
export function provider (provider: string) { | ||
if (provider) { | ||
const key = provider.toLowerCase().trim() | ||
if (providerLookup[key] !== undefined) { | ||
return providerLookup[key].url | ||
if (providers[key]) { | ||
return providers[key].url | ||
} | ||
@@ -129,6 +128,6 @@ } | ||
*/ | ||
export function sample(collection: Array<string | number>): string | number { | ||
export function sample (collection: Array<string | number>): string | number { | ||
return collection[Math.floor(Math.random() * collection.length)] | ||
} | ||
export default slippyTile | ||
export default parse |
{ | ||
"name": "slippy-tile", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"description": "Helps convert Slippy Map url tile schemas", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"scripts": { | ||
"pretest": "tsc && js-yaml providers.yml > providers.json", | ||
"pretest": "js-yaml providers.yml > providers.json", | ||
"test": "npm run lint && nyc ava", | ||
@@ -32,6 +32,5 @@ "docs": "tsc && cat HEADER.md > README.md && documentation build index.js -c documentation.yml -f md >> README.md && cat CHANGELOG.md >> README.md", | ||
"coveralls": "^2.11.14", | ||
"documentation": "^4.0.0-beta10", | ||
"nyc": "^8.3.0", | ||
"documentation": "^4.0.0-beta11", | ||
"js-yaml": "^3.6.1", | ||
"ts-node": "^1.4.3", | ||
"nyc": "^8.3.2", | ||
"tslint": "^3.15.1", | ||
@@ -38,0 +37,0 @@ "typescript": "^2.0.3" |
@@ -72,3 +72,3 @@ [![Build Status](https://travis-ci.org/DenisCarriere/slippy-tile.svg?branch=master)](https://travis-ci.org/DenisCarriere/slippy-tile) | ||
# slippyTile | ||
# parse | ||
@@ -85,3 +85,3 @@ Substitutes the given tile information [x,y,zoom] to the URL tile scheme. | ||
```javascript | ||
slippyTile([10, 15, 8], 'osm') | ||
parse([10, 15, 8], 'osm') | ||
//='https://c.tile.openstreetmap.org/8/10/15.png' | ||
@@ -146,2 +146,7 @@ ``` | ||
## 1.3.0 - 2016-10-25 | ||
- Changed main function to `parse` | ||
- Reduce library file size 400% (268KB to 60KB) | ||
## 1.2.4 - 2016-10-21 | ||
@@ -148,0 +153,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
9
168
0
32758
10
443