Svgo: documented Async .optimize method doesn't work

Created on 27 Jun 2017  路  4Comments  路  Source: svg/svgo

System stats:

OS: Win 7 Pro 64bit
Node: v7.7.1
SVGO: @0.7.2

Issue:

The Node module example listed at https://github.com/svg/svgo/blob/master/examples/test.js#L15 does not work as documented:

svgo
    .optimize(svgstr)
    .then(function(res) { ... })
    ;

The above snippet throws an error message: TypeError: callback is not a function.

This is because the .optimize method specifies an svgstr arg, and a callback arg, and does not return a Promise for .then to be used.

The working snippet should be:

svgo
    .optimize(content, function(res) {
        console.log(res);
    })
;

I suspect this is an oversight in the API design implementation, which I would expect is true as the promise based approach documented in the examples seems like a logical feature.

Most helpful comment

You should never release an unstable version to master.

All 4 comments

..likely because examples refers to a unreleased version. Also, #750.

Fair enough, though I would expect master to be the current stable release available on NPM. Unreleased features seem like a dev branch workflow to me.

I'm not the maintainer, but linking to a file in the "master" branch shouldn't encourage you to make the assumption that latest release is on par. With that said I would love to see more regular releases!

You should never release an unstable version to master.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wuz picture wuz  路  3Comments

madysondesigns picture madysondesigns  路  4Comments

tremby picture tremby  路  5Comments

elidupuis picture elidupuis  路  5Comments

gregberge picture gregberge  路  3Comments