File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ exports.uriToPath = uriToPath;
1515function Files ( base ) {
1616 function read ( uri , encoding ) {
1717 return resolveUri ( uri ) . then ( function ( path ) {
18- return readFile ( path , encoding ) . caught ( function ( error ) {
18+ return readFile ( path , encoding ) . catch ( function ( error ) {
1919 var message = "could not open external image: '" + uri + "' (document directory: '" + base + "')\n" + error . message ;
2020 return Promise . reject ( new Error ( message ) ) ;
2121 } ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ var bluebird = require("bluebird/js/release/promise")();
44exports . defer = defer ;
55exports . extend = extend ;
66exports . props = props ;
7- exports . promisify = bluebird . promisify ;
7+ exports . promisify = promisify ;
88exports . attempt = attempt ;
99exports . forEachSeries = forEachSeries ;
1010exports . toExternalPromise = toExternalPromise ;
@@ -24,6 +24,23 @@ exports.nfcall = function(func) {
2424 } ) ;
2525} ;
2626
27+ function promisify ( func ) {
28+ return function ( ) {
29+ var args = Array . prototype . slice . call ( arguments ) ;
30+
31+ return new Promise ( function ( resolve , reject ) {
32+ args . push ( function ( error , value ) {
33+ if ( error ) {
34+ reject ( error ) ;
35+ } else {
36+ resolve ( value ) ;
37+ }
38+ } ) ;
39+ func . apply ( null , args ) ;
40+ } ) ;
41+ } ;
42+ }
43+
2744function props ( obj ) {
2845 // We rely on .keys() and .values() returning properties in the same order.
2946 var keys = Object . keys ( obj ) ;
You can’t perform that action at this time.
0 commit comments