source: node_modules/ramda-adjunct/es/toArray.js

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