Sha256: 4c3d97a5dc5af0cb1c3bbb6128e1a0159d827cc491117d62fff9d55b72ce1f0d
Contents?: true
Size: 1.05 KB
Versions: 25
Compression:
Stored size: 1.05 KB
Contents
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) };
Version data entries
25 entries across 25 versions & 7 rubygems