parent
396f0a7bf2
commit
b8ca7f5407
@ -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)
|
||||||
);
|
);
|
||||||
|
@ -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"
|
||||||
},
|
},
|
||||||
|
@ -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', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user