Skip to content

Commit

Permalink
currying WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Jan 5, 2018
1 parent cc61e1e commit d5a3b8f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions immer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ let autoFreeze = true
* @returns {any} a new state, or the base state if nothing was modified
*/
function immer(baseState, thunk) {
// curried invocation
if (arguments.length === 1) {
// TODO: check arg is fn
return function() {
// TODO: check arg1 is object / array
const args = arguments
return immer(args[0], draft => {
args[0] = draft // blegh!
baseState.apply(null, args)
})
}
}

// TODO: check args

/**
* Maps baseState objects to revocable proxies
* @type {Map<Object,RevocableProxy>}
Expand Down

0 comments on commit d5a3b8f

Please sign in to comment.