Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 24858d7

Browse files
committed
Replace Object.assign with the spread operator in object inspector.
1 parent 0005b96 commit 24858d7

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

packages/devtools-reps/src/object-inspector/component.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,10 @@ class ObjectInspector extends Component {
267267
return {
268268
label: this.renderGrip(
269269
item,
270-
Object.assign({}, this.props, {
270+
{
271+
...this.props,
271272
functionName: label
272-
})
273+
}
273274
)
274275
};
275276
}
@@ -280,7 +281,7 @@ class ObjectInspector extends Component {
280281
|| nodeIsMapEntry(item)
281282
|| isPrimitive
282283
) {
283-
let repsProp = Object.assign({}, this.props);
284+
let repsProp = {...this.props};
284285
if (depth > 0) {
285286
repsProp.mode = this.props.mode === MODE.LONG
286287
? MODE.SHORT
@@ -416,11 +417,12 @@ class ObjectInspector extends Component {
416417
props: Props
417418
) {
418419
const object = getValue(item);
419-
return Rep(Object.assign({}, props, {
420+
return Rep({
421+
...props,
420422
object,
421423
mode: props.mode || MODE.TINY,
422424
defaultRep: Grip,
423-
}));
425+
});
424426
}
425427

426428
render() {

packages/devtools-reps/src/object-inspector/reducer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function reducer(
1717
data,
1818
} = action;
1919

20-
const cloneState = overrides => Object.assign({}, state, overrides);
20+
const cloneState = overrides => ({ ...state, ...overrides});
2121

2222
if (type === "NODE_EXPAND") {
2323
return cloneState({
@@ -56,7 +56,7 @@ function mergeResponses(responses: Array<Object>) : Object {
5656

5757
for (const response of responses) {
5858
if (response.hasOwnProperty("ownProperties")) {
59-
data.ownProperties = Object.assign({}, data.ownProperties, response.ownProperties);
59+
data.ownProperties = {...data.ownProperties, ...response.ownProperties};
6060
}
6161

6262
if (response.ownSymbols && response.ownSymbols.length > 0) {

packages/devtools-reps/src/object-inspector/store.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ import type {
1414
} from "./types";
1515

1616
function createInitialState(overrides : Object) : State {
17-
return Object.assign({
17+
return {
1818
actors: new Set(),
1919
expandedPaths: new Set(),
2020
focusedItem: null,
2121
loadedProperties: new Map(),
22-
}, overrides);
22+
...overrides,
23+
};
2324
}
2425

2526
module.exports = (props : Props) => {

packages/devtools-reps/src/object-inspector/utils/node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ function makeNodesForProperties(
535535
const parentPath = parent.path;
536536
const parentValue = getValue(parent);
537537

538-
let allProperties = Object.assign({}, ownProperties, safeGetterValues);
538+
let allProperties = {...ownProperties, ...safeGetterValues};
539539

540540
// Ignore properties that are neither non-concrete nor getters/setters.
541541
const propertiesNames = sortProperties(Object.keys(allProperties)).filter(name => {

0 commit comments

Comments
 (0)