xjs-node 3.1.1 → 3.2.0

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.
@@ -29,7 +29,11 @@ export declare namespace UFile {
29
29
  function readAsJson<T = any>(p: MaybeArray<string>, d?: any, encoding?: BufferEncoding): Promise<T>;
30
30
  function cp(from: MaybeArray<string>, to: MaybeArray<string>): Promise<void>;
31
31
  function mv(from: MaybeArray<string>, to: MaybeArray<string>): Promise<void>;
32
- function ls(p: MaybeArray<string>): string[];
32
+ function ls(p: MaybeArray<string>, withStats: true): {
33
+ fname: string;
34
+ stats: fs.Stats;
35
+ }[];
36
+ function ls(p: MaybeArray<string>, withStats?: boolean): string[];
33
37
  /**
34
38
  * check availability to export a file with specified directory and file name.
35
39
  * if it doesn't, this retries to check after appending incremental number to the filename excluding an extension (e.g. `aaa_1.txt`).
@@ -120,11 +120,12 @@ var UFile;
120
120
  });
121
121
  }
122
122
  UFile.mv = mv;
123
- function ls(p) {
123
+ function ls(p, withStats) {
124
124
  const pt = (0, u_1.joinPath)(p);
125
125
  if (!pt || !fs.statSync(pt).isDirectory())
126
126
  throw new xjs_common_1.XjsErr(s_errCode, "Specified path for ls is not directory.");
127
- return fs.readdirSync(pt);
127
+ const fnames = fs.readdirSync(pt);
128
+ return withStats ? fnames.map(f => ({ fname: f, stats: status([pt, f]) })) : fnames;
128
129
  }
129
130
  UFile.ls = ls;
130
131
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xjs-node",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "library modules for nodejs + typescript that bundled general-purpose implementations.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,8 @@
33
33
  "devDependencies": {
34
34
  "@types/node": "^24.2.1",
35
35
  "tsx": "^4.20.3",
36
- "typescript": "^5.8.3"
36
+ "typescript": "^5.8.3",
37
+ "xjs-test": "^1.1.0"
37
38
  },
38
39
  "dependencies": {
39
40
  "xjs-common": "^13.6.1"