@jiminp/tooltool
    Preparing search index...

    Function applyTransforms

    • Applies a sequence of synchronous transform functions to a value.

      Transform functions are applied sequentially in order. Each function can either:

      • Return a new transformed value (pure transformation)
      • Modify the value in-place and return undefined (impure transformation)

      Type Parameters

      • T

        The type of the value being transformed.

      Parameters

      • obj: T

        The initial value to transform.

      • ...fns: NestedArray<TransformFunction<T>>

        Transform functions to apply, which can be arbitrarily nested in arrays for organizational purposes. Nested arrays are flattened during execution.

      Returns T

      The final transformed value after all transform functions have been applied.

      // Pure transformations (returning new values)
      const result = applyTransforms(
      { count: 1 },
      (obj) => ({ ...obj, count: obj.count + 1 }),
      (obj) => ({ ...obj, doubled: obj.count * 2 }),
      );
      // result: { count: 2, doubled: 4 }
      // Impure transformations (modifying in-place)
      const result = applyTransforms(
      { count: 1 },
      (obj) => { obj.count += 1; },
      (obj) => { obj.doubled = obj.count * 2; },
      );
      // result: { count: 2, doubled: 4 }