UNPKG

ts-cast

Version:
6 lines (5 loc) 367 B
export const joinNames = (names, conjunction) => (names.length === 0 ? '' : names.length === 1 ? names[0] : names.length === 2 ? `${names[0]} ${conjunction} ${names[1]}` : `${names.slice(0, -1).join(', ')} ${conjunction} ${names[names.length - 1]}`); export const withName = (obj, name) => Object.defineProperty(obj, 'name', { value: name });