I’m trying to set up a CodePen project that will let me test scripts that I intend to run on a third-party API (roll20.net). The API runs scripts in a specific manner — it simply concatenates all of the code from all of your scripts, in order, then runs the whole thing. Beyond the content of the scripts, I have no access to the hosting API itself.
Here is an example of two scripts I could run in the API:
CONSTANTS.js
const C = (() => {
const COLORS = {
purered: "rgba(255, 0, 0, 1)",
palered: "rgba(255, 175, 175, 1)",
brightred: "rgba(255, 31, 34, 1)",
lightred: "rgba(255, 60, 60, 1)",
black: "rgba(0,0,0,1)"
};
return {
COLORS
};
})();
ACTION.js
const A = (() => {
const getColor = (colorKey) => C.COLORS[colorKey] || C.COLORS.black;
return {
GetColor: getColor
};
})();
Then, in a third script, I could call on either of the above:
console.log(C.COLORS.brightred); // rgba(255, 31, 34, 1)
console.log(A.GetColor("brightred")); // rgba(255, 31, 34, 1)
console.log(C.COLORS.orange) // undefined
console.log(A.GetColor("orange")); // rgba(0,0,0,1)
How can I reproduce this behavior in a CodePen project? Thanks in advance for any insights you can provide!