Socket
Socket
Sign inDemoInstall

thaw

Package Overview
Dependencies
0
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    thaw

The narrow belt for AOP 🎀


Version published
Weekly downloads
65
increased by712.5%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 30 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc