Last active
August 2, 2016 21:04
-
-
Save joepie91/f6a56acdae303e90e44a to your computer and use it in GitHub Desktop.
Revisions
-
joepie91 revised this gist
Aug 2, 2016 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ Promise.try(function(){ return fs.readFileAsync("./config.json").then(JSON.parse); }).catch({code: "ENOENT"}, function(err){ /* Return an empty object. */ return {}; }).then(function(config){ /* `config` now either contains the JSON-parsed configuration file, or an empty object if no configuration file existed. */ }); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ Promise.try(function(){ return fs.readFileAsync("./config.json").then(JSON.parse); }).catch(NonExistentFilePredicate, function(err){ /* Return an empty object. */ return {}; }).then(function(config){ /* `config` now either contains the JSON-parsed configuration file, or an empty object if no configuration file existed. */ }); -
joepie91 revised this gist
Oct 29, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ /* This example is ONLY for Bluebird 2.x. When using Bluebird 3.0 or newer, you should * use the updated example above instead. */ var Promise = require("bluebird"); var fs = Promise.promisifyAll(require("fs")); -
joepie91 revised this gist
Oct 29, 2015 . 2 changed files with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ /* UPDATED: This example has been changed to use the new object predicates, that were * introduced in Bluebird 3.0. If you are using Bluebird 2.x, you will need to use the * older example below, with the predicate function. */ var Promise = require("bluebird"); var fs = Promise.promisifyAll(require("fs")); Promise.try(function(){ return fs.readFileAsync("./config.json").then(JSON.parse); }).catch({code: "ENOENT"}, function(err){ /* Return an empty object. */ return Promise.resolve({}); }).then(function(config){ /* `config` now either contains the JSON-parsed configuration file, or an empty object if no configuration file existed. */ }); File renamed without changes. -
joepie91 revised this gist
May 2, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ var Promise = require("bluebird"); var fs = Promise.promisifyAll(require("fs")); var NonExistentFilePredicate = function(err) { return (err.code === "ENOENT"); }; -
joepie91 created this gist
Mar 12, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ var Promise = require("bluebird"); var fs = Promise.promisifyAll(require("fs")); var NonExistFilePredicate = function(err) { return (err.code === "ENOENT"); }; Promise.try(function(){ return fs.readFileAsync("./config.json").then(JSON.parse); }).catch(NonExistentFilePredicate, function(err){ /* Return an empty object. */ return Promise.resolve({}); }).then(function(config){ /* `config` now either contains the JSON-parsed configuration file, or an empty object if no configuration file existed. */ });