[Pas2js] Promises stripper project

Michael Van Canneyt michael at freepascal.org
Fri Feb 2 20:14:35 CET 2018



On Fri, 2 Feb 2018, warleyalex via Pas2js wrote:

> While converting a Promises project to Pas2JS,
>
> a) hum, there's a minor typo in the Web.pas
>    //function getElementsyClassName(aNames : string) : TJSHTMLCollection;

I will check.

>
> b) Since Pas2JS does not support anonymous methods yet, it's so boring
> writing sub functions :( to do simple things, for instance:
>
>     setTimeout(function () {
>         console.log('1')
>         setTimeout(function () {
>             console.log('2')
>         }, 1000)
>     }, 1000)
>
> c) the TJSPromise (web.pas) is incomplete, I've created my wrapper around
> the Promises.

Where did you get the specs from ? 
I see a lot of things that are not in the official specs ?

I have the 'official' specs implemented in TJSPromise, not yet committed, I
am in the process of creating some examples. I'll have a look at yours and
add it too, if that is OK ?

> //-------------------------------------------------
>
> I don't know if is worthy to strip down the Web.pas and JS.pas units and
> organize in separate units, such
> ECMA.Promises.pas
> ECMA.JSON.pas
> ECMA.Date.pas
> ECMA.Math.pas

Why ? It only makes your uses clause longer and make it difficult to
remember what units you must use. Since they are only import
declarations, they add nothing to the size of the outputted Javascript.

Michael.


More information about the Pas2js mailing list