scratch-analysis/lib/index.js

24 lines
611 B
JavaScript
Raw Normal View History

2018-12-17 18:11:08 -05:00
const parser = require('scratch-parser');
const sb2 = require('./sb2');
const sb3 = require('./sb3');
module.exports = function (buffer, callback) {
2018-12-18 12:26:14 -05:00
parser(buffer, false, (err, result) => {
2018-12-17 18:11:08 -05:00
if (err) return callback(err);
2018-12-18 12:26:14 -05:00
// Extract only the project object from the parser results
const project = result[0];
2018-12-17 18:11:08 -05:00
// Push project object to the appropriate analysis handler
switch (project.projectVersion) {
case 2:
sb2(project, callback);
break;
case 3:
sb3(project, callback);
break;
}
});
};