All files / src/data/builders CoordinateBuilder.js

63.64% Statements 7/11
60% Branches 6/10
100% Functions 0/0
63.64% Lines 7/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33    1x       5x       5x       5x       5x       5x             10x      
'use es6';
 
import Coordinate from '../Coordinate';
 
export default class CoordinateBuilder {
  static build(coordinate) {
    Iif (!('latitude' in coordinate)) {
      throw new ReferenceError('missing latitude field');
    }
 
    Iif (!('longitude' in coordinate)) {
      throw new ReferenceError('missing longitude field');
    }
 
    Iif (!CoordinateBuilder.isNumeric(coordinate['latitude'])) {
      throw new TypeError('latitude is non-numeric');
    }
 
    Iif (!CoordinateBuilder.isNumeric(coordinate['longitude'])) {
      throw new TypeError('longitude is non-numeric');
    }
 
    return new Coordinate({
      lat: coordinate['latitude'],
      lng: coordinate['longitude'],
    });
  }
 
  static isNumeric(n) {
    return !isNaN(parseFloat(n)) && isFinite(n);
  }
}