utils.js 685 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * Copyright (c) 2014, Yahoo Inc. All rights reserved.
  3. * Copyrights licensed under the New BSD License.
  4. * See the accompanying LICENSE file for terms.
  5. */
  6. 'use strict';
  7. exports.assign = Object.assign || require('object.assign');
  8. exports.passError = passError;
  9. exports.passValue = passValue;
  10. // -----------------------------------------------------------------------------
  11. function passError(callback) {
  12. return function (reason) {
  13. setImmediate(function () {
  14. callback(reason);
  15. });
  16. };
  17. }
  18. function passValue(callback) {
  19. return function (value) {
  20. setImmediate(function () {
  21. callback(null, value);
  22. });
  23. };
  24. }