chore: add type definition

This commit is contained in:
Basile Bruneau
2020-05-06 23:05:24 +02:00
parent 147e0f5242
commit b4b84d8d6b
3 changed files with 47 additions and 4 deletions
Vendored
+43
View File
@@ -0,0 +1,43 @@
namespace DottedMapLib {
interface Settings {
height?: number;
width?: number;
countries?: string[];
region?: { lat: { min: number; max: number }; lng: { min: number; max: number } };
grid?: 'vertical' | 'diagonal';
}
interface SvgOptions {
color?: string;
radius?: number;
}
interface Pin {
lat: number;
lng: number;
data?: any;
svgOptions?: SvgOptions;
}
interface SvgSettings {
shape?: 'circle' | 'hexagon';
color?: string;
backgroundColor?: string;
radius?: number;
}
type Point = {
x: number;
y: number;
data?: any;
svgOptions?: SvgOptions;
};
}
export default class DottedMap {
constructor(settings: DottedMapLib.Settings);
addPin(pin: DottedMapLib.Pin): void;
getPoints(): DottedMapLib.Point[];
getSVG(settings: DottedMapLib.SvgSettings): string;
}
+1 -2
View File
@@ -1,8 +1,7 @@
const fs = require('fs');
const proj4 = require('proj4');
const inside = require('point-in-geopolygon');
const geojsonWorld = require('./countries.geo.json');
const geojsonWorld = JSON.parse(fs.readFileSync(__dirname + '/countries.geo.json', { encoding: 'utf8' }));
const geojsonByCountry = geojsonWorld.features.reduce((countries, feature) => {
countries[feature.id] = feature;
return countries;
+3 -2
View File
@@ -1,6 +1,6 @@
{
"name": "dotted-map",
"version": "1.0.0",
"version": "1.0.4",
"description": "",
"main": "index.js",
"scripts": {
@@ -15,5 +15,6 @@
},
"devDependencies": {
"prettier": "^2.0.5"
}
},
"sideEffects": false
}