Skip to content

Commit 402418d

Browse files
committed
add editorconfig and provide correct indentation settings compliant with original project
1 parent 90f057c commit 402418d

File tree

9 files changed

+316
-297
lines changed

9 files changed

+316
-297
lines changed

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
11+
# Matches multiple files with brace expansion notation
12+
# Set default charset
13+
[*.{js}]
14+
charset = utf-8
15+
16+
# Indentation override for all JS
17+
[**.js]
18+
indent_style = tab
19+
indent_size = 2

examples/RedisGraphExample.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ const RedisGraph = require("../src/redisGraph");
33
let graph = new RedisGraph("social");
44

55
graph
6-
.query("CREATE (:person{name:'roi',age:32})")
7-
.then(() => {
8-
return graph.query("CREATE (:person{name:'amit',age:30})");
9-
})
10-
.then(() => {
11-
return graph.query(
12-
"MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(a)"
13-
);
14-
})
15-
.then(() => {
16-
return graph.query("MATCH (a:person)-[:knows]->(:person) RETURN a");
17-
})
18-
.then(res => {
19-
while (res.hasNext()) {
20-
let record = res.next();
21-
console.log(record.getString("a.name"));
22-
}
23-
console.log(res.getStatistics().queryExecutionTime());
24-
})
25-
.catch(err => {
26-
console.log(err);
27-
});
6+
.query("CREATE (:person{name:'roi',age:32})")
7+
.then(() => {
8+
return graph.query("CREATE (:person{name:'amit',age:30})");
9+
})
10+
.then(() => {
11+
return graph.query(
12+
"MATCH (a:person), (b:person) WHERE (a.name = 'roi' AND b.name='amit') CREATE (a)-[:knows]->(a)"
13+
);
14+
})
15+
.then(() => {
16+
return graph.query("MATCH (a:person)-[:knows]->(:person) RETURN a");
17+
})
18+
.then(res => {
19+
while (res.hasNext()) {
20+
let record = res.next();
21+
console.log(record.getString("a.name"));
22+
}
23+
console.log(res.getStatistics().queryExecutionTime());
24+
})
25+
.catch(err => {
26+
console.log(err);
27+
});

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import Statistics from "./statistics";
55
import Label from "./label";
66

77
const redisGraph = {
8-
Record: Record,
9-
RedisGraph: RedisGraph,
10-
ResultSet: ResultSet,
11-
Statistics: Statistics,
12-
Label: Label
8+
Record: Record,
9+
RedisGraph: RedisGraph,
10+
ResultSet: ResultSet,
11+
Statistics: Statistics,
12+
Label: Label
1313
};
1414

1515
export default redisGraph;

src/label.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* Different Statistics labels
33
*/
44
const Label = Object.freeze({
5-
LABELS_ADDED: "Labels added",
6-
NODES_CREATED: "Nodes created",
7-
NODES_DELETED: "Nodes deleted",
8-
RELATIONSHIPS_DELETED: "Relationships deleted",
9-
PROPERTIES_SET: "Properties set",
10-
RELATIONSHIPS_CREATED: "Relationships created",
11-
QUERY_INTERNAL_EXECUTION_TIME: "Query internal execution time"
5+
LABELS_ADDED: "Labels added",
6+
NODES_CREATED: "Nodes created",
7+
NODES_DELETED: "Nodes deleted",
8+
RELATIONSHIPS_DELETED: "Relationships deleted",
9+
PROPERTIES_SET: "Properties set",
10+
RELATIONSHIPS_CREATED: "Relationships created",
11+
QUERY_INTERNAL_EXECUTION_TIME: "Query internal execution time"
1212
});
1313

1414
export default Label;

src/record.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,34 @@
22
* Hold a query record
33
*/
44
class Record {
5-
constructor(header, values) {
6-
this._header = header;
7-
this._values = values;
8-
}
5+
constructor(header, values) {
6+
this._header = header;
7+
this._values = values;
8+
}
99

10-
getString(key) {
11-
let index = key;
12-
if (typeof key === "string") {
13-
index = this._header.indexOf(key);
14-
}
15-
return this._values[index];
16-
}
10+
getString(key) {
11+
let index = key;
12+
if (typeof key === "string") {
13+
index = this._header.indexOf(key);
14+
}
15+
return this._values[index];
16+
}
1717

18-
keys() {
19-
return this._header;
20-
}
18+
keys() {
19+
return this._header;
20+
}
2121

22-
values() {
23-
return this._values;
24-
}
22+
values() {
23+
return this._values;
24+
}
2525

26-
containsKey(key) {
27-
return this._header.includes(key);
28-
}
26+
containsKey(key) {
27+
return this._header.includes(key);
28+
}
2929

30-
size() {
31-
return this._header.length;
32-
}
30+
size() {
31+
return this._header.length;
32+
}
3333
}
3434

3535
export default Record;

src/redisGraph.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,48 @@ import ResultSet from "./ResultSet";
66
* RedisGraph client
77
*/
88
class RedisGraph {
9-
/**
10-
* Creates a client to a specific graph running on the specific host/post
11-
* See: node_redis for more options on createClient
12-
*
13-
* @param graphId the graph id
14-
* @param host Redis host or node_redis client
15-
* @param port Redis port
16-
* @param options node_redis options
17-
*/
18-
constructor(graphId, host, port, options) {
19-
this._graphId = graphId;
20-
let client =
21-
host instanceof redis.RedisClient
22-
? host
23-
: redis.createClient.apply(redis, [].slice.call(arguments, 1));
24-
this._sendCommand = util.promisify(client.send_command).bind(client);
25-
}
9+
/**
10+
* Creates a client to a specific graph running on the specific host/post
11+
* See: node_redis for more options on createClient
12+
*
13+
* @param graphId the graph id
14+
* @param host Redis host or node_redis client
15+
* @param port Redis port
16+
* @param options node_redis options
17+
*/
18+
constructor(graphId, host, port, options) {
19+
this._graphId = graphId;
20+
let client =
21+
host instanceof redis.RedisClient
22+
? host
23+
: redis.createClient.apply(redis, [].slice.call(arguments, 1));
24+
this._sendCommand = util.promisify(client.send_command).bind(client);
25+
}
2626

27-
/**
28-
* Execute a Cypher query
29-
*
30-
* @param query Cypher query
31-
* @return a result set
32-
*/
33-
query(query) {
34-
return this._sendCommand("graph.QUERY", [this._graphId, query]).then(
35-
res => {
36-
return new ResultSet(res);
37-
}
38-
);
39-
}
27+
/**
28+
* Execute a Cypher query
29+
*
30+
* @param query Cypher query
31+
* @return a result set
32+
*/
33+
query(query) {
34+
return this._sendCommand("graph.QUERY", [this._graphId, query]).then(
35+
res => {
36+
return new ResultSet(res);
37+
}
38+
);
39+
}
4040

41-
/**
42-
* Deletes the entire graph
43-
*
44-
* @return delete running time statistics
45-
*/
46-
deleteGraph() {
47-
return this._sendCommand("graph.DELETE", [this._graphId]).then(res => {
48-
return new ResultSet(res);
49-
});
50-
}
41+
/**
42+
* Deletes the entire graph
43+
*
44+
* @return delete running time statistics
45+
*/
46+
deleteGraph() {
47+
return this._sendCommand("graph.DELETE", [this._graphId]).then(res => {
48+
return new ResultSet(res);
49+
});
50+
}
5151
}
5252

5353
export default RedisGraph;

src/resultSet.js

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,42 @@ import Record from "./record";
55
* Hold a query result
66
*/
77
class ResultSet {
8-
constructor(resp) {
9-
this._position = 0;
10-
this._statistics = new Statistics(resp[1]);
11-
12-
let result = resp[0];
13-
14-
// Empty result set
15-
if (result === null || result.length === 0) {
16-
this._header = [];
17-
this._totalResults = 0;
18-
this._results = [];
19-
} else {
20-
this._header = result[0];
21-
this._totalResults = result.length - 1;
22-
this._results = new Array(this._totalResults);
23-
for (let i = 0; i < this._totalResults; ++i) {
24-
this._results[i] = new Record(this._header, result[i + 1]);
25-
}
26-
}
27-
}
28-
29-
getHeader() {
30-
return this._header;
31-
}
32-
33-
hasNext() {
34-
return this._position < this._totalResults;
35-
}
36-
37-
next() {
38-
return this._results[this._position++];
39-
}
40-
41-
getStatistics() {
42-
return this._statistics;
43-
}
8+
constructor(resp) {
9+
this._position = 0;
10+
this._statistics = new Statistics(resp[1]);
11+
12+
let result = resp[0];
13+
14+
// Empty result set
15+
if (result === null || result.length === 0) {
16+
this._header = [];
17+
this._totalResults = 0;
18+
this._results = [];
19+
} else {
20+
this._header = result[0];
21+
this._totalResults = result.length - 1;
22+
this._results = new Array(this._totalResults);
23+
for (let i = 0; i < this._totalResults; ++i) {
24+
this._results[i] = new Record(this._header, result[i + 1]);
25+
}
26+
}
27+
}
28+
29+
getHeader() {
30+
return this._header;
31+
}
32+
33+
hasNext() {
34+
return this._position < this._totalResults;
35+
}
36+
37+
next() {
38+
return this._results[this._position++];
39+
}
40+
41+
getStatistics() {
42+
return this._statistics;
43+
}
4444
}
4545

4646
export default ResultSet;

0 commit comments

Comments
 (0)