UNPKG

@yookue/ts-lang-utils

Version:

Common lang utilities for typescript

14 lines 493 B
import { defaultString } from "./defaultString"; export function joinWith(texts, separator, filter) { if (!texts || Array.isArray(texts) && texts.length === 0) { return undefined; } if (Array.isArray(texts)) { if (!filter) { return texts.join(defaultString(separator)); } var array = texts.filter(filter); return !array || array.length === 0 ? undefined : array.join(defaultString(separator)); } return !filter ? texts : filter(texts) ? texts : undefined; }