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

More documentation work

This commit is contained in:
Dragory 2019-08-22 02:58:32 +03:00
parent e5b8409428
commit 12f25346ec
33 changed files with 286 additions and 57 deletions

View file

@ -39,7 +39,16 @@ export const HOURS = 60 * MINUTES;
export const DAYS = 24 * HOURS;
export function tNullable<T extends t.Type<any, any, unknown>>(type: T) {
return t.union([type, t.undefined, t.null]);
return t.union([type, t.undefined, t.null], type.name);
}
export function dropPropertiesByName(obj, propName) {
if (obj.hasOwnProperty(propName)) delete obj[propName];
for (const value of Object.values(obj)) {
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
dropPropertiesByName(value, propName);
}
}
}
/**
@ -275,6 +284,17 @@ export function trimIndents(str: string, indentLength: number) {
.join("\n");
}
export function indentLine(str: string, indentLength: number) {
return " ".repeat(indentLength) + str;
}
export function indentLines(str: string, indentLength: number) {
return str
.split("\n")
.map(line => indentLine(line, indentLength))
.join("\n");
}
export const emptyEmbedValue = "\u200b";
export const embedPadding = "\n" + emptyEmbedValue;