@rg-dev/stdlib 1.0.11 → 1.0.13

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.
@@ -61,18 +61,18 @@ function promiseRetry(func, options = defaultOptions, attempt = 1) {
61
61
 
62
62
  // src/common-env.ts
63
63
  var Optional = class _Optional {
64
+ value;
64
65
  constructor(value) {
65
66
  this.value = value;
66
67
  }
67
- value = void 0;
68
+ static of(val) {
69
+ return new _Optional(val);
70
+ }
68
71
  orElseThrow(msg) {
69
- if (this.value == void 0)
72
+ if (this.value === void 0)
70
73
  throw new Error(msg || "Value is empty");
71
74
  return this.value;
72
75
  }
73
- static of(val) {
74
- return new _Optional(val);
75
- }
76
76
  setValue(newValue) {
77
77
  this.value = newValue;
78
78
  return this;
@@ -81,7 +81,7 @@ var Optional = class _Optional {
81
81
  return this.value;
82
82
  }
83
83
  ifPresent(action) {
84
- if (this.value == void 0)
84
+ if (this.value === void 0)
85
85
  return;
86
86
  try {
87
87
  action(this.value);
@@ -9,12 +9,12 @@ type MyFn<T extends Record<string, (...args: any[]) => any>> = {
9
9
  [K in keyof T]: (...args: Parameters<T[K]>) => void;
10
10
  };
11
11
  type AsyncReturnType<T extends (...args: any) => any> = Awaited<ReturnType<T>>;
12
- type MaybeFunction = (() => void) | undefined;
12
+ type MaybeFunction = ((...args: any) => void) | undefined;
13
13
  declare class Optional<T> {
14
- private constructor();
15
14
  private value;
16
- orElseThrow(msg?: string): T;
15
+ private constructor();
17
16
  static of<T>(val: T): Optional<T>;
17
+ orElseThrow(msg?: string): T;
18
18
  setValue(newValue: T): this;
19
19
  getValue(): T | undefined;
20
20
  ifPresent(action: (val: Exclude<T, undefined>) => void): void;
@@ -9,12 +9,12 @@ type MyFn<T extends Record<string, (...args: any[]) => any>> = {
9
9
  [K in keyof T]: (...args: Parameters<T[K]>) => void;
10
10
  };
11
11
  type AsyncReturnType<T extends (...args: any) => any> = Awaited<ReturnType<T>>;
12
- type MaybeFunction = (() => void) | undefined;
12
+ type MaybeFunction = ((...args: any) => void) | undefined;
13
13
  declare class Optional<T> {
14
- private constructor();
15
14
  private value;
16
- orElseThrow(msg?: string): T;
15
+ private constructor();
17
16
  static of<T>(val: T): Optional<T>;
17
+ orElseThrow(msg?: string): T;
18
18
  setValue(newValue: T): this;
19
19
  getValue(): T | undefined;
20
20
  ifPresent(action: (val: Exclude<T, undefined>) => void): void;
package/lib/common-env.js CHANGED
@@ -28,18 +28,18 @@ function promiseRetry(func, options = defaultOptions, attempt = 1) {
28
28
 
29
29
  // src/common-env.ts
30
30
  var Optional = class _Optional {
31
+ value;
31
32
  constructor(value) {
32
33
  this.value = value;
33
34
  }
34
- value = void 0;
35
+ static of(val) {
36
+ return new _Optional(val);
37
+ }
35
38
  orElseThrow(msg) {
36
- if (this.value == void 0)
39
+ if (this.value === void 0)
37
40
  throw new Error(msg || "Value is empty");
38
41
  return this.value;
39
42
  }
40
- static of(val) {
41
- return new _Optional(val);
42
- }
43
43
  setValue(newValue) {
44
44
  this.value = newValue;
45
45
  return this;
@@ -48,7 +48,7 @@ var Optional = class _Optional {
48
48
  return this.value;
49
49
  }
50
50
  ifPresent(action) {
51
- if (this.value == void 0)
51
+ if (this.value === void 0)
52
52
  return;
53
53
  try {
54
54
  action(this.value);
@@ -6077,12 +6077,12 @@ async function getFetch() {
6077
6077
  }
6078
6078
  return (await Promise.resolve().then(() => (init_src(), src_exports))).default;
6079
6079
  }
6080
- function downloadFile(url, destination) {
6080
+ function downloadFile(url, destination, headers) {
6081
6081
  return new Promise(
6082
6082
  async (resolve, reject) => {
6083
6083
  try {
6084
6084
  const fetcher = await getFetch();
6085
- const response = await fetcher(url);
6085
+ const response = await fetcher(url, { headers: { ...headers || {} } });
6086
6086
  if (!response.ok)
6087
6087
  throw new Error("Error downloading file");
6088
6088
  const dest = fs2.createWriteStream(destination);
@@ -1,3 +1,3 @@
1
- declare function downloadFile(url: string, destination: string): Promise<string>;
1
+ declare function downloadFile(url: string, destination: string, headers: Record<string, any>): Promise<string>;
2
2
 
3
3
  export { downloadFile };
@@ -1,3 +1,3 @@
1
- declare function downloadFile(url: string, destination: string): Promise<string>;
1
+ declare function downloadFile(url: string, destination: string, headers: Record<string, any>): Promise<string>;
2
2
 
3
3
  export { downloadFile };
@@ -6078,12 +6078,12 @@ async function getFetch() {
6078
6078
  }
6079
6079
  return (await Promise.resolve().then(() => (init_src(), src_exports))).default;
6080
6080
  }
6081
- function downloadFile(url, destination) {
6081
+ function downloadFile(url, destination, headers) {
6082
6082
  return new Promise(
6083
6083
  async (resolve, reject) => {
6084
6084
  try {
6085
6085
  const fetcher = await getFetch();
6086
- const response = await fetcher(url);
6086
+ const response = await fetcher(url, { headers: { ...headers || {} } });
6087
6087
  if (!response.ok)
6088
6088
  throw new Error("Error downloading file");
6089
6089
  const dest = fs2.createWriteStream(destination);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rg-dev/stdlib",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",