Skip to content

Commit 2862c5a

Browse files
authored
Merge pull request #99 from apisearch-io/feature/improve-checks
Improved some checks
2 parents 5a1d648 + 996aba1 commit 2862c5a

9 files changed

+58
-42
lines changed

dist/apisearch.js

Lines changed: 15 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.min.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/apisearch.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Query/SortBy.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,18 @@ var SortBy = /** @class */ (function () {
305305
var newSortBy = SortBy.create();
306306
for (var i in this.sortsBy) {
307307
var sortBy = this.sortsBy[i];
308-
var sortByAsArray = JSON.parse(JSON.stringify(sortBy));
309-
if (typeof sortBy.filter === typeof {} &&
310-
sortBy.filter != null) {
311-
sortByAsArray.filter = Filter_1.Filter.createFromArray(sortBy.filter.toArray());
308+
if (typeof sortBy !== "function") {
309+
var sortByAsArray = JSON.parse(JSON.stringify(sortBy));
310+
if (typeof sortBy.filter === typeof {} &&
311+
sortBy.filter != null) {
312+
sortByAsArray.filter = Filter_1.Filter.createFromArray(sortBy.filter.toArray());
313+
}
314+
if (sortBy.coordinate != null &&
315+
typeof sortBy.coordinate == typeof {}) {
316+
sortByAsArray.coordinate = __1.Coordinate.createFromArray(sortBy.coordinate.toArray());
317+
}
318+
newSortBy.sortsBy.push(sortByAsArray);
312319
}
313-
if (sortBy.coordinate != null &&
314-
typeof sortBy.coordinate == typeof {}) {
315-
sortByAsArray.coordinate = __1.Coordinate.createFromArray(sortBy.coordinate.toArray());
316-
}
317-
newSortBy.sortsBy.push(sortByAsArray);
318320
}
319321
return newSortBy;
320322
};

lib/Result/ResultAggregation.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,10 @@ var ResultAggregation = /** @class */ (function () {
232232
: [];
233233
for (var i in countersAsArray) {
234234
var counterAsArray = countersAsArray[i];
235-
var counter = Counter_1.Counter.createFromArray(counterAsArray);
236-
aggregation.counters['_' + counter.getId()] = counter;
235+
if (typeof counterAsArray !== "function") {
236+
var counter = Counter_1.Counter.createFromArray(counterAsArray);
237+
aggregation.counters['_' + counter.getId()] = counter;
238+
}
237239
}
238240
aggregation.highestActiveElement = typeof array.highest_active_level === "number"
239241
? array.highest_active_level

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "apisearch",
3-
"version": "0.3.15",
3+
"version": "0.3.16",
44
"description": "Javascript client for Apisearch.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",

src/Query/SortBy.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -357,23 +357,25 @@ export class SortBy {
357357
const newSortBy = SortBy.create();
358358
for (const i in this.sortsBy) {
359359
const sortBy = this.sortsBy[i];
360-
const sortByAsArray = JSON.parse(JSON.stringify(sortBy));
361-
362-
if (
363-
typeof sortBy.filter === typeof {} &&
364-
sortBy.filter != null
365-
) {
366-
sortByAsArray.filter = Filter.createFromArray(sortBy.filter.toArray());
367-
}
368-
369-
if (
370-
sortBy.coordinate != null &&
371-
typeof sortBy.coordinate == typeof {}
372-
) {
373-
sortByAsArray.coordinate = Coordinate.createFromArray(sortBy.coordinate.toArray());
360+
if (typeof sortBy !== "function") {
361+
const sortByAsArray = JSON.parse(JSON.stringify(sortBy));
362+
363+
if (
364+
typeof sortBy.filter === typeof {} &&
365+
sortBy.filter != null
366+
) {
367+
sortByAsArray.filter = Filter.createFromArray(sortBy.filter.toArray());
368+
}
369+
370+
if (
371+
sortBy.coordinate != null &&
372+
typeof sortBy.coordinate == typeof {}
373+
) {
374+
sortByAsArray.coordinate = Coordinate.createFromArray(sortBy.coordinate.toArray());
375+
}
376+
377+
newSortBy.sortsBy.push(sortByAsArray);
374378
}
375-
376-
newSortBy.sortsBy.push(sortByAsArray);
377379
}
378380

379381
return newSortBy;

src/Result/ResultAggregation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,10 @@ export class ResultAggregation {
302302

303303
for (const i in countersAsArray) {
304304
const counterAsArray = countersAsArray[i];
305-
const counter = Counter.createFromArray(counterAsArray);
306-
aggregation.counters['_' + counter.getId()] = counter;
305+
if (typeof counterAsArray !== "function") {
306+
const counter = Counter.createFromArray(counterAsArray);
307+
aggregation.counters['_' + counter.getId()] = counter;
308+
}
307309
}
308310

309311
aggregation.highestActiveElement = typeof array.highest_active_level === "number"

0 commit comments

Comments
 (0)