UNPKG
better-substring
Version:
latest (1.0.3)
1.0.3
1.0.2
1.0.1
1.0.0
Improved substring method to avoid splitting mid word
better-substring
/
dist
/
index.js
3 lines
(2 loc)
•
279 B
JavaScript
View Raw
1
2
3
function o(o){
return
o>
47
&&o<
58
|
|o>
64
&&o<
91
|
|o>
96
&&o<
123
}
module
.exports=function(f,i,n,r,u){
if
(void
0
===n&&(n=!
1
),void
0
===u&&(u=!
0
),i>
0
)
for
(;o(f.charCodeAt(i));)n?i++
:i--
;
if
(r)
for
(;o(f.charCodeAt(r));)u?r++
:r--
;
return
f.substring(i,r).trim()};
//
# sourceMappingURL=index.js.map