MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / toJSON

Method toJSON

src/theme/builder.js:265–281  ·  view source on GitHub ↗

* Gets the theme as an object * @param {'rgba'|'hex' | 'none'} colorType * @returns {Object }

(colorType = "none")

Source from the content-addressed store, hash-verified

263 * @returns {Object<string, string>}
264 */
265 toJSON(colorType = "none") {
266 const res = {
267 name: this.name,
268 type: this.type,
269 version: this.version,
270 };
271 Object.keys(this.#theme).forEach((key) => {
272 const color =
273 colorType === "hex"
274 ? Color(this.#theme[key]).hex.toString()
275 : colorType === "rgba"
276 ? Color(this.#theme[key]).rgba.toString()
277 : this.#theme[key];
278 res[ThemeBuilder.#toPascal(key)] = color;
279 });
280 return res;
281 }
282
283 toString() {
284 return JSON.stringify(this.toJSON());

Callers 3

toStringMethod · 0.95
applyFunction · 0.45
updateFunction · 0.45

Calls 3

ColorClass · 0.85
#toPascalMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected