Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ node_modules
.settings.xml
.settings
.c9revisions
/nbproject/private/
/nbproject/private/
.idea
21 changes: 19 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var fs = require("fs");
var mime = require("mime");
var Util = require("./util");
var Url = require("url");
var Promise = require('es6-promise').Promise;

/** section: github
* class Client
Expand Down Expand Up @@ -349,7 +350,10 @@ var Client = module.exports = function(config) {
};
}

self[section][funcName] = function(msg, callback) {



self[section][funcName] = function(msg, callback){
try {
parseParams(msg, block.params);
}
Expand All @@ -363,7 +367,20 @@ var Client = module.exports = function(config) {
return;
}

api[section][funcName].call(api, msg, block, callback);
// good description for standart: http://www.html5rocks.com/en/tutorials/es6/promises/
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

standard*

return new Promise(function (resolve, reject) {
api[section][funcName].call(api, msg, block, function(err, response){
if (Util.isFunction(callback)) {
callback.apply(null, arguments)
}

if (Util.isNull(err)) {
resolve(response);
} else {
reject(err);
}
});
});
};
}
else {
Expand Down
71 changes: 40 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
{
"name" : "github",
"version" : "0.2.3",
"description" : "NodeJS wrapper for the GitHub API",
"author": "Mike de Boer <[email protected]>",
"contributors": [
{ "name": "Mike de Boer", "email": "[email protected]" },
{ "name": "Fabian Jakobs", "email": "[email protected]" }
],
"homepage": "http://github.com/mikedeboer/node-github",
"repository" : {
"type" : "git",
"url" : "http://github.com/mikedeboer/node-github.git"
"name": "github",
"version": "0.2.3",
"description": "NodeJS wrapper for the GitHub API",
"author": "Mike de Boer <[email protected]>",
"contributors": [
{
"name": "Mike de Boer",
"email": "[email protected]"
},
"engine" : {
"node": ">=0.4.0"
},
"dependencies": {
"mime": "^1.2.11"
},
"devDependencies": {
"oauth": "~0.9.7",
"optimist": "~0.6.0",
"mocha": "~1.13.0"
},
"main" : ".",
"scripts": {
"test": "node ./test/all.js"
},
"licenses": [{
"type": "The MIT License",
"url": "http://www.opensource.org/licenses/mit-license.php"
}]
{
"name": "Fabian Jakobs",
"email": "[email protected]"
}
],
"homepage": "http://github.com/mikedeboer/node-github",
"repository": {
"type": "git",
"url": "http://github.com/mikedeboer/node-github.git"
},
"engine": {
"node": ">=0.4.0"
},
"dependencies": {
"es6-promise": "^2.0.1",
"mime": "^1.2.11"
},
"devDependencies": {
"oauth": "~0.9.7",
"optimist": "~0.6.0",
"mocha": "~1.13.0"
},
"main": ".",
"scripts": {
"test": "node ./test/all.js"
},
"licenses": [
{
"type": "The MIT License",
"url": "http://www.opensource.org/licenses/mit-license.php"
}
]
}
22 changes: 18 additions & 4 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ var _slice = Array.prototype.slice;
* - arg1 (mixed): messages to be printed to the standard output
* - type (String): type denotation of the message. Possible values:
* 'info', 'error', 'fatal', 'exit'. Optional, defaults to 'info'.
*
*
* Unified logging to the console; arguments passed to this function will put logged
* to the standard output of the current process and properly formatted.
* Any non-String object will be inspected by the NodeJS util#inspect utility
* function.
* Messages will be prefixed with its type (with corresponding font color), like so:
*
*
* [info] informational message
* [error] error message
* [fatal] fatal error message
* [exit] program exit message (not an error)
*
* The type of message can be defined by passing it to this function as the last/
*
* The type of message can be defined by passing it to this function as the last/
* final argument. If the type can not be found, this last/ final argument will be
* regarded as yet another message.
**/
Expand All @@ -138,3 +138,17 @@ exports.log = function() {
console.log(pfx + " " + line);
});
};



exports.isUndefined = function isUndefined(x) {
return typeof x === 'undefined';
};

exports.isNull = function isNull(x) {
return x === null;
};

exports.isFunction = function isFunction(x) {
return typeof x === 'function';
};