@libpdf/core 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -49,7 +49,10 @@ declare class ByteWriter {
49
49
  writeUtf8(str: string): void;
50
50
  /**
51
51
  * Get final bytes.
52
- * Returns a copy (slice) so the internal buffer can be garbage collected.
52
+ *
53
+ * If the internal buffer is exactly the right size, returns it directly
54
+ * (zero-copy). Otherwise returns a trimmed copy so the oversized buffer
55
+ * can be garbage collected.
53
56
  *
54
57
  * Note: ByteWriter is single-use. Do not write after calling toBytes().
55
58
  */
@@ -1633,6 +1636,11 @@ declare class Operator {
1633
1636
  * Create an operator with operands.
1634
1637
  */
1635
1638
  static of(op: Op, ...operands: Operand[]): Operator;
1639
+ /**
1640
+ * Write operator bytes directly into a shared ByteWriter.
1641
+ * Avoids intermediate allocations compared to toBytes().
1642
+ */
1643
+ writeTo(writer: ByteWriter): void;
1636
1644
  /**
1637
1645
  * Serialize to bytes for content stream output.
1638
1646
  * Format: "operand1 operand2 ... operator"
@@ -1644,7 +1652,9 @@ declare class Operator {
1644
1652
  */
1645
1653
  toString(): string;
1646
1654
  /**
1647
- * Get byte length when serialized (for pre-allocation).
1655
+ * Get byte length when serialized.
1656
+ *
1657
+ * Should be avoided in performance-critical paths, use {@link writeTo} instead.
1648
1658
  */
1649
1659
  byteLength(): number;
1650
1660
  }