silvie
Version:
Typescript Back-end Framework
25 lines (23 loc) • 675 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/* eslint-disable no-underscore-dangle */
function nestedMapper(source, callback, destination = {}) {
Object.keys(source).forEach(key => {
if (key !== '__import_depth') {
if (source[key].__import_depth !== undefined) {
destination[key] = {};
nestedMapper(source[key], callback, destination[key]);
} else {
destination[key] = callback(source[key], key);
}
}
});
return destination;
}
function mapImports(imports, callback) {
return nestedMapper(imports, callback);
}
var _default = exports.default = mapImports;