Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Mar 30, 2024 via pnpm

universalify 2.0.0

Make a callback- or promise-based function support both promises and callbacks.
Package summary
Share
0
issues
1
license
1
MIT
Package created
8 Apr 2017
Version published
25 Jul 2020
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
universalify@2.0.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of universalify 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does universalify do?

Universalify is a powerful npm package that enhances the functionality of callback- or promise-based functions to support both promises and callbacks. By leveraging JavaScript's native promise implementation, Universalify ensures wide-ranging compatibility and enhanced functionality.

How do you use universalify?

Using Universalify is an intuitive process. Upon installing the package with 'npm install universalify', two primary methods can be utilized: 'universalify.fromCallback(fn)' and 'universalify.fromPromise(fn)'.

When dealing with callback-based functions, the 'fromCallback' method can be employed as follows:

const universalify = require('universalify');
function callbackFn(n, cb) {
  setTimeout(() => cb(null, n), 15);
}
const fn = universalify.fromCallback(callbackFn);

This function can work with both Promises and Callbacks. For Promises, the usage would look like this:

fn('Hello World!')
.then(result => console.log(result))
.catch(error => console.error(error));

And for Callbacks:

fn('Hi!', (error, result) => {
  if (error) return console.error(error);
  console.log(result);  // -> Hi!
});

For Promise-based functions 'fromPromise' method can be utilized:

const universalify = require('universalify');
function promiseFn(n) {
  return new Promise(resolve => {
    setTimeout(() => resolve(n), 15);
  });
}
const fn = universalify.fromPromise(promiseFn);

The function can be used with Promises and Callbacks in a similar way as shown above.

Where are the universalify docs?

The documentation for Universalify is primarily accessible on the GitHub page of the package. Simply visit 'https://github.com/RyanZim/universalify' to access detailed explanations, usage scenarios, and example codes. It's a comprehensive repository of knowledge for developers looking to get the most out of the Universalify package.