
Research
Shai-Hulud Descends to Hades: Miasma Worm Campaign Spreads with New PyPI Wave
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.
TeePromise is a very simple utility subclass that makes promises more convenient to use in some situations by exposing `resolve` and `reject` on the promise object itself.
TeePromise is a very simple utility subclass that makes promises more convenient to use
in some situations by exposing resolve and reject on the promise object itself.
const tp = new TeePromise();
tp.resolve(5); // resolve a value
tp.reject(new Error('oops')); // reject a value
await tp; // await a value
Some use cases include:
Shortcomings:
Promise.withResolvers():Promise.withResolvers() - you get the promise, and separately resolve and reject.
const { promise, resolve } = Promise.withResolvers();
doSomethingAsync(value => resolve(value));
return promise;
TeePromise - you get a thenable which also implements resolve and reject.
const tp = new TeePromise();
doSomethingAsync(value => tp.resolve(value));
return tp;
In the implementation of a job queue, TeePromise makes it convenient to include resolve
in an entry of the queue without introducing any unnecessary Promise constructor.
class SomeQueueMananger {
// ...
print (document) {
const tp = new TeePromise();
this.entries.push({
...entry,
donePrinting: printCompletionInfo => {
tp.resolve(printCompletionInfo);
},
});
return tp;
}
}
When a component must return a promise that is resolved or rejected only when the user acts (e.g. clicks OK or Cancel), TeePromise keeps the API simple.
function confirm (message) {
const tp = new TeePromise();
showModal({
message,
onOk: () => tp.resolve(true),
onCancel: () => tp.resolve(false),
});
return tp;
}
TeePromise is useful when you need to reject a promise from outside, for example when implementing a timeout or an abort signal.
function withTimeout (promise, ms) {
const tp = new TeePromise();
promise.then(tp.resolve, tp.reject);
const id = setTimeout(() => tp.reject(new Error('timeout')), ms);
tp.then(() => clearTimeout(id), () => clearTimeout(id));
return tp;
}
When wrapping a callback-based API, you can avoid the Promise constructor and pass
resolve and reject directly into the callback.
function readFile (path) {
const tp = new TeePromise();
fs.readFile(path, (err, data) => {
if (err) tp.reject(err);
else tp.resolve(data);
});
return tp;
}
FAQs
TeePromise is a very simple utility subclass that makes promises more convenient to use in some situations by exposing `resolve` and `reject` on the promise object itself.
The npm package teepromise receives a total of 26 weekly downloads. As such, teepromise popularity was classified as not popular.
We found that teepromise demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Research
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.