Skip to content

Commit

Permalink
code refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Oct 2, 2016
1 parent dc0fcf5 commit 5ed380e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/database.js
Expand Up @@ -285,7 +285,7 @@ function Database(cn, dc, config) {
return new $npm.context(cn, dc, config.options);
}

function singleValue(value, cb, thisArg) {
function transform(value, cb, thisArg) {
if (typeof cb === 'function') {
value = value.then(function (data) {
return cb.call(thisArg, data);
Expand Down Expand Up @@ -395,7 +395,7 @@ function Database(cn, dc, config) {
*/
obj.one = function (query, values, cb, thisArg) {
var v = obj.query.call(this, query, values, $npm.result.one);
return singleValue(v, cb, thisArg);
return transform(v, cb, thisArg);
};

/**
Expand Down Expand Up @@ -489,7 +489,7 @@ function Database(cn, dc, config) {
*/
obj.oneOrNone = function (query, values, cb, thisArg) {
var v = obj.query.call(this, query, values, $npm.result.one | $npm.result.none);
return singleValue(v, cb, thisArg);
return transform(v, cb, thisArg);
};

/**
Expand Down Expand Up @@ -628,7 +628,7 @@ function Database(cn, dc, config) {
*/
obj.result = function (query, values, cb, thisArg) {
var v = obj.query.call(this, query, values, $npm.special.cache.resultQuery);
return singleValue(v, cb, thisArg);
return transform(v, cb, thisArg);
};

/**
Expand Down Expand Up @@ -722,7 +722,7 @@ function Database(cn, dc, config) {
*/
obj.proc = function (procName, values, cb, thisArg) {
var v = obj.func.call(this, procName, values, $npm.result.one | $npm.result.none);
return singleValue(v, cb, thisArg);
return transform(v, cb, thisArg);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "pg-promise",
"version": "5.3.3",
"version": "5.3.4",
"description": "Promises interface for PostgreSQL",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit 5ed380e

Please sign in to comment.