-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tunnckoCore
committed
Oct 10, 2015
1 parent
58fc052
commit 056c828
Showing
4 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/*! | ||
* then-callback <https://github.com/hybridables/then-callback> | ||
* | ||
* Copyright (c) 2015 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk) | ||
* Released under the MIT license. | ||
*/ | ||
|
||
'use strict' | ||
|
||
var fs = require('fs') | ||
var path = require('path') | ||
var redolent = require('redolent') | ||
var readFile = redolent(fs.readFile) | ||
|
||
var thenCallback = require('../index') | ||
var promise = readFile(path.join(__dirname, '..', 'package.json'), 'utf8') | ||
promise = thenCallback(promise) | ||
|
||
promise.then(function (err, res) { | ||
if (err) return console.error(err) | ||
console.log(JSON.parse(res).name) // => 'then-callback' | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/*! | ||
* then-callback <https://github.com/hybridables/then-callback> | ||
* | ||
* Copyright (c) 2015 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk) | ||
* Released under the MIT license. | ||
*/ | ||
|
||
'use strict' | ||
|
||
var thenCallback = require('../index') | ||
var NativePromise = require('native-or-another')() | ||
|
||
// rejected promise | ||
var promise = NativePromise.reject(new Error('foo bar')) | ||
thenCallback(promise).then(console.log, console.error) // => Error: foo bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/*! | ||
* then-callback <https://github.com/hybridables/then-callback> | ||
* | ||
* Copyright (c) 2015 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk) | ||
* Released under the MIT license. | ||
*/ | ||
|
||
'use strict' | ||
|
||
var thenCallback = require('../index') | ||
var NativePromise = require('native-or-another')() | ||
|
||
// resolved promise | ||
var promise = NativePromise.resolve(123) | ||
thenCallback(promise).then(console.log, console.error) // => '123' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters