mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #32160 from unintellisense/master
[flatbuffers] support clear method on flatbuffer builder and bytebuffer
This commit is contained in:
@@ -86,6 +86,27 @@ class Test {
|
||||
builder.writeInt16(a);
|
||||
return builder.offset();
|
||||
}
|
||||
|
||||
static testClear(builder: flatbuffers.Builder, a: number, b: number) {
|
||||
const offsets: number[] = [];
|
||||
const iterations = 100;
|
||||
for (let i = 0; i < iterations; i++) {
|
||||
const offset = Test.createTest(builder, a, b);
|
||||
offsets.push(offset);
|
||||
builder.clear();
|
||||
}
|
||||
|
||||
let lastOffsetValue = offsets[0];
|
||||
let sameValue = true;
|
||||
for (let i = 1; i < offsets.length; i++) {
|
||||
if (lastOffsetValue !== offsets[i]) {
|
||||
sameValue = false;
|
||||
return sameValue;
|
||||
}
|
||||
lastOffsetValue = offsets[i];
|
||||
}
|
||||
return sameValue;
|
||||
}
|
||||
}
|
||||
|
||||
class TestSimpleTableWithEnum {
|
||||
|
||||
Vendored
+8
@@ -42,6 +42,12 @@ declare global {
|
||||
class Builder {
|
||||
constructor(initial_size?: number);
|
||||
|
||||
/**
|
||||
* Reset all the state in this FlatBufferBuilder
|
||||
* so it can be reused to construct another buffer.
|
||||
*/
|
||||
clear(): void;
|
||||
|
||||
/**
|
||||
* In order to save space, fields that are set to their default value
|
||||
* don't get serialized into the buffer. Forcing defaults provides a
|
||||
@@ -211,6 +217,8 @@ declare global {
|
||||
|
||||
static allocate(byte_size: number): ByteBuffer;
|
||||
|
||||
clear(): void;
|
||||
|
||||
bytes(): Uint8Array;
|
||||
|
||||
position(): number;
|
||||
|
||||
Reference in New Issue
Block a user