@difizen/mana-app
Version:
20 lines • 761 B
JavaScript
import { URI } from '@difizen/mana-common';
export var FileSystemUtils;
(function (_FileSystemUtils) {
function generateUniqueResourceURI(parentUri, parent, name) {
var ext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
var children = !parent.children ? [] : parent.children.map(function (child) {
return child.resource;
});
var index = 1;
var base = name + ext;
while (children.some(function (child) {
return child.path.base === base;
})) {
index += 1;
base = "".concat(name, "_").concat(index).concat(ext);
}
return URI.resolve(parentUri, base);
}
_FileSystemUtils.generateUniqueResourceURI = generateUniqueResourceURI;
})(FileSystemUtils || (FileSystemUtils = {}));