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:
834 bytes
|
Line | |
---|
1 | import { ifElse, values, curryN } from 'ramda';
|
---|
2 |
|
---|
3 | import isIterable from './isIterable';
|
---|
4 | import isFunction from './isFunction';
|
---|
5 | import ponyfill from './internal/ponyfills/Array.from';
|
---|
6 |
|
---|
7 | export const fromPonyfill = curryN(1, ponyfill);
|
---|
8 |
|
---|
9 | const fromArray = isFunction(Array.from) ? curryN(1, Array.from) : fromPonyfill;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Converts value to an array.
|
---|
13 | *
|
---|
14 | * @func toArray
|
---|
15 | * @memberOf RA
|
---|
16 | * @since {@link https://char0n.github.io/ramda-adjunct/2.22.0|v2.22.0}
|
---|
17 | * @category List
|
---|
18 | * @sig * -> [a]
|
---|
19 | * @param {*} val The value to convert
|
---|
20 | * @return {Array}
|
---|
21 | * @example
|
---|
22 | *
|
---|
23 | * RA.toArray([1, 2]); //=> [1, 2]
|
---|
24 | * RA.toArray({'foo': 1, 'bar': 2}); //=> [1, 2]
|
---|
25 | * RA.toArray('abc'); //=> ['a', 'b', 'c']
|
---|
26 | * RA.toArray(1); //=> []
|
---|
27 | * RA.toArray(null); //=> []
|
---|
28 | */
|
---|
29 |
|
---|
30 | const toArray = ifElse(isIterable, fromArray, values);
|
---|
31 |
|
---|
32 | export default toArray;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.