Skip to content

Commit

Permalink
refactor(ffi): Use modern es6 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejsmolinski committed Mar 7, 2023
1 parent 5ff4ecc commit 8ea4551
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/Date.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function date() {
var currentDate = new Date();
const currentDate = new Date();

return [
String(currentDate.getDate()).padStart(2, "0"),
Expand All @@ -12,19 +12,19 @@ function date() {
}

export function ddmmyyyy() {
var currentDate = date();
const currentDate = date();

return currentDate[0] + "/" + currentDate[1] + "/" + currentDate[2];
}

export function yyyymmdd() {
var currentDate = date();
const currentDate = date();

return currentDate[2] + "/" + currentDate[1] + "/" + currentDate[0];
}

export function hhmmss() {
var currentDate = date();
const currentDate = date();

return currentDate[3] + ":" + currentDate[4] + ":" + currentDate[5];
}
10 changes: 5 additions & 5 deletions src/HTTP/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { URL } from "url";

export function post_(url, payload) {
return function (onError, onSuccess) {
var parsedUrl = new URL(url);
var hostname = parsedUrl.hostname;
var path = parsedUrl.pathname + parsedUrl.search;
var port =
const parsedUrl = new URL(url);
const hostname = parsedUrl.hostname;
const path = parsedUrl.pathname + parsedUrl.search;
const port =
parsedUrl.protocol === "https:"
? "443"
: parsedUrl.protocol === "http:"
? 80
: parsedUrl.port;

var request = https.request(
const request = https.request(
{
hostname: hostname,
path: path,
Expand Down
4 changes: 2 additions & 2 deletions src/HTTP/Server.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import http from "http";

export function startSync_(port, onSuccess) {
var server = http.createServer(function (req, res) {
const server = http.createServer(function (req, res) {
onSuccess(req.url)();
res.end("success");
});
Expand All @@ -10,7 +10,7 @@ export function startSync_(port, onSuccess) {

export function startAsync_(port) {
return function (onError, onSuccess) {
var server = http.createServer(function (req, res) {
const server = http.createServer(function (req, res) {
onSuccess(req.url);
res.end("success");
});
Expand Down
4 changes: 2 additions & 2 deletions src/HTTP/Utils.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { URL } from "url";

export function pathname(input) {
var url = new URL(input, "http:https://localhost");
const url = new URL(input, "http:https://localhost");

return url.pathname;
}

export function param_(param, input) {
var url = new URL(input, "http:https://localhost");
const url = new URL(input, "http:https://localhost");

return url.searchParams.get(param) || "";
}
2 changes: 1 addition & 1 deletion src/Orchestrator/FS.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as fs from "fs";
export function readFile_(left, right, filename) {
return function () {
try {
var buffer = fs.readFileSync(filename, { encoding: "UTF-8" });
const buffer = fs.readFileSync(filename, { encoding: "UTF-8" });

return right(buffer.toString());
} catch (error) {
Expand Down
6 changes: 3 additions & 3 deletions src/System/Commands.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { spawnSync } from "child_process";

function run(command, args, options) {
var process = spawnSync(command, args, options || {});
var output;
const process = spawnSync(command, args, options || {});
let output;

if (process.status === 0) {
output = process.stdout ? process.stdout.toString().trim() : "";
Expand All @@ -18,7 +18,7 @@ function run(command, args, options) {

export function asyncExec_(right, left, canceler, cb, command, args, options) {
setTimeout(function () {
var result = run(command, args, options);
const result = run(command, args, options);

cb(result[0] ? right(result[1]) : left(new Error(result[1])))();
});
Expand Down

0 comments on commit 8ea4551

Please sign in to comment.