Skip to content

createTransformer

The createTransformer() function creates a recursive transformer from a method name. The returned function walks through nested objects and arrays, and calls this method on values that implement it.

Interactive example

Syntax

typescript
function createTransformer<
	GenericMethodName extends string
>(
	methodName: GenericMethodName
): TransformerFunction<GenericMethodName>

Parameters

  • methodName: Method name to call recursively on compatible values.

Return value

A transformer function that recursively projects nested values.

Two default transformers are provided by the library: toNative and toJSON.

See also

  • createEnum - Typed immutable enum factory
  • unwrap - Retrieves the inner wrapped value

Released under the MIT license.