BetterDiscordApp-rauenzi/renderer/src/structs/string.js

19 lines
466 B
JavaScript
Raw Normal View History

2023-05-20 00:37:21 +02:00
import Utilities from "@modules/utilities";
2019-06-25 22:36:34 +02:00
2020-11-04 03:06:07 +01:00
const LINK = /\[(.+?)]/;
2019-06-25 22:36:34 +02:00
export default class FormattableString extends String {
format(values) {
return Utilities.formatString(this, values);
}
2020-11-04 03:06:07 +01:00
replaceLink(callback) {
const match = this.match(LINK);
if (!match) return [this];
const array = this.split(match[0]);
const element = callback(match[1]);
array.splice(1, 0, element);
return array;
}
2019-06-25 22:36:34 +02:00
}