wrapThunk.js 526 B

123456789101112131415161718
  1. 'use strict';
  2. /*!
  3. * A query thunk is the function responsible for sending the query to MongoDB,
  4. * like `Query#_findOne()` or `Query#_execUpdate()`. The `Query#exec()` function
  5. * calls a thunk. The term "thunk" here is the traditional Node.js definition:
  6. * a function that takes exactly 1 parameter, a callback.
  7. *
  8. * This function defines common behavior for all query thunks.
  9. */
  10. module.exports = function wrapThunk(fn) {
  11. return function _wrappedThunk(cb) {
  12. ++this._executionCount;
  13. fn.call(this, cb);
  14. };
  15. };