File "toArray.ts"

Full path: /home/fsibplc/public_html/sommilito-bank2/splide-4.1.3/src/js/utils/array/toArray/toArray.ts
File size: 353 B (353 B bytes)
MIME-type: text/x-java
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

import { isArray } from '../../type/type';


/**
 * Push the provided value to an array 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( value ) ? value : [ value ];
}