Skip to content

Commit

Permalink
style: upgrade eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber committed Nov 27, 2023
1 parent 30392f2 commit 3b17ef6
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 65 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"devDependencies": {
"@ampproject/remapping": "^2.2.1",
"@pvtnbr/eslint-config": "^0.37.1",
"@pvtnbr/eslint-config": "^0.38.0",
"@types/cross-spawn": "^6.0.6",
"@types/node": "^20.9.4",
"@types/react": "^18.2.38",
Expand Down
122 changes: 86 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/preflight.cts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isMainThread } from 'node:worker_threads';
import { constants as osConstants } from 'os';
import './suppress-warnings.cts';
import './suppress-warnings.cjs';

type BaseEventListener = () => void;

Expand Down
54 changes: 27 additions & 27 deletions src/utils/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,34 @@ export const time = <T extends (...args: any[]) => unknown>(
_function: T,
threshold = 100,
): T => function (
this: unknown,
...args: Parameters<T>
) {
const timeStart = Date.now();
const logTimeElapsed = () => {
const elapsed = Date.now() - timeStart;
this: unknown,
...args: Parameters<T>
) {
const timeStart = Date.now();
const logTimeElapsed = () => {
const elapsed = Date.now() - timeStart;

if (elapsed > threshold) {
console.log(name, {
args,
elapsed,
});
}
};
if (elapsed > threshold) {
console.log(name, {
args,
elapsed,
});
}
};

const result = Reflect.apply(_function, this, args);
if (
result
const result = Reflect.apply(_function, this, args);
if (
result
&& typeof result === 'object'
&& 'then' in result
) {
(result as Promise<unknown>).then(
logTimeElapsed,
// Ignore error in this chain
() => {},
);
} else {
logTimeElapsed();
}
return result;
} as T;
) {
(result as Promise<unknown>).then(
logTimeElapsed,
// Ignore error in this chain
() => {},
);
} else {
logTimeElapsed();
}
return result;
} as T;

0 comments on commit 3b17ef6

Please sign in to comment.