Skip to content

Commit

Permalink
refactor(parsedata): destruct data
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Aug 6, 2019
1 parent fbbd0a9 commit 59cd72d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 39 deletions.
26 changes: 14 additions & 12 deletions dist/ReactGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -29835,21 +29835,23 @@
};

var parseElement = function parseElement(e) {
e.type = e.type || 'default';

if (isEdge(e)) {
e.id = e.id ? e.id.toString() : getEdgeId(e);
return e;
return _objectSpread2({}, e, {
type: e.type || 'default',
id: e.id ? e.id.toString() : getEdgeId(e)
});
}

e.id = e.id.toString();
e.__rg = {
position: e.position,
width: null,
height: null,
handleBounds: {}
};
return _objectSpread2({}, e);
return _objectSpread2({}, e, {
id: e.id.toString(),
type: e.type || 'default',
__rg: {
position: e.position,
width: null,
height: null,
handleBounds: {}
}
});
};
var getBoundingBox = function getBoundingBox(nodes) {
var bbox = nodes.reduce(function (res, node) {
Expand Down
28 changes: 15 additions & 13 deletions example/build/example.e31bb0bc.js
Original file line number Diff line number Diff line change
Expand Up @@ -37639,21 +37639,23 @@ var getEdgeId = function getEdgeId(e) {
};

var parseElement = function parseElement(e) {
e.type = e.type || 'default';

if (isEdge(e)) {
e.id = e.id ? e.id.toString() : getEdgeId(e);
return e;
return _objectSpread({}, e, {
type: e.type || 'default',
id: e.id ? e.id.toString() : getEdgeId(e)
});
}

e.id = e.id.toString();
e.__rg = {
position: e.position,
width: null,
height: null,
handleBounds: {}
};
return _objectSpread({}, e);
return _objectSpread({}, e, {
id: e.id.toString(),
type: e.type || 'default',
__rg: {
position: e.position,
width: null,
height: null,
handleBounds: {}
}
});
};

exports.parseElement = parseElement;
Expand Down Expand Up @@ -42916,7 +42918,7 @@ var parent = module.bundle.parent;
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
var hostname = "" || location.hostname;
var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
var ws = new WebSocket(protocol + '://' + hostname + ':' + "61389" + '/');
var ws = new WebSocket(protocol + '://' + hostname + ':' + "52012" + '/');

ws.onmessage = function (event) {
checkedAssets = {};
Expand Down
2 changes: 1 addition & 1 deletion example/build/example.e31bb0bc.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 15 additions & 12 deletions src/graph-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,25 @@ export const removeElements = (elements, elementsToRemove) => {
const getEdgeId = (e) => `react-graph__edge-${e.source}-${e.target}`;

export const parseElement = (e) => {
e.type = e.type || 'default';

if (isEdge(e)) {
e.id = e.id ? e.id.toString() : getEdgeId(e);
return e;
return {
...e,
type: e.type || 'default',
id: e.id ? e.id.toString() : getEdgeId(e)
};
}

e.id = e.id.toString();
e.__rg = {
position: e.position,
width: null,
height: null,
handleBounds : {}
return {
...e,
id: e.id.toString(),
type: e.type || 'default',
__rg: {
position: e.position,
width: null,
height: null,
handleBounds : {}
}
};

return { ...e };
};

export const separateElements = (res, element) => {
Expand Down

0 comments on commit 59cd72d

Please sign in to comment.