new: protocol

Create instances of JavaScript classes

The new: protocol lets you construct an instance of a JavaScript class. It expects a path to a class constructor and returns a function which will instantiate that class via the JavaScript new keyword.

For example, you can instantiate the JavaScript Date class with:

$ ori "new:Date('2025-12-31')"
2025-12-31T00:00:00.000Z

You can also call new: like a function and pass a class as an argument. This allows you to, for example, fully specify the name of a class with a namespace. Since Date is in the js: namespace, the command below has the same effect as the one above:

$ ori "new(js:Date)('2025-12-31')"
2025-12-31T00:00:00.000Z