8000 remove empty() api · spmjs/immutable-js@f3957c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3957c2

Browse files
committed
remove empty() api
1 parent fd68267 commit f3957c2

File tree

15 files changed

+121
-188
lines changed

15 files changed

+121
-188
lines changed

__tests__/List.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('List', () => {
104104
var v0 = List.of('a', 'b', 'c');
105105
var v1 = List.of('a', 'b');
106106
var v2 = List.of('a');
107-
var v3 = List.empty();
107+
var v3 = List();
108108

109109
expect(v0.rest().toArray()).toEqual(['b', 'c']);
110110
expect(v0.butLast().toArray()).toEqual(['a', 'b']);
@@ -155,7 +155,7 @@ describe('List', () => {
155155
});
156156

157157
it('iterates a dense list', () => {
158-
var v = List.empty().setSize(11).set(1,1).set(3,3).set(5,5).set(7,7).set(9,9);
158+
var v = List().setSize(11).set(1,1).set(3,3).set(5,5).set(7,7).set(9,9);
159159
expect(v.size).toBe(11);
160160

161161
var forEachResults = [];

__tests__/Map.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe('Map', () => {
150150
expect(m2.size).toBe(2);
151151
expect(m3.size).toBe(1);
152152
expect(m4.size).toBe(0);
153-
expect(m4).toBe(Map.empty());
153+
expect(m4).toBe(Map());
154154
});
155155

156156
it('can map many items', () => {

__tests__/Set.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe('Set', () => {
130130

131131
it('deletes down to empty set', () => {
132132
var s = Set.of('A').remove('A');
133-
expect(s).toBe(Set.empty());
133+
expect(s).toBe(Set());
134134
});
135135

136136
it('unions multiple sets', () => {

__tests__/updateIn.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('updateIn', () => {
6666
it('creates new maps if path contains gaps', () => {
6767
var m = I.fromJS({a: {b: {c: 10}}});
6868
expect(
69-
m.updateIn(['a', 'z'], I.Map.empty(), map => map.set('d', 20)).toJS()
69+
m.updateIn(['a', 'z'], I.Map(), map => map.set('d', 20)).toJS()
7070
).toEqual(
7171
{a: {b: {c: 10}, z: {d: 20}}}
7272
);
@@ -91,17 +91,17 @@ describe('updateIn', () => {
9191
it('performs edit when notSetValue is what you return from updater', () => {
9292
var m = I.Map();
9393

94-
m = m.updateIn(['a', 'b', 'c'], I.Set.empty(), id => id);
94+
m = m.updateIn(['a', 'b', 'c'], I.Set(), id => id);
9595

9696
expect(m.size).toBe(1);
9797

98-
expect(m.getIn(['a', 'b', 'c'])).toBe(I.Set.empty());
98+
expect(m.getIn(['a', 'b', 'c'])).toBe(I.Set());
9999
})
100100

101101
it('does not perform edit when new value is the same as old value', () => {
102102
var m = I.Map();
103103

104-
m = m.updateIn(['a', 'b', 'c'], I.Set.empty(), id => undefined);
104+
m = m.updateIn(['a', 'b', 'c'], I.Set(), id => undefined);
105105

106106
expect(m.size).toBe(0);
107107

contrib/cursor/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ KeyedCursorPrototype.update = function(keyOrFn, notSetValue, updater) {
9999

100100
KeyedCursorPrototype.withMutations =
101101
IndexedCursorPrototype.withMutations = function(fn) {
102-
return updateCursor(this, m => (m || Map.empty()).withMutations(fn));
102+
return updateCursor(this, m => (m || Map()).withMutations(fn));
103103
}
104104

105105
KeyedCursorPrototype.cursor =
@@ -170,7 +170,7 @@ function subCursor(cursor, key, value) {
170170
function updateCursor(cursor, changeFn, changeKey) {
171171
var newRootData = cursor._rootData.updateIn(
172172
cursor._keyPath,
173-
changeKey ? Map.empty() : undefined,
173+
changeKey ? Map() : undefined,
174174
changeFn
175175
);
176176
var keyPath = cursor._keyPath || [];

dist/immutable.d.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,10 +1234,6 @@ declare module 'immutable' {
12341234

12351235
export module Map {
12361236

1237-
/**
1238-
* `Map.empty()` creates a new immutable Map of size 0.
1239-
*/
1240-
function empty<K, V>(): Map<K, V>;
12411237
}
12421238

12431239
/**
@@ -1446,10 +1442,6 @@ declare module 'immutable' {
14461442

14471443
export module OrderedMap {
14481444

1449-
/**
1450-
* `OrderedMap.empty()` creates a new immutable ordered Map of size 0.
1451-
*/
1452-
function empty<K, V>(): Map<K, V>;
14531445
}
14541446

14551447
/**
@@ -1535,21 +1527,16 @@ declare module 'immutable' {
15351527
export module Set {
15361528

15371529
/**
1538-
* `Set.empty()` creates a new immutable Set of size 0.
1530+
* Creates a new Set containing `values`.
15391531
*/
1540-
function empty<T>(): Set<T>;
1532+
function of<T>(...< 97AE /span>values: T[]): Set<T>;
15411533

15421534
/**
15431535
* `Set.fromKeys()` creates a new immutable Set containing the keys from
15441536
* this Iterable or JavaScript Object.
15451537
*/
15461538
function fromKeys<T>(iter: Iterable<T, any>): Set<T>;
15471539
function fromKeys(obj: {[key: string]: any}): Set<string>;
1548-
1549-
/**
1550-
* Creates a new Set containing `values`.
1551-
*/
1552-
function of<T>(...values: T[]): Set<T>;
15531540
}
15541541

15551542
/**
@@ -1641,11 +1628,6 @@ declare module 'immutable' {
16411628

16421629
export module List {
16431630

1644-
/**
1645-
* `List.empty()` creates a new immutable List of size 0.
1646-
*/
1647-
function empty<T>(): List<T>;
1648-
16491631
/**
16501632
* Creates a new List containing `values`.
16511633
*/
@@ -1841,11 +1823,6 @@ declare module 'immutable' {
18411823

18421824
export module Stack {
18431825

1844-
/**
1845-
* `Stack.empty()` creates a new immutable Stack of size 0.
1846-
*/
1847-
function empty<T>(): Stack<T>;
1848-
18491826
/**
18501827
* Creates a new Stack containing `values`.
18511828
*/

0 commit comments

Comments
 (0)
0