PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/@ledgerhq/logs/lib-es
Просмотр файла: index.js
/**
* A Log object
*/
let id = 0;
const subscribers = [];
/**
* log something
* @param type a namespaced identifier of the log (it is not a level like "debug", "error" but more like "apdu-in", "apdu-out", etc...)
* @param message a clear message of the log associated to the type
*/
export const log = (type, message, data) => {
const obj = {
type,
id: String(++id),
date: new Date()
};
if (message) obj.message = message;
if (data) obj.data = data;
dispatch(obj);
};
/**
* listen to logs.
* @param cb that is called for each future log() with the Log object
* @return a function that can be called to unsubscribe the listener
*/
export const listen = cb => {
subscribers.push(cb);
return () => {
const i = subscribers.indexOf(cb);
if (i !== -1) {
// equivalent of subscribers.splice(i, 1) // https://twitter.com/Rich_Harris/status/1125850391155965952
subscribers[i] = subscribers[subscribers.length - 1];
subscribers.pop();
}
};
};
function dispatch(log) {
for (let i = 0; i < subscribers.length; i++) {
try {
subscribers[i](log);
} catch (e) {
console.error(e);
}
}
} // for debug purpose
if (typeof window !== "undefined") {
window.__ledgerLogsListen = listen;
}
//# sourceMappingURL=index.js.mapВыполнить команду
Для локальной разработки. Не используйте в интернете!