replace()

Replace function fields.

Signature

replace(object: {*: Any}): FunctionDef

Description

The replace() method replaces the given object function field values with the given object values. The given fields must exist and be mutable.

Parameters

Parameter Type Required Description

object

Object

Yes

Replacement function fields.

Return value

Type Description

FunctionDef

Function with replaced fields.

Examples

Function.byName("double")!.replace({
  name: "triple",
  body: "x => x * 3"
})
{
  name: "triple",
  coll: Function,
  ts: Time("2023-11-09T10:34:06.640Z"),
  body: "x => x * 3"
}

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!