@@ -2,22 +2,32 @@ if ( !("csQuery" in getroottable()) || typeof ::csQuery != "table" )
22 throw " csQuery not found. Make sure you are not directly referencing this script, instead reference csQuery.nut" ;
33
44class csQuery .QueryArray {
5- constructor (_entArray){
6- entArray = _entArray;
5+ constructor (_entArray) {
6+ if (typeof _entArray == " array" ) {
7+ entArray = _entArray;
8+ return ;
9+ }
10+
11+ if (typeof _entArray == " instance" ) {
12+ entArray = [ _entArray ];
13+ return ;
14+ }
15+
16+ throw " The parameter's data type is invalid (Valid Types: array, class instance)" ;
717 }
818
919 entArray = null ;
1020
1121 function Each (callback) {
1222 foreach (ent in entArray) {
13- callback. call (this , ent)
23+ callback. call (this , ent);
1424 }
1525 return this ;
1626 }
1727
1828 function EachWithIndex (callback) {
1929 for (local i = 0 ; i < entArray. len (); i++ ) {
20- callback. call (this , i, entArray[i])
30+ callback. call (this , i, entArray[i]);
2131 }
2232 return this ;
2333 }
@@ -169,11 +179,11 @@ class csQuery.QueryArray {
169179 }
170180
171181 function Eq (index) {
172- return csQuery. QueryArray ([ entArray[index] ]);
182+ return csQuery. QueryArray (entArray[index]);
173183 }
174184
175185 function First () {
176- return csQuery. QueryArray ([ entArray[0 ] ]);
186+ return csQuery. QueryArray (entArray[0 ]);
177187 }
178188
179189 function Get (index) {
0 commit comments