Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should returned value unchanged when units are identical", () => {
const converter = Qty.swiftConverter("m/h", "m/h");
expect(converter(2500)).toEqual(2500);
});
it("should be converted", () => {
const converter = Qty.swiftConverter("MPa", "bar"),
values = [250, 10, 15],
expected = [2500, 100, 150];
expect(converter(values)).toEqual(expected);
});
});
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);
});
});
expect(() => { Qty.swiftConverter("m", "s"); }).toThrow("Incompatible units");
});
"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
}
"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
},
"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]
}
* 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;
}
},
"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"
* 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;
},