export * from "./typeUtils.js";
/**
 * Wraps a function with a try-catch block to catch and log any errors.
 * @param fn - A function to wrap with a try-catch block.
 * @returns A function that returns null if an error is thrown.
 */
export function withSafety({ fn, onError, }) {
    return (...args) => {
        try {
            return fn(...args);
        }
        catch (error) {
            if (onError) {
                onError(error);
            }
            return null;
        }
    };
}
export const safelyJSONStringify = withSafety({ fn: JSON.stringify });
export const safelyJSONParse = withSafety({ fn: JSON.parse });
//# sourceMappingURL=index.js.map