Skip to content

0.3.1

Choose a tag to compare

@JanMiksovsky JanMiksovsky released this 22 Apr 15:51
· 1302 commits to main since this release

Support for more JavaScript syntax

This release adds support for JS-style property access via the . operator, or computed property access via [ ] square brackets.

Because Origami allows . in identifiers, you can't directly append a property name to an object reference. If you want to get the name property from a package.json file, you can't write package.json.name, because that looks like a long file name.

Instead, you can now write these:

  • (package.json).name — Use a . immediately after a closing parenthesis. The property name after the . has to be a legal JavaScript identifier.
  • pagkage.json .name — Put the .name reference after whitespace (JS allows this kind of whitespace before a property name too!)
  • package.json["name"] — Use the string "name" in brackets

You can also use the previously-supported forms:

  • package.json/name — Origami / path syntax
  • package.json("name") — Treat the object as a function

You can use the . property operator directly after a literal: "hello".toUpperCase() returns "HELLO".

Square brackets can also be used for array access. If team.yaml exports an array, you can use any of the following to get the first element of the array:

  • team.yaml[0]
  • team.yaml/0
  • team.yaml(0)

async-tree map enhancements

Some features of the Origami tree:map builtin have been promoted to the underlying async-tree library so that they can be called directly from JavaScript:

  • Support for the extension option
  • The ability to pass just a key option and have an appropriate inverseKey function generated for you