How to use the js-quantities.swiftConverter function in js-quantities

To help you get started, we’ve selected a few js-quantities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / js-quantities / js-quantities-tests.ts View on Github external
it("should returned value unchanged when units are identical", () => {
          const converter = Qty.swiftConverter("m/h", "m/h");

          expect(converter(2500)).toEqual(2500);
        });
github DefinitelyTyped / DefinitelyTyped / js-quantities / js-quantities-tests.ts View on Github external
it("should be converted", () => {
          const converter = Qty.swiftConverter("MPa", "bar"),
            values = [250, 10, 15],
            expected = [2500, 100, 150];

          expect(converter(values)).toEqual(expected);
        });
      });
github DefinitelyTyped / DefinitelyTyped / types / js-quantities / js-quantities-tests.ts View on Github external
it("should be converted", () => {
          const converter = Qty.swiftConverter("MPa", "bar");
          const values = [250, 10, 15];
          const expected = [2500, 100, 150];

          expect(converter(values)).toEqual(expected);
        });
      });
github DefinitelyTyped / DefinitelyTyped / types / js-quantities / js-quantities-tests.ts View on Github external
      expect(() => { Qty.swiftConverter("m", "s"); }).toThrow("Incompatible units");
    });
github SignalK / instrumentpanel / lib / ui / settings / conversions.js View on Github external
"km": Qty.swiftConverter('m', 'km'),
    "nm": Qty.swiftConverter('m', 'nmi')
  },
  "Pa": {
    "kPa": Qty.swiftConverter('pascal', 'kPa'),
    "bar": Qty.swiftConverter('pascal', 'bar'),
    "psi": Qty.swiftConverter('pascal', 'psi')
  },
  "s": {
    "minutes": Qty.swiftConverter('s', 'minutes'),
    "hours": Qty.swiftConverter('s', 'hours'),
    "days": Qty.swiftConverter('s', 'days')
  },
  "rad/s": {
    "deg/s": Qty.swiftConverter('rad/s', 'deg/s'),
    "deg/min": Qty.swiftConverter('rad/s', 'deg/min')
  }
}

const defaultUnits = {
  "rad": "deg",
  "Hz": "1/min"
}

export function getConversionsForUnit(unit) {
  return conversions[unit]
}

export function getDefaultUnit(unit) {
  console.log(unit + " " + defaultUnits[unit])
  return defaultUnits[unit] || unit
}
github SignalK / instrumentpanel / lib / ui / settings / conversions.js View on Github external
"feet": Qty.swiftConverter('m', 'foot'),
    "km": Qty.swiftConverter('m', 'km'),
    "nm": Qty.swiftConverter('m', 'nmi')
  },
  "Pa": {
    "kPa": Qty.swiftConverter('pascal', 'kPa'),
    "bar": Qty.swiftConverter('pascal', 'bar'),
    "psi": Qty.swiftConverter('pascal', 'psi')
  },
  "s": {
    "minutes": Qty.swiftConverter('s', 'minutes'),
    "hours": Qty.swiftConverter('s', 'hours'),
    "days": Qty.swiftConverter('s', 'days')
  },
  "rad/s": {
    "deg/s": Qty.swiftConverter('rad/s', 'deg/s'),
    "deg/min": Qty.swiftConverter('rad/s', 'deg/min')
  }
}

const defaultUnits = {
  "rad": "deg",
  "Hz": "1/min"
}

export function getConversionsForUnit(unit) {
  return conversions[unit]
}

export function getDefaultUnit(unit) {
  console.log(unit + " " + defaultUnits[unit])
  return defaultUnits[unit] || unit
github SignalK / instrumentpanel / lib / ui / settings / conversions.js View on Github external
},
  "m": {
    "fathom": Qty.swiftConverter('m', 'fathom'),
    "feet": Qty.swiftConverter('m', 'foot'),
    "km": Qty.swiftConverter('m', 'km'),
    "nm": Qty.swiftConverter('m', 'nmi')
  },
  "Pa": {
    "kPa": Qty.swiftConverter('pascal', 'kPa'),
    "bar": Qty.swiftConverter('pascal', 'bar'),
    "psi": Qty.swiftConverter('pascal', 'psi')
  },
  "s": {
    "minutes": Qty.swiftConverter('s', 'minutes'),
    "hours": Qty.swiftConverter('s', 'hours'),
    "days": Qty.swiftConverter('s', 'days')
  },
  "rad/s": {
    "deg/s": Qty.swiftConverter('rad/s', 'deg/s'),
    "deg/min": Qty.swiftConverter('rad/s', 'deg/min')
  }
}

const defaultUnits = {
  "rad": "deg",
  "Hz": "1/min"
}

export function getConversionsForUnit(unit) {
  return conversions[unit]
}
github SignalK / instrumentpanel / lib / ui / settings / conversions.js View on Github external
* limitations under the License.
 */

import React from 'react'
import Qty from 'js-quantities'

const conversions = {
  "rad": {
    "deg": Qty.swiftConverter('rad', 'deg')
  },
  "m/s": {
    "kn": Qty.swiftConverter("m/s", "kn"),
    "km/h": Qty.swiftConverter("m/s", "km/h")
  },
  "K": {
    "C": Qty.swiftConverter("tempK", "tempC"),
    "F": Qty.swiftConverter("tempK", "tempF")
  },
  "Hz": {
    "1/min": function(hz) {
      return hz * 60;
    },
    "10/min": function(hz) {
      return hz * 60 / 10;
    },
    "100/min": function(hz) {
      return hz * 60 / 100;
    },
    "1000/min": function(hz) {
      return hz * 60 / 1000;
    }
  },
github SignalK / instrumentpanel / lib / ui / settings / conversions.js View on Github external
"100/min": function(hz) {
      return hz * 60 / 100;
    },
    "1000/min": function(hz) {
      return hz * 60 / 1000;
    }
  },
  "m": {
    "fathom": Qty.swiftConverter('m', 'fathom'),
    "feet": Qty.swiftConverter('m', 'foot'),
    "km": Qty.swiftConverter('m', 'km'),
    "nm": Qty.swiftConverter('m', 'nmi')
  },
  "Pa": {
    "kPa": Qty.swiftConverter('pascal', 'kPa'),
    "bar": Qty.swiftConverter('pascal', 'bar'),
    "psi": Qty.swiftConverter('pascal', 'psi')
  },
  "s": {
    "minutes": Qty.swiftConverter('s', 'minutes'),
    "hours": Qty.swiftConverter('s', 'hours'),
    "days": Qty.swiftConverter('s', 'days')
  },
  "rad/s": {
    "deg/s": Qty.swiftConverter('rad/s', 'deg/s'),
    "deg/min": Qty.swiftConverter('rad/s', 'deg/min')
  }
}

const defaultUnits = {
  "rad": "deg",
  "Hz": "1/min"
github SignalK / instrumentpanel / lib / ui / settings / conversions.js View on Github external
* Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import React from 'react'
import Qty from 'js-quantities'

const conversions = {
  "rad": {
    "deg": Qty.swiftConverter('rad', 'deg')
  },
  "m/s": {
    "kn": Qty.swiftConverter("m/s", "kn"),
    "km/h": Qty.swiftConverter("m/s", "km/h")
  },
  "K": {
    "C": Qty.swiftConverter("tempK", "tempC"),
    "F": Qty.swiftConverter("tempK", "tempF")
  },
  "Hz": {
    "1/min": function(hz) {
      return hz * 60;
    },
    "10/min": function(hz) {
      return hz * 60 / 10;
    },
    "100/min": function(hz) {
      return hz * 60 / 100;
    },