Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
@aikar/dpromise
Advanced tools
Readme
Deferred Promises. Create a promise that allows deferring completion of the promise for more flexible control.
import {deferPromise} from "@aikar/dpromise";
// or
const {deferPromise} = require("@aikar/dpromise");
const promise = deferPromise();
promise.resolve();
promise.reject(new Error());
Standard promise creation implies that the creator of the promise will begin the process of how to fulfill the promise.
But what if that is not what you want? What if you want something else to fulfill the promise?
Deferred promises accomplish this by decoupling Promise creation from Promise fulfillment.
"Isn't this an anti pattern?" You may of heard that Promise.defer() and the like in Bluebird is an "anti-pattern", but rest assured, it is not.
Just because an experienced person says something, does not make it true. Anyone declaring that this is an anti pattern is expressing an OPINION.
And here I am expressing my opinion that they are wrong and used very poor reasoning for declaring such a statement.
Both the reasons stated at Bluebird are invalid.
If we are going to accuse a specific pattern to be an anti pattern because some developer used it when a better solution was available, then we might as well call the entire language an anti pattern.
Let's also mention that this pattern is part of the core system for Java 8+ Promise/Future support. To say this is an anti pattern, would be saying the same for the entire CompletableFuture system in Java.
This is a tool. There are many tools in your toolbox. Misusing a tool is not the tools fault.
Yes, they all return an object wrapper requiring you to do await result.promise;
This library returns an actual extended Promise object.
Override the Promise export this module exports (Not recommended)
require("@aikar/dpromise").Promise = require("bluebird");
dpromise (c) Daniel Ennis (Aikar) 2019-present. dpromise is licensed MIT. See LICENSE
FAQs
Deferred Promises. Create a promise that allows deferring completion of the promise for more flexible control.
We found that @aikar/dpromise 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
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).