xjs-node 3.1.1 → 3.2.1

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.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![npm][npm-badge]][npm-url] [![CI][ci-badge]][ci-url] [![publish][publish-badge]][publish-url]
2
2
 
3
3
  # Overview
4
- Library modules for nodejs + typescript that bundled general-purpose implementations.
4
+ Library modules for nodejs + typescript that bundle general-purpose implementations.
5
5
  This module focuses on implementation that extends nodejs builtin modules, and dependency is only [xjs-common](https://github.com/begyyal/xjs_common).
6
6
 
7
7
  # Install
@@ -6,7 +6,7 @@ export declare namespace UFile {
6
6
  * this returns boolean whether mkdir was executed or not.
7
7
  */
8
8
  function mkdir(p: MaybeArray<string>): boolean;
9
- function write(p: MaybeArray<string>, c: string): Promise<void>;
9
+ function write(p: MaybeArray<string>, c: string | NodeJS.ArrayBufferView): Promise<void>;
10
10
  /**
11
11
  * remove a file. default is no error if the file to be removed doesn't exist.
12
12
  * @param p path of the file. if passed as an array those are joined.
@@ -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,7 +1,7 @@
1
1
  {
2
2
  "name": "xjs-node",
3
- "version": "3.1.1",
4
- "description": "library modules for nodejs + typescript that bundled general-purpose implementations.",
3
+ "version": "3.2.1",
4
+ "description": "library modules for nodejs + typescript that bundle general-purpose implementations.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/begyyal/xjs_node"
@@ -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"