UNPKG

moltres-utils

Version:
46 lines (38 loc) 1.64 kB
"use strict"; require("core-js/modules/es6.object.define-property"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _curry = _interopRequireDefault(require("../common/curry")); var _defn = _interopRequireDefault(require("../common/defn")); var _isFunction = _interopRequireDefault(require("../lang/isFunction")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Returns a string made by inserting the `separator` between each element and * concatenating all the elements into a single string. * * Supports Promises. If a Promise is received for either parameter than the entire method will upgrade to async and return a Promise. * * @function * @since v0.0.6 * @category data * @param {number|string|Promise<number|string>} separator The string used to separate the elements. * @param {Array|Promise<Array>} list The list of elements to join into a string. * @returns {string|Promise<string>} The string made by concatenating `list` with `separator`. * @example * * const spacer = join(' ') * spacer(['a', 2, 3.4]) //=> 'a 2 3.4' * join('|', [1, 2, 3]) //=> '1|2|3' * await join(Promise.resolve('|'), Promise.resolve([1, 2, 3])) //=> '1|2|3' */ var join = (0, _curry.default)((0, _defn.default)('join', function (seperator, list) { if (list != null && (0, _isFunction.default)(list.join)) { return list.join(seperator); } throw new TypeError("".concat(toString(list), " does not have a method named 'join'")); })); var _default = join; exports.default = _default; //# sourceMappingURL=join.js.map