GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - tc39/proposal-array-filtering: A proposal to make filtering arrays easier

BranchesTags
Open more actions menu

Latest commit

 

History

15 Commits
15 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.npmrc
.npmrc
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
index.html
index.html
 
 
package.json
package.json
 
 
spec.emu
spec.emu
 
 

Repository files navigation

proposal-array-filtering

A proposal to add Array.prototype.filterReject.

const array = [1, 2, 3, 4, 5];

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

// filterReject removes the items that return true.
array.filterReject(i => (i < 3)); // => [3, 4, 5];

Champions

  • Justin Ridgewell (@jridgewell)

Status

Current Stage: 1

Motivation

Array.p.filter is confusing. I constantly have to ask myself "am I keeping, or filtering out the current item?".

"Keeping"

Implies that returning true would keep the current item.

"Filtering out"

Implies that returning true would remove the current item.

Array.p.filter acts as "keeping". But when I think of the word "filter", I think of "filtering out". So every time that I attempt to write an array filter, I end up writing the opposite of what I intended.

Array.p.filterReject attempts to fix this confusion. By providing a clearly named filtering function that matches my intuition, I'm able what will happen when calling filterReject. And because it exists, I'm able to assume that filter does something different, so it must be "keep" version.

Polyfill

A polyfill is available in the core-js library. You can find it in the ECMAScript proposals section.

Ongoing Discussions

  • Supporting Data from HTTP Archive and GitHub Archive
  • What should filterOut be called?
  • Should partition be included?

Related

  • Ruby
    • Array#select
    • Array#reject
    • Array#partition
  • Underscore
    • _.select (aliased to _.filter)
    • _.reject
    • _.partition
  • Lodash
    • _.reject (700k downloads/week)
    • _.partition (18k downloads/week)

About

A proposal to make filtering arrays easier

tc39.es/proposal-array-filtering/

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Security policy

Security policy
Activity
Custom properties

Stars

175 stars

Watchers

11 watching

Forks

4 forks
Report repository

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.