3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

map + get_snowflake

Signed-off-by: GitHub <noreply@github.com>
This commit is contained in:
Tiago R 2023-10-09 09:54:36 +00:00 committed by GitHub
parent c44d6b97fe
commit c6f838f333
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -465,6 +465,12 @@ const baseValues = {
if (isNaN(base) || isNaN(power)) return 0;
return Math.pow(parseFloat(base), parseFloat(power));
},
map(obj, key) {
if (Array.isArray(obj)) {
return obj.map((tobj) => tobj[key]);
}
return obj[key];
},
cases(mod, ...cases) {
if (cases.length === 0) return "";
if (isNaN(mod)) return "";
@ -475,6 +481,10 @@ const baseValues = {
const mod = Math.floor(Math.random() * cases.length) + 1;
return baseValues.cases(mod, ...cases);
},
get_snowflake(str) {
if (!str || typeof str !== "string") return "";
return str.replaceAll(/[^\d]+/g, "");
},
};
export async function renderTemplate(