Use identity with u.if's false condition

Fixes #35
This commit is contained in:
Aaron Jensen 2015-09-11 11:57:39 -07:00
parent 396f0a7bf2
commit b8ca7f5407
3 changed files with 6 additions and 2 deletions

View File

@ -2,5 +2,5 @@ import ifElse from './ifElse';
import curry from './util/curry'; import curry from './util/curry';
export default curry((predicate, trueUpdates, object) => export default curry((predicate, trueUpdates, object) =>
ifElse(predicate, trueUpdates, {}, object) ifElse(predicate, trueUpdates, x => x, object)
); );

View File

@ -20,6 +20,7 @@
], ],
"scripts": { "scripts": {
"test": "gulp", "test": "gulp",
"test:watch": "gulp watch",
"prepublish": "gulp prepublish", "prepublish": "gulp prepublish",
"perf-server": "`npm bin`/webpack-dev-server --config perf/webpack.config.js --hot" "perf-server": "`npm bin`/webpack-dev-server --config perf/webpack.config.js --hot"
}, },

View File

@ -4,8 +4,11 @@ import u from '../lib';
describe('u.if', () => { describe('u.if', () => {
it('does not update if the predicate is false', () => { it('does not update if the predicate is false', () => {
const object = { a: 0 }; const object = { a: 0 };
const result = u.if(false, { b: 1 }, object); let result = u.if(false, { b: 1 }, object);
expect(result).to.eql(object); expect(result).to.eql(object);
result = u({ x: u.if(false, 1)}, {});
expect(result).to.eql({});
}); });
it('does update if the predicate is true', () => { it('does update if the predicate is true', () => {