Skip to content

normalizeToArray

Converts a value to an array if it is not already an array. If the input is an array, it returns the input as-is.

Usage

ts
import { normalizeToArray } from 'rattail'

normalizeToArray(5) // return [5]
normalizeToArray([1, 2, 3]) // return [1, 2, 3]

Arguments

ArgTypeDefaults
valueany

Return

Type
Array