all files / math.js/lib/unit/ index.js

100% Statements 20/20
100% Branches 0/0
100% Functions 18/18
100% Lines 20/20
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78                                                                                                                    
var constants = require('../constants');
module.exports = {
 
    // Unit converters
    yardsToFeet: function(n) {
        return n * constants.YARDS_TO_FEET_FACTOR;
    },
 
    feetToYards: function(n) {
        return n * constants.FEET_TO_YARDS_FACTOR;
    },
 
    yardsToInches: function(n) {
        return n * constants.YARDS_TO_INCHES_FACTOR;
    },
 
    inchesToYards: function(n) {
        return constants.INCHES_TO_YARDS_FACTOR * n;
    },
 
    inchesToMiles: function(n) {
        return constants.INCHES_TO_MILES_FACTOR * n;
    },
 
    feetToInches: function(n) {
        return constants.FEET_TO_INCHES_FACTOR * n;
    },
 
    feetToMeters: function (n) {
        return constants.FEET_TO_METERS_FACTOR * n;
    },
 
    feetToMiles: function(n) {
        return constants.FEET_TO_MILES_FACTOR * n;
    },
 
    inchesToFeet: function(n) {
        return constants.INCHES_TO_FEET_FACTOR * n;
    },
 
    inchesToMeters: function(n) {
        return constants.INCHES_TO_METERS_FACTOR * n;
    },
 
    milesToYards: function(n) {
        return constants.MILES_TO_YARDS_FACTOR * n;
    },
 
    milesToMeters: function(n) {
        return constants.MILES_TO_METERS_FACTOR * n;
    },
 
    milesToInches: function(n) {
        return constants.MILES_TO_INCHES_FACTOR * n;
    },
 
    milesToFeet: function(n) {
        return constants.MILES_TO_FEET_FACTOR * n;
    },
 
    yardsToMiles: function(n) {
        return constants.YARDS_TO_MILES_FACTOR * n;
    },
 
    yardsToMeters: function(n) {
        return constants.YARDS_TO_METERS_FACTOR * n;
    },
 
    toFahrenheit: function(val) {
        return val * constants.CELSIUS_TO_FAHRENEIT_MUTLIPLIER_FACTOR + constants.CELSIUS_TO_FAHRENEIT_FACTOR;
    },
 
    toCelsius: function(val) {
        return (val - constants.CELSIUS_TO_FAHRENEIT_FACTOR) / constants.CELSIUS_TO_FAHRENEIT_MUTLIPLIER_FACTOR;
    },
 
};