|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
756 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var trimStart = require('string.prototype.trimstart');
|
|---|
| 4 | var trimEnd = require('string.prototype.trimend');
|
|---|
| 5 |
|
|---|
| 6 | var $TypeError = require('es-errors/type');
|
|---|
| 7 |
|
|---|
| 8 | var RequireObjectCoercible = require('./RequireObjectCoercible');
|
|---|
| 9 | var ToString = require('./ToString');
|
|---|
| 10 |
|
|---|
| 11 | // https://262.ecma-international.org/10.0/#sec-trimstring
|
|---|
| 12 |
|
|---|
| 13 | module.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.