@enonic/js-utils
    Preparing search index...

    Function forceArray

    • Wraps a non-array value in an array, or returns the array as-is.

      Type Parameters

      • T

      Parameters

      • data: T | T[]

        The value or array to process.

      Returns T[]

      The original array, or the value wrapped in a new array.

      Use noNilsArray instead for safe null/undefined handling.

      Known issues with nil values:

      • Wraps standalone null/undefined as [null]/[undefined] instead of returning [].
      • Does not filter out null/undefined elements within existing arrays.
      • Provides a false sense of type safety, often leading to runtime errors downstream.