helpers.js 821 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. 'use strict';
  2. function noop() {}
  3. var defaultExts = {
  4. create: noop,
  5. before: noop,
  6. after: noop,
  7. error: noop,
  8. };
  9. function defaultExtensions(extensions) {
  10. extensions = extensions || {};
  11. return {
  12. create: extensions.create || defaultExts.create,
  13. before: extensions.before || defaultExts.before,
  14. after: extensions.after || defaultExts.after,
  15. error: extensions.error || defaultExts.error,
  16. };
  17. }
  18. function initializeResults(values) {
  19. var keys = Object.keys(values);
  20. var results = Array.isArray(values) ? [] : {};
  21. var idx = 0;
  22. var length = keys.length;
  23. for (idx = 0; idx < length; idx++) {
  24. var key = keys[idx];
  25. results[key] = undefined;
  26. }
  27. return results;
  28. }
  29. module.exports = {
  30. defaultExtensions: defaultExtensions,
  31. noop: noop,
  32. initializeResults: initializeResults,
  33. };