lafy
is a ridiculously small module that adds a simpler way to promisify instance methods. It can obviously be used on normal promisifiable methods:const fs = require('fs'); const lafy = require('lafy'); // Don't want to bother promisifying a function ? let contents = await lafy(cb => fs.readFile("/etc/passwd", cb)); // Oh no, this class' methods use callbacks ;( // The only way to promisify methods would be to bind them to an instance const userManager = new UserManager(/* ... */); let users = await lafy(cb => userManager.getUsers(cb)); // Much simpler if you only need to do this once or twice !
npm install lafy
If you notice any bug or have a suggestion, please tell me about it in the issues, it will help everyone!
Tests are created with mocha and asserted with chai.expect and chai-as-promised.
You can run the suite using
npm test
lafy is licensed under the very permissive MIT License. You may use it for commercial projects if you comply to the license.