@eddaic/nestjs-decorators
Version:
Additional decorators intended for use with NestJS framework.
23 lines (22 loc) • 715 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.splitString = splitString;
exports.SplitString = SplitString;
const class_transformer_1 = require("class-transformer");
function splitString(value, options = {}) {
const { separator = ',', limit } = options;
if (typeof value === 'string') {
return value.split(separator, limit);
}
else {
return value;
}
}
/**
* Transforms a string by a delimiter which defaults to `,`. If the
* passed value is not a string, the value is returned unchanged.
* @returns
*/
function SplitString(options) {
return (0, class_transformer_1.Transform)(({ value }) => splitString(value, options), options);
}