The js
built-in provides access to a number of JavaScript classes and utility functions that you may find useful to call directly in Origami expressions:
- Array
- Boolean
- Date
- decodeURI
- decodeURIComponent
- encodeURI
- encodeURIComponent
- Error
- false
- fetch (see below)
- Infinity
- Intl
- isFinite
- isNaN
- JSON
- Map
- Math
- NaN
- null
- Number
- Object
- parseFloat
- parseInt
- RegExp
- Set
- String
- Symbol
- true
- undefined
For example, if you want to explicitly cast a value to a string in an Origami expression, you can write:
text = String(value)
See also node
, which provides access to a number of Node.js modules.
fetch(url, options)
The js:fetch()
function wraps the basic fetch API so that it returns an ArrayBuffer. This can be fed directly to Origami functions that accept files.
See also post
.
Instantiating JavaScript classes
To instantiate a class like Date
, use the new:
protocol.