UNPKG
mutate-on-copy
Version:
latest (1.0.1)
1.0.1
1.0.0
mutate on copy
mutate-on-copy
/
dist
/
index.js
8 lines
•
283 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
export
function
mutate
(
target, fn
) {
if
(!target)
return
target;
const
copyState = (
Array
.
isArray
(target) ? target.
slice
() :
Object
.
assign
({}, target));
const
res =
fn
(copyState);
return
res ===
undefined
? copyState : res; }
//# sourceMappingURL=index.js.map