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/84a11a1b Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/84a11a1b Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/84a11a1b Branch: refs/heads/tp32 Commit: 84a11a1b10ddbb06558663a062dc1ae3a1062c68 Parents: 44e6535 Author: Jorge Bay Gondra <jorgebaygon...@gmail.com> Authored: Thu Nov 3 14:34:28 2016 +0100 Committer: Jorge Bay Gondra <jorgebaygon...@gmail.com> Committed: Fri Jan 19 09:30:14 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/84a11a1b/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/84a11a1b/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); }); };