graphics.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* eslint-disable
  2. max-len,
  3. */
  4. // TODO: This file was created by bulk-decaffeinate.
  5. // Fix any style issues and re-enable lint.
  6. /*
  7. * decaffeinate suggestions:
  8. * DS102: Remove unnecessary code created because of implicit returns
  9. * DS103: Rewrite code to no longer use __guard__
  10. * DS207: Consider shorter variations of null checks
  11. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  12. */
  13. import App from '../../../base'
  14. export default App.factory('graphics', function(ide) {
  15. const Graphics = {
  16. getGraphicsFiles() {
  17. const graphicsFiles = []
  18. ide.fileTreeManager.forEachEntity(function(entity, folder, path) {
  19. if (
  20. entity.type === 'file' &&
  21. __guardMethod__(
  22. entity != null ? entity.name : undefined,
  23. 'match',
  24. o => o.match(/.*\.(png|jpg|jpeg|pdf|eps)/i)
  25. )
  26. ) {
  27. const cloned = _.clone(entity)
  28. cloned.path = path
  29. return graphicsFiles.push(cloned)
  30. }
  31. })
  32. return graphicsFiles
  33. }
  34. }
  35. return Graphics
  36. })
  37. function __guardMethod__(obj, methodName, transform) {
  38. if (
  39. typeof obj !== 'undefined' &&
  40. obj !== null &&
  41. typeof obj[methodName] === 'function'
  42. ) {
  43. return transform(obj, methodName)
  44. } else {
  45. return undefined
  46. }
  47. }