UNPKG

@mantine/form

Version:

Mantine form management library

1 lines 826 B
{"version":3,"file":"insert-path.mjs","names":[],"sources":["../../src/paths/insert-path.ts"],"sourcesContent":["import { getPath } from './get-path';\nimport { setPath } from './set-path';\n\nexport function insertPath<T>(path: unknown, value: unknown, index: number | undefined, values: T) {\n const currentValue = getPath(path, values);\n\n if (!Array.isArray(currentValue)) {\n return values;\n }\n\n const cloned = [...currentValue];\n cloned.splice(typeof index === 'number' ? index : cloned.length, 0, value);\n\n return setPath(path, cloned, values);\n}\n"],"mappings":";;;;AAGA,SAAgB,WAAc,MAAe,OAAgB,OAA2B,QAAW;CACjG,MAAM,eAAe,QAAQ,MAAM,MAAM;CAEzC,IAAI,CAAC,MAAM,QAAQ,YAAY,GAC7B,OAAO;CAGT,MAAM,SAAS,CAAC,GAAG,YAAY;CAC/B,OAAO,OAAO,OAAO,UAAU,WAAW,QAAQ,OAAO,QAAQ,GAAG,KAAK;CAEzE,OAAO,QAAQ,MAAM,QAAQ,MAAM;AACrC"}