Merge pull request #15898 from backstage/freben/substr

🧹  get rid of usages of substr which is deprecated
This commit is contained in:
Fredrik Adelöw
2023-01-26 13:29:56 +01:00
committed by GitHub
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);
}