Skip to content

Instantly share code, notes, and snippets.

View aaaristo's full-sized avatar

Andrea Gariboldi aaaristo

View GitHub Profile
@aaaristo
aaaristo / newer.js
Last active October 10, 2018 14:09
a "ThreadLocal"-like context for asynchronous callback domains
function isIterator(obj)
{
return obj&&obj.next&&obj.throw;
}
function isRunWithContext(obj)
{
return obj&&typeof obj=='function'&&obj.ctx;
}
@mhevery
mhevery / Zone.md
Last active March 30, 2022 11:54
TC39 Zone Proposal

Zone Motivation

Make writing asynchronous code easier by having a consistent way of propagating "context" across related asynchronous operations. Have the "context" be responsible for async-local-storage, allowing the execution before and after hooks, and "context"-local error handling. Finally make sure that the "context"s are composable.

This feature needs to be part of the platform so that library and framework authors can relay on a common well know API, otherwise adoption will be limited.