Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Indent code properly in README.md

  • Loading branch information...
commit b142d078942a1772ba87d783e851fa2c8935b8cc 1 parent 275326b
@cosbynator cosbynator authored
Showing with 17 additions and 17 deletions.
  1. +17 −17 README.md
View
34 README.md
@@ -163,29 +163,29 @@ will throw an Error.
To transparently handle object acquisition for a function,
one can use `pooled()`:
- var privateFn, publicFn;
- publicFn = pool.pooled(privateFn = function(client, arg, cb) {
- // Do something with the client and arg. Client is auto-released when cb is called
- cb(null, arg);
- });
+ var privateFn, publicFn;
+ publicFn = pool.pooled(privateFn = function(client, arg, cb) {
+ // Do something with the client and arg. Client is auto-released when cb is called
+ cb(null, arg);
+ });
Keeping both private and public versions of each function allows for pooled
functions to call other pooled functions with the same member. This is a handy
pattern for database transactions:
- var privateTop, privateBottom, publicTop, publicBottom;
- publicBottom = pool.pooled(privateBottom = function(client, arg, cb) {
- //Use client, assumed auto-release
- });
-
- publicTop = pool.pooled(privateTop = function(client, cb) {
- // e.g., open a database transaction
- privateBottom(client, "arg", function(err, retVal) {
- if(err) { return cb(err); }
- // e.g., close a transaction
- cb();
+ var privateTop, privateBottom, publicTop, publicBottom;
+ publicBottom = pool.pooled(privateBottom = function(client, arg, cb) {
+ //Use client, assumed auto-release
+ });
+
+ publicTop = pool.pooled(privateTop = function(client, cb) {
+ // e.g., open a database transaction
+ privateBottom(client, "arg", function(err, retVal) {
+ if(err) { return cb(err); }
+ // e.g., close a transaction
+ cb();
+ });
});
- });
## Pool info
Please sign in to comment.
Something went wrong with that request. Please try again.