Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ide/node-promised
Convert Node-style callbacks to promises, using the built-in Promise implementation
https://github.com/ide/node-promised
Last synced: 7 days ago
JSON representation
Convert Node-style callbacks to promises, using the built-in Promise implementation
- Host: GitHub
- URL: https://github.com/ide/node-promised
- Owner: ide
- License: mit
- Created: 2014-12-04T06:03:38.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-04T07:27:57.000Z (almost 10 years ago)
- Last Synced: 2024-10-05T01:17:21.672Z (about 1 month ago)
- Language: JavaScript
- Size: 156 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
`node-promised` is a small library to convert APIs with Node-style callbacks into promises. It is similar to "promisify" libraries except that it uses the built-in `Promise` implementation included with ES6.
# Usage
```js
// Define the Promise constructor if you are not using ES6
require('es6-promise').polyfill();var fs = require('fs');
var promised = require('node-promised');var promiseReadFile = promised(fs.readFile);
promiseReadFile('example.txt', 'utf8').then(function(contents) {
console.log('File contents:', contents);
}, function(error) {
console.error(error);
});
```# Tests
Run `npm test` to run the unit tests, which are written with [jest](https://facebook.github.io/jest/).