nanomap/tools/Debug.js

28 lines
516 B
JavaScript
Raw Permalink Normal View History

2023-12-27 11:06:29 +08:00
// no dependencies
import {__DEBUG__} from "../PublicProperty";
export function noexcept(_f) {
2023-12-27 11:06:29 +08:00
/**
* No exceptions.
* @returns {*}
* @private
*/
function _wrap() {
try {
return _f.apply(this, arguments);
2023-12-27 11:06:29 +08:00
} catch (e) {
console.debug(e);
}
}
return _wrap;
}
export const sill = noexcept((_x) => {
2023-12-27 11:06:29 +08:00
if(__DEBUG__) {
console.log(_x);
2023-12-27 11:06:29 +08:00
}
});
export const sill_unwrap = noexcept((_x) => {
sill(JSON.stringify(_x));
2023-12-27 11:06:29 +08:00
});