Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async/await version #26

Open
vsimko opened this issue Sep 25, 2017 · 1 comment
Open

async/await version #26

vsimko opened this issue Sep 25, 2017 · 1 comment

Comments

@vsimko
Copy link
Contributor

vsimko commented Sep 25, 2017

Here is a async/await wrapper for the getExifFromLocalFileUsingNodeFs function.
What do you think, is it worth including to the README.md file ?

/**
 * @param path
 * @returns {Promise}
 */
async function extractExif(path) {
  return new Promise((resolve, reject) => {
    exiftool.getExifFromLocalFileUsingNodeFs(fs, path, (error, exif) => {
      error
        ? reject(error)
        : resolve(Object.assign({file: path}, exif))
    });
  })
}

.. then inside your async code, you can write:

// inside an async function...
const exif = await extractExif('/path/to/my/file1.jpg')
@mattburns
Copy link
Owner

Promises are new to me (I don't write much JS) but looks good. Feel free to add to README.md. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants