Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setIn: function setIn(obj, path, val) {
return immer(obj, function (x) {
x = path.slice(0, path.length - 1).reduce(function (x, path) {
return x[path];
}, x);
x[path[path.length - 1]] = val;
});
},
merge: function merge(obj1, obj2) {
setAt: function setAt(arr, idx, val) {
return immer(arr, function (x) {
x[idx] = val;
});
},
getAtDeep: function getAtDeep(arr, idx1, idx2) {
setAtDeep: function(arr, idx1, idx2, val) {
return immer(arr, x => {
x[idx1][idx2] = val;
});
}
};
benchmark(() => {
return immer(original, transformer);
}, 'immer without autofreeze - array');
setAtDeep: function(arr, idx1, idx2, val) {
return immer(arr, x => {
x[idx1][idx2] = val;
});
}
};
function updateJSON(filepath, updateFn) {
const content = readFileSync(filepath, {encoding: 'utf-8'});
const {indent} = detectIndent(content);
const data = JSON.parse(content);
const modified = immer(data, updateFn);
writeFileSync(filepath, JSON.stringify(modified, null, indent), {
encoding: 'utf-8',
});
}
reducer = React.useMemo(() => produce(reducer), [produce, reducer]);
return React.useReducer(reducer, initialState, initialAction);
function update(target, updater) {
let currState = target.get();
let nextState = immer(currState, updater);
if (nextState !== currState) target.set(nextState);
}
setAtDeep: function setAtDeep(arr, idx1, idx2, val) {
return immer(arr, function (x) {
x[idx1][idx2] = val;
});
}
};
var setPartialState = function (name, partialState) {
if (partialState === void 0) { partialState = {}; }
if (typeof partialState === 'function') {
var state_1 = GlobalState[name].state;
state_1 = immer_1["default"](state_1, partialState);
GlobalState = immer_1["default"](GlobalState, function (s) {
s[name].state = state_1;
});
}
else {
GlobalState = immer_1["default"](GlobalState, function (s) {
s[name].state = __assign({}, s[name].state, partialState);
});
}
return GlobalState;
};
var getState = function (modelName) {