Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 687 Bytes

extend.md

File metadata and controls

43 lines (32 loc) · 687 Bytes

object.extend

Adds key/value(s) to the input object.

object.extend: Object -> Object
  on_error: fail|handler|null|skip|[...] = fail
  defn: Object<String -> Lens> = {}

This lens extends its input object with new key/value pairs as specified by defn. Each pair of the defn associates a new key to a lens that, when evaluated on the input object, brings the corresponding output value.

Example

Applying the following lens:

---
object.extend:
  defn:
    upcased:
    - core.dig: { defn: [firstname] }
    - str.upcase

to the following input:

---
firstname: 'Bernard'

will return:

---
firstname: 'Bernard'
upcased: 'BERNARD'