Skip to content

Commit

Permalink
refactor: improve import & exports
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Dec 16, 2019
1 parent a856635 commit 7479de3
Show file tree
Hide file tree
Showing 19 changed files with 29 additions and 56 deletions.
23 changes: 9 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@


/* dependencies */
const path = require('path');
const _ = require('lodash');
const geojson = require(path.join(__dirname, 'lib', 'geojson'));
const geojson = require('./lib/geojson');
const {
isGeometry,
isPoint,
Expand Down Expand Up @@ -49,18 +48,14 @@ _.forEach(geojson, function (value, key) {


/* import geometries */
const { Geometry } = require(path.join(__dirname, 'lib', 'geometry'));
const { Point } = require(path.join(__dirname, 'lib', 'point'));
const { LineString } = require(path.join(__dirname, 'lib', 'linestring'));
const { Polygon } = require(path.join(__dirname, 'lib', 'polygon'));
const { MultiPoint } = require(path.join(__dirname, 'lib', 'multipoint'));
const { MultiPolygon } = require(path.join(__dirname, 'lib', 'multipolygon'));
const {
MultiLineString
} = require(path.join(__dirname, 'lib', 'multilinestring'));
const {
GeometryCollection
} = require(path.join(__dirname, 'lib', 'geometrycollection'));
const { Geometry } = require('./lib/geometry');
const { Point } = require('./lib/point');
const { LineString } = require('./lib/linestring');
const { Polygon } = require('./lib/polygon');
const { MultiPoint } = require('./lib/multipoint');
const { MultiPolygon } = require('./lib/multipolygon');
const { MultiLineString } = require('./lib/multilinestring');
const { GeometryCollection } = require('./lib/geometrycollection');


/* constants */
Expand Down
5 changes: 1 addition & 4 deletions lib/geojson.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ const {
randomGeometry,
randomGeometryCollection,
} = require('@lykmapipo/geo-tools');
const {
isPosition,
isPolygonCoor
} = require('geojson-validation');
const { isPosition, isPolygonCoor } = require('geojson-validation');


/* geojson geometry types */
Expand Down
5 changes: 1 addition & 4 deletions lib/geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@


/* dependencies */
const path = require('path');
const { Schema } = require('mongoose');
const {
GEOMETRIES
} = require(path.join(__dirname, 'geojson'));
const { GEOMETRIES } = require('./geojson');


/* constants */
Expand Down
5 changes: 2 additions & 3 deletions lib/geometrycollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@


/* dependencies */
const path = require('path');
const { Schema } = require('mongoose');
const { TYPE_GEOMETRYCOLLECTION } = require(path.join(__dirname, 'geojson'));
const { Geometry } = require(path.join(__dirname, 'geometry'));
const { TYPE_GEOMETRYCOLLECTION } = require('./geojson');
const { Geometry } = require('./geometry');


/* constants */
Expand Down
3 changes: 1 addition & 2 deletions lib/linestring.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@


/* dependencies */
const path = require('path');
const { Schema } = require('mongoose');
const { TYPE_LINESTRING } = require(path.join(__dirname, 'geojson'));
const { TYPE_LINESTRING } = require('./geojson');


/* constants */
Expand Down
3 changes: 1 addition & 2 deletions lib/multilinestring.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
/* @todo refactor types to utilities */

/* dependencies */
const path = require('path');
const { Schema } = require('mongoose');
const { TYPE_MULTILINESTRING } = require(path.join(__dirname, 'geojson'));
const { TYPE_MULTILINESTRING } = require('./geojson');


/* constants */
Expand Down
3 changes: 1 addition & 2 deletions lib/multipoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@


/* dependencies */
const path = require('path');
const { Schema } = require('mongoose');
const { TYPE_MULTIPOINT } = require(path.join(__dirname, 'geojson'));
const { TYPE_MULTIPOINT } = require('./geojson');


/* constants */
Expand Down
3 changes: 1 addition & 2 deletions lib/multipolygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@


/* dependencies */
const path = require('path');
const { Schema } = require('mongoose');
const { TYPE_MULTIPOLYGON } = require(path.join(__dirname, 'geojson'));
const { TYPE_MULTIPOLYGON } = require('./geojson');


/* constants */
Expand Down
3 changes: 1 addition & 2 deletions lib/point.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@


/* dependencies */
const path = require('path');
const { Schema } = require('mongoose');
const { TYPE_POINT } = require(path.join(__dirname, 'geojson'));
const { TYPE_POINT } = require('./geojson');


/* constants */
Expand Down
3 changes: 1 addition & 2 deletions lib/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
/* @todo refactor types to utilities */

/* dependencies */
const path = require('path');
const { Schema } = require('mongoose');
const { TYPE_POLYGON } = require(path.join(__dirname, 'geojson'));
const { TYPE_POLYGON } = require('./geojson');


/* constants */
Expand Down
3 changes: 1 addition & 2 deletions test/geometry.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


/*** dependencies */
const path = require('path');
const _ = require('lodash');
const { createTestModel, expect } = require('@lykmapipo/mongoose-test-helpers');
const {
Expand All @@ -11,7 +10,7 @@ const {
randomPoint,
randomLineString,
randomPolygon
} = require(path.join(__dirname, '..'));
} = require('..');


describe('Geometry', () => {
Expand Down
3 changes: 1 addition & 2 deletions test/geometrycollection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@


/*** dependencies */
const path = require('path');
const _ = require('lodash');
const { createTestModel, expect } = require('@lykmapipo/mongoose-test-helpers');
const {
GeometryCollection,
GEO_2DSPHERE,
randomGeometryCollection
} = require(path.join(__dirname, '..'));
} = require('..');


describe('GeometryCollection', () => {
Expand Down
5 changes: 2 additions & 3 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@


/* dependencies */
const path = require('path');
const { expect } = require('chai');
const { expect } = require('@lykmapipo/mongoose-test-helpers');
const {
randomPoint,
randomMultiPoint,
Expand All @@ -14,7 +13,7 @@ const {
centroidOf,
parseCoordinateString,
toCoordinateString
} = require(path.join(__dirname, '..'));
} = require('..');

describe('GeoJSON', () => {

Expand Down
3 changes: 1 addition & 2 deletions test/linestring.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@


/*** dependencies */
const path = require('path');
const _ = require('lodash');
const { createTestModel, expect } = require('@lykmapipo/mongoose-test-helpers');
const { LineString, GEO_2DSPHERE } = require(path.join(__dirname, '..'));
const { LineString, GEO_2DSPHERE } = require('..');


describe('LineString', () => {
Expand Down
3 changes: 1 addition & 2 deletions test/multilinestring.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@


/*** dependencies */
const path = require('path');
const _ = require('lodash');
const { createTestModel, expect } = require('@lykmapipo/mongoose-test-helpers');
const { MultiLineString, GEO_2DSPHERE } = require(path.join(__dirname, '..'));
const { MultiLineString, GEO_2DSPHERE } = require('..');


describe('MultiLineString', () => {
Expand Down
3 changes: 1 addition & 2 deletions test/multipoint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@


/*** dependencies */
const path = require('path');
const _ = require('lodash');
const { createTestModel, expect } = require('@lykmapipo/mongoose-test-helpers');
const { MultiPoint, GEO_2DSPHERE } = require(path.join(__dirname, '..'));
const { MultiPoint, GEO_2DSPHERE } = require('..');


describe('MultiPoint', () => {
Expand Down
3 changes: 1 addition & 2 deletions test/multipolygon.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@


/*** dependencies */
const path = require('path');
const _ = require('lodash');
const { createTestModel, expect } = require('@lykmapipo/mongoose-test-helpers');
const { MultiPolygon, GEO_2DSPHERE } = require(path.join(__dirname, '..'));
const { MultiPolygon, GEO_2DSPHERE } = require('..');


describe('MultiPolygon', () => {
Expand Down
3 changes: 1 addition & 2 deletions test/point.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@


/*** dependencies */
const path = require('path');
const _ = require('lodash');
const { createTestModel, expect } = require('@lykmapipo/mongoose-test-helpers');
const { Point, GEO_2DSPHERE } = require(path.join(__dirname, '..'));
const { Point, GEO_2DSPHERE } = require('..');


describe('Point', () => {
Expand Down
3 changes: 1 addition & 2 deletions test/polygon.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@


/*** dependencies */
const path = require('path');
const _ = require('lodash');
const { createTestModel, expect } = require('@lykmapipo/mongoose-test-helpers');
const { Polygon, GEO_2DSPHERE } = require(path.join(__dirname, '..'));
const { Polygon, GEO_2DSPHERE } = require('..');


describe('Polygon', () => {
Expand Down

0 comments on commit 7479de3

Please sign in to comment.