File tree Expand file tree Collapse file tree 4 files changed +22
-26
lines changed Expand file tree Collapse file tree 4 files changed +22
-26
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ import {
21
21
} from './TrieUtils' ;
22
22
import { hash } from './Hash' ;
23
23
import { Iterator , iteratorValue , iteratorDone } from './Iterator' ;
24
- import { sortFactory } from './Operations' ;
25
24
import arrCopy from './utils/arrCopy' ;
26
25
import assertNotInfinite from './utils/assertNotInfinite' ;
27
26
import { setIn } from './methods/setIn' ;
@@ -37,8 +36,6 @@ import { asMutable } from './methods/asMutable';
37
36
import { asImmutable } from './methods/asImmutable' ;
38
37
import { wasAltered } from './methods/wasAltered' ;
39
38
40
- import { OrderedMap } from './OrderedMap' ;
41
-
42
39
export class Map extends KeyedCollection {
43
40
// @pragma Construction
44
41
@@ -115,16 +112,6 @@ export class Map extends KeyedCollection {
115
112
116
113
// @pragma Composition
117
114
118
- sort ( comparator ) {
119
- // Late binding
120
- return OrderedMap ( sortFactory ( this , comparator ) ) ;
121
- }
122
-
123
- sortBy ( mapper , comparator ) {
124
- // Late binding
125
- return OrderedMap ( sortFactory ( this , comparator , mapper ) ) ;
126
- }
127
-
128
115
map ( mapper , context ) {
129
116
return this . withMutations ( map => {
130
117
map . forEach ( ( value , key ) => {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { IS_ORDERED_SYMBOL } from './predicates/isOrdered';
10
10
import { isOrderedMap } from './predicates/isOrderedMap' ;
11
11
import { Map , emptyMap } from './Map' ;
12
12
import { emptyList } from './List' ;
13
+ import { reify , sortFactory } from './Operations' ;
13
14
import { DELETE , NOT_SET , SIZE } from './TrieUtils' ;
14
15
import assertNotInfinite from './utils/assertNotInfinite' ;
15
16
@@ -66,6 +67,16 @@ export class OrderedMap extends Map {
66
67
return updateOrderedMap ( this , k , NOT_SET ) ;
67
68
}
68
69
70
+ // @pragma Composition
71
+
72
+ sort ( comparator ) {
73
+ return reify ( this , sortFactory ( this , comparator ) ) ;
74
+ }
75
+
76
+ sortBy ( mapper , comparator ) {
77
+ return reify ( this , sortFactory ( this , comparator , mapper ) ) ;
78
+ }
79
+
69
80
wasAltered ( ) {
70
81
return this . _map . wasAltered ( ) || this . _list . wasAltered ( ) ;
71
82
}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { IS_ORDERED_SYMBOL } from './predicates/isOrdered';
10
10
import { isOrderedSet } from './predicates/isOrderedSet' ;
11
11
import { IndexedCollectionPrototype } from './CollectionImpl' ;
12
12
import { Set } from './Set' ;
13
+ import { reify , sortFactory } from './Operations' ;
13
14
import { emptyOrderedMap } from './OrderedMap' ;
14
15
import assertNotInfinite from './utils/assertNotInfinite' ;
15
16
@@ -36,6 +37,16 @@ export class OrderedSet extends Set {
36
37
return this ( KeyedCollection ( value ) . keySeq ( ) ) ;
37
38
}
38
39
40
+ // Composition
41
+
42
+ sort ( comparator ) {
43
+ return reify ( this , sortFactory ( this , comparator ) ) ;
44
+ }
45
+
46
+ sortBy ( mapper , comparator ) {
47
+ return reify ( this , sortFactory ( this , comparator , mapper ) ) ;
48
+ }
49
+
39
50
toString ( ) {
40
51
return this . __toString ( 'OrderedSet {' , '}' ) ;
41
52
}
Original file line number Diff line number Diff line change @@ -10,14 +10,11 @@ import { isOrdered } from './predicates/isOrdered';
10
10
import { IS_SET_SYMBOL , isSet } from './predicates/isSet' ;
11
11
import { emptyMap } from './Map' ;
12
12
import { DELETE } from './TrieUtils' ;
13
- import { sortFactory } from './Operations' ;
14
13
import assertNotInfinite from './utils/assertNotInfinite' ;
15
14
import { asImmutable } from './methods/asImmutable' ;
16
15
import { asMutable } from './methods/asMutable' ;
17
16
import { withMutations } from './methods/withMutations' ;
18
17
19
- import { OrderedSet } from './OrderedSet' ;
20
-
21
18
export class Set extends SetCollection {
22
19
// @pragma Construction
23
20
@@ -136,16 +133,6 @@ export class Set extends SetCollection {
136
133
} ) ;
137
134
}
138
135
139
- sort ( comparator ) {
140
- // Late binding
141
- return OrderedSet ( sortFactory ( this , comparator ) ) ;
142
- }
143
-
144
- sortBy ( mapper , comparator ) {
145
- // Late binding
146
- return OrderedSet ( sortFactory ( this , comparator , mapper ) ) ;
147
- }
148
-
149
136
wasAltered ( ) {
150
137
return this . _map . wasAltered ( ) ;
151
138
}
You can’t perform that action at this time.
0 commit comments