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

spex

Package Overview
Dependencies
Maintainers
0
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spex

Specialized Promise Extensions

  • 3.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

What is spex?

The 'spex' npm package is a specialized library for handling advanced promise operations in JavaScript. It provides a set of tools for managing and orchestrating multiple promises, making it easier to handle complex asynchronous workflows.

What are spex's main functionalities?

Batch Processing

Batch processing allows you to execute multiple promise-returning functions in parallel and collect their results. The example demonstrates how to use the 'batch' method to run an array of tasks and handle their results.

const spex = require('spex')();
const tasks = [
  () => Promise.resolve(1),
  () => Promise.resolve(2),
  () => Promise.resolve(3)
];
spex.batch(tasks)
  .then(data => {
    console.log(data); // [1, 2, 3]
  })
  .catch(error => {
    console.error(error);
  });

Sequence Processing

Sequence processing allows you to execute multiple promise-returning functions in sequence, one after another. The example demonstrates how to use the 'sequence' method to run an array of tasks sequentially and handle their results.

const spex = require('spex')();
const tasks = [
  () => Promise.resolve(1),
  () => Promise.resolve(2),
  () => Promise.resolve(3)
];
spex.sequence(tasks)
  .then(data => {
    console.log(data); // [1, 2, 3]
  })
  .catch(error => {
    console.error(error);
  });

Page Processing

Page processing allows you to handle paginated data sources. The example demonstrates how to use the 'page' method to process pages of data until the source function returns null.

const spex = require('spex')();
let pageIndex = 0;
const source = (index) => {
  if (index < 3) {
    return Promise.resolve(index);
  } else {
    return null;
  }
};
spex.page(source)
  .then(data => {
    console.log(data); // {pages: 3, total: 3}
  })
  .catch(error => {
    console.error(error);
  });

Other packages similar to spex

Keywords

FAQs

Package last updated on 13 Oct 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