@technobuddha/library
Version:
A large library of useful functions
16 lines (15 loc) • 591 B
JavaScript
import { empty } from '../constants';
import compact from 'lodash/compact';
import isString from 'lodash/isString';
import isArray from 'lodash/isArray';
import isFunction from 'lodash/isFunction';
/**
* Concatenates strings and/or arrays of strings
*
* @param args Concatenates a list of strings, string arrays, or functions that return a string or string array.
* @returns The concatenation of *args*.
*/
export function build(...args) {
return compact(args.flatMap(a => (isString(a) || isArray(a) ? a : isFunction(a) ? a() : Array.from(a)))).join(empty);
}
export default build;