object module is the primary bridge between Lion programs and the JavaScript host environment. It covers everything from simple property access to calling methods deep in an object graph, constructing class instances, and serializing data to JSON strings.
Property access
object/get
Returns the value of a single key on an object.
1
object/get-path
Traverses a dot-separated path through nested objects and arrays. Numeric path segments index into arrays.
42
Array indexing with a numeric segment:
"Turing"
Dot-path segments are split on
.. A numeric segment (digits only) indexes into an array at that position. A non-numeric segment accesses an object key. Accessing a missing key or an out-of-bounds index produces a typed error.Inspection
object/keys
Returns an array of the string keys of an object.
["a", "b"]
object/values
Returns an array of the values of an object.
[1, 2]
Serialization
object/json-stringify
Serializes an object to a JSON string. Accepts the same arguments as JSON.stringify: the object, an optional replacer, and an optional indentation width.
"{\n \"a\": 1\n}"
Construction
object/new
Calls a JavaScript constructor with the provided arguments and returns the new instance. The first argument must resolve to a function (class) in the environment.
object/new is mainly useful when Lion programs interact with host objects injected through a custom environment, such as UI framework classes or Node.js built-ins.Method access and invocation
object/get-method
Retrieves a method from an object and returns it bound to that object. Useful when you want to pass the method to a higher-order function.
object/call-method
Retrieves and immediately calls a method on an object, passing any additional arguments.
object/get-method-path
Like object/get-method, but traverses a dot-separated path before retrieving the method. The method is bound to the object found at the parent path.