https://github.com/whaaaley/universal-proxy
https://github.com/whaaaley/universal-proxy
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/whaaaley/universal-proxy
- Owner: whaaaley
- License: mit
- Created: 2025-06-27T00:47:38.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-27T00:54:51.000Z (12 months ago)
- Last Synced: 2025-06-27T01:35:25.761Z (12 months ago)
- Language: TypeScript
- Size: 0 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Universal Proxy
**A proxy that handles any property access, function call, or constructor.**
## What it does
Returns a proxy that responds to any operation:
- Property access: `obj.any.nested.property`
- Function calls: `obj.anyMethod()`
- Constructors: `new obj.AnyClass()`
- Array destructuring: `const [a, b] = obj()`
- Primitive operations: `obj + 10`, `obj > 0`, `String(obj)`
## Installation
```bash
deno add jsr:@cynthia/universal-proxy
```
## Usage
```javascript
import anything from 'jsr:@cynthia/universal-proxy'
const { api, config, service } = anything()
// All operations work without errors
const user = api.users.fetch()
const settings = config.app.theme
const instance = new service.Validator()
const [state] = api.useState()
```
## Known Limitations
**Infinite iterators**: The proxy uses infinite generators for array destructuring. This means:
```javascript
const { hook } = anything()
// ✅ Works - manual break
for (const item of hook()) {
if (count++ > 2) break
}
// ✅ Works - limited destructuring
const [a, b, c] = hook()
// ❌ Hangs - tries to consume infinite iterator
const items = [...hook()]
const all = Array.from(hook())
```
Use manual breaks or limited destructuring when working with iterators.