CancelToken and Cancel Polyfill
This a polyfill of the polyfillable parts of the proposed cancellable promises spec.
See https://github.com/littledan/proposal-cancelable-promises for more details.
Use
; const source = CancelTokensource; const result = ; eventSource; // This may throw a Cancel if we called source.cancel().const value = await result; // Elsewhere, maybe in another library { await ; // I'm outside of a critical section here, so it's ok if I were to throw. cancelToken; return ;}
Developing
To test:
npm test
To watch source files and rerun tests when they change:
npm test:watch