@moonwell-fi/moonwell-sdk
Version:
TypeScript Interface for Moonwell
33 lines • 919 B
JavaScript
import lodash from "lodash";
const { uniqueId } = lodash;
const messages = {};
export function start(action, message) {
if (typeof window !== "undefined") {
const id = uniqueId();
messages[id] = {
id,
start: new Date(),
action,
message,
};
window.dispatchEvent(new CustomEvent("moonwell-sdk", {
detail: messages[id],
}));
return id;
}
return undefined;
}
export function end(id) {
if (typeof window !== "undefined" && id) {
const message = messages[id];
if (message) {
message.end = new Date();
message.duration = message.end.getTime() - message.start.getTime();
window.dispatchEvent(new CustomEvent("moonwell-sdk", {
detail: message,
}));
}
}
return undefined;
}
//# sourceMappingURL=console.js.map