aplus-promesse
v1.0.2
Published
A functional style Promises/A+ implementation that aims to be concise and clean.
Downloads
4
Readme
Promesse
Promesse is a Promises/A+ compliant Promise library. This implementation passes all the tests of the standard test suite.
Why oh Why?
I've written it because I love using promises in JS and I like to know how the tools I use work.
There are many implementations out there, I wanted mine to be very small and written as much as possible in functional programming style.
I'm rather happy about the result:
- 100 lines of code (no comments, comments are for the weak), so probably one of the shortest implementations out there
- looks a bit like Haskell :)
It's been a really enriching experience, now I know a lot more about the subtleties of promises than any documentation would tell.
Besides, working against an existing huge test suite is a cool programming exercise.
Installing
This is probably not very useful since promises are standard, but, if for some reason you need to:
npm i --save aplus-promesse
Testing
git clone https://github.com/djfm/promesse
cd promesse
npm i
npm test
There are two test suites, the one from Promises/A+, and the one I wrote to help me when I did not understand the feedback from the official tests.
Making it Smaller
Now that the library is working and tested, I want to make it smaller in terms of number of lines of code.
The rules are:
- lines must not exceed 80 columns
- block declarations (by that I mean a declaration that takes more than one line or a succession of one line declarations) and top level declarations are followed with one blank line at least
- more subjectively: the code needs to remain easy to read