Function buildObj

  • Builds an object in multiple steps, where each step can access the accumulated properties of the previous steps.

    Each passed-in argument represents a step. Each step provides the new properties to merge into the accumulated object. A step may be a plain object, or a function returning an object which takes in the currently-accumulated object as its only argument.

    Parameters

    • Rest ...steps: any[]

    Returns {}

      Example

      const person = build_obj({
      first_name: "John",
      last_name: "Doe",
      age: 27,
      }, (o) => ({
      full_name: `${o.first_name} ${o.last_name}`,
      is_adult: o.age >= 18,
      }), (o) => ({
      is_child: !o.is_adult,
      }));

    Generated using TypeDoc