-
Notifications
You must be signed in to change notification settings - Fork 1
/
normalize.js
28 lines (21 loc) · 905 Bytes
/
normalize.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use strict";
var _extends2 = require("babel-runtime/helpers/extends");
var _extends3 = _interopRequireDefault(_extends2);
var _objectWithoutProperties2 = require("babel-runtime/helpers/objectWithoutProperties");
var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const nodeFromData = datum => {
const { attributes: { id: _attributes_id } = {} } = datum,
attributes = (0, _objectWithoutProperties3.default)(datum.attributes, ["id"]);
const preservedId = typeof _attributes_id !== `undefined` ? { _attributes_id } : {};
return (0, _extends3.default)({
id: datum.id,
parent: null,
children: []
}, attributes, preservedId, {
internal: {
type: datum.type.replace(/-|__|:|\.|\s/g, `_`)
}
});
};
exports.nodeFromData = nodeFromData;