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

Version Path
immosquare-cleaner-0.1.32 node_modules/es-abstract/2019/TrimString.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2022/TrimString.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2020/TrimString.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2021/TrimString.js
immosquare-cleaner-0.1.32 node_modules/es-abstract/2023/TrimString.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2019/TrimString.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2022/TrimString.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2020/TrimString.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2023/TrimString.js
immosquare-cleaner-0.1.31 node_modules/es-abstract/2021/TrimString.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2021/TrimString.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2022/TrimString.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2019/TrimString.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2023/TrimString.js
immosquare-cleaner-0.1.30 node_modules/es-abstract/2020/TrimString.js
immosquare-cleaner-0.1.29 node_modules/es-abstract/2021/TrimString.js
immosquare-cleaner-0.1.29 node_modules/es-abstract/2022/TrimString.js
immosquare-cleaner-0.1.29 node_modules/es-abstract/2019/TrimString.js
immosquare-cleaner-0.1.29 node_modules/es-abstract/2020/TrimString.js
immosquare-cleaner-0.1.29 node_modules/es-abstract/2023/TrimString.js