1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.PathSegment = exports.Path = exports.UnboundRelationship = exports.Relationship = exports.Node = undefined;
|
7 |
|
8 | var _stringify = require("babel-runtime/core-js/json/stringify");
|
9 |
|
10 | var _stringify2 = _interopRequireDefault(_stringify);
|
11 |
|
12 | var _keys = require("babel-runtime/core-js/object/keys");
|
13 |
|
14 | var _keys2 = _interopRequireDefault(_keys);
|
15 |
|
16 | var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
|
17 |
|
18 | var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
19 |
|
20 | var _createClass2 = require("babel-runtime/helpers/createClass");
|
21 |
|
22 | var _createClass3 = _interopRequireDefault(_createClass2);
|
23 |
|
24 | var _integer = require("./integer");
|
25 |
|
26 | var _integer2 = _interopRequireDefault(_integer);
|
27 |
|
28 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | var Node = function () {
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | function Node(identity, labels, properties) {
|
41 | (0, _classCallCheck3.default)(this, Node);
|
42 |
|
43 | this.identity = identity;
|
44 | this.labels = labels;
|
45 | this.properties = properties;
|
46 | }
|
47 |
|
48 | (0, _createClass3.default)(Node, [{
|
49 | key: "toString",
|
50 | value: function toString() {
|
51 | var s = "(" + this.identity;
|
52 | for (var i = 0; i < this.labels.length; i++) {
|
53 | s += ":" + this.labels[i];
|
54 | }
|
55 | var keys = (0, _keys2.default)(this.properties);
|
56 | if (keys.length > 0) {
|
57 | s += " {";
|
58 | for (var _i = 0; _i < keys.length; _i++) {
|
59 | if (_i > 0) s += ",";
|
60 | s += keys[_i] + ":" + (0, _stringify2.default)(this.properties[keys[_i]]);
|
61 | }
|
62 | s += "}";
|
63 | }
|
64 | s += ")";
|
65 | return s;
|
66 | }
|
67 | }]);
|
68 | return Node;
|
69 | }();
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | var Relationship = function () {
|
93 | |
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 | function Relationship(identity, start, end, type, properties) {
|
102 | (0, _classCallCheck3.default)(this, Relationship);
|
103 |
|
104 | this.identity = identity;
|
105 | this.start = start;
|
106 | this.end = end;
|
107 | this.type = type;
|
108 | this.properties = properties;
|
109 | }
|
110 |
|
111 | (0, _createClass3.default)(Relationship, [{
|
112 | key: "toString",
|
113 | value: function toString() {
|
114 | var s = "(" + this.start + ")-[:" + this.type;
|
115 | var keys = (0, _keys2.default)(this.properties);
|
116 | if (keys.length > 0) {
|
117 | s += " {";
|
118 | for (var i = 0; i < keys.length; i++) {
|
119 | if (i > 0) s += ",";
|
120 | s += keys[i] + ":" + (0, _stringify2.default)(this.properties[keys[i]]);
|
121 | }
|
122 | s += "}";
|
123 | }
|
124 | s += "]->(" + this.end + ")";
|
125 | return s;
|
126 | }
|
127 | }]);
|
128 | return Relationship;
|
129 | }();
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | var UnboundRelationship = function () {
|
138 | |
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | function UnboundRelationship(identity, type, properties) {
|
145 | (0, _classCallCheck3.default)(this, UnboundRelationship);
|
146 |
|
147 | this.identity = identity;
|
148 | this.type = type;
|
149 | this.properties = properties;
|
150 | }
|
151 |
|
152 | |
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 | (0, _createClass3.default)(UnboundRelationship, [{
|
161 | key: "bind",
|
162 | value: function bind(start, end) {
|
163 | return new Relationship(this.identity, start, end, this.type, this.properties);
|
164 | }
|
165 | }, {
|
166 | key: "toString",
|
167 | value: function toString() {
|
168 | var s = "-[:" + this.type;
|
169 | var keys = (0, _keys2.default)(this.properties);
|
170 | if (keys.length > 0) {
|
171 | s += " {";
|
172 | for (var i = 0; i < keys.length; i++) {
|
173 | if (i > 0) s += ",";
|
174 | s += keys[i] + ":" + (0, _stringify2.default)(this.properties[keys[i]]);
|
175 | }
|
176 | s += "}";
|
177 | }
|
178 | s += "]->";
|
179 | return s;
|
180 | }
|
181 | }]);
|
182 | return UnboundRelationship;
|
183 | }();
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 | var PathSegment =
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 | function PathSegment(start, rel, end) {
|
198 | (0, _classCallCheck3.default)(this, PathSegment);
|
199 |
|
200 | this.start = start;
|
201 | this.relationship = rel;
|
202 | this.end = end;
|
203 | };
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 | var Path =
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 | function Path(start, end, segments) {
|
218 | (0, _classCallCheck3.default)(this, Path);
|
219 |
|
220 | this.start = start;
|
221 | this.end = end;
|
222 | this.segments = segments;
|
223 | this.length = segments.length;
|
224 | };
|
225 |
|
226 | exports.Node = Node;
|
227 | exports.Relationship = Relationship;
|
228 | exports.UnboundRelationship = UnboundRelationship;
|
229 | exports.Path = Path;
|
230 | exports.PathSegment = PathSegment; |
\ | No newline at end of file |