Skip to content

Commit

Permalink
Update is-shallow-equal to use ES5 code as before (#8132)
Browse files Browse the repository at this point in the history
* Update is-shallow-equal to use ES5 code as before

* Fix order of properties in package.json of is-shallow-equal
  • Loading branch information
gziolo authored Jul 23, 2018
1 parent 1533c33 commit 5f69fc8
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 22 deletions.
5 changes: 5 additions & 0 deletions packages/is-shallow-equal/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"no-var": 0
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

/**
* Returns true if the two arrays are shallow equal, or false otherwise.
*
Expand All @@ -7,6 +9,8 @@
* @return {boolean} Whether the two arrays are shallow equal.
*/
function isShallowEqualArrays( a, b ) {
var i;

if ( a === b ) {
return true;
}
Expand All @@ -15,7 +19,7 @@ function isShallowEqualArrays( a, b ) {
return false;
}

for ( let i = 0; i < a.length; i++ ) {
for ( i = 0; i < a.length; i++ ) {
if ( a[ i ] !== b[ i ] ) {
return false;
}
Expand All @@ -24,4 +28,4 @@ function isShallowEqualArrays( a, b ) {
return true;
}

export default isShallowEqualArrays;
module.exports = isShallowEqualArrays;
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/**
* Internal dependencies
*/
import isShallowEqualObjects from './objects';
import isShallowEqualArrays from './arrays';
'use strict';

/**
* Local variables
* Internal dependencies;
*/
const { isArray } = Array;
var isShallowEqualObjects = require( './objects' );
var isShallowEqualArrays = require( './arrays' );

var isArray = Array.isArray;

/**
* Returns true if the two arrays or objects are shallow equal, or false
Expand All @@ -30,4 +29,4 @@ function isShallowEqual( a, b ) {
return a === b;
}

export default isShallowEqual;
module.exports = isShallowEqual;
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* Local variables
*/
const { keys } = Object;
'use strict';

var keys = Object.keys;

/**
* Returns true if the two objects are shallow equal, or false otherwise.
Expand All @@ -12,21 +11,23 @@ const { keys } = Object;
* @return {boolean} Whether the two objects are shallow equal.
*/
function isShallowEqualObjects( a, b ) {
var aKeys, bKeys, i, key;

if ( a === b ) {
return true;
}

const aKeys = keys( a );
const bKeys = keys( b );
aKeys = keys( a );
bKeys = keys( b );

if ( aKeys.length !== bKeys.length ) {
return false;
}

let i = 0;
i = 0;

while ( i < aKeys.length ) {
const key = aKeys[ i ];
key = aKeys[ i ];
if ( a[ key ] !== b[ key ] ) {
return false;
}
Expand All @@ -37,4 +38,4 @@ function isShallowEqualObjects( a, b ) {
return true;
}

export default isShallowEqualObjects;
module.exports = isShallowEqualObjects;
7 changes: 5 additions & 2 deletions packages/is-shallow-equal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
"bugs": {
"url": "https://github.com/WordPress/gutenberg/issues"
},
"main": "build/index.js",
"module": "build-module/index.js",
"files": [
"arrays.js",
"objects.js"
],
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.0.0-beta.52"
},
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ const config = {
test: /\.js$/,
exclude: [
/block-serialization-spec-parser/,
/is-shallow-equal/,
/node_modules/,
],
use: 'babel-loader',
Expand Down Expand Up @@ -233,7 +234,6 @@ const config = {
'api-fetch',
'deprecated',
'dom-ready',
'is-shallow-equal',
].map( camelCaseDash ) ),
],
stats: {
Expand Down

0 comments on commit 5f69fc8

Please sign in to comment.