15 lines
No EOL
387 B
TypeScript
15 lines
No EOL
387 B
TypeScript
export const splitAt = (subject: string, index: number): readonly [string, string] => {
|
|
if (index < 0) {
|
|
return [subject, ''];
|
|
}
|
|
|
|
if (index > subject.length) {
|
|
return [subject, ''];
|
|
}
|
|
|
|
return [subject.slice(0, index), subject.slice(index + 1)];
|
|
};
|
|
|
|
export const toSlug = (subject: string) => {
|
|
return subject.toLowerCase().replaceAll(' ', '-');
|
|
}; |