Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Qty('100 tempC').div(qty); // throws error
Qty('100 tempC*unit'); // throws error
Qty('100 tempC/unit'); // throws error
Qty('100 unit/tempC'); // throws error
Qty('100 tempC').inverse(); // throws error
Qty('100 tempC').to('degC'); // => 100 degC
Qty('100 degC').to('tempC'); // => -173.15 tempC
Qty('0 tempC').add('100 degC'); // => 100 tempC
try {
// code triggering an error inside JS-quantities
} catch (e) {
if (e instanceof Qty.Error) {
// ...
} else {
// ...
}
}
// From project spec
describe("js-quantities", () => {
"use strict";
describe("initialization", () => {
it("should create unit only", () => {
const qty = Qty("m");
expect(qty.numerator).toEqual(["<meter>"]);
expect(qty.scalar).toBe(1);</meter>
Qty('100 tempC').div(qty); // throws error
Qty('100 tempC*unit'); // throws error
Qty('100 tempC/unit'); // throws error
Qty('100 unit/tempC'); // throws error
Qty('100 tempC').inverse(); // throws error
Qty('100 tempC').to('degC'); // => 100 degC
Qty('100 degC').to('tempC'); // => -173.15 tempC
Qty('0 tempC').add('100 degC'); // => 100 tempC
try {
// code triggering an error inside JS-quantities
} catch (e) {
if (e instanceof Qty.Error) {
// ...
} else {
// ...
}
}
// From project spec
describe("js-quantities", () => {
"use strict";
describe("initialization", () => {
it("should create unit only", () => {
const qty = Qty("m");
expect(qty.numerator).toEqual(["<meter>"]);
expect(qty.scalar).toBe(1);</meter>