11 lines
433 B
JavaScript
11 lines
433 B
JavaScript
![]() |
var makeString = require('./helper/makeString');
|
||
|
var defaultToWhiteSpace = require('./helper/defaultToWhiteSpace');
|
||
|
var nativeTrim = String.prototype.trim;
|
||
|
|
||
|
module.exports = function trim(str, characters) {
|
||
|
str = makeString(str);
|
||
|
if (!characters && nativeTrim) return nativeTrim.call(str);
|
||
|
characters = defaultToWhiteSpace(characters);
|
||
|
return str.replace(new RegExp('^' + characters + '+|' + characters + '+$', 'g'), '');
|
||
|
};
|