@dignetwork/dig-sdk 0.0.1-alpha.13 → 0.0.1-alpha.14

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,3 +1,9 @@
1
1
  import { DataIntegrityTree } from "../DataIntegrityTree";
2
2
  export declare const addDirectory: (datalayer: DataIntegrityTree, dirPath: string, baseDir?: string) => Promise<void>;
3
+ /**
4
+ * Calculate the total size of the DIG_FOLDER_PATH
5
+ * @param folderPath - The path of the folder to calculate size.
6
+ * @returns The total size of the folder in bytes.
7
+ */
8
+ export declare const calculateFolderSize: (folderPath: string) => bigint;
3
9
  //# sourceMappingURL=directoryUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"directoryUtils.d.ts","sourceRoot":"","sources":["../../src/utils/directoryUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA2BzD,eAAO,MAAM,YAAY,cACZ,iBAAiB,WACnB,MAAM,YACN,MAAM,KACd,OAAO,CAAC,IAAI,CA2Cd,CAAC"}
1
+ {"version":3,"file":"directoryUtils.d.ts","sourceRoot":"","sources":["../../src/utils/directoryUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AA2BzD,eAAO,MAAM,YAAY,cACZ,iBAAiB,WACnB,MAAM,YACN,MAAM,KACd,OAAO,CAAC,IAAI,CA2Cd,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,eAAgB,MAAM,KAAG,MAiBxD,CAAC"}
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.addDirectory = void 0;
29
+ exports.calculateFolderSize = exports.addDirectory = void 0;
30
30
  const path = __importStar(require("path"));
31
31
  const fs = __importStar(require("fs"));
32
32
  const ignore_1 = __importDefault(require("ignore"));
@@ -86,3 +86,24 @@ const addDirectory = async (datalayer, dirPath, baseDir = dirPath) => {
86
86
  await limitConcurrency(10, tasks); // Adjust 10 based on your system limits
87
87
  };
88
88
  exports.addDirectory = addDirectory;
89
+ /**
90
+ * Calculate the total size of the DIG_FOLDER_PATH
91
+ * @param folderPath - The path of the folder to calculate size.
92
+ * @returns The total size of the folder in bytes.
93
+ */
94
+ const calculateFolderSize = (folderPath) => {
95
+ let totalSize = BigInt(0);
96
+ const files = fs.readdirSync(folderPath);
97
+ for (const file of files) {
98
+ const filePath = path.join(folderPath, file);
99
+ const stat = fs.statSync(filePath);
100
+ if (stat.isDirectory()) {
101
+ totalSize += (0, exports.calculateFolderSize)(filePath);
102
+ }
103
+ else {
104
+ totalSize += BigInt(stat.size);
105
+ }
106
+ }
107
+ return totalSize;
108
+ };
109
+ exports.calculateFolderSize = calculateFolderSize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dignetwork/dig-sdk",
3
- "version": "0.0.1-alpha.13",
3
+ "version": "0.0.1-alpha.14",
4
4
  "description": "",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/index.js",