Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.repo.loadAs("blob", self.hash, function (err, buffer) {
if (err) throw err;
var imageMime = imagetypes[self.name.substr(self.name.lastIndexOf(".") + 1)];
if (imageMime) {
self.session = {
tiled: false,
url: URL.createObjectURL(new Blob([buffer], {type: imageMime}))
};
return onSession();
}
var mode = modelist.getModeForPath(self.name);
var code;
try {
code = binary.toUnicode(buffer);
}
catch (err) {
// Data is not unicode!
return;
}
self.session = ace.createEditSession(code, mode.mode);
whitespace.detectIndentation(self.session);
return onSession();
});
var imageMime = imagetypes[getExtension(name)];
if (imageMime) {
doc = docPaths[path] = {
tiled: false,
name: name,
url: URL.createObjectURL(new Blob([buffer], {type: imageMime}))
};
return loadDoc(doc);
}
var mode = parseInt(node.mode, 8) === modes.sym ?
"ace/mode/text" : modelist.getModeForPath(name).mode;
var code;
try {
code = binary.toUnicode(buffer);
}
catch (err) {
// Data is not unicode!
return;
}
doc = docPaths[path] = ace.createEditSession(code, mode);
doc.name = name;
whitespace.detectIndentation(doc);
loadDoc(doc);
});
defer(function () {
var realType = (type === "text" || type === "raw") ? "blob" : type;
if (!types[hash]) return callback();
if (realType !== types[hash]) return callback(new TypeError("Type mismatch"));
var result = objects[hash];
if (type === "text") result = binary.toUnicode(result);
else if (type !== "blob") result = encoders.normalizeAs(type, result);
callback(null, result, hash);
});
}