react-addons-shallow-compare
Advanced tools
Comparing version 15.5.0-alpha.0 to 15.5.0-rc.1
77
index.js
@@ -1,76 +0,1 @@ | ||
/** | ||
* Copyright 2013-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @providesModule shallowCompare | ||
*/ | ||
'use strict'; | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
/** | ||
* inlined Object.is polyfill to avoid requiring consumers ship their own | ||
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is | ||
*/ | ||
function is(x, y) { | ||
// SameValue algorithm | ||
if (x === y) { | ||
// Steps 1-5, 7-10 | ||
// Steps 6.b-6.e: +0 != -0 | ||
// Added the nonzero y check to make Flow happy, but it is redundant | ||
return x !== 0 || y !== 0 || 1 / x === 1 / y; | ||
} else { | ||
// Step 6.a: NaN == NaN | ||
return x !== x && y !== y; | ||
} | ||
} | ||
/** | ||
* Performs equality by iterating through keys on an object and returning false | ||
* when any key has values which are not strictly equal between the arguments. | ||
* Returns true when the values of all keys are strictly equal. | ||
*/ | ||
function shallowEqual(objA, objB) { | ||
if (is(objA, objB)) { | ||
return true; | ||
} | ||
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { | ||
return false; | ||
} | ||
var keysA = Object.keys(objA); | ||
var keysB = Object.keys(objB); | ||
if (keysA.length !== keysB.length) { | ||
return false; | ||
} | ||
// Test for A's keys different from B. | ||
for (var i = 0; i < keysA.length; i++) { | ||
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
/** | ||
* Does a shallow comparison for props and state. | ||
* See ReactComponentWithPureRenderMixin | ||
* See also https://facebook.github.io/react/docs/shallow-compare.html | ||
*/ | ||
function shallowCompare(instance, nextProps, nextState) { | ||
return ( | ||
!shallowEqual(instance.props, nextProps) || | ||
!shallowEqual(instance.state, nextState) | ||
); | ||
} | ||
module.exports = shallowCompare; | ||
module.exports = require('react/lib/shallowCompare'); |
{ | ||
"name": "react-addons-shallow-compare", | ||
"version": "15.5.0-alpha.0", | ||
"version": "15.5.0-rc.1", | ||
"main": "index.js", | ||
@@ -12,7 +12,7 @@ "repository": "facebook/react", | ||
"dependencies": { | ||
"fbjs": "^0.8.4", | ||
"fbjs": "^0.8.9", | ||
"object-assign": "^4.1.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^15.5.0" | ||
"react": "^15.5.0-rc.1" | ||
}, | ||
@@ -24,12 +24,3 @@ "files": [ | ||
"index.js" | ||
], | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"devDependencies": { | ||
"jest": "^19.0.2", | ||
"react": "^16.0.0-alpha.4", | ||
"react-addons-test-utils": "^16.0.0-alpha.3", | ||
"react-dom": "^16.0.0-alpha.4" | ||
} | ||
} | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
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
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
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
0
5
4150
0
1
Updatedfbjs@^0.8.9