swc/crates/swc_bundler/tests/.cache/deno/b15f356f842ef09da42d267398da87b4f0019166.ts
2021-11-09 20:42:49 +09:00

61 lines
1.9 KiB
TypeScript

// Loaded from https://deno.land/x/ramda@v0.27.2/source/concat.js
import _curry2 from './internal/_curry2.js';
import _isArray from './internal/_isArray.js';
import _isFunction from './internal/_isFunction.js';
import _isString from './internal/_isString.js';
import toString from './toString.js';
/**
* Returns the result of concatenating the given lists or strings.
*
* Note: `R.concat` expects both arguments to be of the same type,
* unlike the native `Array.prototype.concat` method. It will throw
* an error if you `concat` an Array with a non-Array value.
*
* Dispatches to the `concat` method of the first argument, if present.
* Can also concatenate two members of a [fantasy-land
* compatible semigroup](https://github.com/fantasyland/fantasy-land#semigroup).
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig [a] -> [a] -> [a]
* @sig String -> String -> String
* @param {Array|String} firstList The first list
* @param {Array|String} secondList The second list
* @return {Array|String} A list consisting of the elements of `firstList` followed by the elements of
* `secondList`.
*
* @example
*
* R.concat('ABC', 'DEF'); // 'ABCDEF'
* R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
* R.concat([], []); //=> []
*/
var concat = _curry2(function concat(a, b) {
if (_isArray(a)) {
if (_isArray(b)) {
return a.concat(b);
}
throw new TypeError(toString(b) + ' is not an array');
}
if (_isString(a)) {
if (_isString(b)) {
return a + b;
}
throw new TypeError(toString(b) + ' is not a string');
}
if (a != null && _isFunction(a['fantasy-land/concat'])) {
return a['fantasy-land/concat'](b);
}
if (a != null && _isFunction(a.concat)) {
return a.concat(b);
}
throw new TypeError(toString(a) + ' does not have a method named "concat" or "fantasy-land/concat"');
});
export default concat;