@@ -25,20 +25,20 @@ test('Index', function (t) {
25
25
'new Index(keyFn)'
26
26
)
27
27
28
- instance = new Index ( tree , 'id' )
28
+ instance = new Index ( 'id' , tree )
29
29
30
30
t . deepEqual (
31
31
[ instance instanceof Index , instance . get ( 1 ) ] ,
32
32
[ true , [ node , alt ] ] ,
33
- 'new Index(tree, prop )'
33
+ 'new Index(prop, tree )'
34
34
)
35
35
36
- instance = new Index ( tree , filter , 'id' )
36
+ instance = new Index ( 'id' , tree , filter )
37
37
38
38
t . deepEqual (
39
39
[ instance instanceof Index , instance . get ( 1 ) ] ,
40
40
[ true , [ node ] ] ,
41
- 'new Index(tree, filter, prop )'
41
+ 'new Index(prop, tree, filter )'
42
42
)
43
43
44
44
t . end ( )
@@ -56,7 +56,7 @@ test('index.add', function (t) {
56
56
var ast = u ( 'root' , [ u ( 'node' , { word : 'foo' } ) , u ( 'node' , { word : 'bar' } ) ] )
57
57
var extraNode = u ( 'node' , { word : 'foo' } )
58
58
59
- var index = new Index ( ast , 'word' )
59
+ var index = new Index ( 'word' , ast )
60
60
t . deepEqual ( index . get ( 'foo' ) , [ select ( '[word=foo]' , ast ) ] )
61
61
62
62
var result = index . add ( extraNode )
@@ -98,7 +98,7 @@ test('index.get', function (t) {
98
98
] )
99
99
] )
100
100
101
- var index = new Index ( ast , 'color' )
101
+ var index = new Index ( 'color' , ast )
102
102
103
103
st . deepEqual ( index . get ( 'black' ) , [
104
104
select ( '[id=0]' , ast ) ,
@@ -132,7 +132,7 @@ test('index.get', function (t) {
132
132
u ( 'node' , { word : 'constructor' , id : 1 } ) ,
133
133
u ( 'node' , { word : 'toString' , id : 2 } )
134
134
] )
135
- var index = new Index ( ast , 'word' )
135
+ var index = new Index ( 'word' , ast )
136
136
137
137
sst . deepEqual ( index . get ( '__proto__' ) , [ select ( '[id=0]' , ast ) ] )
138
138
sst . deepEqual ( index . get ( 'constructor' ) , [ select ( '[id=1]' , ast ) ] )
@@ -151,7 +151,7 @@ test('index.get', function (t) {
151
151
u ( 'node' , { word : id1 , id : 4 } ) ,
152
152
u ( 'node' , { word : id2 , id : 5 } )
153
153
] )
154
- var index = new Index ( ast , 'word' )
154
+ var index = new Index ( 'word' , ast )
155
155
156
156
sst . deepEqual ( index . get ( false ) , [ select ( '[id=0]' , ast ) ] )
157
157
sst . deepEqual ( index . get ( 'false' ) , [ select ( '[id=1]' , ast ) ] )
@@ -167,7 +167,7 @@ test('index.get', function (t) {
167
167
} )
168
168
169
169
t . test ( 'empty index' , function ( st ) {
170
- st . deepEqual ( new Index ( null , 'foo' ) . get ( 'bar' ) , [ ] )
170
+ st . deepEqual ( new Index ( 'foo' , null ) . get ( 'bar' ) , [ ] )
171
171
st . deepEqual ( new Index ( 'foo' ) . get ( 'bar' ) , [ ] )
172
172
st . end ( )
173
173
} )
@@ -181,14 +181,14 @@ test('index.get', function (t) {
181
181
] )
182
182
183
183
st . test ( 'type test' , function ( sst ) {
184
- var index = new Index ( ast , 'node ', 'word ')
184
+ var index = new Index ( 'word ', ast , 'node ')
185
185
sst . deepEqual ( index . get ( 'foo' ) , [ select ( 'node[word="foo"]' , ast ) ] )
186
186
sst . deepEqual ( index . get ( 'bar' ) , [ select ( 'node[word="bar"]' , ast ) ] )
187
187
sst . end ( )
188
188
} )
189
189
190
190
st . test ( 'function test' , function ( sst ) {
191
- var index = new Index ( ast , filter , 'word' )
191
+ var index = new Index ( 'word' , ast , filter )
192
192
sst . deepEqual ( index . get ( 'foo' ) , [ select ( 'node[word="foo"]' , ast ) ] )
193
193
sst . deepEqual ( index . get ( 'bar' ) , [ select ( 'node[word="bar"]' , ast ) ] )
194
194
sst . end ( )
@@ -210,7 +210,7 @@ test('index.get', function (t) {
210
210
] )
211
211
var index
212
212
213
- index = new Index ( ast , xPlusY )
213
+ index = new Index ( xPlusY , ast )
214
214
st . deepEqual ( index . get ( 4 ) , [
215
215
select ( '[id=0]' , ast ) ,
216
216
select ( '[id=2]' , ast ) ,
@@ -219,7 +219,7 @@ test('index.get', function (t) {
219
219
st . deepEqual ( index . get ( 0 ) , [ ] )
220
220
st . deepEqual ( index . get ( 5 ) , [ select ( '[id=1]' , ast ) , select ( '[id=4]' , ast ) ] )
221
221
222
- st . deepEqual ( new Index ( ast , 'node' , xPlusY ) . get ( 4 ) , [
222
+ st . deepEqual ( new Index ( xPlusY , ast , 'node' ) . get ( 4 ) , [
223
223
select ( '[id=2]' , ast ) ,
224
224
select ( '[id=3]' , ast )
225
225
] )
@@ -241,7 +241,7 @@ test('index.remove', function (t) {
241
241
u ( 'node' , { word : 'bar' } )
242
242
] )
243
243
244
- var index = new Index ( ast , 'word' )
244
+ var index = new Index ( 'word' , ast )
245
245
t . deepEqual ( index . get ( 'foo' ) , [
246
246
select ( 'bad[word=foo]' , ast ) ,
247
247
select ( 'node[word=foo]' , ast )
0 commit comments