Skip to content

Commit

Permalink
Add Typescript default plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Oct 1, 2017
1 parent 5c06b60 commit 4bd68cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
17 changes: 8 additions & 9 deletions packages/turf-bbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ import { coordEach } from '@turf/meta';
* //addToMap
* var addToMap = [line, bboxPolygon]
*/
function turfBBox(geojson) {
var bbox = [Infinity, Infinity, -Infinity, -Infinity];
function bbox(geojson) {
var BBox = [Infinity, Infinity, -Infinity, -Infinity];
coordEach(geojson, function (coord) {
if (bbox[0] > coord[0]) bbox[0] = coord[0];
if (bbox[1] > coord[1]) bbox[1] = coord[1];
if (bbox[2] < coord[0]) bbox[2] = coord[0];
if (bbox[3] < coord[1]) bbox[3] = coord[1];
if (BBox[0] > coord[0]) BBox[0] = coord[0];
if (BBox[1] > coord[1]) BBox[1] = coord[1];
if (BBox[2] < coord[0]) BBox[2] = coord[0];
if (BBox[3] < coord[1]) BBox[3] = coord[1];
});
return bbox;
return BBox;
}

export default turfBBox;
module.exports.default = turfBBox;
export default bbox;
15 changes: 14 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
function typesciptDefaultExport() {
return {
name: 'typescript-default-export',
transformBundle(code) {
code = code.trim();
const name = code.match(/module.exports = (\w+)/)
if (name) code += `\nmodule.exports.default = ${name[1]};\n`;
return code;
}
}
}

export default {
input: 'index.js',
output: {
extend: true,
file: 'main.js',
format: 'cjs'
}
},
plugins: [typesciptDefaultExport()]
};

0 comments on commit 4bd68cb

Please sign in to comment.