-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: try to run gc() with more JS runtimes
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
- Loading branch information
1 parent
5146ef7
commit 1cef68c
Showing
2 changed files
with
10 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
/** | ||
* @returns {Function} logger | ||
*/ | ||
const buildLogger = () => { | ||
const getLogger = () => { | ||
let logger | ||
try { | ||
logger = console.log | ||
} catch { | ||
logger = print | ||
if (typeof globalThis.console?.log === 'function') { | ||
logger = globalThis.console.log | ||
} else if (typeof globalThis.print === 'function') { | ||
logger = globalThis.print | ||
} else { | ||
throw new Error('no logger function found') | ||
} | ||
if ('function' !== typeof logger) | ||
throw new TypeError(`logger is not a function: ${typeof logger}`) | ||
return logger | ||
} | ||
|
||
export const logger = buildLogger() | ||
export const logger = getLogger() |