Use null as empty result
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9d7687f9 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9d7687f9 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9d7687f9 Branch: refs/heads/TINKERPOP-1489 Commit: 9d7687f9a4ca3d5c498a72a8e824c25d17bffe60 Parents: 0ec3993 Author: Jorge Bay Gondra <jorgebaygon...@gmail.com> Authored: Thu Nov 3 14:34:28 2016 +0100 Committer: Jorge Bay Gondra <jorgebaygon...@gmail.com> Committed: Wed Jan 17 16:16:18 2018 +0100 ---------------------------------------------------------------------- .../tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy | 2 +- .../src/main/javascript/gremlin-javascript/process/traversal.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9d7687f9/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy ---------------------------------------------------------------------- diff --git a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy index 46f65a4..d5899f0 100644 --- a/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy +++ b/gremlin-javascript/src/main/groovy/org/apache/tinkerpop/gremlin/javascript/TraversalSourceGenerator.groovy @@ -87,7 +87,7 @@ class TraversalSourceGenerator { /** @param {Function} callback */ Traversal.prototype.one = function (callback) { this.list(function (err, result) { - callback(err, result ? result[0] : null); + callback(err, result && result.length > 0 ? result[0] : null); }); }; http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9d7687f9/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js ---------------------------------------------------------------------- diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js index a7a9bb7..f585161 100644 --- a/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js +++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/process/traversal.js @@ -50,7 +50,7 @@ /** @param {Function} callback */ Traversal.prototype.one = function (callback) { this.list(function (err, result) { - callback(err, result ? result[0] : null); + callback(err, result && result.length > 0 ? result[0] : null); }); };