Skip to content

Commit

Permalink
chore: make prettier happy because some collabrator always want to pu…
Browse files Browse the repository at this point in the history
…sh something without considering existing PRs
  • Loading branch information
SukkaW committed Sep 16, 2023
1 parent cfbc6d2 commit 59396fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/node/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export function nullCheck(path, callback?) {
const er = new Error('Path must be a string without null bytes');
(er as any).code = 'ENOENT';
if (typeof callback !== 'function') throw er;
queueMicrotask(() => { callback(er); });
queueMicrotask(() => {
callback(er);
});
return false;
}
return true;
Expand Down
16 changes: 10 additions & 6 deletions src/queueMicrotask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import setImmediate from './setImmediate';

type TQueueMicroTask = (callback: () => void) => void;

let promise: Promise<void>
let promise: Promise<void>;

const _queueMicrotask: TQueueMicroTask = typeof queueMicrotask === 'function'
? queueMicrotask.bind(typeof window !== 'undefined' ? window : global)
: cb => (promise ||= Promise.resolve())
.then(cb)
.catch(err => setImmediate(() => { throw err }))
const _queueMicrotask: TQueueMicroTask =
typeof queueMicrotask === 'function'
? queueMicrotask.bind(typeof window !== 'undefined' ? window : global)
: cb =>
(promise ||= Promise.resolve()).then(cb).catch(err =>
setImmediate(() => {
throw err;
}),
);

export default _queueMicrotask;

0 comments on commit 59396fa

Please sign in to comment.