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

Make JavaScript String wrapper methods null/undefined-safe #484

Open
d215steinberg opened this issue Jan 28, 2016 · 0 comments
Open

Make JavaScript String wrapper methods null/undefined-safe #484

d215steinberg opened this issue Jan 28, 2016 · 0 comments

Comments

@d215steinberg
Copy link

A great benefit of Java String Utils libraries such as Apache Commons StringUtils is their null-safety. You should be able to provide null/undefined-safety to your JavaScript String wrapper functions, e.g.

expect(_s(null).toUpperCase().value()).to.be.a('null');
expect(_s(undefined).toUpperCase().value()).to.be.an('undefined');

I successfully spiked out this functionality with a couple of tweaks to index.js.

You may also want to add explicit null/undefined-safe wrapper functions, so that one can tap into this safety without chaining, e.g.

expect(_s.toUpperCase(null)).to.be.a('null');
expect(_s.toUpperCase(undefined)).to.be.an('undefined');
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

1 participant