Documentation

extend()

Extends this builder with custom methods, returning a new builder object.

extend<E extends object>(
extensions: E & ThisType<this & E>,
defer?: (result: this & E, base: this) => void,
): this & E;

Parameters

Return value

A new builder with both the original and extension methods.

Description

The returned object inherits all base builder methods via prototype chain. Extension methods can access base builder methods via this. Note that all extension methods must return this.

The optional defer callback runs exactly once, on the first call to build(). Use defer to finalize configuration that depends on closure variables set by custom methods.

Related