triangle-utils 1.0.33 → 1.0.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "main": "Utils.js",
5
5
  "author": "",
6
6
  "license": "ISC",
package/test.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import Utils from "./Utils.js";
2
2
 
3
3
 
4
- const utils = new Utils({ region : "us-east-2"})
4
+ const utils = new Utils({ region : "us-east-1"})
5
5
 
6
- const items = await utils.s3vectors.batch_get("doersnetwork", "candidate-document-chunks", ["yeeerp", "text|2025-12-10T21:34:37.429Z|0|1761", "text|2025-12-10T21:37:00.719Z|0|2413"])
6
+ const items = await utils.dynamodb.scan("article_hashes", { concurrency : 1 })
7
7
 
8
- console.log(items)
8
+ console.log(items.length)
@@ -62,15 +62,25 @@ export default class Utils_DynamoDB {
62
62
  this.dynamodb = new DynamoDB({ region : config.region })
63
63
  }
64
64
 
65
- async scan(table, attribute_names = [], filters = {}) {
66
- const request = Object.fromEntries(Object.entries({
67
- TableName : table,
68
- ExpressionAttributeNames : Object.fromEntries((Object.keys(filters).concat(attribute_names)).map(attribute_name => ["#" + attribute_name, attribute_name])),
69
- ExpressionAttributeValues : Object.fromEntries(Object.entries(filters).map(([attribute_name, attribute_value]) => [":" + attribute_name, convert_input(attribute_value)])),
70
- FilterExpression : Object.keys(filters).map(attribute_name => "#" + attribute_name + " = :" + attribute_name).join(","),
71
- ProjectionExpression : attribute_names.map(attribute_name => "#" + attribute_name).join(", ")
72
- }).filter(([field, value]) => value !== undefined && Object.keys(value).length !== 0))
73
- return await paginate(request, (request) => this.dynamodb.scan(request))
65
+ async scan(table, options = {}) {
66
+ const filters = options.filters !== undefined ? options.filters : {}
67
+ const concurrency = options.concurrency !== undefined ? options.concurrency : 1
68
+ const attribute_names = options.attribute_names !== undefined ? options.attribute_names : []
69
+ const iterators = []
70
+ for (let i = 0; i < concurrency; i++) {
71
+ const request = Object.fromEntries(Object.entries({
72
+ TableName : table,
73
+ ExpressionAttributeNames : Object.fromEntries((Object.keys(filters).concat(attribute_names)).map(attribute_name => ["#" + attribute_name, attribute_name])),
74
+ ExpressionAttributeValues : Object.fromEntries(Object.entries(filters).map(([attribute_name, attribute_value]) => [":" + attribute_name, convert_input(attribute_value)])),
75
+ FilterExpression : Object.keys(filters).map(attribute_name => "#" + attribute_name + " = :" + attribute_name).join(","),
76
+ ProjectionExpression : attribute_names.map(attribute_name => "#" + attribute_name).join(", "),
77
+ Segment : i,
78
+ TotalSegments : concurrency
79
+ }).filter(([field, value]) => value !== undefined && (typeof value === typeof 3 || Object.keys(value).length !== 0)))
80
+ iterators.push(paginate(request, (request) => this.dynamodb.scan(request)))
81
+ }
82
+ const segments = await Promise.all(iterators)
83
+ return segments.flat()
74
84
  }
75
85
 
76
86
  async get(table, key, consistent=false) {
package/utils/Utils_S3.js CHANGED
@@ -17,7 +17,6 @@ export default class Utils_S3 {
17
17
  this.s3 = new S3({ region : config.region })
18
18
  }
19
19
 
20
-
21
20
  async file_exists(s3_filename) {
22
21
  const s3_key = parse_s3_filename(s3_filename)
23
22
  if (s3_key === undefined) {
@@ -31,7 +30,6 @@ export default class Utils_S3 {
31
30
  }
32
31
  }
33
32
 
34
-
35
33
  async get_file(s3_filename, json=false) {
36
34
  const s3_key = parse_s3_filename(s3_filename)
37
35
  if (s3_key === undefined) {