@chakra-ui/object-utils
Version:
A Quick description of the component
24 lines (22 loc) • 569 B
JavaScript
// src/assign-after.ts
function assignAfter(target, ...sources) {
if (target == null) {
throw new TypeError("Cannot convert undefined or null to object");
}
const result = { ...target };
for (const nextSource of sources) {
if (nextSource == null)
continue;
for (const nextKey in nextSource) {
if (!Object.prototype.hasOwnProperty.call(nextSource, nextKey))
continue;
if (nextKey in result)
delete result[nextKey];
result[nextKey] = nextSource[nextKey];
}
}
return result;
}
export {
assignAfter
};