mirror of
https://github.com/HeyPuter/puter.git
synced 2026-07-17 20:47:13 +00:00
omg this is getting out of hand
This commit is contained in:
@@ -1 +0,0 @@
|
||||
import puter from './index.js';
|
||||
@@ -529,12 +529,34 @@ export default window.puter = (function() {
|
||||
container = document.getElementById("--puter-printbox");
|
||||
}
|
||||
|
||||
// Copy args to avoid modifying the original array
|
||||
let processedArgs = [...args];
|
||||
|
||||
// Check if the last argument is an options object
|
||||
const options = typeof args[args.length - 1] === 'object' && args[args.length - 1] !== null ? args.pop() : { newline: false };
|
||||
const lastArg = processedArgs.length > 0 ? processedArgs[processedArgs.length - 1] : null;
|
||||
let options = { newline: false };
|
||||
|
||||
if (lastArg && typeof lastArg === 'object' && lastArg !== null &&
|
||||
!Array.isArray(lastArg) &&
|
||||
Object.getPrototypeOf(lastArg) === Object.prototype &&
|
||||
typeof lastArg.toString === 'undefined') {
|
||||
options = processedArgs.pop();
|
||||
}
|
||||
|
||||
// Process each argument
|
||||
for(let arg of args) {
|
||||
container.innerText += arg;
|
||||
for(let arg of processedArgs) {
|
||||
// If arg has custom toString, use it
|
||||
if (arg && typeof arg === 'object' && typeof arg.toString === 'function') {
|
||||
const stringValue = arg.toString();
|
||||
if (typeof stringValue === 'string') {
|
||||
container.innerText += stringValue;
|
||||
} else {
|
||||
container.innerText += String(arg);
|
||||
}
|
||||
} else {
|
||||
container.innerText += arg;
|
||||
}
|
||||
|
||||
if (options.newline) {
|
||||
container.innerText += '\n';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user