parent
035727b2e0
commit
49fdc9cad4
3 changed files with 29 additions and 6 deletions
@ -0,0 +1,15 @@ |
|||||||
|
const join = ( |
||||||
|
elements: string[] | undefined, |
||||||
|
{ beforeReturn, elementWrapper = '', separator = '' }: JoinOptions, |
||||||
|
) => { |
||||||
|
const joinSeparator = `${elementWrapper}${separator}${elementWrapper}`; |
||||||
|
|
||||||
|
const toReturn = |
||||||
|
elements instanceof Array && elements.length > 0 |
||||||
|
? `${elementWrapper}${elements.join(joinSeparator)}${elementWrapper}` |
||||||
|
: undefined; |
||||||
|
|
||||||
|
return typeof beforeReturn === 'function' ? beforeReturn(toReturn) : toReturn; |
||||||
|
}; |
||||||
|
|
||||||
|
export default join; |
@ -0,0 +1,5 @@ |
|||||||
|
type JoinOptions = { |
||||||
|
beforeReturn?: (toReturn?: string) => string; |
||||||
|
elementWrapper?: string; |
||||||
|
separator?: string; |
||||||
|
}; |
Loading…
Reference in new issue