Thursday 24 March 2016

I made a module that adds features to native Promises, and that also polyfills promises if they dont exist

I've never published a module before so I would love feedback (code/documentation/feature/any feedback is welcome):http://ift.tt/1UPiQGM basically, I wanted to use native JS Promises, I wanted spread and delay from Q, and I didn't want to special case old browsers / versions of node that don't support promises.So I made this library which polyfills Promises for old versions of JS, and that also sprinkles some useful features similar to Q in: spread, delay, makeNodeResolver, fcall, all(), nbind, ninvoke, nfcall, nfapply, denodify, nbind and npost.I also made a (somewhat controversial I imagine) decision to extend objects with a $promise method that makes it very easy to convert any non-promise returning function into something promise compliant:Fs.$promise('readFile', 'foo.txt').then(function(text){ ... }); (so you can call obj.$promise('methodName, arg0, arg1, ..) on any object and it will wrap it as a promise)So yeah, I would love to get some feedback on this, give it to me straight!

Submitted March 24, 2016 at 11:42PM by Macmee

No comments:

Post a Comment