triangle-utils 1.4.18 → 1.4.19

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.
@@ -3,7 +3,7 @@ export declare class UtilsS3 {
3
3
  private readonly s3;
4
4
  constructor(region: string);
5
5
  file_exists(s3_filename: string): Promise<boolean | undefined>;
6
- get_file(s3_filename: string): Promise<string | undefined>;
6
+ get_file(s3_filename: string, encoding?: string): Promise<string | undefined>;
7
7
  get_file_buffer(s3_filename: string): Promise<Buffer | undefined>;
8
8
  get_file_stream(s3_filename: string): Promise<Readable | undefined>;
9
9
  create_file(s3_filename: string, content: string | Buffer, options?: {
@@ -28,7 +28,7 @@ export class UtilsS3 {
28
28
  return false;
29
29
  }
30
30
  }
31
- async get_file(s3_filename) {
31
+ async get_file(s3_filename, encoding = "utf-8") {
32
32
  const s3_key = parse_s3_filename(s3_filename);
33
33
  if (s3_key === undefined) {
34
34
  return undefined;
@@ -39,7 +39,7 @@ export class UtilsS3 {
39
39
  if (body === undefined) {
40
40
  return undefined;
41
41
  }
42
- const text = await body.transformToString("utf-8");
42
+ const text = await body.transformToString(encoding);
43
43
  return text;
44
44
  }
45
45
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.18",
3
+ "version": "1.4.19",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/UtilsS3.ts CHANGED
@@ -38,7 +38,7 @@ export class UtilsS3 {
38
38
  }
39
39
  }
40
40
 
41
- async get_file(s3_filename : string) : Promise<string | undefined> {
41
+ async get_file(s3_filename : string, encoding : string = "utf-8") : Promise<string | undefined> {
42
42
  const s3_key = parse_s3_filename(s3_filename)
43
43
  if (s3_key === undefined) {
44
44
  return undefined
@@ -49,7 +49,7 @@ export class UtilsS3 {
49
49
  if (body === undefined) {
50
50
  return undefined
51
51
  }
52
- const text = await body.transformToString("utf-8")
52
+ const text = await body.transformToString(encoding)
53
53
  return text
54
54
  } catch (error) {
55
55
  if (error instanceof NoSuchKey) {