soda-nodejs 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -1,23 +1,23 @@
1
- # soda-node
2
-
3
- [![NPM version](https://img.shields.io/npm/v/soda-node.svg?style=flat)](https://npmjs.com/package/soda-node)
4
- [![NPM downloads](http://img.shields.io/npm/dm/soda-node.svg?style=flat)](https://npmjs.com/package/soda-node)
5
-
6
- ## Install
7
-
8
- ```bash
9
- $ pnpm install
10
- ```
11
-
12
- ```bash
13
- $ npm run dev
14
- $ npm run build
15
- ```
16
-
17
- ## Options
18
-
19
- TODO
20
-
21
- ## LICENSE
22
-
23
- MIT
1
+ # soda-node
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/soda-node.svg?style=flat)](https://npmjs.com/package/soda-node)
4
+ [![NPM downloads](http://img.shields.io/npm/dm/soda-node.svg?style=flat)](https://npmjs.com/package/soda-node)
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ $ pnpm install
10
+ ```
11
+
12
+ ```bash
13
+ $ npm run dev
14
+ $ npm run build
15
+ ```
16
+
17
+ ## Options
18
+
19
+ TODO
20
+
21
+ ## LICENSE
22
+
23
+ MIT
@@ -1,5 +1,6 @@
1
1
  export * from "./utils/execAsync";
2
2
  export * from "./utils/saveFile";
3
+ export * from "./utils/saveResponse";
3
4
  export * from "./utils/spawnAsync";
4
5
  export * from "./utils/unzip";
5
6
  export * from "./utils/zip";
package/dist/cjs/index.js CHANGED
@@ -18,6 +18,7 @@ var src_exports = {};
18
18
  module.exports = __toCommonJS(src_exports);
19
19
  __reExport(src_exports, require("./utils/execAsync"), module.exports);
20
20
  __reExport(src_exports, require("./utils/saveFile"), module.exports);
21
+ __reExport(src_exports, require("./utils/saveResponse"), module.exports);
21
22
  __reExport(src_exports, require("./utils/spawnAsync"), module.exports);
22
23
  __reExport(src_exports, require("./utils/unzip"), module.exports);
23
24
  __reExport(src_exports, require("./utils/zip"), module.exports);
@@ -25,6 +26,7 @@ __reExport(src_exports, require("./utils/zip"), module.exports);
25
26
  0 && (module.exports = {
26
27
  ...require("./utils/execAsync"),
27
28
  ...require("./utils/saveFile"),
29
+ ...require("./utils/saveResponse"),
28
30
  ...require("./utils/spawnAsync"),
29
31
  ...require("./utils/unzip"),
30
32
  ...require("./utils/zip")
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from \"@utils/execAsync\"\nexport * from \"@utils/saveFile\"\nexport * from \"@utils/spawnAsync\"\nexport * from \"@utils/unzip\"\nexport * from \"@utils/zip\"\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,8BAAd;AACA,wBAAc,6BADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,0BAHd;AAIA,wBAAc,wBAJd;",
4
+ "sourcesContent": ["export * from \"@utils/execAsync\"\nexport * from \"@utils/saveFile\"\nexport * from \"@utils/saveResponse\"\nexport * from \"@utils/spawnAsync\"\nexport * from \"@utils/unzip\"\nexport * from \"@utils/zip\"\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,8BAAd;AACA,wBAAc,6BADd;AAEA,wBAAc,iCAFd;AAGA,wBAAc,+BAHd;AAIA,wBAAc,0BAJd;AAKA,wBAAc,wBALd;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 从 Response 对象中下载文件
3
+ * @param response Response 对象
4
+ * @param file 文件路径
5
+ */
6
+ export declare function saveResponse(response: Response, file: string): Promise<void>;
@@ -0,0 +1,37 @@
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/utils/saveResponse.ts
20
+ var saveResponse_exports = {};
21
+ __export(saveResponse_exports, {
22
+ saveResponse: () => saveResponse
23
+ });
24
+ module.exports = __toCommonJS(saveResponse_exports);
25
+ var import_fs = require("fs");
26
+ var import_stream = require("stream");
27
+ async function saveResponse(response, file) {
28
+ const writeable = (0, import_fs.createWriteStream)(file);
29
+ await new Promise(
30
+ (resolve, reject) => import_stream.Readable.fromWeb(response.body).pipe(writeable).on("close", resolve).on("error", reject)
31
+ );
32
+ }
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ saveResponse
36
+ });
37
+ //# sourceMappingURL=saveResponse.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils/saveResponse.ts"],
4
+ "sourcesContent": ["import { createWriteStream } from \"fs\"\r\nimport { Readable } from \"stream\"\r\n\r\n/**\r\n * 从 Response 对象中下载文件\r\n * @param response Response 对象\r\n * @param file 文件路径\r\n */\r\nexport async function saveResponse(response: Response, file: string) {\r\n const writeable = createWriteStream(file)\r\n await new Promise((resolve, reject) =>\r\n Readable.fromWeb(response.body! as any)\r\n .pipe(writeable)\r\n .on(\"close\", resolve)\r\n .on(\"error\", reject)\r\n )\r\n}\r\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAkC;AAClC,oBAAyB;AAOzB,eAAsB,aAAa,UAAoB,MAAc;AACjE,QAAM,gBAAY,6BAAkB,IAAI;AACxC,QAAM,IAAI;AAAA,IAAQ,CAAC,SAAS,WACxB,uBAAS,QAAQ,SAAS,IAAY,EACjC,KAAK,SAAS,EACd,GAAG,SAAS,OAAO,EACnB,GAAG,SAAS,MAAM;AAAA,EAC3B;AACJ;",
6
+ "names": []
7
+ }
@@ -1,5 +1,6 @@
1
1
  export * from "./utils/execAsync";
2
2
  export * from "./utils/saveFile";
3
+ export * from "./utils/saveResponse";
3
4
  export * from "./utils/spawnAsync";
4
5
  export * from "./utils/unzip";
5
6
  export * from "./utils/zip";
package/dist/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./utils/execAsync";
2
2
  export * from "./utils/saveFile";
3
+ export * from "./utils/saveResponse";
3
4
  export * from "./utils/spawnAsync";
4
5
  export * from "./utils/unzip";
5
6
  export * from "./utils/zip";
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"@utils/execAsync\"\nexport * from \"@utils/saveFile\"\nexport * from \"@utils/spawnAsync\"\nexport * from \"@utils/unzip\"\nexport * from \"@utils/zip\"\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA"}
1
+ {"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"@utils/execAsync\"\nexport * from \"@utils/saveFile\"\nexport * from \"@utils/saveResponse\"\nexport * from \"@utils/spawnAsync\"\nexport * from \"@utils/unzip\"\nexport * from \"@utils/zip\"\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 从 Response 对象中下载文件
3
+ * @param response Response 对象
4
+ * @param file 文件路径
5
+ */
6
+ export declare function saveResponse(response: Response, file: string): Promise<void>;
@@ -0,0 +1,13 @@
1
+ import { createWriteStream } from "fs";
2
+ import { Readable } from "stream";
3
+
4
+ /**
5
+ * 从 Response 对象中下载文件
6
+ * @param response Response 对象
7
+ * @param file 文件路径
8
+ */
9
+ export async function saveResponse(response, file) {
10
+ const writeable = createWriteStream(file);
11
+ await new Promise((resolve, reject) => Readable.fromWeb(response.body).pipe(writeable).on("close", resolve).on("error", reject));
12
+ }
13
+ //# sourceMappingURL=saveResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createWriteStream","Readable","saveResponse","response","file","writeable","Promise","resolve","reject","fromWeb","body","pipe","on"],"sources":["../../../src/utils/saveResponse.ts"],"sourcesContent":["import { createWriteStream } from \"fs\"\r\nimport { Readable } from \"stream\"\r\n\r\n/**\r\n * 从 Response 对象中下载文件\r\n * @param response Response 对象\r\n * @param file 文件路径\r\n */\r\nexport async function saveResponse(response: Response, file: string) {\r\n const writeable = createWriteStream(file)\r\n await new Promise((resolve, reject) =>\r\n Readable.fromWeb(response.body! as any)\r\n .pipe(writeable)\r\n .on(\"close\", resolve)\r\n .on(\"error\", reject)\r\n )\r\n}\r\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,IAAI;AACtC,SAASC,QAAQ,QAAQ,QAAQ;;AAEjC;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAACC,QAAkB,EAAEC,IAAY,EAAE;EACjE,MAAMC,SAAS,GAAGL,iBAAiB,CAACI,IAAI,CAAC;EACzC,MAAM,IAAIE,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAC9BP,QAAQ,CAACQ,OAAO,CAACN,QAAQ,CAACO,IAAY,CAAC,CAClCC,IAAI,CAACN,SAAS,CAAC,CACfO,EAAE,CAAC,OAAO,EAAEL,OAAO,CAAC,CACpBK,EAAE,CAAC,OAAO,EAAEJ,MAAM,CAC3B,CAAC;AACL"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soda-nodejs",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -24,8 +24,7 @@
24
24
  "homepage": "https://github.com/1adybug/deepsea/tree/main/packages/soda-nodejs",
25
25
  "devDependencies": {
26
26
  "@types/node": "^20.14.10",
27
- "@types/which": "^3.0.4",
28
- "father": "^4.5.0-rc.2"
27
+ "@types/which": "^3.0.4"
29
28
  },
30
29
  "dependencies": {
31
30
  "iconv-lite": "^0.6.3",
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "@utils/execAsync"
2
2
  export * from "@utils/saveFile"
3
+ export * from "@utils/saveResponse"
3
4
  export * from "@utils/spawnAsync"
4
5
  export * from "@utils/unzip"
5
6
  export * from "@utils/zip"
@@ -0,0 +1,17 @@
1
+ import { createWriteStream } from "fs"
2
+ import { Readable } from "stream"
3
+
4
+ /**
5
+ * 从 Response 对象中下载文件
6
+ * @param response Response 对象
7
+ * @param file 文件路径
8
+ */
9
+ export async function saveResponse(response: Response, file: string) {
10
+ const writeable = createWriteStream(file)
11
+ await new Promise((resolve, reject) =>
12
+ Readable.fromWeb(response.body! as any)
13
+ .pipe(writeable)
14
+ .on("close", resolve)
15
+ .on("error", reject)
16
+ )
17
+ }