Skip to content

Commit 44adf7c

Browse files
committed
prevent non string keys
1 parent fa0911d commit 44adf7c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/normalize.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import assert from 'node:assert'
2+
13
/**
24
* Lower first letter of the string.
35
*/
@@ -49,7 +51,7 @@ function _lowerCamelCase(name: string) {
4951
* @param obj object to traverse
5052
* @param fn function to apply
5153
*/
52-
export function morph(
54+
function morph(
5355
obj: any,
5456
fn: (key: string, value: any) => { key: string; value: any }
5557
) {
@@ -60,6 +62,8 @@ export function morph(
6062
}
6163
} else {
6264
for (let [key, value] of Object.entries(obj)) {
65+
// technically this should never happen here, but let's be safe
66+
assert(typeof key === 'string', 'Only string keys are supported')
6367
if (typeof value === 'object') {
6468
morph(value, fn)
6569
} else {

0 commit comments

Comments
 (0)