Comparing version 2.5.0 to 2.5.1
@@ -15,2 +15,7 @@ # Changelog | ||
## v2.5.1 | ||
- **Internal** | ||
- `t.update` should not change the reference when no changes occur, fix #153 | ||
## v2.5.0 | ||
@@ -17,0 +22,0 @@ |
10
index.js
@@ -167,2 +167,3 @@ /*! @preserve | ||
var value = getShallowCopy(instance); | ||
var isChanged = false; | ||
for (var k in spec) { | ||
@@ -174,7 +175,9 @@ if (spec.hasOwnProperty(k)) { | ||
else { | ||
value[k] = update(value[k], spec[k]); | ||
var newValue = update(value[k], spec[k]); | ||
isChanged = isChanged || ( newValue !== value[k] ); | ||
value[k] = newValue; | ||
} | ||
} | ||
} | ||
return value; | ||
return isChanged ? value : instance; | ||
} | ||
@@ -425,2 +428,5 @@ | ||
var type = Union.dispatch(value); | ||
if (!type && Union.is(value)) { | ||
return value; | ||
} | ||
@@ -427,0 +433,0 @@ if (process.env.NODE_ENV !== 'production') { |
{ | ||
"name": "tcomb", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"description": "Type checking and DDD for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -91,3 +91,3 @@ [![build status](https://img.shields.io/travis/gcanti/tcomb/master.svg?style=flat-square)](https://travis-ci.org/gcanti/tcomb) | ||
Instances are immutables using `Object.freeze`. This means you can use standard JavaScript objects and arrays. You don't have to change how you normally code. You can update an immutable instance with the provided `update(instance, spec)` function: | ||
Instances are immutable using `Object.freeze`. This means you can use standard JavaScript objects and arrays. You don't have to change how you normally code. You can update an immutable instance with the provided `update(instance, spec)` function: | ||
@@ -94,0 +94,0 @@ ```js |
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
59762
845