Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ec32c6b

Browse filesBrowse files
committed
use ES6 naming "includes" - alias "contains" to be non-breaking
1 parent 3bb9792 commit ec32c6b
Copy full SHA for ec32c6b

File tree

Expand file treeCollapse file tree

9 files changed

+77
-65
lines changed
Filter options
Expand file treeCollapse file tree

9 files changed

+77
-65
lines changed

‎dist/immutable.d.ts

Copy file name to clipboardExpand all lines: dist/immutable.d.ts
+15-13Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ declare module 'immutable' {
7272

7373
/**
7474
* Value equality check with semantics similar to `Object.is`, but treats
75-
* Immutable `Iterable`s as values, equal if the second `Iterable` contains
75+
* Immutable `Iterable`s as values, equal if the second `Iterable` includes
7676
* equivalent values.
7777
*
7878
* It's used throughout Immutable when checking for equality, including `Map`
@@ -454,7 +454,7 @@ declare module 'immutable' {
454454
* If any of the values provided to `merge` are not Iterable (would return
455455
* false for `Immutable.isIterable`) then they are deeply converted via
456456
* `Immutable.fromJS` before being merged. However, if the value is an
457-
* Iterable but contains non-iterable JS objects or arrays, those nested
457+
* Iterable but includes non-iterable JS objects or arrays, those nested
458458
* values will be preserved.
459459
*
460460
* var x = Immutable.Map({a: 10, b: 20, c: 30});
@@ -1405,7 +1405,9 @@ declare module 'immutable' {
14051405

14061406
/**
14071407
* True if a value exists within this `Iterable`.
1408+
* @alias contains
14081409
*/
1410+
includes(value: V): boolean;
14091411
contains(value: V): boolean;
14101412

14111413
/**
@@ -1637,7 +1639,7 @@ declare module 'immutable' {
16371639
reverse(): /*this*/Iterable<K, V>;
16381640

16391641
/**
1640-
* Returns a new Iterable of the same type which contains the same entries,
1642+
* Returns a new Iterable of the same type which includes the same entries,
16411643
* stably sorted by using a `comparator`.
16421644
*
16431645
* If a `comparator` is not provided, a default comparator uses `<` and `>`.
@@ -1739,7 +1741,7 @@ declare module 'immutable' {
17391741
skipLast(amount: number): /*this*/Iterable<K, V>;
17401742

17411743
/**
1742-
* Returns a new Iterable of the same type which contains entries starting
1744+
* Returns a new Iterable of the same type which includes entries starting
17431745
* from when `predicate` first returns false.
17441746
*
17451747
* Seq.of('dog','frog','cat','hat','god')
@@ -1753,7 +1755,7 @@ declare module 'immutable' {
17531755
): /*this*/Iterable<K, V>;
17541756

17551757
/**
1756-
* Returns a new Iterable of the same type which contains entries starting
1758+
* Returns a new Iterable of the same type which includes entries starting
17571759
* from when `predicate` first returns true.
17581760
*
17591761
* Seq.of('dog','frog','cat','hat','god')
@@ -1767,19 +1769,19 @@ declare module 'immutable' {
17671769
): /*this*/Iterable<K, V>;
17681770

17691771
/**
1770-
* Returns a new Iterable of the same type which contains the first `amount`
1772+
* Returns a new Iterable of the same type which includes the first `amount`
17711773
* entries from this Iterable.
17721774
*/
17731775
take(amount: number): /*this*/Iterable<K, V>;
17741776

17751777
/**
1776-
* Returns a new Iterable of the same type which contains the last `amount`
1778+
* Returns a new Iterable of the same type which includes the last `amount`
17771779
* entries from this Iterable.
17781780
*/
17791781
takeLast(amount: number): /*this*/Iterable<K, V>;
17801782

17811783
/**
1782-
* Returns a new Iterable of the same type which contains entries from this
1784+
* Returns a new Iterable of the same type which includes entries from this
17831785
* Iterable as long as the `predicate` returns true.
17841786
*
17851787
* Seq.of('dog','frog','cat','hat','god')
@@ -1793,7 +1795,7 @@ declare module 'immutable' {
17931795
): /*this*/Iterable<K, V>;
17941796

17951797
/**
1796-
* Returns a new Iterable of the same type which contains entries from this
1798+
* Returns a new Iterable of the same type which includes entries from this
17971799
* Iterable as long as the `predicate` returns false.
17981800
*
17991801
* Seq.of('dog','frog','cat','hat','god').takeUntil(x => x.match(/at/))
@@ -1900,7 +1902,7 @@ declare module 'immutable' {
19001902
join(separator?: string): string;
19011903

19021904
/**
1903-
* Returns true if this Iterable contains no values.
1905+
* Returns true if this Iterable includes no values.
19041906
*
19051907
* For some lazy `Seq`, `isEmpty` might need to iterate to determine
19061908
* emptiness. At most one iteration will occur.
@@ -2040,13 +2042,13 @@ declare module 'immutable' {
20402042
// Comparison
20412043

20422044
/**
2043-
* True if `iter` contains every value in this Iterable.
2045+
* True if `iter` includes every value in this Iterable.
20442046
*/
20452047
isSubset(iter: Iterable<any, V>): boolean;
20462048
isSubset(iter: Array<V>): boolean;
20472049

20482050
/**
2049-
* True if this Iterable contains every value in `iter`.
2051+
* True if this Iterable includes every value in `iter`.
20502052
*/
20512053
isSuperset(iter: Iterable<any, V>): boolean;
20522054
isSuperset(iter: Array<V>): boolean;
@@ -2239,7 +2241,7 @@ declare module 'immutable' {
22392241
* Returns an Iterable of the same type with the provided `iterables`
22402242
* interleaved into this iterable.
22412243
*
2242-
* The resulting Iterable contains the first item from each, then the
2244+
* The resulting Iterable includes the first item from each, then the
22432245
* second from each, etc.
22442246
*
22452247
* I.Seq.of(1,2,3).interleave(I.Seq.of('A','B','C'))

‎dist/immutable.js

Copy file name to clipboardExpand all lines: dist/immutable.js
+18-14Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,8 @@
10071007
this.size = iter.size;
10081008
}
10091009

1010-
ToIndexedSequence.prototype.contains = function(value) {
1011-
return this._iter.contains(value);
1010+
ToIndexedSequence.prototype.includes = function(value) {
1011+
return this._iter.includes(value);
10121012
};
10131013

10141014
ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
@@ -1035,7 +1035,7 @@
10351035
}
10361036

10371037
ToSetSequence.prototype.has = function(key) {
1038-
return this._iter.contains(key);
1038+
return this._iter.includes(key);
10391039
};
10401040

10411041
ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
@@ -1122,8 +1122,8 @@
11221122
reversedSequence.flip = function() {return iterable.reverse()};
11231123
return reversedSequence;
11241124
};
1125-
flipSequence.has = function(key ) {return iterable.contains(key)};
1126-
flipSequence.contains = function(key ) {return iterable.has(key)};
1125+
flipSequence.has = function(key ) {return iterable.includes(key)};
1126+
flipSequence.includes = function(key ) {return iterable.has(key)};
11271127
flipSequence.cacheResult = cacheResultThrough;
11281128
flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
11291129
return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
@@ -1203,7 +1203,7 @@
12031203
{return iterable.get(useKeys ? key : -1 - key, notSetValue)};
12041204
reversedSequence.has = function(key )
12051205
{return iterable.has(useKeys ? key : -1 - key)};
1206-
reversedSequence.contains = function(value ) {return iterable.contains(value)};
1206+
reversedSequence.includes = function(value ) {return iterable.includes(value)};
12071207
reversedSequence.cacheResult = cacheResultThrough;
12081208
reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
12091209
return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
@@ -3577,7 +3577,7 @@
35773577
var originalSet = this;
35783578
return this.withMutations(function(set ) {
35793579
originalSet.forEach(function(value ) {
3580-
if (!iters.every(function(iter ) {return iter.contains(value)})) {
3580+
if (!iters.every(function(iter ) {return iter.includes(value)})) {
35813581
set.remove(value);
35823582
}
35833583
});
@@ -3592,7 +3592,7 @@
35923592
var originalSet = this;
35933593
return this.withMutations(function(set ) {
35943594
originalSet.forEach(function(value ) {
3595-
if (iters.some(function(iter ) {return iter.contains(value)})) {
3595+
if (iters.some(function(iter ) {return iter.includes(value)})) {
35963596
set.remove(value);
35973597
}
35983598
});
@@ -3995,7 +3995,7 @@
39953995
notSetValue;
39963996
};
39973997

3998-
Range.prototype.contains = function(searchValue) {
3998+
Range.prototype.includes = function(searchValue) {
39993999
var possibleIndex = (searchValue - this._start) / this._step;
40004000
return possibleIndex >= 0 &&
40014001
possibleIndex < this.size &&
@@ -4092,7 +4092,7 @@
40924092
return this.has(index) ? this._value : notSetValue;
40934093
};
40944094

4095-
Repeat.prototype.contains = function(searchValue) {
4095+
Repeat.prototype.includes = function(searchValue) {
40964096
return is(this._value, searchValue);
40974097
};
40984098

@@ -4258,6 +4258,10 @@
42584258
},
42594259

42604260
contains: function(searchValue) {
4261+
return this.includes(searchValue);
4262+
},
4263+
4264+
includes: function(searchValue) {
42614265
return this.some(function(value ) {return is(value, searchValue)});
42624266
},
42634267

@@ -4464,8 +4468,8 @@
44644468
},
44654469

44664470
isSubset: function(iter) {
4467-
iter = typeof iter.contains === 'function' ? iter : Iterable(iter);
4468-
return this.every(function(value ) {return iter.contains(value)});
4471+
iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
4472+
return this.every(function(value ) {return iter.includes(value)});
44694473
},
44704474

44714475
isSuperset: function(iter) {
@@ -4783,7 +4787,7 @@
47834787
return this.has(value) ? value : notSetValue;
47844788
},
47854789

4786-
contains: function(value) {
4790+
includes: function(value) {
47874791
return this.has(value);
47884792
},
47894793

@@ -4796,7 +4800,7 @@
47964800

47974801
});
47984802

4799-
SetIterable.prototype.has = IterablePrototype.contains;
4803+
SetIterable.prototype.has = IterablePrototype.includes;
48004804

48014805

48024806
// Mixin subclasses

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.