@castlabs/ui 7.23.1 → 7.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /* @castlabs/ui v7.23.1 */
1
+ /* @castlabs/ui v7.23.2 */
2
2
 
3
3
  /*!
4
4
  * Bootstrap v5.3.8 (https://getbootstrap.com/)
@@ -1285,16 +1285,22 @@ function clSubselectorQuery (main, subselectors) {
1285
1285
  // -----------------------------------------------------------------------------
1286
1286
 
1287
1287
  /**
1288
- * Convert bytes into human-readable format.
1288
+ * Convert bytes into human-readable format. It will always show the 4 most significant digits be that before or after the comma.
1289
1289
  *
1290
1290
  * @param {Number} bytes Bytes to format, e.g. 1212345678.
1291
- * @return {String} Formatted size, e.g. '12MB'.
1291
+ * @return {String} Formatted size, e.g. '12.12MB'.
1292
1292
  */
1293
1293
  function clFormatFilesize (bytes) {
1294
- if (bytes < 1024) return `${bytes}B`
1295
- if (bytes < 1024 * 1024) return `${Math.floor(bytes / 1024)}kB`
1296
- if (bytes < 1024 * 1024 * 1024) return `${Math.floor(bytes / 1024 / 1024)}MB`
1297
- return `${Math.floor(bytes / 1024 / 1024 / 1024)}GB`
1294
+ const most = value => value.toFixed(5).substr(0, 5).replace(/\.$/, '')
1295
+
1296
+ if (bytes === 1) return '1 byte'
1297
+ if (bytes < 1024) return `${bytes} bytes`
1298
+ if (bytes < 1024 * 1024) return `${most(bytes / 1024)} kB`
1299
+ if (bytes < 1024 * 1024 * 1024) return `${most(bytes / 1024 / 1024)} MB`
1300
+ if (bytes < 1024 * 1024 * 1024 * 1024) return `${most(bytes / 1024 / 1024 / 1024)} GB`
1301
+ if (bytes < 1024 * 1024 * 1024 * 1024 * 1024)
1302
+ return `${most(bytes / 1024 / 1024 / 1024 / 1024)} TB`
1303
+ return `${Math.floor(bytes / 1024 / 1024 / 1024 / 1024)} TB`
1298
1304
  }
1299
1305
 
1300
1306
  /**