@rg-dev/stdlib 1.0.16 → 1.0.18
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/lib/common-env.d.cts +1 -1
- package/lib/common-env.d.ts +1 -1
- package/lib/node-download.cjs +13 -6
- package/lib/node-download.js +13 -6
- package/package.json +1 -1
package/lib/common-env.d.cts
CHANGED
|
@@ -13,7 +13,7 @@ type MaybeFunction = ((...args: any) => void) | undefined;
|
|
|
13
13
|
declare class Optional<T> {
|
|
14
14
|
private value;
|
|
15
15
|
private constructor();
|
|
16
|
-
static of<T>(val: T): Optional<T>;
|
|
16
|
+
static of<T>(val: T | any): Optional<T>;
|
|
17
17
|
orElseThrow(msg?: string): T;
|
|
18
18
|
setValue(newValue: T): this;
|
|
19
19
|
getValue(): T | undefined;
|
package/lib/common-env.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type MaybeFunction = ((...args: any) => void) | undefined;
|
|
|
13
13
|
declare class Optional<T> {
|
|
14
14
|
private value;
|
|
15
15
|
private constructor();
|
|
16
|
-
static of<T>(val: T): Optional<T>;
|
|
16
|
+
static of<T>(val: T | any): Optional<T>;
|
|
17
17
|
orElseThrow(msg?: string): T;
|
|
18
18
|
setValue(newValue: T): this;
|
|
19
19
|
getValue(): T | undefined;
|
package/lib/node-download.cjs
CHANGED
|
@@ -6071,6 +6071,17 @@ __export(node_download_exports, {
|
|
|
6071
6071
|
module.exports = __toCommonJS(node_download_exports);
|
|
6072
6072
|
var fs2 = __toESM(require("fs"), 1);
|
|
6073
6073
|
var import_stream = require("stream");
|
|
6074
|
+
|
|
6075
|
+
// src/common-env.ts
|
|
6076
|
+
async function catchInline(cb) {
|
|
6077
|
+
try {
|
|
6078
|
+
return { error: void 0, result: await cb };
|
|
6079
|
+
} catch (e2) {
|
|
6080
|
+
return { error: e2, result: void 0 };
|
|
6081
|
+
}
|
|
6082
|
+
}
|
|
6083
|
+
|
|
6084
|
+
// src/node-download.ts
|
|
6074
6085
|
async function getFetch() {
|
|
6075
6086
|
if (typeof fetch !== "undefined") {
|
|
6076
6087
|
return fetch;
|
|
@@ -6084,12 +6095,8 @@ function downloadFile(url, destination, headers) {
|
|
|
6084
6095
|
const fetcher = await getFetch();
|
|
6085
6096
|
const response = await fetcher(url, { headers: { ...headers || {} } });
|
|
6086
6097
|
if (!response.ok) {
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
error = await (response == null ? void 0 : response.text());
|
|
6090
|
-
} catch (e2) {
|
|
6091
|
-
}
|
|
6092
|
-
throw new Error(`Error downloading file ${error || "status code: " + response.status}`);
|
|
6098
|
+
const { result: error } = await catchInline(response.text());
|
|
6099
|
+
throw new Error(`Error throwed while downloading file: ${error || "status code: " + response.status}`);
|
|
6093
6100
|
}
|
|
6094
6101
|
const dest = fs2.createWriteStream(destination);
|
|
6095
6102
|
const body = response.body;
|
package/lib/node-download.js
CHANGED
|
@@ -6072,6 +6072,17 @@ var init_src = __esm({
|
|
|
6072
6072
|
// src/node-download.ts
|
|
6073
6073
|
import * as fs2 from "fs";
|
|
6074
6074
|
import { Readable } from "stream";
|
|
6075
|
+
|
|
6076
|
+
// src/common-env.ts
|
|
6077
|
+
async function catchInline(cb) {
|
|
6078
|
+
try {
|
|
6079
|
+
return { error: void 0, result: await cb };
|
|
6080
|
+
} catch (e2) {
|
|
6081
|
+
return { error: e2, result: void 0 };
|
|
6082
|
+
}
|
|
6083
|
+
}
|
|
6084
|
+
|
|
6085
|
+
// src/node-download.ts
|
|
6075
6086
|
async function getFetch() {
|
|
6076
6087
|
if (typeof fetch !== "undefined") {
|
|
6077
6088
|
return fetch;
|
|
@@ -6085,12 +6096,8 @@ function downloadFile(url, destination, headers) {
|
|
|
6085
6096
|
const fetcher = await getFetch();
|
|
6086
6097
|
const response = await fetcher(url, { headers: { ...headers || {} } });
|
|
6087
6098
|
if (!response.ok) {
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
error = await (response == null ? void 0 : response.text());
|
|
6091
|
-
} catch (e2) {
|
|
6092
|
-
}
|
|
6093
|
-
throw new Error(`Error downloading file ${error || "status code: " + response.status}`);
|
|
6099
|
+
const { result: error } = await catchInline(response.text());
|
|
6100
|
+
throw new Error(`Error throwed while downloading file: ${error || "status code: " + response.status}`);
|
|
6094
6101
|
}
|
|
6095
6102
|
const dest = fs2.createWriteStream(destination);
|
|
6096
6103
|
const body = response.body;
|