mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-18 20:18:56 +00:00
JS- support clear() method on builder (#5109)
* support clearing flatBuffer builder in js * remove unused member reset force_defaults dont actually need to clear data in bytebuffer
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
b99332efd7
commit
46208b1e91
@@ -226,6 +226,19 @@ flatbuffers.Builder = function(opt_initial_size) {
|
||||
this.force_defaults = false;
|
||||
};
|
||||
|
||||
flatbuffers.Builder.prototype.clear = function() {
|
||||
this.bb.clear();
|
||||
this.space = this.bb.capacity();
|
||||
this.minalign = 1;
|
||||
this.vtable = null;
|
||||
this.vtable_in_use = 0;
|
||||
this.isNested = false;
|
||||
this.object_start = 0;
|
||||
this.vtables = [];
|
||||
this.vector_num_elems = 0;
|
||||
this.force_defaults = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* In order to save space, fields that are set to their default value
|
||||
* don't get serialized into the buffer. Forcing defaults provides a
|
||||
@@ -816,6 +829,7 @@ flatbuffers.ByteBuffer = function(bytes) {
|
||||
* @private
|
||||
*/
|
||||
this.position_ = 0;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -828,6 +842,10 @@ flatbuffers.ByteBuffer.allocate = function(byte_size) {
|
||||
return new flatbuffers.ByteBuffer(new Uint8Array(byte_size));
|
||||
};
|
||||
|
||||
flatbuffers.ByteBuffer.prototype.clear = function() {
|
||||
this.position_ = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the underlying `Uint8Array`.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user