Skip to content

Commit 362cbf6

Browse files
committed
allow for index as input
1 parent a48312e commit 362cbf6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dashi/src/lib/utils/objPath.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,18 @@ export function _setValue<S extends object>(
6161
return obj;
6262
}
6363

64-
export function toObjPath(property: ObjPath | string): ObjPath {
64+
export function toObjPath(
65+
property: ObjPath | string | number | undefined | null,
66+
): ObjPath {
6567
if (Array.isArray(property)) {
6668
return property as ObjPath;
6769
}
68-
if (property === "") {
70+
if (property === "" || !property) {
6971
return [];
7072
}
73+
if (typeof property === "number") {
74+
return [property];
75+
}
7176
const objPath: ObjPath = property.split(".");
7277
for (let i = 0; i < objPath.length; i++) {
7378
const index = Number(objPath[i]);

0 commit comments

Comments
 (0)