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 = 1024 should be defined as const at the top of the file, after the define statement and before const Utilities = {}. See for example, see how we're starting to define CLASS_NAMES in views.
[x] Import the Utilities module in the files where the function is used, and use it instead of repeating the function in each file.
The
bytesToSize
method is repeated in multiple files. This method should be moved to theUtilities
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.
src/js/common/Utilities.js
kibibyte = 1024
should be defined asconst
at the top of the file, after thedefine
statement and beforeconst Utilities = {}
. See for example, see how we're starting to define CLASS_NAMES in views.src/js/models/DataONEObject.js
src/js/models/PackageModel.js
src/js/models/SolrResult.js
src/js/views/StatsView.js