Skip to content

Instantly share code, notes, and snippets.

@masnagam
Created July 17, 2017 14:37
Show Gist options
  • Save masnagam/15a7e112566a9d825baca7d06dfe8d22 to your computer and use it in GitHub Desktop.
Save masnagam/15a7e112566a9d825baca7d06dfe8d22 to your computer and use it in GitHub Desktop.
'use strict';
const $ = require('jquery');
const html2canvas = require('html2canvas');
if (ARGS.length < 2) {
throw new Error('Selector is required');
}
const selector = ARGS[0];
const callback = ARGS[ARGS.length - 1];
Promise.all($(selector).map(function() {
return html2canvas(this)
.then((canvas) => canvas.toDataURL('image/png'));
}))
.then(callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment