
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Execute a function ambidextrously (normalizes the differences between synchronous and asynchronous functions). Useful for treating synchronous functions as asynchronous functions (like supporting both synchronous and asynchronous event definitions automat
Execute a function ambidextrously (normalizes the differences between synchronous and asynchronous functions). Useful for treating synchronous functions as asynchronous functions (like supporting both synchronous and asynchronous event definitions automatically).
require('ambi')
npm install --save ambi
require('ambi')
ender add ambi
// Import
var ambi = require('ambi');
var result;
// Sample methods
var syncMethod = function(x,y){
return x*y;
};
var asyncMethod = function(x,y,next){
return setTimeout(function(){
next(null,x*y);
},0);
};
// Call the synchronous function asynchronously
result = ambi(syncMethod, 5, 2, function(err,result){ // ambi adds support for this asynchronous callback automatically
console.log(err, result); // null, 10
});
console.log(result); // 10 - just like normal
// Call the asynchronous function asynchronously
result = ambi(asyncMethod, 5, 2, function(err,result){ // ambi doesn't do anything special here
console.log(err, result); // null, 10
});
console.log(result); // setTimeout - just like normal
(method, args...)
method
is the function to executeargs...
is the arguments to send to the method
(err, results...)
err
argumenterr
argument equal to null, and a result
argument equal to the returned result of the synchronous method[methodToFire, methodToIntrospect]
as the method
argumentDiscover the change history by heading on over to the History.md
file.
Discover how you can contribute by heading on over to the Contributing.md
file.
These amazing people are maintaining this project:
No sponsors yet! Will you be the first?
These amazing people have contributed code to this project:
Licensed under the incredibly permissive MIT license
Copyright © 2013+ Bevry Pty Ltd us@bevry.me (http://bevry.me)
Copyright © 2011-2012 Benjamin Lupton b@lupton.cc (http://balupton.com)
v2.1.6 2013 November 1
FAQs
Ambi lets you execute any function ambidextrously; providing you the ability to execute any function (be it synchronous, asynchronous, returns, callbacks, promises) as if it returned a promise.
The npm package ambi receives a total of 60,316 weekly downloads. As such, ambi popularity was classified as popular.
We found that ambi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.