Merge branch 'tp32' into tp33

Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/1bd35dcc
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/1bd35dcc
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/1bd35dcc

Branch: refs/heads/TINKERPOP-1967
Commit: 1bd35dcc5383373ed07fb72fdba7da274f982497
Parents: 421839d db46c0f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Jul 25 09:46:11 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Jul 25 09:46:11 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                |  1 +
 .../lib/structure/io/graph-serializer.js          |  2 ++
 .../lib/structure/io/type-serializers.js          | 18 ++++++++++++++++++
 .../gremlin-javascript/test/unit/graphson-test.js |  8 ++++++++
 4 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1bd35dcc/CHANGELOG.asciidoc
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1bd35dcc/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/graph-serializer.js
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1bd35dcc/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
----------------------------------------------------------------------
diff --cc 
gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
index 3b2b9e6,4bc2935..5044ee7
--- 
a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
+++ 
b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/structure/io/type-serializers.js
@@@ -283,78 -293,9 +300,79 @@@ class TSerializer extends TypeSerialize
    }
  }
  
 +class ArraySerializer extends TypeSerializer {
 +  constructor(typeKey) {
 +    super();
 +    this.typeKey = typeKey;
 +  }
 +
 +  deserialize(obj) {
 +    const value = obj[valueKey];
 +    if (!Array.isArray(value)) {
 +      throw new Error('Expected Array, obtained: ' + value);
 +    }
 +    return value.map(x => this.reader.read(x));
 +  }
 +
 +  /** @param {Array} item */
 +  serialize(item) {
 +    return {
 +      [typeKey]: this.typeKey,
 +      [valueKey]: item.map(x => this.writer.adaptObject(x))
 +    };
 +  }
 +
 +  canBeUsedFor(value) {
 +    return Array.isArray(value);
 +  }
 +}
 +
 +class MapSerializer extends TypeSerializer {
 +  deserialize(obj) {
 +    const value = obj[valueKey];
 +    if (!Array.isArray(value)) {
 +      throw new Error('Expected Array, obtained: ' + value);
 +    }
 +    const result = new Map();
 +    for (let i = 0; i < value.length; i += 2) {
 +      result.set(this.reader.read(value[i]), this.reader.read(value[i + 1]));
 +    }
 +    return result;
 +  }
 +
 +  /** @param {Map} map */
 +  serialize(map) {
 +    const arr = [];
 +    map.forEach((v, k) => {
 +      arr.push(this.writer.adaptObject(k));
 +      arr.push(this.writer.adaptObject(v));
 +    });
 +    return {
 +      [typeKey]: 'g:Map',
 +      [valueKey]: arr
 +    };
 +  }
 +
 +  canBeUsedFor(value) {
 +    return value instanceof Map;
 +  }
 +}
 +
 +class ListSerializer extends ArraySerializer {
 +  constructor() {
 +    super('g:List');
 +  }
 +}
 +
 +class SetSerializer extends ArraySerializer {
 +  constructor() {
 +    super('g:Set');
 +  }
 +}
 +
  module.exports = {
    BytecodeSerializer,
+   DateSerializer,
    EdgeSerializer,
    EnumSerializer,
    LambdaSerializer,

Reply via email to