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

Question: how should this library handle undefined/null ? #20

Open
callmemagnus opened this issue Mar 9, 2017 · 2 comments
Open

Question: how should this library handle undefined/null ? #20

callmemagnus opened this issue Mar 9, 2017 · 2 comments

Comments

@callmemagnus
Copy link

This is more a question than an issue.

I was looking at the tests and wasn't able to answer the following question: how should word-wrap handle the nullor undefined case ?

I saw this in the index.js

if (str == null) {
    return str;
}

Don't you think this should return an empty string ?

@jonschlinkert
Copy link
Owner

Hmm, maybe. Typically I would throw a TypeError there, but I might have gone the "silent" route since this presumably is mostly used in command line apps. But I see you're point. Maybe we should do something like:

if (typeof str !== 'string') return '';

Thoughts?

@callmemagnus
Copy link
Author

Would definitely make sense. As a consumer of your library, I would expect it to always return a string.

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

No branches or pull requests

2 participants