validate-but-with-9-custom-methods.fixture.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Module dependencies
  3. */
  4. var parley = require('../../');
  5. /**
  6. * validate-but-with-9-custom-methods.fixture.js
  7. *
  8. * A simplified mock of a hypothetical `validate()` model method,
  9. * just like the other fixture (see `validate.fixture.js`) but with 9
  10. * distinct custom methods available on the Deferred instance.
  11. * (This is primarily for use in benchmarks.)
  12. *
  13. * @param {Function} explicitCbMaybe
  14. *
  15. * @returns {Deferred} If no callback specified
  16. */
  17. module.exports = function validateButWith9CustomMethods(explicitCbMaybe){
  18. // This deferred may or may not actually need to get built.
  19. //
  20. // If an explicit callback was specified, then go ahead
  21. // and proceed to where the real action is at & return `undefined`.
  22. // Otherwise, no callback was specified explicitly,
  23. // so we'll build and return a Deferred instance instead.
  24. var deferred = parley(function (finalCb){
  25. // Now actually do stuff.
  26. // ...except actually don't-- this is just pretend.
  27. // All done.
  28. return finalCb();
  29. }, explicitCbMaybe, {
  30. a: function (beep, boop) { this._mathIsFun = (Math.random()+'hi0'); return this; },
  31. b: function (baa, baaa, black, sheep) { this._mathIsFun = (Math.random()+'hi1'); return this; },
  32. c: function (beep, boop) { this._mathIsFun = (Math.random()+'hi2'); return this; },
  33. d: function (baa, baaa, black, sheep) { this._mathIsFun = (Math.random()+'hi3'); return this; },
  34. e: function (beep, boop) { this._mathIsFun = (Math.random()+'hi5'); return this; },
  35. f: function (baa, baaa, black, sheep) { this._mathIsFun = (Math.random()+'hi5'); return this; },
  36. g: function (beep, boop) { this._mathIsFun = (Math.random()+'hi6'); return this; },
  37. h: function (baa, baaa, black, sheep) { this._mathIsFun = (Math.random()+'hi7'); return this; },
  38. i: function (beep, boop) { this._mathIsFun = (Math.random()+'hi8'); return this; },
  39. });
  40. return deferred;
  41. };