get rid of usages of substr which is deprecated

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-01-23 14:20:17 +01:00
parent fc94542b2a
commit 85b04f659a
18 changed files with 37 additions and 21 deletions
@@ -22,11 +22,11 @@ export function stringToColor(str: string) {
let color = '#';
for (let i = 0; i < 3; i++) {
const value = (hash >> (i * 8)) & 0xff;
color += `00${value.toString(16)}`.substr(-2);
color += `00${value.toString(16)}`.slice(-2);
}
return color;
}
export function extractInitials(value: string) {
return value.match(/\b\w/g)?.join('').substring(0, 2);
return value.match(/\b\w/g)?.join('').slice(0, 2);
}