Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pagoru committed Mar 19, 2024
1 parent 78ac4af commit 2236d77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const serveGame = async () => {
socketClientList.length
})`,
);
socketClientList.forEach((ws: WebSocket) => ws.send(JSON.stringify(data)));
socketClientList.forEach((ws: WebSocket | undefined) => ws?.send(JSON.stringify(data)));
};

{
Expand Down Expand Up @@ -52,6 +52,7 @@ export const serveGame = async () => {
sendMessageToClients({ type: 'reload' });
return new Response();
case '/_hotSwap':
if(!request.body) break;
const reader = request.body.getReader();
let text = '';
while (true) {
Expand All @@ -69,7 +70,7 @@ export const serveGame = async () => {

sendMessageToClients({
type: 'hotSwap',
data: list.map(({ name, mtime, globalReference }) => ({
data: list.map(({ name, mtime, globalReference }: any) => ({
name,
mtime,
globalReference,
Expand Down
10 changes: 5 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const bundle = (
plugins: string[],
) => {
const environments = JSON.parse(envs).reduce(
(obj, key) => ({ ...obj, [key]: Deno.env.get(key) }),
(obj: any, key: any) => ({ ...obj, [key]: Deno.env.get(key) }),
{},
);
const command = new Deno.Command(Deno.execPath(), {
Expand Down Expand Up @@ -145,7 +145,7 @@ export const getBuildArgs = ({
};

export const getFileList = async () => {
const fileList = {};
const fileList: any = {};
const _getFileList = async (dirname: string) => {
for await (const dirEntry of Deno.readDir(dirname)) {
const entryPath = `${dirname}/${dirEntry.name}`;
Expand All @@ -163,20 +163,20 @@ export const getFileList = async () => {
return fileList;
};

export const getObjectComparison = (obj1, obj2) => {
export const getObjectComparison = (obj1: any, obj2: any) => {
let keys1 = Object.keys(obj1);
let keys2 = Object.keys(obj2);

let deletedKeys = keys1.filter(key => !keys2.includes(key));

let addedKeys = keys2.filter(key => !keys1.includes(key));

let modifiedValues = keys1.reduce((acc, key) => {
let modifiedValues = keys1.reduce((acc: any, key) => {
if (keys2.includes(key) && obj1[key] !== obj2[key]) {
acc[key] = { old: obj1[key], new: obj2[key] };
}
return acc;
}, {});
}, {} as any);

return { deletedKeys, modifiedValues, addedKeys };
};

0 comments on commit 2236d77

Please sign in to comment.