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

AMD / CommonJS support #2

Open
juanbrujo opened this issue Oct 8, 2018 · 3 comments
Open

AMD / CommonJS support #2

juanbrujo opened this issue Oct 8, 2018 · 3 comments

Comments

@juanbrujo
Copy link

Is your feature request related to a problem? Please describe.
This could me imported as an module

Describe the solution you'd like
Add AMD / CommonJS / ES modules support

@victorqribeiro
Copy link
Owner

I think I would have to write a different .js for that, don't I?

a simple

if (typeof module !== 'undefined') {
  module.exports = imgToAscii;
}

wouldn't do it, cause Node doesn't don't support Image class, which is fundamental.

From what I've been reading, I would have to import Canvas and then process the image. Am I right?

@juanbrujo
Copy link
Author

You can return a base64 and then the user can use ir right to an or output it in or anything else.

@victorqribeiro
Copy link
Owner

Yeah, but to process the ASCII the algorithm uses a Image and a Canvas object (DOM Element) which node doesn't implement. So I would have to rewrite the code as a module, using fs.read to read the image and then process it, generating the ASCII code.

It could be done. I'll look in to it.

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

No branches or pull requests

2 participants