immutable-lens
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -101,9 +101,13 @@ "use strict"; | ||
}; | ||
ImmutableLens.prototype.setValue = function (newValue) { | ||
ImmutableLens.prototype.setValue = function () { | ||
var _this = this; | ||
if (newValue === undefined) { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
if (args.length === 0) { | ||
return function (value) { return _this.setValueUpdater(value); }; | ||
} | ||
else { | ||
return this.setValueUpdater(newValue); | ||
return this.setValueUpdater(args[0]); | ||
} | ||
@@ -110,0 +114,0 @@ }; |
{ | ||
"name": "immutable-lens", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Type-safe Lens API for immutable updates in complex data structures", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -200,7 +200,7 @@ import { cherryPick } from './cherryPick' | ||
public setValue(newValue?: Target) { | ||
if (newValue === undefined) { | ||
public setValue(...args: any[]) { | ||
if (args.length === 0) { | ||
return (value: Target) => this.setValueUpdater(value) | ||
} else { | ||
return this.setValueUpdater(newValue) | ||
return this.setValueUpdater(args[0]) | ||
} | ||
@@ -207,0 +207,0 @@ } |
@@ -151,2 +151,11 @@ import { expect } from 'chai' | ||
}) | ||
it('can set field value to undefined', () => { | ||
const updater = lens.focusPath('user').setValue(undefined) | ||
const updated = updater(source) | ||
expect(updated).to.deep.equal({ | ||
...source, | ||
user: undefined, | ||
}) | ||
}) | ||
}) | ||
@@ -153,0 +162,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
117993
2401
0