Skip to content

Commit 9af5aed

Browse files
committed
Export isValidLocation and locationToFeature
1 parent 5527f76 commit 9af5aed

5 files changed

+32
-16
lines changed

index.mjs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
/* DATA */
12
import { features } from './dist/features.json';
2-
export { features };
3-
43
import { resources } from './dist/resources.json';
5-
export { resources };
4+
5+
/* CODE */
6+
import locationToFeature from './lib/locationToFeature.js';
7+
import isValidLocation from './lib/isValidLocation.js';
8+
9+
export {
10+
features, resources,
11+
locationToFeature, isValidLocation
12+
};

lib/isValidLocation.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const CountryCoder = require('country-coder');
22

3-
module.exports = (location, features) => {
3+
4+
function isValidLocation(location, features) {
45
features = features || {};
56

67
if (Array.isArray(location)) { // a [lon,lat] coordinate pair?
@@ -17,5 +18,6 @@ module.exports = (location, features) => {
1718
let ccmatch = CountryCoder.feature(location);
1819
return !!ccmatch;
1920
}
21+
}
2022

21-
};
23+
module.exports = isValidLocation;

lib/locationToFeature.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const CountryCoder = require('country-coder');
22
const circleToPolygon = require('circle-to-polygon');
33

44

5-
module.exports = (location, features) => {
5+
function locationToFeature(location, features) {
66
features = features || {};
77

88
if (Array.isArray(location)) { // a [lon,lat] coordinate pair?
@@ -54,5 +54,6 @@ module.exports = (location, features) => {
5454
return null;
5555
}
5656
}
57+
}
5758

58-
};
59+
module.exports = locationToFeature;

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
"json-stringify-pretty-compact": "^1.1.0",
4242
"jsonschema": "^1.1.0",
4343
"rollup": "^1.25.1",
44+
"rollup-plugin-commonjs": "^10.0.0",
4445
"rollup-plugin-json": "^4.0.0",
46+
"rollup-plugin-node-resolve": "^5.0.4",
4547
"shelljs": "^0.8.0",
4648
"tap": "^14.8.2"
4749
},

rollup.config.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
import commonjs from 'rollup-plugin-commonjs';
12
import json from 'rollup-plugin-json';
3+
import nodeResolve from 'rollup-plugin-node-resolve';
24

35
export default {
4-
input: 'index.mjs',
5-
output: {
6-
name: 'oci',
7-
file: 'dist/index.js',
8-
format: 'umd'
9-
},
10-
plugins: [
11-
json({ indent: '' })
12-
]
6+
input: 'index.mjs',
7+
output: {
8+
name: 'oci',
9+
file: 'dist/index.js',
10+
format: 'umd'
11+
},
12+
plugins: [
13+
nodeResolve(),
14+
commonjs(),
15+
json({ indent: '' })
16+
]
1317
};

0 commit comments

Comments
 (0)