source: imaps-frontend/node_modules/es-abstract/2023/TrimString.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 756 bytes
RevLine 
[d565449]1'use strict';
2
3var trimStart = require('string.prototype.trimstart');
4var trimEnd = require('string.prototype.trimend');
5
6var $TypeError = require('es-errors/type');
7
8var RequireObjectCoercible = require('./RequireObjectCoercible');
9var ToString = require('./ToString');
10
11// https://262.ecma-international.org/10.0/#sec-trimstring
12
13module.exports = function TrimString(string, where) {
14 var str = RequireObjectCoercible(string);
15 var S = ToString(str);
16 var T;
17 if (where === 'start') {
18 T = trimStart(S);
19 } else if (where === 'end') {
20 T = trimEnd(S);
21 } else if (where === 'start+end') {
22 T = trimStart(trimEnd(S));
23 } else {
24 throw new $TypeError('Assertion failed: invalid `where` value; must be "start", "end", or "start+end"');
25 }
26 return T;
27};
Note: See TracBrowser for help on using the repository browser.