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

degenerator

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

degenerator

Turns sync functions into async generator functions

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9M
increased by3.12%
Maintainers
1
Weekly downloads
 
Created

What is degenerator?

The 'degenerator' npm package is a tool that allows you to convert asynchronous functions using callbacks into functions that return Promises. It is particularly useful for adapting older, callback-style codebases to modern Promise-based patterns or async/await syntax in JavaScript.

What are degenerator's main functionalities?

Converting callback-based functions to Promises

This feature allows you to wrap a traditional callback-based function, such as 'fs.readFile', into a function that returns a Promise. This makes it easier to work with asynchronous code using 'then' and 'catch' methods or async/await syntax.

const degenerator = require('degenerator');
const fs = require('fs');

const readFilePromise = degenerator(fs.readFile, { callback: true });

readFilePromise('example.txt', 'utf8').then(contents => {
  console.log(contents);
}).catch(error => {
  console.error('Error reading file:', error);
});

Other packages similar to degenerator

FAQs

Package last updated on 18 Oct 2019

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