* Push a document to the document sequence. Will serialize the document * as well and return the current serialized length of all documents. * @param document - The document to add. * @param buffer - The serialized document in raw BSON. * @returns The new total document sequence length.
(document: Document, buffer: Uint8Array)
| 475 | * @returns The new total document sequence length. |
| 476 | */ |
| 477 | push(document: Document, buffer: Uint8Array): number { |
| 478 | this.serializedDocumentsLength += buffer.length; |
| 479 | // Push the document. |
| 480 | this.documents.push(document); |
| 481 | // Push the document raw bson. |
| 482 | this.chunks.push(buffer); |
| 483 | // Write the new length. |
| 484 | if (this.header) { |
| 485 | NumberUtils.setInt32LE( |
| 486 | this.header, |
| 487 | 1, |
| 488 | 4 + this.field.length + 1 + this.serializedDocumentsLength |
| 489 | ); |
| 490 | } |
| 491 | return this.serializedDocumentsLength + this.header.length; |
| 492 | } |
| 493 | |
| 494 | /** |
| 495 | * Get the fully serialized bytes for the document sequence section. |
no outgoing calls
no test coverage detected