@unikue/ts-lang-utils 1.2.10 → 1.2.11

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.
@@ -0,0 +1 @@
1
+ export declare function formatBytes(bytes?: number | null, precision?: number): string | undefined;
@@ -0,0 +1,45 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util/FileUtils/formatBytes.ts
20
+ var formatBytes_exports = {};
21
+ __export(formatBytes_exports, {
22
+ formatBytes: () => formatBytes
23
+ });
24
+ module.exports = __toCommonJS(formatBytes_exports);
25
+ function formatBytes(bytes, precision = 2) {
26
+ if (bytes === void 0 || bytes === null) {
27
+ return void 0;
28
+ }
29
+ if (bytes <= 0 || !Number.isFinite(bytes)) {
30
+ return "0 B";
31
+ }
32
+ const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB"];
33
+ const base = 1024;
34
+ let unitIndex = 0;
35
+ let value = bytes;
36
+ while (value >= base && unitIndex < units.length - 1) {
37
+ value /= base;
38
+ unitIndex++;
39
+ }
40
+ return `${parseFloat(value.toFixed(precision))} ${units[unitIndex]}`;
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ formatBytes
45
+ });
@@ -1 +1,2 @@
1
+ export { formatBytes } from './formatBytes';
1
2
  export { readAsDataUrl } from './readAsDataUrl';
@@ -19,11 +19,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/util/FileUtils/index.ts
20
20
  var FileUtils_exports = {};
21
21
  __export(FileUtils_exports, {
22
+ formatBytes: () => import_formatBytes.formatBytes,
22
23
  readAsDataUrl: () => import_readAsDataUrl.readAsDataUrl
23
24
  });
24
25
  module.exports = __toCommonJS(FileUtils_exports);
26
+ var import_formatBytes = require("./formatBytes");
25
27
  var import_readAsDataUrl = require("./readAsDataUrl");
26
28
  // Annotate the CommonJS export names for ESM import in node:
27
29
  0 && (module.exports = {
30
+ formatBytes,
28
31
  readAsDataUrl
29
32
  });
@@ -0,0 +1 @@
1
+ export declare function formatBytes(bytes?: number | null, precision?: number): string | undefined;
@@ -0,0 +1,18 @@
1
+ export function formatBytes(bytes) {
2
+ var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
3
+ if (bytes === undefined || bytes === null) {
4
+ return undefined;
5
+ }
6
+ if (bytes <= 0 || !Number.isFinite(bytes)) {
7
+ return '0 B';
8
+ }
9
+ var units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB'];
10
+ var base = 1024;
11
+ var unitIndex = 0;
12
+ var value = bytes;
13
+ while (value >= base && unitIndex < units.length - 1) {
14
+ value /= base;
15
+ unitIndex++;
16
+ }
17
+ return "".concat(parseFloat(value.toFixed(precision)), " ").concat(units[unitIndex]);
18
+ }
@@ -1 +1,2 @@
1
+ export { formatBytes } from './formatBytes';
1
2
  export { readAsDataUrl } from './readAsDataUrl';
@@ -1 +1,2 @@
1
+ export { formatBytes } from "./formatBytes";
1
2
  export { readAsDataUrl } from "./readAsDataUrl";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unikue/ts-lang-utils",
3
- "version": "1.2.10",
3
+ "version": "1.2.11",
4
4
  "title": "TsLangUtils",
5
5
  "description": "Common lang utilities for typescript",
6
6
  "homepage": "https://unikueltd.github.io/ts-lang-utils",
@@ -55,11 +55,11 @@
55
55
  "@babel/runtime": "^7.29.7",
56
56
  "@imranbarbhuiya/duration": "^5.1.8",
57
57
  "lodash": "^4.18.1",
58
- "nanoid": "^3.3.15",
58
+ "nanoid": "^3.3.16",
59
59
  "universal-cookie": "^8.1.2"
60
60
  },
61
61
  "devDependencies": {
62
- "@eslint/eslintrc": "^3.3.5",
62
+ "@eslint/eslintrc": "^3.3.6",
63
63
  "@eslint/js": "^10.0.1",
64
64
  "@types/jest": "^30.0.0",
65
65
  "@types/lodash": "^4.17.24",
@@ -67,16 +67,16 @@
67
67
  "@unikue/typedoc-plugin-raw-content": "^1.1.1",
68
68
  "@unikue/typedoc-theme-dumi": "^1.1.3",
69
69
  "del-cli": "^7.0.0",
70
- "eslint": "^10.6.0",
70
+ "eslint": "^10.7.0",
71
71
  "eslint-plugin-jest": "^29.15.4",
72
- "father": "^4.6.25",
72
+ "father": "^4.6.31",
73
73
  "gh-pages": "^6.3.0",
74
74
  "globals": "^17.7.0",
75
75
  "jest-environment-jsdom": "^30.4.1",
76
76
  "ts-jest": "^29.4.11",
77
- "typedoc": "~0.28.19",
77
+ "typedoc": "~0.28.20",
78
78
  "typescript": "^6.0.3",
79
- "typescript-eslint": "^8.62.1"
79
+ "typescript-eslint": "^8.64.0"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "typescript": ">=4.0.0"