How to use the js-quantities.divSafe 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 divide while trying to avoid numerical errors", () => {
      expect(Qty.divSafe(0.000773, 0.000001)).toBe(773);
      // TODO uncomment and fix
      // expect(Qty.divSafe(24.5, 0.2777777777777778)).toBe(88.2);
    });
  });
github DefinitelyTyped / DefinitelyTyped / js-quantities / js-quantities-tests.ts View on Github external
it("should divide while trying to avoid numerical errors", () => {
      expect(Qty.divSafe(0.000773, 0.000001)).toBe(773);
      // TODO uncomment and fix
      // expect(Qty.divSafe(24.5, 0.2777777777777778)).toBe(88.2);
    });
  });
github DefinitelyTyped / DefinitelyTyped / js-quantities / js-quantities-tests.ts View on Github external
it("should convert to compatible units", () => {
      let qty = Qty("10 cm");
      expect(qty.to("ft").scalar).toBe(Qty.divSafe(0.1, 0.3048));
      qty = Qty("2m^3");
      expect(qty.to("l").scalar).toBe(2000);

      qty = Qty("10 cm");
      expect(qty.to(Qty("m")).scalar).toBe(0.1);
      expect(qty.to(Qty("20m")).scalar).toBe(0.1);

      qty = Qty("1 m3");
      expect(qty.to("cm3").scalar).toBe(1000000);

      qty = Qty("1 cm3");
      expect(qty.to("mm3").scalar).toBe(1000);

      qty = Qty("550 cm3");
      expect(qty.to("cm^3").scalar).toBe(550);
github DefinitelyTyped / DefinitelyTyped / types / js-quantities / js-quantities-tests.ts View on Github external
it("should convert to compatible units", () => {
      let qty = Qty("10 cm");
      expect(qty.to("ft").scalar).toBe(Qty.divSafe(0.1, 0.3048));
      qty = Qty("2m^3");
      expect(qty.to("l").scalar).toBe(2000);

      qty = Qty("10 cm");
      expect(qty.to(Qty("m")).scalar).toBe(0.1);
      expect(qty.to(Qty("20m")).scalar).toBe(0.1);

      qty = Qty("1 m3");
      expect(qty.to("cm3").scalar).toBe(1000000);

      qty = Qty("1 cm3");
      expect(qty.to("mm3").scalar).toBe(1000);

      qty = Qty("550 cm3");
      expect(qty.to("cm^3").scalar).toBe(550);