UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

13 lines (12 loc) 658 B
import { formatString, toCalendarInteger } from "../_helpers/_calendar.js"; export function formatstring(items, cols = 20, spacing = 6) { // discuss at: https://locutus.io/python/calendar/formatstring/ // parity verified: Python 3.12 // original by: Kevin van Zonneveld (https://kvz.io) // example 1: formatstring(['a', 'bb', 'ccc'], 2, 0) // returns 1: 'a bbccc' if (arguments.length === 0) { throw new TypeError("formatstring() missing 1 required positional argument: 'cols'"); } return formatString(items, toCalendarInteger(cols, 'formatstring'), toCalendarInteger(spacing, 'formatstring')); }