Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is the documentation on methods available? #19

Closed
mplungjan opened this issue Jun 15, 2016 · 10 comments
Closed

Where is the documentation on methods available? #19

mplungjan opened this issue Jun 15, 2016 · 10 comments

Comments

@mplungjan
Copy link

mplungjan commented Jun 15, 2016

Seems there are some thing missing like setTimeout? Is it delay() ?

@Tatsh
Copy link

Tatsh commented Jun 15, 2016

All global names (osascript -l JavaScript <<< 'Object.getOwnPropertyNames(this)' 2>&1 | tr ',' $'\n' | sort -u | pbcopy):

 $
 Application
 Array
 ArrayBuffer
 Automation
 Boolean
 DataView
 Date
 Error
 EvalError
 Float32Array
 Float64Array
 Function
 Infinity
 Int16Array
 Int32Array
 Int8Array
 JSON
 Library
 Map
 Math
 Number
 ObjC
 Object
 ObjectSpecifier
 Path
 Progress
 RangeError
 Ref
 ReferenceError
 RegExp
 Set
 String
 Symbol
 SyntaxError
 TypeError
 URIError
 Uint16Array
 Uint32Array
 Uint8Array
 Uint8ClampedArray
 WeakMap
 WeakSet
 __private__
 console
 decodeURI
 decodeURIComponent
 delay
 encodeURI
 encodeURIComponent
 escape
 eval
 isFinite
 isNaN
 parseFloat
 parseInt
 undefined
 unescape
 NaN

@mplungjan
Copy link
Author

Great (well not great since there seems to be stuff missing from ECMAScript)
Thanks

@Tatsh
Copy link

Tatsh commented Jun 16, 2016

setTimeout and others are part of the HTML5 standard, where they live on the window DOM object, which is not part of ECMAScript.

The equivalent is not delay because delay is synchronous.

Like any other non-web environment, you need the system equivalent. Those are things like select() and kqueue() in C. How you get those in and call them properly is a bit of trial and error, but I would like to see a shim of setTimeout()/setInterval() via C calls if you end up making one.

@umireon
Copy link

umireon commented Nov 30, 2016

@Tatsh
FYI, I ended up with NSTimer based implementation for shimming setTimeout, etc.
https://gist.github.com/umireon/d1d449be666053b005e48db48aad6c46

@Tatsh
Copy link

Tatsh commented Nov 30, 2016

Very neat. If that's up to the standards of the Wiki code, you can add that in for those who want to use it.

@Tatsh
Copy link

Tatsh commented Nov 30, 2016

There are still many things missing to make this compatible with (web) JavaScript without DOM stuff. Just a few things:

atob
btoa
crypto
File
FileList
FileReader

@JMichaelTX
Copy link

FYI, I ended up with NSTimer based implementation for shimming setTimeout, etc.
https://gist.github.com/umireon/d1d449be666053b005e48db48aad6c46

@umireon , thanks for sharing this.
For those of us not well-versed in ObjC, can you please give us a JXA example of how this is used, should be used?
How does it compare with the AppleScript delay()?

Thanks.

@umireon
Copy link

umireon commented Jun 29, 2017

@JMichaelTX

how this is used, should be used?

My answer on SO would help.
https://stackoverflow.com/questions/37834749/settimout-with-javascript-for-automation/41087510#41087510

How does it compare with the AppleScript delay()?

delay() is blocking and mine is non-blocking.
IMO, delay() suffices in usual situations.

@BrokenFreelancer
Copy link

@umireon Nice! just a couple of days ago before seeing this issue, I added a stub for a new section in the ObjC Bridge page of the wiki about asynchronous functions calls through $.system() and $.NSTimer and added a link to that SO question.

@Tatsh
Copy link

Tatsh commented Aug 3, 2020

Closing due to age.

@Tatsh Tatsh closed this as completed Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants