mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-28 14:50:58 +00:00
20 lines
486 B
JavaScript
20 lines
486 B
JavaScript
'use client';
|
|
import { getPath } from './get-path.mjs';
|
|
import { setPath } from './set-path.mjs';
|
|
|
|
function replacePath(path, item, index, values) {
|
|
const currentValue = getPath(path, values);
|
|
if (!Array.isArray(currentValue)) {
|
|
return values;
|
|
}
|
|
if (currentValue.length <= index) {
|
|
return values;
|
|
}
|
|
const cloned = [...currentValue];
|
|
cloned[index] = item;
|
|
return setPath(path, cloned, values);
|
|
}
|
|
|
|
export { replacePath };
|
|
//# sourceMappingURL=replace-path.mjs.map
|