This repository has been archived by the owner on Apr 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
spec.emu
50 lines (48 loc) · 2.77 KB
/
spec.emu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!doctype html>
<meta charset="utf8">
<link rel="stylesheet" href="./spec.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="./spec.js"></script>
<pre class="metadata">
title: String.prototype.padStart / padEnd
stage: 3
contributors: Jordan Harband
</pre>
<emu-clause id="String.prototype.padStart">
<h1>String.prototype.padStart( maxLength [ , fillString ] )</h1>
<p>When the `padStart` method is called, the following steps are taken:</p>
<emu-alg>
1. Let _O_ be ? RequireObjectCoercible(*this* value).
1. Let _S_ be ? ToString(_O_).
1. Let _intMaxLength_ be ? ToLength(_maxLength_).
1. Let _stringLength_ be the number of elements in S.
1. If _intMaxLength_ is not greater than _stringLength_, return _S_.
1. If _fillString_ is *undefined*, let _filler_ be a string consisting solely of the code unit U+0020 (SPACE).
1. Else, let _filler_ be ? ToString(_fillString_).
1. If _filler_ is the empty String, return _S_.
1. Let _fillLen_ be _intMaxLength_ - _stringLength_.
1. Let _truncatedStringFiller_ be a new String value consisting of repeated concatenations of _filler_ truncated to length _fillLen_.
1. Return a new String value computed by the concatenation of _truncatedStringFiller_ and _S_.
</emu-alg>
<emu-note>The first argument _maxLength_ will be clamped such that it can be no smaller than the length of the *this* value.</emu-note>
<emu-note>The optional second argument _fillString_ defaults to *" "* (a string consisting of U+0020 SPACE).</emu-note>
</emu-clause>
<emu-clause id="String.prototype.padEnd">
<h1>String.prototype.padEnd( maxLength [ , fillString ] )</h1>
<p>When the `padEnd` method is called, the following steps are taken:</p>
<emu-alg>
1. Let _O_ be ? RequireObjectCoercible(*this* value).
1. Let _S_ be ? ToString(_O_).
1. Let _intMaxLength_ be ? ToLength(_maxLength_).
1. Let _stringLength_ be the number of elements in S.
1. If _intMaxLength_ is not greater than _stringLength_, return _S_.
1. If _fillString_ is *undefined*, let _filler_ be a string consisting solely of the code unit U+0020 (SPACE).
1. Else, let _filler_ be ? ToString(_fillString_).
1. If _filler_ is the empty String, return _S_.
1. Let _fillLen_ be _intMaxLength_ - _stringLength_.
1. Let _truncatedStringFiller_ be a new String value consisting of repeated concatenations of _filler_ truncated to length _fillLen_.
1. Return a new String value computed by the concatenation of _S_ and _truncatedStringFiller_.
</emu-alg>
<emu-note>The first argument _maxLength_ will be clamped such that it can be no smaller than the length of the *this* value.</emu-note>
<emu-note>The optional second argument _fillString_ defaults to *" "* (a string consisting of U+0020 SPACE).</emu-note>
</emu-clause>