Enable using multiple macho parsers

This commit is contained in:
Sam Carlton 2022-07-18 16:56:30 -05:00
parent 6bebb57e58
commit dda7623fda
2 changed files with 42 additions and 2 deletions

View file

@ -0,0 +1,40 @@
export class MachoManiac {
constructor ({ machoFileInstance, FileApi }) {
this.machoFileInstance = machoFileInstance
this.FileApi = FileApi
}
async run () {
// import parseMacho from '~/helpers/macho/index.js'
const { default: parseMacho } = await import( '~/helpers/macho/index.js' )
return await parseMacho( this.machoFileInstance, this.FileApi )
}
}
export async function extraMachoMeta ({ machoFileInstance, FileApi = null }) {
const parsers = [
MachoManiac
]
// Run through each parser
for ( const Parser of parsers ) {
try {
// Run the parser
const parserInstance = new Parser({
machoFileInstance,
FileApi
})
const meta = await parserInstance.run()
return meta
} catch ( err ) {
// console.log( 'err', err )
}
}
return null
}