[d24f17c] | 1 | var _curry2 =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./internal/_curry2.js");
|
---|
| 4 |
|
---|
| 5 | var _isArray =
|
---|
| 6 | /*#__PURE__*/
|
---|
| 7 | require("./internal/_isArray.js");
|
---|
| 8 |
|
---|
| 9 | var _isFunction =
|
---|
| 10 | /*#__PURE__*/
|
---|
| 11 | require("./internal/_isFunction.js");
|
---|
| 12 |
|
---|
| 13 | var _isString =
|
---|
| 14 | /*#__PURE__*/
|
---|
| 15 | require("./internal/_isString.js");
|
---|
| 16 |
|
---|
| 17 | var toString =
|
---|
| 18 | /*#__PURE__*/
|
---|
| 19 | require("./toString.js");
|
---|
| 20 | /**
|
---|
| 21 | * Returns the result of concatenating the given lists or strings.
|
---|
| 22 | *
|
---|
| 23 | * Note: `R.concat` expects both arguments to be of the same type,
|
---|
| 24 | * unlike the native `Array.prototype.concat` method. It will throw
|
---|
| 25 | * an error if you `concat` an Array with a non-Array value.
|
---|
| 26 | *
|
---|
| 27 | * Dispatches to the `concat` method of the first argument, if present.
|
---|
| 28 | * Can also concatenate two members of a [fantasy-land
|
---|
| 29 | * compatible semigroup](https://github.com/fantasyland/fantasy-land#semigroup).
|
---|
| 30 | *
|
---|
| 31 | * @func
|
---|
| 32 | * @memberOf R
|
---|
| 33 | * @since v0.1.0
|
---|
| 34 | * @category List
|
---|
| 35 | * @sig [a] -> [a] -> [a]
|
---|
| 36 | * @sig String -> String -> String
|
---|
| 37 | * @param {Array|String} firstList The first list
|
---|
| 38 | * @param {Array|String} secondList The second list
|
---|
| 39 | * @return {Array|String} A list consisting of the elements of `firstList` followed by the elements of
|
---|
| 40 | * `secondList`.
|
---|
| 41 | *
|
---|
| 42 | * @example
|
---|
| 43 | *
|
---|
| 44 | * R.concat('ABC', 'DEF'); // 'ABCDEF'
|
---|
| 45 | * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
|
---|
| 46 | * R.concat([], []); //=> []
|
---|
| 47 | */
|
---|
| 48 |
|
---|
| 49 |
|
---|
| 50 | var concat =
|
---|
| 51 | /*#__PURE__*/
|
---|
| 52 | _curry2(function concat(a, b) {
|
---|
| 53 | if (_isArray(a)) {
|
---|
| 54 | if (_isArray(b)) {
|
---|
| 55 | return a.concat(b);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | throw new TypeError(toString(b) + ' is not an array');
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | if (_isString(a)) {
|
---|
| 62 | if (_isString(b)) {
|
---|
| 63 | return a + b;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | throw new TypeError(toString(b) + ' is not a string');
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | if (a != null && _isFunction(a['fantasy-land/concat'])) {
|
---|
| 70 | return a['fantasy-land/concat'](b);
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | if (a != null && _isFunction(a.concat)) {
|
---|
| 74 | return a.concat(b);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | throw new TypeError(toString(a) + ' does not have a method named "concat" or "fantasy-land/concat"');
|
---|
| 78 | });
|
---|
| 79 |
|
---|
| 80 | module.exports = concat; |
---|