triangle-utils 1.4.56 → 1.4.58
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/dist/src/UtilsMisc.js +7 -5
- package/dist/src/f.js +4 -2
- package/package.json +1 -1
- package/src/UtilsMisc.ts +7 -5
- package/src/f.ts +7 -3
package/dist/src/UtilsMisc.js
CHANGED
|
@@ -25,19 +25,21 @@ export class UtilsMisc {
|
|
|
25
25
|
const print_freq = typeof print_option === "boolean" ? (print_option === true ? 1 : 0) : print_option;
|
|
26
26
|
let index = 0;
|
|
27
27
|
let iterators = [];
|
|
28
|
-
const outputs =
|
|
28
|
+
const outputs = new Array(inputs.length).fill(undefined);
|
|
29
29
|
for (let iterator_id = 0; iterator_id < num_iterators; iterator_id++) {
|
|
30
30
|
iterators.push((async () => {
|
|
31
31
|
while (index < inputs.length) {
|
|
32
|
+
const local_index = index;
|
|
32
33
|
index += 1;
|
|
33
|
-
if (print_freq !== undefined && (
|
|
34
|
-
console.log(iterator_id + ":" +
|
|
34
|
+
if (print_freq !== undefined && (local_index % print_freq === 0)) {
|
|
35
|
+
console.log(iterator_id + ":" + local_index + "/" + inputs.length);
|
|
35
36
|
}
|
|
36
|
-
const output = await this.safe_run(() => f(inputs[
|
|
37
|
-
outputs
|
|
37
|
+
const output = await this.safe_run(() => f(inputs[local_index], iterator_id, local_index));
|
|
38
|
+
outputs[local_index] = output;
|
|
38
39
|
}
|
|
39
40
|
})());
|
|
40
41
|
}
|
|
42
|
+
await Promise.all(iterators);
|
|
41
43
|
return outputs;
|
|
42
44
|
}
|
|
43
45
|
static async wait(duration) {
|
package/dist/src/f.js
CHANGED
|
@@ -17,7 +17,9 @@ console.log(config);
|
|
|
17
17
|
const utils = new TriangleUtils(config);
|
|
18
18
|
// const foods = await utils.dynamodb.query("triage_docket_documents:register_document_id", { register_document_id : "E6-17065" })
|
|
19
19
|
// console.log(foods)
|
|
20
|
-
const text = await utils.bee.get("https://www.doyourjobs.org", { return_page_text: true })
|
|
21
|
-
console.log(text)
|
|
20
|
+
// const text = await utils.bee.get("https://www.doyourjobs.org", { return_page_text : true })
|
|
21
|
+
// console.log(text)
|
|
22
22
|
// const text = await utils.bedrock.claude_invoke("global.anthropic.claude-opus-4-6-v1", "hi", undefined, { print_usage : true })
|
|
23
23
|
// console.log(text)
|
|
24
|
+
const output = await utils.iterate([1, 2, 3], async (i) => (i * 2), 1, true);
|
|
25
|
+
console.log(output);
|
package/package.json
CHANGED
package/src/UtilsMisc.ts
CHANGED
|
@@ -35,19 +35,21 @@ export class UtilsMisc {
|
|
|
35
35
|
const print_freq : number | undefined = typeof print_option === "boolean" ? (print_option === true ? 1 : 0) : print_option
|
|
36
36
|
let index = 0
|
|
37
37
|
let iterators = []
|
|
38
|
-
const outputs : (U | undefined)[] =
|
|
38
|
+
const outputs : (U | undefined)[] = new Array(inputs.length).fill(undefined)
|
|
39
39
|
for (let iterator_id = 0; iterator_id < num_iterators; iterator_id++) {
|
|
40
40
|
iterators.push((async () => {
|
|
41
41
|
while (index < inputs.length) {
|
|
42
|
+
const local_index = index
|
|
42
43
|
index += 1
|
|
43
|
-
if (print_freq !== undefined && (
|
|
44
|
-
console.log(iterator_id + ":" +
|
|
44
|
+
if (print_freq !== undefined && (local_index % print_freq === 0)) {
|
|
45
|
+
console.log(iterator_id + ":" + local_index + "/" + inputs.length)
|
|
45
46
|
}
|
|
46
|
-
const output = await this.safe_run(() => f(inputs[
|
|
47
|
-
outputs
|
|
47
|
+
const output = await this.safe_run(() => f(inputs[local_index], iterator_id, local_index))
|
|
48
|
+
outputs[local_index] = output
|
|
48
49
|
}
|
|
49
50
|
})())
|
|
50
51
|
}
|
|
52
|
+
await Promise.all(iterators)
|
|
51
53
|
return outputs
|
|
52
54
|
}
|
|
53
55
|
|
package/src/f.ts
CHANGED
|
@@ -28,9 +28,13 @@ const utils = new TriangleUtils(config)
|
|
|
28
28
|
|
|
29
29
|
// console.log(foods)
|
|
30
30
|
|
|
31
|
-
const text = await utils.bee.get("https://www.doyourjobs.org", { return_page_text : true })
|
|
31
|
+
// const text = await utils.bee.get("https://www.doyourjobs.org", { return_page_text : true })
|
|
32
32
|
|
|
33
|
-
console.log(text)
|
|
33
|
+
// console.log(text)
|
|
34
34
|
|
|
35
35
|
// const text = await utils.bedrock.claude_invoke("global.anthropic.claude-opus-4-6-v1", "hi", undefined, { print_usage : true })
|
|
36
|
-
// console.log(text)
|
|
36
|
+
// console.log(text)
|
|
37
|
+
|
|
38
|
+
const output = await utils.iterate([1, 2, 3], async (i) => (i * 2), 1, true)
|
|
39
|
+
|
|
40
|
+
console.log(output)
|