UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

19 lines (17 loc) 509 B
import { of, unless } from 'ramda'; import isArray from './isArray'; /** * Wraps input in an Array if it's not an Array already. * * @func * @category List * * @example * * R_.ensureArray("A string yo.") // ["A string yo."] * R_.ensureArray(["an array item yo"]) // ["an array item yo"] * R_.ensureArray([{ consoleLog: "yo" }]) // [{ consoleLog: "yo" }] * @sig a -> Array */ var ensureArray = /*#__PURE__*/unless(isArray, /*#__PURE__*/of(Array)); export default ensureArray;