@camunda8/sdk
Version:
[](https://www.npmjs.com/package/@camunda8/sdk)
25 lines • 772 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDtoInstance = void 0;
/**
* Create an instance of a DTO class with the provided data.
*
* This provides a type-safe method to create a DTO instance from a plain object.
*
* Node 22's experimental strip types does not play well with the previous "via the constructor" method.
*
* See: https://gist.github.com/jwulf/6e7b093b5b7b3e12c7b76f55b9e4be84
*
* @param dtoClass
* @param dtoData
* @returns
*/
function createDtoInstance(dtoClass, dtoData) {
const newDto = new dtoClass();
for (const key in dtoData) {
newDto[key] = dtoData[key];
}
return newDto;
}
exports.createDtoInstance = createDtoInstance;
//# sourceMappingURL=CreateDtoInstance.js.map