Initial working version

This commit is contained in:
Andrew Sliwinski 2018-12-17 18:11:08 -05:00
parent 4f28eeef52
commit 590b71a0aa
22 changed files with 1414 additions and 0 deletions

25
lib/index.js Normal file
View file

@ -0,0 +1,25 @@
const parser = require('scratch-parser');
const sb2 = require('./sb2');
const sb3 = require('./sb3');
module.exports = function (buffer, callback) {
parser(buffer, false, (err, project) => {
if (err) return callback(err);
// Flatten array
project = project[0];
// Push project object to the appropriate analysis handler
switch (project.projectVersion) {
case 2:
sb2(project, callback);
break;
case 3:
sb3(project, callback);
break;
default:
throw new Error('Unsupported project version');
}
});
};