Skip to content

Commit 6907133

Browse files
committed
refactor: use single-pass regex with zero-width assertions
1 parent 5a3a484 commit 6907133

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import type {
66
} from './types';
77

88
const camelToKebab = (string: string) => string
9-
.replaceAll(/([a-z])([A-Z])/g, '$1-$2')
10-
.replaceAll(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
9+
.replaceAll(/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g, '-')
1110
.toLowerCase();
1211

1312
const { hasOwnProperty } = Object.prototype;

0 commit comments

Comments
 (0)