tatsh / jxa-lib Goto Github PK
View Code? Open in Web Editor NEWLibrary to simplify use of JXA with ES6 and TypeScript.
Home Page: https://tatsh.github.io/jxa-lib/
Library to simplify use of JXA with ES6 and TypeScript.
Home Page: https://tatsh.github.io/jxa-lib/
npm install jxa-lib
inside a project does not result in a usable, importable package from within node_modules
.
Update the following to work with this library when npm install
works:
Does your webpack configuration for jxa-lib
allow keeping the run
function global for passing in CLI arguments?
This library for example has a webpack config file + custom webpack plugin that allows for this: https://github.com/pahund/patricks-little-jxa-helpers
The entire module gets set to main
and then the global run function gets defined as such: function run(args) { this.main(args); }
.
whose
whose
filter on ArrayApple has a whose
filter for arrays. It is basically filter
with an object predicate.
// documentation only gives string and num; we are guessing here
type JXAPrimitive = string | number | boolean | void
interface JXAWhosePredicateExpression {
// equals, beginsWith...
}
type JXALogical= '_and' | '_or' | '_not'
interface JXAWhosePredicate {
[logi: JXALogical]: JXAWhosePredicate[],
[key: string]?: string | number | boolean | JXAWhosePredicateExpression
}
interface JXAArray<T> extends Array<T>, JXAReadonlyArray<T> {}
interface JXAReadonlyArray<T> extends ReadonlyArray<T> {
/**
* Returns the elements of an array that meet the condition specified in a filter predicate.
*/
whose(predicate: JXAWhosePredicate, thisArg?: any): JXAArray<T>;
}
It is possible that they went forward and changed the entire Array.prototype
. In that case just remove the extends BS.
Currently bindFunction
and registerSubclass
do not have type signatures. Judging from the doc it should resemble:
type ObjCType = string | RefType
type ObjCSignature = [ObjCType, ObjCType []]
interface ObjCClass {
name: string
properties: {
[key: string]: string
}
methods: (...x?: any[]) => any | {
type: ObjCSignature
implementation: (...x?: any[]) => any
}
}
namespace ObjC {
export function bindFunction(name: string, args: ObjCSignature);
export function registerSubclass(class: ObjCClass);
}
Since Ref
operates on bytes (uint8_t
), it might be a good idea to define a concept of bytes somewhere so it becomes more clear. We will also need utility functions for reading/writing longer integer types and even floats.
Unfortunately the typing part is not something we can do perfectly right now; see microsoft/TypeScript#15480.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.