metacatui
metacatui copied to clipboard
Move repeated method to Utilities module
The bytesToSize method is repeated in multiple files. This method should be moved to the Utilities module so that it can be used in multiple places without repeating the code, making it easier to maintain and update.
This will also help reduce the size of some of our larger files and make it easier to continue implementation of the file hierarchy table.
- [x] Add bytesToSize function to
src/js/common/Utilities.js- constants like
kibibyte = 1024should be defined asconstat the top of the file, after thedefinestatement and beforeconst Utilities = {}. See for example, see how we're starting to define CLASS_NAMES in views.
- constants like
- [x] Import the Utilities module in the files where the function is used, and use it instead of repeating the function in each file.
src/js/models/DataONEObject.jssrc/js/models/PackageModel.jssrc/js/models/SolrResult.jssrc/js/views/StatsView.js