@raona/sp
Version:
Raona utilities to work with Sharepoint using pnp/sp
36 lines (35 loc) • 1.33 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
// import { TypedHash, RelativeFile } from "../../entities";
var getFileExtensionNameByUrl_1 = require("./getFileExtensionNameByUrl");
function assignIconToFile(iconsUrls) {
var files = [];
for (var _i = 1; _i < arguments.length; _i++) {
files[_i - 1] = arguments[_i];
}
var assignIconLogic = function (file) {
if (!file)
return null;
var extension = getFileExtensionNameByUrl_1.getFileExtensionNameByUrl(file);
return __assign({}, file, { iconUrl: iconsUrls[extension] || iconsUrls.default });
};
// TODO: this should work without the casting (something maybe about TS version)
if (Array.isArray(files[0])) {
return files[0].map(assignIconLogic);
}
else {
return assignIconLogic(files[0]);
}
}
exports.assignIconToFile = assignIconToFile;