Sha256: 497ddda1a6981ecb64a4c5ea120100f61569ad519055b30741ad77d0aae3d458
Contents?: true
Size: 804 Bytes
Versions: 143
Compression:
Stored size: 804 Bytes
Contents
'use strict'; var trimStart = require('string.prototype.trimstart'); var trimEnd = require('string.prototype.trimend'); var GetIntrinsic = require('get-intrinsic'); var $TypeError = GetIntrinsic('%TypeError%'); var RequireObjectCoercible = require('./RequireObjectCoercible'); var ToString = require('./ToString'); // https://262.ecma-international.org/10.0/#sec-trimstring module.exports = function TrimString(string, where) { var str = RequireObjectCoercible(string); var S = ToString(str); var T; if (where === 'start') { T = trimStart(S); } else if (where === 'end') { T = trimEnd(S); } else if (where === 'start+end') { T = trimStart(trimEnd(S)); } else { throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"'); } return T; };
Version data entries
143 entries across 30 versions & 4 rubygems