@webilix/nestjs-helper
Version:
Helper library for NestJS
29 lines • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExportStringMethod = void 0;
const helper_library_1 = require("@webilix/helper-library");
const formats_1 = require("../../formats");
const getValue = (value, column) => {
var _a, _b;
if (!helper_library_1.Helper.IS.string(value))
return '';
if (column.format && !formats_1.FormatsEnum[column.format].validate(value))
return '';
return column.format && formats_1.FormatsEnum[column.format].export ? ((_b = (_a = formats_1.FormatsEnum[column.format]).export) === null || _b === void 0 ? void 0 : _b.call(_a, value)) || '' : value;
};
exports.ExportStringMethod = {
xlsx: {
format: '@',
english: (column) => !!column.english || !!(column.format && column.format !== 'PLATE'),
value: (value, column) => getValue(value, column),
},
docx: {
english: (column) => !!column.english || !!(column.format && column.format !== 'PLATE'),
value: (value, column) => getValue(value, column),
},
validate: (value, column) => helper_library_1.Helper.IS.string(value) && (!column.format || formats_1.FormatsEnum[column.format].validate(value)),
width: (value, column) => Math.max(...getValue(value, column)
.split('\n')
.map((v) => v.length)),
};
//# sourceMappingURL=string.js.map