Comparing version 0.3.4 to 0.4.0
{ | ||
"name": "reduxerit", | ||
"version": "0.3.4", | ||
"version": "0.4.0", | ||
"description": "redux utils to generate reducer and actions in a shorter way", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -59,3 +59,13 @@ import _deepmerge from 'deepmerge'; | ||
export const set = target => (state, action) => (setIn(state,target,action.payload )) | ||
export const update = (target, updateCB) => (state, action) => (updateIn(state,target, (oldValue) => updateCB(oldValue, action.payload) )) | ||
export const update = (target, updateCB) => (state, action) => { | ||
let updateFinalCb; | ||
if( typeof(updateCB) === 'function' ) | ||
updateFinalCb = (oldValue) => updateCB(oldValue, action.payload) | ||
else | ||
updateFinalCb = () => updateCB | ||
return updateIn(state,target, updateFinalCb) | ||
} | ||
export const deepmerge = target => (state, action) => updateIn(state, target, (obj) => _deepmerge(obj, action.payload)) | ||
@@ -62,0 +72,0 @@ export const merge = target => (state, action) => updateIn(state, target, (obj) => ({...obj, ...action.payload}) ) |
@@ -222,3 +222,3 @@ import chai from 'chai'; | ||
/* update */ | ||
it("update - ", () =>{ | ||
it("update - update collaback", () =>{ | ||
const action = { | ||
@@ -239,8 +239,23 @@ type:'TYPE', | ||
it("remove - ", () =>{ | ||
it("update - set fixed value", () =>{ | ||
const action = { | ||
type:'TYPE', | ||
payload:5 | ||
type:'TYPE' | ||
} | ||
update(['b','c'] , 'settedWithoutCallback' )(state,action) | ||
.should.be.deep.equal({ | ||
a: "aa", | ||
b: { | ||
c:"settedWithoutCallback", | ||
d: "dd" | ||
} | ||
}) | ||
}) | ||
it("remove - remove b.c", () =>{ | ||
const action = { | ||
type:'TYPE' | ||
} | ||
remove(['b','c'])(state,action) | ||
@@ -247,0 +262,0 @@ .should.be.deep.equal({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14691
499