import { when, of } from 'ramda';
import isNotArray from './isNotArray';
/**
* Returns a singleton array containing the value provided.
* If value is already an array, it is returned as is.
*
* @func ensureArray
* @memberOf RA
* @since {@link https://char0n.github.io/ramda-adjunct/2.6.0|v2.6.0}
* @category List
* @sig a | [a] -> [a]
* @param {*|Array} val the value ensure as Array
* @return {Array}
* @see {@link http://ramdajs.com/docs/#of|R.of}
* @example
*
* RA.ensureArray(42); //=> [42]
* RA.ensureArray([42]); //=> [42]
*/
const ensureArray = when(isNotArray, of(Array));
export default ensureArray;