Socket
Socket
Sign inDemoInstall

@hapi/teamwork

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hapi/teamwork

Wait for multiple callback


Version published
Weekly downloads
1.3M
increased by2.38%
Maintainers
1
Weekly downloads
 
Created

What is @hapi/teamwork?

@hapi/teamwork is a utility for managing asynchronous tasks and their completion. It provides a simple way to create and manage promises, making it easier to handle multiple asynchronous operations and their results.

What are @hapi/teamwork's main functionalities?

Creating a Teamwork instance

This feature allows you to create a new instance of Teamwork, which can be used to manage a group of asynchronous tasks.

const Teamwork = require('@hapi/teamwork');
const team = new Teamwork();

Registering tasks

This feature allows you to register asynchronous tasks with the Teamwork instance. The `attend` method is used to add a task to the team.

const Teamwork = require('@hapi/teamwork');
const team = new Teamwork();

async function asyncTask() {
  // Simulate an async task
  return new Promise((resolve) => setTimeout(resolve, 1000));
}

team.attend(asyncTask());

Waiting for all tasks to complete

This feature allows you to wait for all registered tasks to complete. The `work` property returns a promise that resolves when all tasks have finished.

const Teamwork = require('@hapi/teamwork');
const team = new Teamwork();

async function asyncTask() {
  // Simulate an async task
  return new Promise((resolve) => setTimeout(resolve, 1000));
}

team.attend(asyncTask());
team.attend(asyncTask());

team.work.then(() => {
  console.log('All tasks completed');
});

Other packages similar to @hapi/teamwork

Keywords

FAQs

Package last updated on 04 Jan 2020

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