
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
tiny-thenable
Advanced tools
This is a lightweight thenable implementation in JavaScript. It is entirely self-contained within a single function with no external dependencies, so it can be easily serialized to a web worker, for example.
This implementation conforms fully to the Promises/A+ spec, so it can safely interoperate with other thenable implementations.
However, it is not a full implementation of ES2015 Promises, e.g. it does not have the same constructor signature and does not expose a catch
method or the static resolve
/reject
/all
/race
initializer methods. If you need to hand a Thenable instance off to consuming code that may expect a true Promise, you'll want to wrap it in a native-or-polyfilled Promise first.
Why yet another Promises/A+ implementation? Great question. We needed a polyfill-like thing that was (a) wrapped in a single function for easy serialization across to a Worker, and (b) was as small as possible -- at ~900B minified (~500B gzipped) this is the smallest implementation I found at the time. And also, exercises like this are challenging and fun!
This began as a utility in troika-worker-utils as a way to use Promise
-like objects in web workers where the browser may not have a native Promise
implementation. The browser support landscape changed since such that native Promises can now be used reliably in that project, so this JS implementation has been extracted and placed here for posterity and for anyone else who might need such a thing.
npm install tiny-thenable
import Thenable from 'tiny-thenable'
const myThenable = Thenable()
myThenable.then(
result => {
console.log('Got result: ' + result)
},
error => {
console.error(error)
}
)
myThenable.resolve('OK!')
// or: myThenable.reject(new Error('Oopsie!'))
Since it has a then()
method, it should be usable as
There's also a Thenable.all([...thenables])
utility function that behaves like Promise.all()
.
FAQs
A small JavaScript implementation of Promises/A+ thenables
We found that tiny-thenable 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
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.