fix: sort and where bug when using strictVariables

This commit is contained in:
Francisco Soto
2023-08-28 21:08:45 +08:00
committed by Jun Yang
parent 88aa63fd58
commit 8af682d2ca
+2 -2
View File
@@ -14,7 +14,7 @@ export function * sort<T> (this: FilterImpl, arr: T[], property?: string): Itera
for (const item of toArray(toValue(arr))) {
values.push([
item,
property ? yield this.context._getFromScope(item, stringify(property).split('.')) : item
property ? yield this.context._getFromScope(item, stringify(property).split('.'), false) : item
])
}
return values.sort((lhs, rhs) => {
@@ -70,7 +70,7 @@ export function * where<T extends object> (this: FilterImpl, arr: T[], property:
const values: unknown[] = []
arr = toArray(toValue(arr))
for (const item of arr) {
values.push(yield this.context._getFromScope(item, stringify(property).split('.')))
values.push(yield this.context._getFromScope(item, stringify(property).split('.'), false))
}
return arr.filter((_, i) => {
if (expected === undefined) return isTruthy(values[i], this.context)