esamattis / esamattis/underscore.string
Enhance _.surround() with leftWrapper and rightWrapper instead of just wrapper
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 367
- PR merge metrics
- No merged PRs in 30d
Description
Currently `surround` allows only 1 wrapper parameter. Allowing an optional 2nd wrapper parameter would make it useful for enclosing a string with HTML tags or parentheses and brackets.
Here is the current surround implementation:
``` javascript
surround: function(str, wrapper) {
return [wrapper, str, wrapper].join('');
}
```
May I suggest we upgrade it to this:
``` javascript
surround: function(str, lWrapper, rWrapper) {
return [lWrapper, str, rWrapper || lWrapper].join('');
}
```
Just throwing this out there because I thought it can be useful. If there is no objection or obvious flaw with the suggested change, I will put in a PR by tomorrow.
Contributor guide
Assessment
This issue has not been assessed yet.