main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
623 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import { when, of } from 'ramda';
|
---|
| 2 | import isNotArray from './isNotArray';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Returns a singleton array containing the value provided.
|
---|
| 6 | * If value is already an array, it is returned as is.
|
---|
| 7 | *
|
---|
| 8 | * @func ensureArray
|
---|
| 9 | * @memberOf RA
|
---|
| 10 | * @since {@link https://char0n.github.io/ramda-adjunct/2.6.0|v2.6.0}
|
---|
| 11 | * @category List
|
---|
| 12 | * @sig a | [a] -> [a]
|
---|
| 13 | * @param {*|Array} val the value ensure as Array
|
---|
| 14 | * @return {Array}
|
---|
| 15 | * @see {@link http://ramdajs.com/docs/#of|R.of}
|
---|
| 16 | * @example
|
---|
| 17 | *
|
---|
| 18 | * RA.ensureArray(42); //=> [42]
|
---|
| 19 | * RA.ensureArray([42]); //=> [42]
|
---|
| 20 | */
|
---|
| 21 | var ensureArray = when(isNotArray, of(Array));
|
---|
| 22 | export default ensureArray; |
---|
Note:
See
TracBrowser
for help on using the repository browser.