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

Add an .svg public method to the API #171

Merged
merged 2 commits into from
Jun 3, 2019
Merged

Add an .svg public method to the API #171

merged 2 commits into from
Jun 3, 2019

Conversation

lleaff
Copy link
Contributor

@lleaff lleaff commented Aug 4, 2018

This method does the exact same as .image when used to output an SVG, but it outputs the raw Buffer from Graphviz instead of writing it to a file and returning the file path.

For a project where I use madge to generate many images, bypassing the file system improves performance and simplifies the logic a lot.

Obviously this is just a proposition, the method name could be changed and I could add better tests.

@pahen
Copy link
Owner

pahen commented Aug 6, 2018

Thanks for the contribution! It's a good suggestion but it would be nice with a more generic solution which is not restricted to generating a SVG. What about adding a .buffer method instead?

const madge = require('madge');

madge('path/to/app.js', {type: 'svg'})
  .then((res) => res.buffer())
  .then((output) => {
    console.log(output.toString());
});

@Tymek Tymek mentioned this pull request Dec 23, 2018
8 tasks
@pahen pahen merged commit cf3d3d1 into pahen:master Jun 3, 2019
nmeylan pushed a commit to nmeylan/madge that referenced this pull request Jan 7, 2020
Add an .svg public method to the API
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

Successfully merging this pull request may close these issues.

None yet

2 participants