Skip to content

Commit 3bb33a8

Browse files
authored
Rename to filterReject (#18)
* Change to filterReject * Update index.html * Update spec.emu
1 parent 290acab commit 3bb33a8

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# proposal-array-filtering
22

3-
A proposal to add `Array.prototype.filterOut`.
3+
A proposal to add `Array.prototype.filterReject`.
44

55
```js
66
const array = [1, 2, 3, 4, 5];
77

88
// filter keeps the items that return true.
99
array.filter(i => (i < 3)); // => [1, 2];
1010

11-
// filterOut removes the items that return true.
12-
array.filterOut(i => (i < 3)); // => [3, 4, 5];
11+
// filterReject removes the items that return true.
12+
array.filterReject(i => (i < 3)); // => [3, 4, 5];
1313
```
1414

1515
## Champions

index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<link rel="stylesheet" href="./spec.css">
44
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
55
<script src="./spec.js"></script>
6-
<title>Array Filtering</title><script type="application/json" id="menu-search-biblio">[{"type":"clause","id":"sec-scope","aoid":null,"title":"Scope","titleHTML":"Scope","number":"1","namespace":"https://tc39.es/proposal-array-filtering/","location":"","referencingIds":[],"key":"Scope"},{"type":"clause","id":"sec-array.prototype.filterOut","aoid":null,"title":"Array.prototype.filterOut ( callbackfn [ , thisArg ] )","titleHTML":"Array.prototype.filterOut ( <var>callbackfn</var> [ , <var>thisArg</var> ] )","number":"2.1","namespace":"https://tc39.es/proposal-array-filtering/","location":"","referencingIds":[],"key":"Array.prototype.filterOut ( callbackfn [ , thisArg ] )"},{"type":"clause","id":"sec-array.prototype.groupby","aoid":null,"title":"Array.prototype.groupBy ( callbackfn [ , thisArg ] )","titleHTML":"Array.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )","number":"2.2","namespace":"https://tc39.es/proposal-array-filtering/","location":"","referencingIds":[],"key":"Array.prototype.groupBy ( callbackfn [ , thisArg ] )"},{"type":"clause","id":"sec-properties-of-the-array-prototype-object","aoid":null,"title":"Properties of the Array Prototype Object (22.1.3)","titleHTML":"Properties of the Array Prototype Object (<a href=\"https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object\">22.1.3</a>)","number":"2","namespace":"https://tc39.es/proposal-array-filtering/","location":"","referencingIds":[],"key":"Properties of the Array Prototype Object (22.1.3)"},{"type":"clause","id":"sec-copyright-and-software-license","aoid":null,"title":"Copyright & Software License","titleHTML":"Copyright &amp; Software License","number":"A","namespace":"https://tc39.es/proposal-array-filtering/","location":"","referencingIds":[],"key":"Copyright & Software License"}]</script><script>"use strict";
6+
<title>Array Filtering</title><script type="application/json" id="menu-search-biblio">[{"type":"clause","id":"sec-scope","aoid":null,"title":"Scope","titleHTML":"Scope","number":"1","namespace":"https://tc39.es/proposal-array-filtering/","location":"","referencingIds":[],"key":"Scope"},{"type":"clause","id":"sec-array.prototype.filterReject","aoid":null,"title":"Array.prototype.filterReject ( callbackfn [ , thisArg ] )","titleHTML":"Array.prototype.filterReject ( <var>callbackfn</var> [ , <var>thisArg</var> ] )","number":"2.1","namespace":"https://tc39.es/proposal-array-filtering/","location":"","referencingIds":[],"key":"Array.prototype.filterReject ( callbackfn [ , thisArg ] )"},{"type":"clause","id":"sec-array.prototype.groupby","aoid":null,"title":"Array.prototype.groupBy ( callbackfn [ , thisArg ] )","titleHTML":"Array.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )","number":"2.2","namespace":"https://tc39.es/proposal-array-filtering/","location":"","referencingIds":[],"key":"Array.prototype.groupBy ( callbackfn [ , thisArg ] )"},{"type":"clause","id":"sec-properties-of-the-array-prototype-object","aoid":null,"title":"Properties of the Array Prototype Object (22.1.3)","titleHTML":"Properties of the Array Prototype Object (<a href=\"https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object\">22.1.3</a>)","number":"2","namespace":"https://tc39.es/proposal-array-filtering/","location":"","referencingIds":[],"key":"Properties of the Array Prototype Object (22.1.3)"},{"type":"clause","id":"sec-copyright-and-software-license","aoid":null,"title":"Copyright & Software License","titleHTML":"Copyright &amp; Software License","number":"A","namespace":"https://tc39.es/proposal-array-filtering/","location":"","referencingIds":[],"key":"Copyright & Software License"}]</script><script>"use strict";
77

88
function Search(menu) {
99
this.menu = menu;
@@ -1845,7 +1845,7 @@
18451845
display: none;
18461846
}
18471847
}
1848-
</style></head><body><div id="menu-toggle">☰</div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-scope" title="Scope"><span class="secnum">1</span> Scope</a></li><li><span class="item-toggle">◢</span><a href="#sec-properties-of-the-array-prototype-object" title="Properties of the Array Prototype Object (22.1.3)"><span class="secnum">2</span> Properties of the Array Prototype Object (</a><a href="https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object">22.1.3</a>)<ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-array.prototype.filterOut" title="Array.prototype.filterOut ( callbackfn [ , thisArg ] )"><span class="secnum">2.1</span> Array.prototype.filterOut ( <var>callbackfn</var> [ , <var>thisArg</var> ] )</a></li><li><span class="item-toggle-none"></span><a href="#sec-array.prototype.groupby" title="Array.prototype.groupBy ( callbackfn [ , thisArg ] )"><span class="secnum">2.2</span> Array.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version first">Stage 1 Draft / July 7, 2021</h1><h1 class="title">Array Filtering</h1>
1848+
</style></head><body><div id="menu-toggle">☰</div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-scope" title="Scope"><span class="secnum">1</span> Scope</a></li><li><span class="item-toggle">◢</span><a href="#sec-properties-of-the-array-prototype-object" title="Properties of the Array Prototype Object (22.1.3)"><span class="secnum">2</span> Properties of the Array Prototype Object (</a><a href="https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object">22.1.3</a>)<ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-array.prototype.filterReject" title="Array.prototype.filterReject ( callbackfn [ , thisArg ] )"><span class="secnum">2.1</span> Array.prototype.filterReject ( <var>callbackfn</var> [ , <var>thisArg</var> ] )</a></li><li><span class="item-toggle-none"></span><a href="#sec-array.prototype.groupby" title="Array.prototype.groupBy ( callbackfn [ , thisArg ] )"><span class="secnum">2.2</span> Array.prototype.groupBy ( <var>callbackfn</var> [ , <var>thisArg</var> ] )</a></li></ol></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version first">Stage 1 Draft / July 7, 2021</h1><h1 class="title">Array Filtering</h1>
18491849
18501850
<emu-clause id="sec-scope">
18511851
<h1><span class="secnum">1</span> Scope</h1>
@@ -1858,19 +1858,19 @@ <h1><span class="secnum">1</span> Scope</h1>
18581858
<h1><span class="secnum">2</span> Properties of the Array Prototype Object (<a href="https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object">22.1.3</a>)</h1>
18591859
18601860
<ins class="block">
1861-
<emu-clause id="sec-array.prototype.filterOut">
1862-
<h1><span class="secnum">2.1</span> Array.prototype.filterOut ( <var>callbackfn</var> [ , <var>thisArg</var> ] )</h1>
1861+
<emu-clause id="sec-array.prototype.filterReject">
1862+
<h1><span class="secnum">2.1</span> Array.prototype.filterReject ( <var>callbackfn</var> [ , <var>thisArg</var> ] )</h1>
18631863
<emu-note><span class="note">Note 1</span><div class="note-contents">
1864-
<p><var>callbackfn</var> should be a function that accepts three arguments and returns a value that is coercible to the Boolean value <emu-val>true</emu-val> or <emu-val>false</emu-val>. <code>filterOut</code> calls <var>callbackfn</var> once for each element in the array, in ascending order, and constructs a new array of all the values for which <var>callbackfn</var> returns <emu-val>false</emu-val>. <var>callbackfn</var> is called only for elements of the array which actually exist; it is not called for missing elements of the array.</p>
1864+
<p><var>callbackfn</var> should be a function that accepts three arguments and returns a value that is coercible to the Boolean value <emu-val>true</emu-val> or <emu-val>false</emu-val>. <code>filterReject</code> calls <var>callbackfn</var> once for each element in the array, in ascending order, and constructs a new array of all the values for which <var>callbackfn</var> returns <emu-val>false</emu-val>. <var>callbackfn</var> is called only for elements of the array which actually exist; it is not called for missing elements of the array.</p>
18651865
<p>If a <var>thisArg</var> parameter is provided, it will be used as the <emu-val>this</emu-val> value for each invocation of <var>callbackfn</var>. If it is not provided, <emu-val>undefined</emu-val> is used instead.</p>
18661866
<p><var>callbackfn</var> is called with three arguments: the value of the element, the index of the element, and the object being traversed.</p>
1867-
<p><code>filterOut</code> does not directly mutate the object on which it is called but the object may be mutated by the calls to <var>callbackfn</var>.</p>
1868-
<p>The range of elements processed by <code>filterOut</code> is set before the first call to <var>callbackfn</var>. Elements which are appended to the array after the call to <code>filterOut</code> begins will not be visited by <var>callbackfn</var>. If existing elements of the array are changed their value as passed to <var>callbackfn</var> will be the value at the time <code>filterOut</code> visits them; elements that are deleted after the call to <code>filterOut</code> begins and before being visited are not visited.</p>
1867+
<p><code>filterReject</code> does not directly mutate the object on which it is called but the object may be mutated by the calls to <var>callbackfn</var>.</p>
1868+
<p>The range of elements processed by <code>filterReject</code> is set before the first call to <var>callbackfn</var>. Elements which are appended to the array after the call to <code>filterReject</code> begins will not be visited by <var>callbackfn</var>. If existing elements of the array are changed their value as passed to <var>callbackfn</var> will be the value at the time <code>filterReject</code> visits them; elements that are deleted after the call to <code>filterReject</code> begins and before being visited are not visited.</p>
18691869
</div></emu-note>
1870-
<p>When the <code>filterOut</code> method is called with one or two arguments, the following steps are taken:</p>
1870+
<p>When the <code>filterReject</code> method is called with one or two arguments, the following steps are taken:</p>
18711871
<emu-alg><ol><li>Let <var>O</var> be ?&nbsp;<emu-xref aoid="ToObject" id="_ref_0"><a href="https://tc39.es/ecma262/#sec-toobject">ToObject</a></emu-xref>(<emu-val>this</emu-val> value).</li><li>Let <var>len</var> be ?&nbsp;<emu-xref aoid="LengthOfArrayLike" id="_ref_1"><a href="https://tc39.es/ecma262/#sec-lengthofarraylike">LengthOfArrayLike</a></emu-xref>(<var>O</var>).</li><li>If <emu-xref aoid="IsCallable" id="_ref_2"><a href="https://tc39.es/ecma262/#sec-iscallable">IsCallable</a></emu-xref>(<var>callbackfn</var>) is <emu-val>false</emu-val>, throw a <emu-val>TypeError</emu-val> exception.</li><li>Let <var>A</var> be ?&nbsp;<emu-xref aoid="ArraySpeciesCreate" id="_ref_3"><a href="https://tc39.es/ecma262/#sec-arrayspeciescreate">ArraySpeciesCreate</a></emu-xref>(<var>O</var>, 0).</li><li>Let <var>k</var> be 0.</li><li>Let <var>to</var> be 0.</li><li>Repeat, while <var>k</var> &lt; <var>len</var><ol><li>Let <var>Pk</var> be !&nbsp;<emu-xref aoid="ToString" id="_ref_4"><a href="https://tc39.es/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>k</var>).</li><li>Let <var>kPresent</var> be ?&nbsp;<emu-xref aoid="HasProperty" id="_ref_5"><a href="https://tc39.es/ecma262/#sec-hasproperty">HasProperty</a></emu-xref>(<var>O</var>, <var>Pk</var>).</li><li>If <var>kPresent</var> is <emu-val>true</emu-val>, then<ol><li>Let <var>kValue</var> be ?&nbsp;<emu-xref aoid="Get" id="_ref_6"><a href="https://tc39.es/ecma262/#sec-get-o-p">Get</a></emu-xref>(<var>O</var>, <var>Pk</var>).</li><li>Let <var>rejected</var> be !&nbsp;<emu-xref aoid="ToBoolean" id="_ref_7"><a href="https://tc39.es/ecma262/#sec-toboolean">ToBoolean</a></emu-xref>(? <emu-xref aoid="Call" id="_ref_8"><a href="https://tc39.es/ecma262/#sec-call">Call</a></emu-xref>(<var>callbackfn</var>, <var>thisArg</var>, « <var>kValue</var>, <var>k</var>, <var>O</var> »)).</li><li>If <var>rejected</var> is <emu-val>false</emu-val>, then<ol><li>Perform ?&nbsp;<emu-xref aoid="CreateDataPropertyOrThrow" id="_ref_9"><a href="https://tc39.es/ecma262/#sec-createdatapropertyorthrow">CreateDataPropertyOrThrow</a></emu-xref>(<var>A</var>, !&nbsp;<emu-xref aoid="ToString" id="_ref_10"><a href="https://tc39.es/ecma262/#sec-tostring">ToString</a></emu-xref>(<var>to</var>), <var>kValue</var>).</li><li>Set <var>to</var> to <var>to</var> + 1.</li></ol></li></ol></li><li>Set <var>k</var> to <var>k</var> + 1.</li></ol></li><li>Return <var>A</var>.</li></ol></emu-alg>
18721872
<emu-note><span class="note">Note 2</span><div class="note-contents">
1873-
<p>The <code>filterOut</code> function is intentionally generic; it does not require that its <emu-val>this</emu-val> value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
1873+
<p>The <code>filterReject</code> function is intentionally generic; it does not require that its <emu-val>this</emu-val> value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
18741874
</div></emu-note>
18751875
</emu-clause>
18761876
</ins>
@@ -1912,4 +1912,4 @@ <h2>Software License</h2>
19121912
<p>THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
19131913
19141914
</emu-annex>
1915-
</div></body>
1915+
</div></body>

spec.emu

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ location: https://tc39.es/proposal-array-filtering/
2222
<h1>Properties of the Array Prototype Object (<a href="https://tc39.es/ecma262/#sec-properties-of-the-array-prototype-object">22.1.3</a>)</h1>
2323

2424
<ins class="block">
25-
<emu-clause id="sec-array.prototype.filterOut">
26-
<h1>Array.prototype.filterOut ( _callbackfn_ [ , _thisArg_ ] )</h1>
25+
<emu-clause id="sec-array.prototype.filterReject">
26+
<h1>Array.prototype.filterReject ( _callbackfn_ [ , _thisArg_ ] )</h1>
2727
<emu-note>
28-
<p>_callbackfn_ should be a function that accepts three arguments and returns a value that is coercible to the Boolean value *true* or *false*. `filterOut` calls _callbackfn_ once for each element in the array, in ascending order, and constructs a new array of all the values for which _callbackfn_ returns *false*. _callbackfn_ is called only for elements of the array which actually exist; it is not called for missing elements of the array.</p>
28+
<p>_callbackfn_ should be a function that accepts three arguments and returns a value that is coercible to the Boolean value *true* or *false*. `filterReject` calls _callbackfn_ once for each element in the array, in ascending order, and constructs a new array of all the values for which _callbackfn_ returns *false*. _callbackfn_ is called only for elements of the array which actually exist; it is not called for missing elements of the array.</p>
2929
<p>If a _thisArg_ parameter is provided, it will be used as the *this* value for each invocation of _callbackfn_. If it is not provided, *undefined* is used instead.</p>
3030
<p>_callbackfn_ is called with three arguments: the value of the element, the index of the element, and the object being traversed.</p>
31-
<p>`filterOut` does not directly mutate the object on which it is called but the object may be mutated by the calls to _callbackfn_.</p>
32-
<p>The range of elements processed by `filterOut` is set before the first call to _callbackfn_. Elements which are appended to the array after the call to `filterOut` begins will not be visited by _callbackfn_. If existing elements of the array are changed their value as passed to _callbackfn_ will be the value at the time `filterOut` visits them; elements that are deleted after the call to `filterOut` begins and before being visited are not visited.</p>
31+
<p>`filterReject` does not directly mutate the object on which it is called but the object may be mutated by the calls to _callbackfn_.</p>
32+
<p>The range of elements processed by `filterReject` is set before the first call to _callbackfn_. Elements which are appended to the array after the call to `filterReject` begins will not be visited by _callbackfn_. If existing elements of the array are changed their value as passed to _callbackfn_ will be the value at the time `filterReject` visits them; elements that are deleted after the call to `filterReject` begins and before being visited are not visited.</p>
3333
</emu-note>
34-
<p>When the `filterOut` method is called with one or two arguments, the following steps are taken:</p>
34+
<p>When the `filterReject` method is called with one or two arguments, the following steps are taken:</p>
3535
<emu-alg>
3636
1. Let _O_ be ? ToObject(*this* value).
3737
1. Let _len_ be ? LengthOfArrayLike(_O_).
@@ -52,7 +52,7 @@ location: https://tc39.es/proposal-array-filtering/
5252
1. Return _A_.
5353
</emu-alg>
5454
<emu-note>
55-
<p>The `filterOut` function is intentionally generic; it does not require that its *this* value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
55+
<p>The `filterReject` function is intentionally generic; it does not require that its *this* value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method.</p>
5656
</emu-note>
5757
</emu-clause>
5858
</ins>

0 commit comments

Comments
 (0)