Skip to content

Commit ca8486f

Browse files
committed
fix proxy's access to private class props
1 parent d95b4f8 commit ca8486f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/loaders/zarr_utils/CachingArray.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ export default function cachingArray<T extends DataType, Store extends Readable
2727
};
2828

2929
return new Proxy(array, {
30-
get: (target, prop, reciever) => (prop === "getChunk" ? getChunk : Reflect.get(target, prop, reciever)),
30+
get: (target, prop) => {
31+
if (prop === "getChunk") {
32+
return getChunk;
33+
}
34+
35+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#no_private_property_forwarding
36+
const value = target[prop];
37+
if (value instanceof Function) {
38+
return function (...args: unknown[]) {
39+
return value.apply(target, args);
40+
};
41+
}
42+
return value;
43+
},
3144
});
3245
}

0 commit comments

Comments
 (0)