limulus / call-me-maybe Goto Github PK
View Code? Open in Web Editor NEWLet your JS API users either give you a callback or receive a promise
License: MIT License
Let your JS API users either give you a callback or receive a promise
License: MIT License
will this code from pongstr:
'use strict';
var next = function (f) {
setTimeout(f, 0);
};
module.exports = function maybe(cb, promise) {
if (cb) {
promise.then(
function (result) {
next(function () {
cb(null, result);
});
},
function (err) {
next(function () {
cb(err);
});
}
);
return undefined;
} else {
return promise;
}
};
will be merged anytime in this repository ?
i tried it and then it works, but if i want to use it in a docker container it always loads the current index, which causes me the global undefined error.
kind regards :)
Hello,
It would be great if the module could detect if bluebird promises are used instead of native ones. Currently returning 'undefined' yields a warning. null
should be returned instead.
Seems like by checking the version field of the Promise object is enough to determine if it's a native one or not. petkaantonov/bluebird#1237
Testing libraries that help developers mock timers will globally replace setTimeout
and setImmediate
. We only use these for getting an new call stack, so per taylorhakes/promise-polyfill#15, it is justified to keep these from getting replaced.
The change should be a simple addition of var setTimeout = setTimeout
, plus a comment to explain why we are doing it. Our usage of setImmediate
happens to already be protected, but a comment that covers that should be used as well.
The test is creating a dummy promise, which it then would be entirely disregarded as the test is checking that only the first resolve
operation actually fulfills.
This is the actual line: https://github.com/limulus/call-me-maybe/blob/master/test/maybeTest.js#L134
And here is the text output:
β should allow errors thrown in the callback to be uncaught
(node:13030) UnhandledPromiseRejectionWarning: Error: bah
at call-me-maybe/test/maybeTest.js:134:29
at call-me-maybe/index.js:11:28
at process._tickCallback (internal/process/next_tick.js:61:11)
(node:13030) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13030) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Such text output looks misleading as..
More so, this test will start failing once nodejs changes the warning into an error.
More info about the deprecation:
https://nodejs.org/api/deprecations.html#deprecations_dep0018_unhandled_promise_rejections
Solution:
The test could simple resolve a dummy value, like:
return Promise.resolve("bah")
Please let me know if this is worth a PR, I'm more than glad to submit one.
master
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can fix this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
An npm token must be created and set in the NPM_TOKEN
environment variable on your CI environment.
Please make sure to create an npm token and to set it in the NPM_TOKEN
environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/
.
Good luck with your project β¨
Your semantic-release bot π¦π
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.