[Pas2js] [feature request + ideas] Implementing TStream based classes (TBytesStream, TFileStream, TStringStream and so on)

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Nov 10 07:41:09 CET 2018


On Sat, 10 Nov 2018 00:50:12 -0300
silvioprog <silvioprog at gmail.com> wrote:

>[...]
> Both File/Blob objects allows to create a URL object, that can
> assigned to a control (even hidden) and finally downloaded to the
> user downloads without his consent. It could be useful for our
> SaveToFile() methods. Please take a look at this project
> (implementing the W3C's saveAs() FileSaver interface):
> https://eligrey.com/demos/FileSaver.js . It allows you to specify the
> name of the file to be saved (the example uses an image, text and a
> rich text) .

Yes, but that is async and interactive, so has little todo with
SaveToFile. Correct?

 
>[...]
> Does that mean streams require at least ECMAScript6?
> >  
> 
> After checking how pas2js already handles the TBytes (array of byte)
> type, we don't need ArrayBuffer anymore. :-)

Huh? Of course you still need TJSArrayBuffer for reading binary
data and storing large data.


> The growing buffer logic
> and the error handling can be easily done in purely Pascal code, as
> you suggested. Advantages by using TBytes: it will be compatible in
> any ES (1st edition or higher). :-)
> 
> What about the nodejs platform? As you stated below it provides an
> API,
> > that gives more complete and more direct access.
> >  
> 
> The nodejs' fs is awesome. We should use it for that platform. 

I used it for the nodepas2js. Not so sure about if it is awesome. It
seems to start a lot of threads and I missed fast functions for reading
directories. I'm spoiled by fpc.


>[...]
> What transpiler parameter?
> >  
> 
> ... switched using something like this:
> 
> {$IFDEF BROWSER} // when the -Tbrowser parameter is passed
> ... browser logic ...
> {$ENDIF}
> ...
> {$IFDEF NODEJS} // when the -Tnodejs parameter is passed
> ... nodejs logic ...
> {$ENDIF}
> 
> I'm not sure if these macros are available when passing the
> '-T<script-style>' parameter,

Do you mean the -P parameters like -PECMAScript6?
Works the same:
{$IFDEF ECMAScript6} or {$IF ECMAScript>5}


>[...]

Mattias


More information about the Pas2js mailing list