Skip to content

Commit

Permalink
chore: migrate from require to import
Browse files Browse the repository at this point in the history
  • Loading branch information
alcb1310 committed Jan 9, 2025
1 parent c5da23d commit 6de7fe1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "jest",
"start": "node src/index.cjs"
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"start": "node src/index.js"
},
"type": "module",
"keywords": [
"chingu",
"roundtables",
Expand Down
8 changes: 4 additions & 4 deletions src/celcius.cjs → src/celcius.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
*/
function ConverToCelcius(temp) {
/** @type {number} */
var value = temp - 32
value = value * 5 / 9
var value = temp - 32;
value = (value * 5) / 9;

return value
return value;
}

module.exports = ConverToCelcius
export default ConverToCelcius;
8 changes: 4 additions & 4 deletions src/farenheit.cjs → src/farenheit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
*/
function ConvertToFarenheit(temp) {
/** @type {number} */
let value = temp * 9 / 5;
value = value + 32
let value = (temp * 9) / 5;
value = value + 32;

return value
return value;
}

module.exports = ConvertToFarenheit
export default ConvertToFarenheit;
8 changes: 0 additions & 8 deletions src/index.cjs

This file was deleted.

8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import ConvertToFarenheit from "./farenheit.js";
import ConverToCelcius from "./celcius.js";

const far = ConvertToFarenheit(21);
const cel = ConverToCelcius(69.8);

console.log(far);
console.log(cel);
4 changes: 2 additions & 2 deletions tests/celsius.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { it, describe, expect } = require("@jest/globals");
const convertToCelcius = require("../src/celcius.cjs");
import { it, describe, expect } from "@jest/globals";
import convertToCelcius from "../src/celcius.js";

describe("Convert to Celcius", () => {
it("should convert 32°F to equal 0°C", () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/farenheit.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { it, describe, expect } = require("@jest/globals");
const convertToFarenheit = require("../src/farenheit.cjs");
import { it, describe, expect } from "@jest/globals";
import convertToFarenheit from "../src/farenheit.js";

describe("Convert to Celcius", () => {
it("should convert 0°C to equal 32°F", () => {
Expand Down

0 comments on commit 6de7fe1

Please sign in to comment.