mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
var requireObjectCoercible = require('../internals/require-object-coercible');
|
|
var whitespaces = require('../internals/whitespaces');
|
|
|
|
var whitespace = '[' + whitespaces + ']';
|
|
var ltrim = RegExp('^' + whitespace + whitespace + '*');
|
|
var rtrim = RegExp(whitespace + whitespace + '*$');
|
|
|
|
// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
|
|
var createMethod = function (TYPE) {
|
|
return function ($this) {
|
|
var string = String(requireObjectCoercible($this));
|
|
if (TYPE & 1) string = string.replace(ltrim, '');
|
|
if (TYPE & 2) string = string.replace(rtrim, '');
|
|
return string;
|
|
};
|
|
};
|
|
|
|
module.exports = {
|
|
// `String.prototype.{ trimLeft, trimStart }` methods
|
|
// https://tc39.github.io/ecma262/#sec-string.prototype.trimstart
|
|
start: createMethod(1),
|
|
// `String.prototype.{ trimRight, trimEnd }` methods
|
|
// https://tc39.github.io/ecma262/#sec-string.prototype.trimend
|
|
end: createMethod(2),
|
|
// `String.prototype.trim` method
|
|
// https://tc39.github.io/ecma262/#sec-string.prototype.trim
|
|
trim: createMethod(3)
|
|
};
|