Files
yaak-mountain-loop/src-tauri/plugins/importer-yaak/src/index.js
2023-11-10 11:39:17 -08:00

21 lines
445 B
JavaScript

export function pluginHookImport(contents) {
let parsed;
try {
parsed = JSON.parse(contents);
} catch (err) {
return undefined;
}
if (!isJSObject(parsed)) {
return undefined;
}
if (parsed.yaakSchema !== 1) return undefined;
return { resources: parsed.resources }; // Should already be in the correct format
}
export function isJSObject(obj) {
return Object.prototype.toString.call(obj) === '[object Object]';
}