Skip to content

Commit abd1b25

Browse files
author
Robert Kesterson
committed
Converted to typescript
1 parent e8bf88d commit abd1b25

22 files changed

+853
-793
lines changed

Diff for: .circleci/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ jobs:
4545

4646
# run tests!
4747
- run: sudo npm install -g istanbul codecov
48+
- run: npx tsc
4849
- run: istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec --exit
4950
- early_return_for_forked_pull_requests
5051
- run: codecov -t ${CODECOV_TOKEN}

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ yarn.lock
77
examples/node_modules
88
coverage/
99
.DS_Store
10+
dist/

Diff for: examples/redisGraphExample.js renamed to examples/redisGraphExample.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const RedisGraph = require("redisgraph.js").Graph;
1+
2+
import {Graph as RedisGraph} from 'redisgraph.js';
23

34
let graph = new RedisGraph("social");
45

@@ -18,7 +19,7 @@ try {
1819
let record = res.next();
1920
console.log(record.get("a.name"));
2021
}
21-
console.log(res.getStatistics().queryExecutionTime());
22+
console.log(res.getStatistics()?.queryExecutionTime());
2223

2324
// Match with parameters.
2425
let param = { age: 30 };

Diff for: examples/tsconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "UMD",
5+
"lib": ["es5"],
6+
"strict": true,
7+
"allowJs": true,
8+
"inlineSourceMap": true,
9+
"inlineSources": true,
10+
"outDir": "./dist",
11+
"moduleResolution": "node",
12+
"downlevelIteration": true,
13+
"rootDir": "./",
14+
"baseUrl": "./",
15+
"declaration": true,
16+
17+
},
18+
"include": ["./"],
19+
"exclude": ["dist"]
20+
}

Diff for: index.js

-13
This file was deleted.

Diff for: package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
"redis": "^3.0.2"
1414
},
1515
"devDependencies": {
16-
"mocha": "^7.0.1"
16+
"@types/deep-equal": "^1.0.1",
17+
"@types/redis": "^2.8.28",
18+
"mocha": "^7.0.1",
19+
"typescript": "^4.1.3"
1720
},
1821
"scripts": {
19-
"test": "mocha --exit"
22+
"test": "npx tsc && mocha --exit"
2023
},
21-
"main": "index.js"
24+
"main": "dist/index.js"
2225
}

Diff for: src/edge.js renamed to src/edge.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
"use strict";
1+
import {Node} from "./node";
22
/**
33
* An edge connecting two nodes.
44
*/
5-
class Edge {
5+
export class Edge {
6+
7+
private id?: number;
68
/**
79
* Builds an Edge object.
810
* @constructor
@@ -11,7 +13,7 @@ class Edge {
1113
* @param {Node} destNode - Destination node of the edge.
1214
* @param {Map} properties - Properties map of the edge.
1315
*/
14-
constructor(srcNode, relation, destNode, properties) {
16+
constructor(private srcNode: Node, private relation: string, private destNode: Node, private properties: Map<string, any>) {
1517
this.id = undefined; //edge's id - set by RedisGraph
1618
this.relation = relation; //edge's relationship type
1719
this.srcNode = srcNode; //edge's source node
@@ -23,7 +25,7 @@ class Edge {
2325
* Sets the edge ID.
2426
* @param {int} id
2527
*/
26-
setId(id) {
28+
setId(id:number) {
2729
this.id = id;
2830
}
2931

@@ -35,4 +37,3 @@ class Edge {
3537
}
3638
}
3739

38-
module.exports = Edge;

Diff for: src/graph.js

-260
This file was deleted.

0 commit comments

Comments
 (0)