triangle-utils 1.4.37 → 1.4.39

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,9 +3,9 @@ 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_s3_filenames(s3_filename_prefix: string, options: {
6
+ get_s3_filenames(s3_filename_prefix: string, options?: {
7
7
  compile?: boolean;
8
- }): Promise<string[] | undefined>;
8
+ }): Promise<string[]>;
9
9
  get_file(s3_filename: string, encoding?: string): Promise<string | undefined>;
10
10
  get_file_buffer(s3_filename: string): Promise<Buffer | undefined>;
11
11
  get_file_stream(s3_filename: string): Promise<Readable | undefined>;
@@ -28,11 +28,11 @@ export class UtilsS3 {
28
28
  return false;
29
29
  }
30
30
  }
31
- async get_s3_filenames(s3_filename_prefix, options) {
31
+ async get_s3_filenames(s3_filename_prefix, options = {}) {
32
32
  const compile = options.compile !== undefined ? options.compile : false;
33
33
  const s3_key = parse_s3_filename(s3_filename_prefix);
34
34
  if (s3_key === undefined) {
35
- return undefined;
35
+ return [];
36
36
  }
37
37
  const s3_filenames = [];
38
38
  let last_token = undefined;
@@ -46,7 +46,11 @@ export class UtilsS3 {
46
46
  if (response.Contents === undefined) {
47
47
  return [];
48
48
  }
49
- const new_s3_filenames = response.Contents.map(content => content.Key).filter(key => key !== undefined).map(key => "s3://" + s3_key.Bucket + "/" + key);
49
+ const new_s3_filenames = response.Contents
50
+ .map(content => content.Key)
51
+ .filter(key => key !== undefined)
52
+ .filter(key => key.substring(key.length - 1) !== "/")
53
+ .map(key => "s3://" + s3_key.Bucket + "/" + key);
50
54
  s3_filenames.push(...new_s3_filenames);
51
55
  if (response.ContinuationToken === undefined || !compile) {
52
56
  return s3_filenames;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.37",
3
+ "version": "1.4.39",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/UtilsS3.ts CHANGED
@@ -38,11 +38,11 @@ export class UtilsS3 {
38
38
  }
39
39
  }
40
40
 
41
- async get_s3_filenames(s3_filename_prefix : string, options : { compile? : boolean }) {
41
+ async get_s3_filenames(s3_filename_prefix : string, options : { compile? : boolean } = {}) {
42
42
  const compile = options.compile !== undefined ? options.compile : false
43
43
  const s3_key = parse_s3_filename(s3_filename_prefix)
44
44
  if (s3_key === undefined) {
45
- return undefined
45
+ return []
46
46
  }
47
47
  const s3_filenames = []
48
48
  let last_token : string | undefined = undefined
@@ -56,7 +56,11 @@ export class UtilsS3 {
56
56
  if (response.Contents === undefined) {
57
57
  return []
58
58
  }
59
- const new_s3_filenames = response.Contents.map(content => content.Key).filter(key => key !== undefined).map(key => "s3://" + s3_key.Bucket + "/" + key)
59
+ const new_s3_filenames = response.Contents
60
+ .map(content => content.Key)
61
+ .filter(key => key !== undefined)
62
+ .filter(key => key.substring(key.length - 1) !== "/")
63
+ .map(key => "s3://" + s3_key.Bucket + "/" + key)
60
64
  s3_filenames.push(...new_s3_filenames)
61
65
  if (response.ContinuationToken === undefined || !compile) {
62
66
  return s3_filenames