Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kareem

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kareem

Next-generation take on pre/post function hooks

  • 2.6.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is kareem?

Kareem is a lightweight middleware framework for handling pre and post hooks in JavaScript. It is often used in conjunction with Mongoose to manage middleware for MongoDB operations, but it can be used independently for any asynchronous control flow.

What are kareem's main functionalities?

Pre Hooks

Pre hooks allow you to run functions before a specified event. In this example, a pre-save hook is defined and executed before the 'save' event.

const Kareem = require('kareem');
const hooks = new Kareem();

hooks.pre('save', function(next) {
  console.log('This is a pre-save hook');
  next();
});

hooks.execPre('save', null, function() {
  console.log('Pre-save hooks executed');
});

Post Hooks

Post hooks allow you to run functions after a specified event. In this example, a post-save hook is defined and executed after the 'save' event.

const Kareem = require('kareem');
const hooks = new Kareem();

hooks.post('save', function() {
  console.log('This is a post-save hook');
});

hooks.execPost('save', null, [function() {
  console.log('Post-save hooks executed');
}]);

Parallel Hooks

Parallel hooks allow you to run multiple hooks in parallel. In this example, two pre-save hooks are defined to run in parallel before the 'save' event.

const Kareem = require('kareem');
const hooks = new Kareem();

hooks.pre('save', true, function(next, done) {
  setTimeout(function() {
    console.log('First parallel pre-save hook');
    done();
  }, 100);
});

hooks.pre('save', true, function(next, done) {
  setTimeout(function() {
    console.log('Second parallel pre-save hook');
    done();
  }, 50);
});

hooks.execPre('save', null, function() {
  console.log('All parallel pre-save hooks executed');
});

Other packages similar to kareem

FAQs

Package last updated on 05 Apr 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc