UNPKG

@tidyjs/tidy

Version:

Tidy up your data with JavaScript, inspired by dplyr and the tidyverse

27 lines (25 loc) 1.08 kB
function debug(label, options) { const _debug = (items, context) => { var _a; let prefix = "[tidy.debug"; if ((_a = context == null ? void 0 : context.groupKeys) == null ? void 0 : _a.length) { const groupKeys = context.groupKeys; const groupKeyStrings = groupKeys.map((keyPair) => keyPair.join(": ")).join(", "); if (groupKeyStrings.length) { prefix += "|" + groupKeyStrings; } } options = options != null ? options : {}; const {limit = 10, output = "table"} = options; const dashString = "--------------------------------------------------------------------------------"; let numDashes = dashString.length; const prefixedLabel = prefix + "]" + (label == null ? "" : " " + label); numDashes = Math.max(0, numDashes - (prefixedLabel.length + 2)); console.log(`${prefixedLabel} ${dashString.substring(0, numDashes)}`); console[output](limit == null || limit >= items.length ? items : items.slice(0, limit)); return items; }; return _debug; } export { debug }; //# sourceMappingURL=debug.js.map