Skip to content

Commit

Permalink
Fix crash on NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
thebestnom committed May 23, 2023
1 parent 134f8d6 commit 5b175cb
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
4 changes: 3 additions & 1 deletion __tests__/neovis.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,8 @@ describe('Neovis', () => {
test6: new Neo4j.types.LocalTime(1, 2, 3, 4),
test7: new Neo4j.types.Point(1, 2, 3, 4),
test8: new Neo4j.types.Point(1, 2, 3),
test9: new Neo4j.types.Time(1, 2, 3, 4, 5)
test9: new Neo4j.types.Time(1, 2, 3, 4, 5),
test10: NaN
}),
new Neo4j.types.Relationship(new Neo4j.types.Integer(0, 0), new Neo4j.types.Integer(0, 0), new Neo4j.types.Integer(1, 0), 'TEST', {}),
new Neo4j.types.Path(
Expand Down Expand Up @@ -647,6 +648,7 @@ describe('Neovis', () => {
expect(neovis.nodes.get(1)?.raw.properties.test7).toBeInstanceOf(Neo4j.types.Point);
expect(neovis.nodes.get(1)?.raw.properties.test8).toBeInstanceOf(Neo4j.types.Point);
expect(neovis.nodes.get(1)?.raw.properties.test9).toBeInstanceOf(Neo4j.types.Time);
expect(neovis.nodes.get(1)?.raw.properties.test10).toBeNaN();
});
});
});
1 change: 0 additions & 1 deletion dist/main.map60ef0e3e7494c6dd3a6d

This file was deleted.

1 change: 1 addition & 0 deletions dist/main.map877f9266ed26e5e4321b

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/neovis-without-dependencies.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/neovis.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions examples/simple-dataFunction-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
viz = new NeoVis.default(config);
viz.render();
console.log(viz);
viz.registerOnEvent('error', ({error}) => console.error(error))

}
</script>
Expand Down
6 changes: 4 additions & 2 deletions src/neovis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ function isFakeInteger(property: FakeIdentity | unknown): property is FakeIdenti
}

function propertyToNormal(value: unknown): unknown {
if (Array.isArray(value)) {
if (value === null) {
return NaN;
} else if (Array.isArray(value)) {
return value.map(propertyToNormal);
} else if(typeof value === 'object' && Object.keys(value).length in FakeTypeToType) {
} else if(typeof value === 'object' && value !== null && Object.keys(value).length in FakeTypeToType) {
for(const fakeType of FakeTypeToType[Object.keys(value).length]) {
let isCorrectType = true;
const rets: unknown[] = [];
Expand Down

0 comments on commit 5b175cb

Please sign in to comment.