triangle-utils 1.0.17 → 1.0.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.
- package/package.json +1 -1
- package/utils/Utils_Misc.js +9 -9
package/package.json
CHANGED
package/utils/Utils_Misc.js
CHANGED
|
@@ -25,7 +25,7 @@ export default class Utils_Misc {
|
|
|
25
25
|
return new Promise(resolve => setTimeout(resolve, duration))
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
get_current_time(
|
|
28
|
+
get_current_time(milliseconds = false) {
|
|
29
29
|
if (milliseconds) {
|
|
30
30
|
return (new Date()).getTime()
|
|
31
31
|
}
|
|
@@ -36,7 +36,7 @@ export default class Utils_Misc {
|
|
|
36
36
|
for (let i = 0; i < 3; i++) {
|
|
37
37
|
try {
|
|
38
38
|
await this.transporter.sendMail({
|
|
39
|
-
from:
|
|
39
|
+
from: this.config.alerts_email,
|
|
40
40
|
to: recipient,
|
|
41
41
|
subject: subject,
|
|
42
42
|
text: text
|
|
@@ -50,17 +50,17 @@ export default class Utils_Misc {
|
|
|
50
50
|
|
|
51
51
|
async admin_alert(text) {
|
|
52
52
|
console.log("ADMIN ALERT:", text)
|
|
53
|
-
await send_email(this.config.google_email, "ADMIN ALERT", text)
|
|
53
|
+
await this.send_email(this.config.google_email, "ADMIN ALERT", text)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
async safe_run(
|
|
56
|
+
async safe_run(f) {
|
|
57
57
|
try {
|
|
58
58
|
await f()
|
|
59
59
|
} catch (error) {
|
|
60
60
|
if (error.stack !== undefined) {
|
|
61
|
-
await admin_alert(error.stack.toString())
|
|
61
|
+
await this.admin_alert(error.stack.toString())
|
|
62
62
|
} else {
|
|
63
|
-
await admin_alert(error.toString())
|
|
63
|
+
await this.admin_alert(error.toString())
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
}
|
|
@@ -76,7 +76,7 @@ export default class Utils_Misc {
|
|
|
76
76
|
if (print_indices) {
|
|
77
77
|
console.log(i + ":" + (index - 1) + "/" + inputs.length)
|
|
78
78
|
}
|
|
79
|
-
await safe_run(() => f(inputs[index - 1]))
|
|
79
|
+
await this.safe_run(() => f(inputs[index - 1]))
|
|
80
80
|
}
|
|
81
81
|
})())
|
|
82
82
|
}
|
|
@@ -84,14 +84,14 @@ export default class Utils_Misc {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
async sha256(input) {
|
|
87
|
-
const input_buffer = text_encoder.encode(input);
|
|
87
|
+
const input_buffer = this.text_encoder.encode(input);
|
|
88
88
|
|
|
89
89
|
const hash_buffer = await crypto.subtle.digest("SHA-256", input_buffer)
|
|
90
90
|
|
|
91
91
|
const hash_array = Array.from(new Uint8Array(hash_buffer))
|
|
92
92
|
|
|
93
93
|
const hash = hash_array.map(b => b.toString(16).padStart(2, "0")).join("")
|
|
94
|
-
return hash
|
|
94
|
+
return hash
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
get_election_id(year, office, state, district) {
|