Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/t2ym/thin-wrap
Thin Class Wrapper
https://github.com/t2ym/thin-wrap
Last synced: 22 days ago
JSON representation
Thin Class Wrapper
- Host: GitHub
- URL: https://github.com/t2ym/thin-wrap
- Owner: t2ym
- License: other
- Created: 2017-01-19T06:19:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-19T13:34:25.000Z (almost 8 years ago)
- Last Synced: 2024-10-09T03:12:45.575Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![npm](https://img.shields.io/npm/v/thin-wrap.svg)](https://www.npmjs.com/package/thin-wrap)
[![Bower](https://img.shields.io/bower/v/thin-wrap.svg)](https://customelements.io/t2ym/thin-wrap/)# thin-wrap
Thin Class Wrapper (experimental)
```javascript
function loggerForwarder(prop, f, args, self, newTarget) {
console.log('wrap: ' + (newTarget ? 'new ' : '') + f.name + ' is called for ', (self && self.name ? self.name : self), 'with arguments', args);
return newTarget ? Reflect.construct(f, args) : f.apply(self, args);
}
wrap(XMLHttpRequest, loggerForwarder);
wrap(EventTarget, loggerForwarder);
```## Install
### Browsers
```sh
bower install --save thin-wrap
```### NodeJS
```sh
npm install --save thin-wrap
```## Import
### Browsers
```html
```
### NodeJS
```javascript
const wrap = require('thin-wrap/wrap.js');
```## API
TBD
## Advantages
- Small overheads (Significantly faster than ES6 Proxy)
- `this` is unique and identical for each instance## Known Limitations
### Architectural Limitations
- `Class !== Class.prototype.constructor`
- `new Class()` is not trackable
- `new Class.prototype.constructor()` or `new (wrap(Class))()` is trackable
- Properties without setter/getter are not trackable### Current Design Limitations
- Inherited properties are not tracked
- Generation of setter/getter for properties are not implemented## License
[BSD-2-Clause](https://github.com/t2ym/thin-wrap/blob/master/LICENSE.md)