UNPKG

@multiversx/sdk-nestjs-http

Version:
44 lines 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApiUtils = void 0; class ApiUtils { static mergeObjects(obj1, obj2) { for (const key of Object.keys(obj2)) { if (key in obj1) { obj1[key] = obj2[key]; } } return obj1; } static cleanupApiValueRecursively(obj) { if (Array.isArray(obj)) { for (const item of obj) { if (item && typeof item === 'object') { ApiUtils.cleanupApiValueRecursively(item); } } } else if (obj && typeof obj === 'object') { for (const [key, value] of Object.entries(obj)) { if (typeof value === 'object' || Array.isArray(value)) { ApiUtils.cleanupApiValueRecursively(value); } if (value === null || value === '' || value === undefined) { delete obj[key]; } if (Array.isArray(value) && value.length === 0) { delete obj[key]; } } } return obj; } static replaceUri(uri, pattern, replacer) { if (uri.startsWith(pattern)) { return uri.replace(pattern, replacer); } return uri; } } exports.ApiUtils = ApiUtils; //# sourceMappingURL=api.utils.js.map