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(tree)
Add next/previous fields to the tree’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
Dev.changes(old, new)
Return a tree of changes
Tree.clear(tree)
Remove all values from the tree
Tree.concat(…objs)
Concatenate text and/or trees of text
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.deepValues(tree)
The in-order leaf values of the tree
Tree.defineds(tree)
Only the defined values of the tree
Origami.document(text, [data])
Create a document object with the text and data
Tree.entries(tree)
The tree’s [key, value] pairs
Protocol.explore
Treat a website with JSON keys as a tree
Origami.extension
Helpers for working with file extensions
Protocol.files
File system folders and files
Tree.filter(source, options)
Filter the source tree
Tree.first(tree)
The first value in the tree
Tree.forEach(tree, fn)
Apply fn to each (value, key)
Tree.from(object, options)
Create a tree from an object
Tree.fromFn(fn, [keys])
A tree defined by a value function
Tree.globKeys(patterns)
A tree whose keys can include glob wildcard patterns
Tree.group(tree, fn)
A new tree with values grouped by the function
Tree.has(tree, key)
True if key exists in tree
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.isAsyncMutableTree(object)
True if object is an async mutable tree
Tree.isAsyncTree(object)
True if object is an async tree
Tree.isTraversable(object)
True if object is traversable
Tree.isTreelike(object)
True if object can be coerced to a tree
Tree.json(obj)
Render the object in JSON format
Origami.jsonKeys(tree)
Add .keys.json files to a tree
Origami.jsonParse(text)
Parse text as JSON
Tree.keys(tree)
The keys of the tree
Tree.length(tree)
The tree’s size (number of keys)
Dev.log(a, message)
Log message to the console and return a
Tree.map(tree, options)
Create a new tree by mapping keys and/or values
Tree.mapReduce(tree, valueFn, reduceFn)
Map values 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
Tree.merge(…trees)
Return a new tree merging the given trees
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(tree, [n])
Group the tree’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
Tree.remove(tree, key)
Remove the value for the key from tree
Origami.repeat(n, obj)
An array of n copies of the object
Tree.reverse(tree)
Reverse the order of the tree’s keys
Tree.root(tree)
The root node of the given tree
Origami.rss(feed)
Transforms a JSON Feed tree to RSS XML
Dev.serve(tree, port)
Start a web server for the tree
Tree.setDeep(target, source)
Applies the source tree to the target
Origami.shell(text)
Run the text as a shell command, return the output
Tree.shuffle(tree)
Shuffle the keys of the tree
Origami.sitemap(tree)
Generate a sitemap for the tree
Origami.slash
Helpers for working with trailing slashes
Origami.slug(text)
A version of the text suitable for use in URLs
Tree.sort(tree, options)
A new tree 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.take(tree, n)
The first n values in the tree
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(tree)
The tree’s values
Dev.version()
Return the version number of the Origami language
Dev.watch(tree, fn)
Reevaluate fn when tree changes
Origami.yaml(obj)
Render the object in YAML format
Origami.yamlParse(text)
Parse text as YAML