Code Monkey home page Code Monkey logo

Comments (10)

Tatsh avatar Tatsh commented on May 24, 2024 1

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

from jxa-cookbook.

mplungjan avatar mplungjan commented on May 24, 2024

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

from jxa-cookbook.

Tatsh avatar Tatsh commented on May 24, 2024

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.

from jxa-cookbook.

umireon avatar umireon commented on May 24, 2024

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

from jxa-cookbook.

Tatsh avatar Tatsh commented on May 24, 2024

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.

from jxa-cookbook.

Tatsh avatar Tatsh commented on May 24, 2024

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

from jxa-cookbook.

JMichaelTX avatar JMichaelTX commented on May 24, 2024

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.

from jxa-cookbook.

umireon avatar umireon commented on May 24, 2024

@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.

from jxa-cookbook.

BrokenFreelancer avatar BrokenFreelancer commented on May 24, 2024

@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.

from jxa-cookbook.

Tatsh avatar Tatsh commented on May 24, 2024

Closing due to age.

from jxa-cookbook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.