esamattis / esamattis/underscore.string

Enhance _.surround() with leftWrapper and rightWrapper instead of just wrapper

Open
#303 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.