From 58e6fad9b48836ce21b2d5a298a262a2ceadef9d Mon Sep 17 00:00:00 2001 From: Cosmo Myzrail Gorynych Date: Wed, 22 Dec 2021 19:06:30 +1200 Subject: [PATCH] :fire: Replace ct.types.with with ct.types.withCopy and ct.types.withType. --- app/data/ct.release/types.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/data/ct.release/types.js b/app/data/ct.release/types.js index 87c02b9a9..99e35ed68 100644 --- a/app/data/ct.release/types.js +++ b/app/data/ct.release/types.js @@ -318,12 +318,24 @@ const Copy = (function Copy() { func.apply(copy, this); } }, - /* + /** * Applies a function to a given object (e.g. to a copy) + * @param {Copy} obj The copy to perform function upon. + * @param {Function} function The function to be applied. */ - 'with'(obj, func) { + withCopy(obj, func) { func.apply(obj, this); }, + /** + * Applies a function to a given object (e.g. to a copy) + * @param {string} type The name of the type to perform function upon. + * @param {Function} function The function to be applied. + */ + withType(type, func) { + for (const copy of ct.types.list[type]) { + func.apply(copy, this); + } + }, /** * Checks whether there are any copies of this type's name. * Will throw an error if you pass an invalid type name.