From c90503812ab85049c2dd6adfca0b7d81b3932671 Mon Sep 17 00:00:00 2001
From: mattias <nc-gaertnma@netcologne.de>
Date: Sun, 7 Jan 2024 13:48:46 +0100
Subject: [PATCH] fcl-js: fixed TBufferWriter on nodejs

---
 packages/fcl-js/src/jswriter.pp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/packages/fcl-js/src/jswriter.pp b/packages/fcl-js/src/jswriter.pp
index 66eb6fb9c4..24f5a43b13 100644
--- a/packages/fcl-js/src/jswriter.pp
+++ b/packages/fcl-js/src/jswriter.pp
@@ -384,9 +384,14 @@ end;
 procedure TBufferWriter.SetCapacity(AValue: Cardinal);
 begin
   if FCapacity=AValue then Exit;
+  {$ifdef pas2js}
+  // capacity not needed, FBuffer is an JS array
+  FCapacity:=AValue;
+  {$else}
   SetLength(FBuffer,AValue);
   if (FBufPos>Capacity) then
     FBufPos:=Capacity;
+  {$endif}
 end;
 
 function TBufferWriter.DoWrite(const S: TJSWriterString): integer;