Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/johnhof/tfy
Simple thenify wrapper with context binding
https://github.com/johnhof/tfy
Last synced: 20 days ago
JSON representation
Simple thenify wrapper with context binding
- Host: GitHub
- URL: https://github.com/johnhof/tfy
- Owner: johnhof
- License: mit
- Created: 2016-02-09T22:42:21.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-09T23:29:04.000Z (almost 9 years ago)
- Last Synced: 2024-10-26T01:25:54.819Z (20 days ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tfy
Simple thenify wrapper with context binding. See [thenify](https://github.com/thenables/thenify) for more documentation
```javascript
'use strict';let co = require('co');
let tfy = require('tfy');
let thenify = require('thenify');function Foo () { this.name = 'bar'; }
Foo.prototype.getName = function (cb) { cb(null, this.name); }co(function *() {
let foo = new Foo();
let thenified;
let result;result = yield thenify(foo.getName)(); // thenified and context not bound
console.log(result); // undefinedresult = yield tfy(foo.getName)(); // thenified and context not bound
console.log(result); // undefinedresult = yield tfy(foo.getName, foo); // thenified, and context bound
console.log(result) // 'bar'}).catch((e) => { console.log(e.stack); });
```