Origami built-in functions

The Origami language includes a number of functions that you can call from Origami site definitions, Origami templates, and command-line interface commands.

Namespaces #

  • Dev — Develop and debug Origami projects
  • Origami — Create sites and other digital artifacts
  • Protocol — Retrieve resources via URL protocols
  • Tree — Work with trees of files and data

Functions and objects by name #

Tree.addNextPrevious(map)
Add next/previous fields to the map’s values
Tree.assign(target, source)
Apply key/values from source to target
Dev.audit(tree)
Identify broken internal links and references
Origami.basename(key)
Removes an extension from the key if present
Dev.breakpoint(a)
Break into the JavaScript debugger, then return a
Tree.cache(tree, [cache])
Caches values from the tree
Tree.calendar(options)
Return a tree structure for years/months/days
Dev.changes(old, new)
Return a tree of changes
Tree.clear(map)
Remove all values from the map
Origami.config
The current project’s configuration
Tree.constant(value)
Return a deep tree with a single constant value
Dev.copy(source, target)
Copy the source tree to the target
Dev.crawl(tree, base)
A tree of a site’s discoverable resources
Origami.csv(tree)
Render the tree as a CSV file
Dev.debug(tree)
Add debug features to the tree
Tree.deepMap(tree, options)
Map the keys and values of a deep tree
Tree.deepMerge(…trees)
Return a deeply-merged tree
Tree.deepReverse(tree)
Reverse order of keys at all levels of the tree
Tree.deepTake(tree, n)
The first n values from the deep tree
Tree.deepText(tree)
The text values of the deep tree
Tree.deepValues(tree)
The in-order leaf values of the tree
Tree.delete(map, key)
Delete the value for the key from map
Origami.document(text, [data])
Create a document object with the text and data
Tree.entries(map)
The map’s [key, value] pairs
Protocol.explore
Treat a website with JSON keys as a tree
Origami.extension
Helpers for working with file extensions
Origami.fetch(url, options)
Fetch a resource from a URL with support for extensions
Protocol.files
File system folders and files
Tree.filter(tree, options)
Filter a tree by a condition
Tree.first(map)
The first value in the map
Tree.forEach(map, fn)
Apply fn to each (value, key)
Tree.from(object, options)
Create a map from an object
Tree.globKeys(patterns)
A tree whose keys can include glob wildcard patterns
Tree.groupBy(map, fn)
A new map with values grouped by the function
Tree.has(map, key)
True if key exists in map
Dev.help(namespace|command)
Get help on builtin namespaces and commands
Protocol.http
Web resources via HTTP
Protocol.https
Web resources via HTTPS
Protocol.httpstree
Website tree via HTTPS
Protocol.httptree
Website tree via HTTP
Origami.image
Collection of functions for working with images
Tree.indent`…`
Tagged template literal for normalizing indentation
Origami.indexPage(tree)
A default index.html page for the tree
Origami.inline(text)
Inline Origami expressions found in the text
Tree.inners(tree)
The tree’s interior nodes
Tree.isMap(object)
True if object is a map
Tree.isMaplike(object)
True if object can be coerced to a tree
Tree.isReadOnlyMap(object)
True if object is a read-only map
Tree.isTraversable(object)
True if object is traversable
Tree.json(tree)
Render the tree in JSON format
Origami.jsonKeys(tree)
Add .keys.json files to a tree
Origami.jsonParse(text)
Parse text as JSON
Tree.keys(map)
The keys of the map
Dev.log(a, message)
Log message to the console and return a
Tree.map(source, options)
Create a new map by transforming keys and/or values
Tree.mapExtension(source, ext, options)
Create a new map by transforming extensions
Tree.mapReduce(tree, mapFn, reduceFn)
Map the keys and/or values in a tree and reduce them
Tree.mask(source, mask)
Return the source tree with only the keys in the mask
Tree.match(pattern, fn, [keys])
Matches simple patterns or regular expressions
Origami.mdHtml(markdown)
Render the markdown as HTML
Origami.mdOutline(markdown)
The outline structure of the markdown document
Tree.merge(…maps)
Return a new tree merging the given maps
Origami.naturalOrder
A comparison function for natural sort order
Protocol.node
Installed Node.js modules
Origami.once(fn)
Run the function only once, return the same result
Origami.ori(text)
Evaluate the text as an Origami expression
Protocol.package
Packages installed in node_modules
Tree.paginate(map, [n])
Group the map’s values into fixed-size sets
Tree.parent(tree)
The parent of the given tree node
Tree.paths(tree)
Slash-separated paths for the tree’s values
Tree.plain(tree)
Render the tree as a plain JavaScript object
Origami.post(url, data)
POST the given data to the URL
Origami.project
The root folder for the current Origami project
Origami.redirect(url, options)
Redirect to the given URL
Tree.regExpKeys(tree)
A tree whose keys are regular expression strings
Origami.repeat(n, obj)
An array of n copies of the object
Tree.reverse(map)
Reverse the order of the map’s keys
Tree.root(tree)
The root node of the given tree
Origami.rss(feed)
Transforms a JSON Feed tree to RSS XML
Tree.scope(tree)
A merged view of the tree and its ancestors
Dev.serve(tree, port)
Start a web server for the tree
Origami.shell(text)
Run the text as a shell command, return the output
Tree.shuffle(map)
Shuffle the keys of the map
Origami.sitemap(tree)
Generate a sitemap for the tree
Tree.size(map)
The map’s size (number of keys)
Origami.slash
Helpers for working with trailing slashes
Origami.slug(text)
A version of the text suitable for use in URLs
Tree.sort(map, options)
A new map with its keys sorted
Origami.static(tree)
Define common static files for the tree
Dev.stdin
Returns the content of the standard input stream
Origami.string(obj)
Coerce a buffer or document to a string
Dev.svg(tree, options)
Render a tree visually in SVG format
Tree.sync(tree)
Awaits all asynchronous values in the tree
Tree.take(map, n)
The first n values in the map
Tree.text`…`
Tagged template literal for rendering trees
Origami.toFunction(obj)
Coerce a tree or packed function definition to a function
Tree.traverse(tree, …keys)
Return the value at the path of keys
Tree.traverseOrThrow(tree, …keys)
Return the value at the path of keys or throw
Tree.traversePath(tree, path)
Traverse a slash-separated path
Origami.unpack(buffer)
Unpack the buffer into a usable form
Tree.values(map)
The map’s values
Dev.version()
Return the version number of the Origami language
Dev.watch(tree, fn)
Reevaluate fn when tree changes
Tree.withKeys(map, keys)
Use the given keys for the map
Origami.yaml(obj)
Render the object in YAML format
Origami.yamlParse(text)
Parse text as YAML