Browse Source

Update flatbuffers.js

Lutz Roeder 4 years ago
parent
commit
4bf9b42737
1 changed files with 8 additions and 2 deletions
  1. 8 2
      source/flatbuffers.js

+ 8 - 2
source/flatbuffers.js

@@ -265,8 +265,14 @@ flatbuffers.BinaryReader = class {
         throw new flatbuffers.Error('Not implemented.');
     }
 
-    structArray(/* position, offset, size, decode */) {
-        throw new flatbuffers.Error('Not implemented.');
+    structArray(position, offset, size, decode) {
+        offset = this._offset(position, offset);
+        const length = offset ? this._length(position + offset) : 0;
+        const list = new Array(length);
+        for (let i = 0; i < length; i++) {
+            list[i] = decode(this, this._indirect(this._vector(position + offset) + i * 4));
+        }
+        return list;
     }
 
     tableArray(position, offset, decode) {