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:
628 bytes
|
Line | |
---|
1 | import { when, of } from 'ramda';
|
---|
2 |
|
---|
3 | import isNotArray from './isNotArray';
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * Returns a singleton array containing the value provided.
|
---|
7 | * If value is already an array, it is returned as is.
|
---|
8 | *
|
---|
9 | * @func ensureArray
|
---|
10 | * @memberOf RA
|
---|
11 | * @since {@link https://char0n.github.io/ramda-adjunct/2.6.0|v2.6.0}
|
---|
12 | * @category List
|
---|
13 | * @sig a | [a] -> [a]
|
---|
14 | * @param {*|Array} val the value ensure as Array
|
---|
15 | * @return {Array}
|
---|
16 | * @see {@link http://ramdajs.com/docs/#of|R.of}
|
---|
17 | * @example
|
---|
18 | *
|
---|
19 | * RA.ensureArray(42); //=> [42]
|
---|
20 | * RA.ensureArray([42]); //=> [42]
|
---|
21 | */
|
---|
22 | const ensureArray = when(isNotArray, of(Array));
|
---|
23 |
|
---|
24 | export default ensureArray;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.