https://github.com/bricss/thaw
The narrow belt for AOP 🎀
https://github.com/bricss/thaw
aspect-oriented-programming
Last synced: about 1 month ago
JSON representation
The narrow belt for AOP 🎀
- Host: GitHub
- URL: https://github.com/bricss/thaw
- Owner: bricss
- Created: 2014-08-23T23:49:03.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2026-02-02T01:00:28.000Z (about 1 month ago)
- Last Synced: 2026-02-10T21:30:33.767Z (about 1 month ago)
- Topics: aspect-oriented-programming
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/thaw
- Size: 1.19 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
The narrow belt for AOP 🎀
---
This package provides **narrow-trench** methods for aspect-oriented programming (AOP).
## Prerequisites
* Node.js `>= 20.0.0`
## Installation
```bash
npm install thaw --save
```
### Usage
```javascript
import * as thaw from 'thaw';
const around = thaw.around((val) => val + 1, (val) => val + val);
const after = thaw.after((val) => val + 1, (val) => val + val);
const before = thaw.before((val) => val + 1, (val) => val + val);
const compose = thaw.compose(around, after, before);
console.assert(around(1) === 6, 'around');
console.assert(after(1) === 4, 'after');
console.assert(before(1) === 3, 'before');
console.assert(compose(1) === 29, 'compose');
let bip = 0;
const debounce = thaw.debounce(() => bip++, 100);
setTimeout(debounce, 0);
setTimeout(debounce, 100);
setTimeout(debounce, 250); // will fire
setTimeout(debounce, 300);
setTimeout(debounce, 350); // will fire
setTimeout(debounce, 400);
setTimeout(() => console.assert(bip === 2, 'debounce'), 1e3);
let pib = 0;
const throttle = thaw.throttle(() => pib++, 100);
setTimeout(throttle, 0); // will fire
setTimeout(throttle, 100);
setTimeout(throttle, 250); // will fire
setTimeout(throttle, 300);
setTimeout(throttle, 350); // will fire
setTimeout(throttle, 400);
setTimeout(() => console.assert(pib === 3, 'throttle'), 1e3);
```