UNPKG

locutus

Version:

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

16 lines (15 loc) 809 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatstring = formatstring; const _calendar_ts_1 = require("../_helpers/_calendar.js"); 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 (0, _calendar_ts_1.formatString)(items, (0, _calendar_ts_1.toCalendarInteger)(cols, 'formatstring'), (0, _calendar_ts_1.toCalendarInteger)(spacing, 'formatstring')); }