|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
-
- var _lodash = _interopRequireDefault(require("lodash"));
-
- var _getBorderCharacters = _interopRequireDefault(require("./getBorderCharacters"));
-
- var _validateConfig = _interopRequireDefault(require("./validateConfig"));
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
-
- const makeBorder = (border = {}) => {
- return Object.assign({}, (0, _getBorderCharacters.default)('honeywell'), border);
- };
-
-
-
- const makeColumns = (columnCount, columns = {}, columnDefault = {}) => {
- _lodash.default.times(columnCount, index => {
- if (_lodash.default.isUndefined(columns[index])) {
- columns[index] = {};
- }
-
- columns[index] = Object.assign({
- alignment: 'left',
- paddingLeft: 1,
- paddingRight: 1,
- truncate: Infinity,
- wrapWord: false
- }, columnDefault, columns[index]);
- });
-
- return columns;
- };
-
-
-
-
-
-
-
- const makeStreamConfig = (userConfig = {}) => {
- (0, _validateConfig.default)('streamConfig.json', userConfig);
-
- const config = _lodash.default.cloneDeep(userConfig);
-
- if (!config.columnDefault || !config.columnDefault.width) {
- throw new Error('Must provide config.columnDefault.width when creating a stream.');
- }
-
- if (!config.columnCount) {
- throw new Error('Must provide config.columnCount.');
- }
-
- config.border = makeBorder(config.border);
- config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);
- return config;
- };
-
- var _default = makeStreamConfig;
- exports.default = _default;
-
|