MCPcopy Index your code
hub / github.com/developit/htm / wrap

Function wrap

test/__d8.mjs:55–74  ·  view source on GitHub ↗
(obj, method)

Source from the content-addressed store, hash-verified

53let logBuffer;
54
55function wrap(obj, method) {
56 obj[method] = function() {
57 let out = ' ';
58 for (let i=0; i<arguments.length; i++) {
59 let val = arguments[i];
60 if (typeof val === 'object' && val) {
61 val = JSON.stringify(val);
62 }
63 if (out) out += ' ';
64 out += val;
65 }
66 if (method!=='error') out = `\u001b[37m${out}\u001b[0m`;
67 if (logBuffer) {
68 logBuffer.push([method.toUpperCase(), out]);
69 }
70 else {
71 log(method.toUpperCase(), out);
72 }
73 };
74}
75wrap(console, 'log');
76wrap(console, 'info');
77wrap(console, 'warn');

Callers 1

__d8.mjsFile · 0.85

Calls 1

logFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…