https://github.com/termosa/lixy
Live proxy
https://github.com/termosa/lixy
Last synced: about 1 year ago
JSON representation
Live proxy
- Host: GitHub
- URL: https://github.com/termosa/lixy
- Owner: termosa
- Created: 2018-11-06T18:36:36.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-08T18:18:29.000Z (over 7 years ago)
- Last Synced: 2025-04-02T01:02:02.392Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lixy is live lazy proxy
Live means that it lives wonderful and unpredictable life.
While you call to proxied object it stays a proxy unless you get a primitive
value.
```
const lixy = require('lixy');
const math = {
add (a, b) {
return a + b;
}
};
const { add } = lixy.lazy(() => math);
add(5, 3); // 8
math.add = (a, b) => a - b;
add(5, 3); // 2
```
If the root object will not change, the example above can be simplified:
```
const { add } = lixy(math);
```
**Note:** proxified objects will always have the type `function` to handle the
case when you need to replace the source object with a function, eg
`math = eval`. If you want to change this behaviour pass the second argument
`lixy(getter, { safeType: false })`.