UNPKG

@ryusei/light

Version:

<div align="center"> <a href="https://light.ryuseijs.com"> <img alt="RyuseiLight" src="https://light.ryuseijs.com/images/svg/logo.svg" width="70"> </a>

14 lines (11 loc) 361 B
import { isArray } from '../../type/type'; /** * Push the provided value to an array only if the value is not an array. * * @param value - A value to push. * * @return An array containing the value, or the value itself if it is already an array. */ export function toArray<T>( value: T | T[] ): T[] { return isArray<T>( value ) ? value : [ value ]; }