There are tons of p5.js variables, and they are all defined globally, which can seriously clutter the global scope. Is there a way to store them in a single object, like this:
const p5 = [something goes here]
p5.setup
p5.draw
p5.preload
p5.color
p5.fill
p5.stroke
// instead of
setup
draw
preload
// ...etc
Is there a way to do that?
I think what you are looking for is the usage pattern for p5.js called instance mode. In this mode you create an instance of the p5 object with a callback that defines your sketch.
Additionally, if you are using TypeScript and/or compiling a Node.js package as a bundle or module for use in the browser than you can use the npm packages p5 and @types/p5 so that you can import/require p5 as a module and if you are using TypeScript get type checking.