ui.file_manager.common.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * DevExtreme (ui/file_manager/ui.file_manager.common.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var _deferred = require("../../core/utils/deferred");
  11. var _common = require("../../core/utils/common");
  12. var _type = require("../../core/utils/type");
  13. var _type2 = _interopRequireDefault(_type);
  14. function _interopRequireDefault(obj) {
  15. return obj && obj.__esModule ? obj : {
  16. "default": obj
  17. }
  18. }
  19. var ErrorCode = {
  20. NoAccess: 0,
  21. FileExists: 1,
  22. FileNotFound: 2,
  23. DirectoryExists: 3,
  24. Other: 32767
  25. };
  26. var whenSome = function(arg, onSuccess, onError) {
  27. onSuccess = onSuccess || _common.noop;
  28. onError = onError || _common.noop;
  29. if (!Array.isArray(arg)) {
  30. arg = [arg]
  31. }
  32. var deferreds = arg.map(function(item, index) {
  33. return (0, _deferred.when)(item).then(function() {
  34. _type2.default.isFunction(onSuccess) && onSuccess()
  35. }, function(error) {
  36. if (!error) {
  37. error = {}
  38. }
  39. error.index = index;
  40. _type2.default.isFunction(onError) && onError(error)
  41. })
  42. });
  43. return _deferred.when.apply(null, deferreds)
  44. };
  45. module.exports = whenSome;
  46. module.exports.ErrorCode = ErrorCode;