Skip to content

Commit

Permalink
support iterative access in ResultWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
KSDaemon committed Jan 10, 2025
1 parent ae8af63 commit 8222582
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/cubejs-backend-native/js/ResultWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ export class ResultWrapper extends BaseWrapper implements DataResult {

this.proxy = new Proxy(this, {
get: (target, prop: string | symbol) => {
// To support iterative access
if (prop === Symbol.iterator) {
const array = this.getArray();
const l = array.length;

return function* () {

Check warning on line 59 in packages/cubejs-backend-native/js/ResultWrapper.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected unnamed generator function
for (let i = 0; i < l; i++) {
yield array[i];
}
};
}

// intercept indexes
if (typeof prop === 'string' && !Number.isNaN(Number(prop))) {
const array = this.getArray();
Expand Down

0 comments on commit 8222582

Please sign in to comment.