jiaola / marc4js

A Node.js API for handling MARC
Apache License 2.0
39 stars 7 forks source link

Async/Await #8

Open librarywebchic opened 5 years ago

librarywebchic commented 5 years ago

Can this library be used via Async/Await?

ulikoehler commented 5 years ago

I'm using it using async/await by wrapping it in a Promise like this

return new Promise((resolve, reject) => {
    marc4js.parse(data, {
            format: 'marcxml'
        }, function (err, records) {
        if(err) {return reject(err);}
        return resolve(records);
    });
});