Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jxa/run

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jxa/run

Run JXA code and get result.

  • 1.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
910
decreased by-52.65%
Maintainers
1
Weekly downloads
 
Created
Source

@jxa/run

Run JXA code and get result.

Install

Install with npm:

npm install @jxa/run

Requirement:

  • macOS 10.10 or later.

Usage

export declare function run<R>(jxaCodeFunction: (...args: any[]) => void, ...args: any[]): Promise<R>

Illustration of usage

const resultPromise = run(JSXFn, argumentsOfJSXFn);
  • JSXFn: This function is run as JXA.
    • :memo: This JSXFn is serialized(toString) and pass to JXA environment.
    • :waring: Warning: function cannot close over variables in a parent's scope.
    • Pass data as arguments explicitly instead.
  • argumentsOfJSXFn: An arguments of JSXFn

OK:

// OK
(async () => {
    // `name` is "nodejs"
    const result = await run(name => {
        return "Hello there, " + name + "!"
    }, "nodejs");
    assert.strictEqual(result, "Hello there, nodejs!");
})();

NG:

// NG
(async () => {
    const name = "nodejs"
    const result = await run(name => {
        return "Hello there, " + name + "!"; // can not access to `name` from JXA enviroment
    });
    assert.strictEqual(result, "Hello there, nodejs!");
})();

Example

(async () => {
    const result = await run(
        // run this function as JXA code
        () => {
            return Application("System Events")
                .currentUser()
                .name()
        }
    );
    assert.strictEqual(result, process.env.USER);
})();

Changelog

See Releases page.

Running tests

yarn test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

Keywords

FAQs

Package last updated on 05 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc