npm package: @geostarters/common
Description: ICGC JS common
Author: @geostarters
Latest version: 0.4.3

# ICGC-COMMON
[![npm version](https://badge.fury.io/js/%40geostarters%2Fcommon.svg)](https://badge.fury.io/js/%40geostarters%2Fcommon)

[![Build status](https://ci.appveyor.com/api/projects/status/aa2bikit893mt4xq/branch/master?svg=true)](https://ci.appveyor.com/project/geostarters/icgc-js-common/branch/master)

![License](https://img.shields.io/badge/license-MIT-blue.svg)

A Javascript lib with common functionalities to use across different projects.

## <a name="install"></a>INSTALLATION

```
npm i --save @geostarters/common
```

## USAGE


Usage example with Svelte

```js

import {GeoCommons} from "@geostarters/common/dist/commonjs";

 const geoCommons = new GeoCommons();

 geoCommons.getEmptyGeoJSON());

```


Usage with ES6 modules:
``` js
import * as ICGCCommon from " @geostarters/common";
```

Usage with Commonjs:
``` js
const Utils =  require("@geostarters/common");
```

Besides it,  it is generated a single file package and its .map, using [browserify](http://browserify.org/):

  *dist/ICGCCommon.js*

  *dist/ICGCCommon.map.js*



## DOCUMENTATION

[DOCS API](api.md)




## Environment

* Uses [documentation.js](https://github.com/documentationjs/documentation) to generate a JSON file to be consumed by another package (see the [documenting the code](#documentation) section) (TODO: Ingest it with [@mapbox/batfish](https://github.com/mapbox/batfish)?)
* Uses [eslint](https://eslint.org/) to perform static analysis in code
* Uses [flow](https://flow.org/) to check types (see the [using types](#types) section)
* Uses [jest](https://jestjs.io/) for testing (see the [writting tests](#testing) section)


## <a name="documentation"></a>Documenting the code
The documentation follows the [JSDoc](http://usejsdoc.org/about-getting-started.html) syntax. 

To get started you can read the documentation.js start guide [here](https://github.com/documentationjs/documentation/blob/master/docs/GETTING_STARTED.md) or take a look at the provided example file [here](https://github.com/geostarters/js-project-template/blob/master/src/geo/latlon.js)

## <a name="types"></a>Using types
Using flow provides a way to check for common syntax errors while calling functions. Flow provides a simple example of which kind of problems it can solve in their [Type Annotations guide](https://flow.org/en/docs/types/). There's also a list of annotations it supports there.

## <a name="testing"></a>Writting tests

* The project uses JEST.
* **test** folder included
  

## Provided scripts

* __build-dev__: Creates a single file package with all the assertions intact to be ussed in browsers. 
* __watch-dev__: Watches the source
* __build-min__: Creates a minified package with its map file and without assertions to be ussed in browsers
* __build-unflow__: Builds ready-to-use modules in dist by removing flow types
* __build-react__: Builds ready-to-use es modules in dist/es by removing flow types
* __build-modules__: Builds ready-to-use commonjs modules in dist/commonjs
* __build-docs__: Generates the documentation file
* __lint__: Checks the code linting
* __lint-docs__: Lints the documentation files
* __test__: Runs the static type checker and runs the tests
* __test:unit__: Runs the unit tests
* __test-flow__: Runs the static type checks
* __test-cov__: Runs the testing coverage


## Folder structure

__dist:__ Contains the built files generated by the scripts (dev package, minified package and map, commonjs folder and es folder)

__src:__ Contains an index file that requires all the modules that should be exported and all the source files that compound the package.

__test:__ Contains the unit and integration tests

## License

Copyright (c) 2019 - Geostarters (MIT License)
See LICENSE file for more info.