summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorunintellisense <weldonconsulting@gmail.com>2019-01-14 09:21:42 -0800
committerWouter van Oortmerssen <aardappel@gmail.com>2019-01-14 09:21:42 -0800
commit46208b1e918cfa7e92abc109264e2bc3b3627711 (patch)
tree7df6ef58db3e4dda856edadb024af1157734b55d /js
parentb99332efd732e6faf60bb7ce1ce5902ed65d5ba3 (diff)
downloadflatbuffers-46208b1e918cfa7e92abc109264e2bc3b3627711.tar.gz
flatbuffers-46208b1e918cfa7e92abc109264e2bc3b3627711.tar.bz2
flatbuffers-46208b1e918cfa7e92abc109264e2bc3b3627711.zip
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
Diffstat (limited to 'js')
-rw-r--r--js/flatbuffers.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/flatbuffers.js b/js/flatbuffers.js
index 580020a4..0c970bd8 100644
--- a/js/flatbuffers.js
+++ b/js/flatbuffers.js
@@ -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`.
*