in remote/data-info-manager.js [72:127]
realizeDataInfo(dataInfo) {
if (dataInfo.id) {
const existingValue = this.get(dataInfo.id);
if (!utils.isNullOrUndefined(existingValue)) {
return existingValue;
}
if (dataInfo.type === "object") {
// @ts-ignore
return this.realizeObjectDataInfo(dataInfo);
} else if (dataInfo.type === "function") {
return this.realizeFunctionDataInfo(dataInfo);
} else {
throw new Error(`Unsupported DataType for IDataInfo with an id: ${dataInfo.type}.`);
}
}
if (dataInfo.type === "node.buffer") {
return Buffer.from(dataInfo.value.data, "base64");
}
if (!dataInfo.value) {
return dataInfo.value;
}
return JSON.parse(dataInfo.value,
(key, value) => {
if (key === "" || typeof value !== "string") {
return value;
}
const separatorIndex = value.indexOf(":");
if (separatorIndex <= 0) {
return value;
}
/** @type {Donuts.Remote.DataType} */
// @ts-ignore
const dataType = value.substring(0, separatorIndex);
switch (dataType) {
case "string":
return value.substring(separatorIndex + 1);
case "node.buffer":
return Buffer.from(value.substring(separatorIndex + 1), "base64");
default:
return value;
}
});
}