tc39/proposal-set-methods

Name: proposal-set-methods

Owner: Ecma TC39

Description: Strawman for new Set methods

Created: 2016-05-28 16:40:47.0

Updated: 2018-05-23 21:26:23.0

Pushed: 2018-05-22 20:27:40.0

Homepage: https://tc39.github.io/proposal-set-methods/

Size: 84

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

New Set methods

See formal spec WIP.

See proposal extending Set and Map with Array-like methods.

(Semi)relevant previous discussions

Motivations

Comparision with Immutable.js
Comparison with other languages
Java

Java Set interface is rather limited and doesn't include APIs found in this proposal.

Though, Java 8 introduces stream API that allow to deal with arbitrary collections.

Stream API has methods from this proposal like union (as concat).

Stream API nor Set does not include intersection, xor.

Other languages

.union, .intersection etc. desired signature

Signature of these functions isn't obvious. They can accept:

Proposal

This proposal does not change syntax of language.

New methods based on set theory are added to Set.prototype.

Not included in this proposal but worth considering
Naming

Symmetric difference

Proposed names: xor, symmetricDifference, disjointUnion

Intersection

Proposed names: intersect, intersection.

Union

Proposed names: union, concat.

Difference

Proposed names: difference, minus, except, without, withoutAll, relativeComplement.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.