-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Allow sync usage #584
Comments
I see some efforts have been made here #580, though, they didn't succeed. |
I'm afraid the only option use it sync is to wait for execution in command prompt. |
|
@ArmorDarks It's maybe a bit ugly but you can make a hack using deasync import SVGO from "svgo";
import deasync from "deasync";
function svgoOptimizeSync(svgo, content) {
let res;
svgo.optimize(content, result => res = result);
deasync.loopWhile(() => !res);
return res;
} PS: I've made a gist of it |
@yvele Thanks for additional solution. Unfortunately, it implies additional dependency or a hack, which we'd like to avoid. I think the real issue here is that SVGO does not use promises and instead relies on callback. Otherwise it would be very easy to do with Though, I don't want to insult developers. SVGO is great library and it saved us like a ton of kbs and time. |
SVGO has appeared when there was no promises. |
Yeap, I know. |
Because we are now doing the file transforms in the Pug filter, we have to be syncronous. All the filter-specific transforms have been moved to the transform() method. Note that .json and .yml files are NOT in the transform() method, they stay as Pug variables. See deasync for a possible (ugly) workaround for svgo: svg/svgo#584 (comment)
|
Because we are now doing the file transforms in the Pug filter, we have to be syncronous. All the filter-specific transforms have been moved to the transform() method. Note that .json and .yml files are NOT in the transform() method, they stay as Pug variables. See deasync for a possible (ugly) workaround for svgo: svg/svgo#584 (comment)
It would be great if async usage would be optional
So far forceful usage of async in SVGO causes a lot of pain in libraries, which can't handle natively async calls. For example, some templates language doesn't play well with it at all.
Any chances for optional sync implementation?
The text was updated successfully, but these errors were encountered: