4.0.6 • Published 10 months ago

thaw v4.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
10 months ago

The narrow belt for AOP 🎀

This package provides narrow-trench methods for aspect-oriented programming (AOP).

Prerequisites

  • Node.js >= 18.x

Installation

npm install thaw --save

Usage

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);
4.0.6

10 months ago

4.0.5

12 months ago

4.0.4

1 year ago

4.0.3

1 year ago

4.0.2

2 years ago

4.0.1

2 years ago

3.0.1

2 years ago

4.0.0

2 years ago

3.0.0

2 years ago

2.1.5

3 years ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

4 years ago

2.0.6

4 years ago

2.0.3

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.0

9 years ago

1.0.1

10 years ago

1.0.0

10 years ago