Skip to content

Commit ead059f

Browse files
committed
support iterative access in ResultWrapper
1 parent 64f03c1 commit ead059f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/cubejs-backend-native/js/ResultWrapper.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ export class ResultWrapper extends BaseWrapper implements DataResult {
5151

5252
this.proxy = new Proxy(this, {
5353
get: (target, prop: string | symbol) => {
54+
// To support iterative access
55+
if (prop === Symbol.iterator) {
56+
const array = this.getArray();
57+
const l = array.length;
58+
59+
return function* () {
60+
for (let i = 0; i < l; i++) {
61+
yield array[i];
62+
}
63+
};
64+
}
65+
5466
// intercept indexes
5567
if (typeof prop === 'string' && !Number.isNaN(Number(prop))) {
5668
const array = this.getArray();

0 commit comments

Comments
 (0)