Skip to content
Browse files

Had some typos.

  • Loading branch information...
1 parent 56b054c commit cd8d2b8433153b9d0306326a57025f0f18a00e13 @Kijewski Kijewski committed Mar 16, 2011
Showing with 16 additions and 18 deletions.
  1. +3 −2 Readme.md
  2. +12 −15 lib/mysql-pool/pool.js
  3. +1 −1 package.json
View
5 Readme.md
@@ -25,7 +25,7 @@ If you find an error, please file an [issue](https://github.com/Kijewski/node-my
This module was only tested using node >= 0.4.x. It may work for older versions,
but I am not going to actively support them.
-The node-mysql-pool works even with unknown forks of node-mysql, as long as
+The node-mysql-pool even works with unknown forks of node-mysql, as long as
* the last parameter of any method is the callback function,
* no events *at all* are emitted when supplying a callback function, and
@@ -109,7 +109,7 @@ Defaults:
* The number of connections to establish to the server.
* `pool.Client`:
* If you do not want the npm version of node-mysql—e.g. because you forked and
- tweaked it for you purposes—you can supply a different `Client` object.
+ tweaked it for your purposes—you can supply a different `Client` object.
* `pool.properties.xyz = undefined`:
* Property `xyz` of the `Client` object.
See the [original documentation](https://github.com/felixge/node-mysql/blob/master/Readme.md)
@@ -143,6 +143,7 @@ All methods of the `Client` object will be supported—with `connect(...)`, `end
If you do not use a fork, that are currently:
query(sql, [params], cb)
+ ping([cb]))
statistics([cb])
See the [original documentation](https://github.com/felixge/node-mysql/blob/master/Readme.md)
View
27 lib/mysql-pool/pool.js
@@ -8,15 +8,17 @@ function MySQLPool(properties) {
return new MySQLPool(properties);
}
- var self = this;
EventEmitter.call(this);
this.poolSize = 1;
this.Client = null;
this.properties = {};
+ // connections waiting for a query to execute
this._idleQueue = [];
+ // all connections that belong to this pool
this._connectionPool = [];
+ // queries to execute when a connection is ready
this._todoQueue = [];
for(var key in properties) {
@@ -108,11 +110,13 @@ MySQLPool.prototype.connect = function connect(n, cb) {
MySQLPool.prototype._forEach = function _forEach(params) {
// TODO: callback _once_
var pool = this;
+ var args = Array.prototype.slice.call(params.args);
+ var cb = args.pop();
function mkCallback(client) {
return function(err) {
if(params.cb) {
- params.cb.apply(client, arguments);
+ cb.apply(client, arguments);
} else if(err) {
pool.emit("error", err);
}
@@ -143,25 +147,18 @@ MySQLPool.prototype._populate = function _populate() {
if(key in COPY) {
return method;
}
+
if(key in FOR_EACH) {
- return function(cb) {
- var args = Array.prototype.slice.call(arguments, 1);
+ return function() {
return this._forEach({
- method: method,
- destroying: FOR_EACH[key],
- cb: cb,
- args: args
+ method:method, args:arguments, destroying:FOR_EACH[key]
});
};
}
- pool[key + "All"] = function(cb) {
- var args = Array.prototype.slice.call(arguments, 1);
+ pool[key + "All"] = function() {
return this._forEach({
- method: method,
- destroying: false,
- cb: cb,
- args: args
+ method:method, args:arguments, destroying:false
});
};
@@ -192,7 +189,7 @@ MySQLPool.prototype._populate = function _populate() {
}
for(key in this.Client.prototype) {
- if(!key.match(/^_/) && !(key in this) && !(key in EventEmitter.prototype)) {
+ if(!key.match(/^[_A-Z]/) && !(key in this) && !(key in EventEmitter.prototype)) {
this[key] = mkPrototypeMethod(this.Client.prototype[key], key);
}
}
View
2 package.json
@@ -1,7 +1,7 @@
{
"name": "mysql-pool",
"description": "MySQL connection pool for node.js on top of node-mysql.",
- "version": "0.1.0",
+ "version": "0.1.1",
"homepage": "https://github.com/Kijewski/node-mysql-pool",
"repository": {
"type": "git",

0 comments on commit cd8d2b8

Please sign in to comment.
Something went wrong with that request. Please try again.