triangle-utils 1.4.119 → 1.4.121

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.
@@ -12,7 +12,7 @@ export declare class UtilsMisc {
12
12
  verbosity?: number | boolean;
13
13
  }): Promise<(U | undefined)[]>;
14
14
  batch_iterate<T, U>(inputs: T[], f: (inputs: T[], iterator_id: number, index: number) => Promise<U>, options: {
15
- batch_size?: number;
15
+ batch_num_items?: number;
16
16
  num_iterators?: number;
17
17
  verbosity?: number | boolean;
18
18
  }): Promise<(U | undefined)[]>;
@@ -44,7 +44,7 @@ export class UtilsMisc {
44
44
  return outputs;
45
45
  }
46
46
  async batch_iterate(inputs, f, options) {
47
- const batch_size = options.batch_size || 1;
47
+ const batch_num_items = options.batch_num_items || 1;
48
48
  const num_iterators = options.num_iterators || 1;
49
49
  const verbosity = typeof options.verbosity === "boolean" ? (options.verbosity === true ? 1 : 0) : (options.verbosity || 0);
50
50
  let index = 0;
@@ -54,11 +54,11 @@ export class UtilsMisc {
54
54
  iterators.push((async () => {
55
55
  while (index < inputs.length) {
56
56
  const local_index = index;
57
- index += batch_size;
57
+ index += batch_num_items;
58
58
  if (verbosity !== undefined && (local_index % verbosity === 0)) {
59
59
  console.log(iterator_id + ":" + local_index + "/" + inputs.length);
60
60
  }
61
- const output = await this.safe_run(() => f(inputs.slice(local_index, local_index + batch_size), iterator_id, local_index));
61
+ const output = await this.safe_run(() => f(inputs.slice(local_index, local_index + batch_num_items), iterator_id, local_index));
62
62
  outputs[local_index] = output;
63
63
  }
64
64
  })());
@@ -10,6 +10,7 @@ export declare class GlobalConfig {
10
10
  readonly s3_triage: string;
11
11
  readonly super_federal_gov_api_keys: string;
12
12
  readonly federal_gov_api_keys: string;
13
+ readonly federal_census_api_key: string;
13
14
  readonly federal_lobby_api_key: string;
14
15
  readonly scraping_bee_api_key: string;
15
16
  readonly twitter_api_key: string;
@@ -10,6 +10,7 @@ export class GlobalConfig {
10
10
  s3_triage;
11
11
  super_federal_gov_api_keys;
12
12
  federal_gov_api_keys;
13
+ federal_census_api_key;
13
14
  federal_lobby_api_key;
14
15
  scraping_bee_api_key;
15
16
  twitter_api_key;
@@ -30,6 +31,7 @@ export class GlobalConfig {
30
31
  this.s3_triage = global_config.s3_triage;
31
32
  this.super_federal_gov_api_keys = global_config.super_federal_gov_api_keys;
32
33
  this.federal_gov_api_keys = global_config.federal_gov_api_keys;
34
+ this.federal_census_api_key = global_config.federal_census_api_key;
33
35
  this.federal_lobby_api_key = global_config.federal_lobby_api_key;
34
36
  this.scraping_bee_api_key = global_config.scraping_bee_api_key;
35
37
  this.twitter_api_key = global_config.twitter_api_key;
@@ -49,6 +51,7 @@ export class GlobalConfig {
49
51
  typeof global_config.s3_triage === "string" &&
50
52
  typeof global_config.super_federal_gov_api_keys === "string" &&
51
53
  typeof global_config.federal_gov_api_keys === "string" &&
54
+ typeof global_config.federal_census_api_key === "string" &&
52
55
  typeof global_config.federal_lobby_api_key === "string" &&
53
56
  typeof global_config.scraping_bee_api_key === "string" &&
54
57
  typeof global_config.twitter_api_key === "string" &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.119",
3
+ "version": "1.4.121",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/UtilsMisc.ts CHANGED
@@ -55,8 +55,8 @@ export class UtilsMisc {
55
55
  }
56
56
 
57
57
  async batch_iterate<T, U>(inputs : T[], f : (inputs : T[], iterator_id : number, index : number) => Promise<U>,
58
- options : { batch_size? : number, num_iterators? : number, verbosity? : number | boolean }) {
59
- const batch_size = options.batch_size || 1
58
+ options : { batch_num_items? : number, num_iterators? : number, verbosity? : number | boolean }) {
59
+ const batch_num_items = options.batch_num_items || 1
60
60
  const num_iterators = options.num_iterators || 1
61
61
  const verbosity : number = typeof options.verbosity === "boolean" ? (options.verbosity === true ? 1 : 0) : (options.verbosity || 0)
62
62
  let index = 0
@@ -66,11 +66,11 @@ export class UtilsMisc {
66
66
  iterators.push((async () => {
67
67
  while (index < inputs.length) {
68
68
  const local_index = index
69
- index += batch_size
69
+ index += batch_num_items
70
70
  if (verbosity !== undefined && (local_index % verbosity === 0)) {
71
71
  console.log(iterator_id + ":" + local_index + "/" + inputs.length)
72
72
  }
73
- const output = await this.safe_run(() => f(inputs.slice(local_index, local_index + batch_size), iterator_id, local_index))
73
+ const output = await this.safe_run(() => f(inputs.slice(local_index, local_index + batch_num_items), iterator_id, local_index))
74
74
  outputs[local_index] = output
75
75
  }
76
76
  })())
@@ -10,6 +10,7 @@ export class GlobalConfig {
10
10
  readonly s3_triage : string
11
11
  readonly super_federal_gov_api_keys : string
12
12
  readonly federal_gov_api_keys : string
13
+ readonly federal_census_api_key : string
13
14
  readonly federal_lobby_api_key : string
14
15
  readonly scraping_bee_api_key : string
15
16
  readonly twitter_api_key : string
@@ -32,6 +33,7 @@ export class GlobalConfig {
32
33
  this.s3_triage = global_config.s3_triage
33
34
  this.super_federal_gov_api_keys = global_config.super_federal_gov_api_keys
34
35
  this.federal_gov_api_keys = global_config.federal_gov_api_keys
36
+ this.federal_census_api_key = global_config.federal_census_api_key
35
37
  this.federal_lobby_api_key = global_config.federal_lobby_api_key
36
38
  this.scraping_bee_api_key = global_config.scraping_bee_api_key
37
39
  this.twitter_api_key = global_config.twitter_api_key
@@ -53,6 +55,7 @@ export class GlobalConfig {
53
55
  typeof global_config.s3_triage === "string" &&
54
56
  typeof global_config.super_federal_gov_api_keys === "string" &&
55
57
  typeof global_config.federal_gov_api_keys === "string" &&
58
+ typeof global_config.federal_census_api_key === "string" &&
56
59
  typeof global_config.federal_lobby_api_key === "string" &&
57
60
  typeof global_config.scraping_bee_api_key === "string" &&
58
61
  typeof global_config.twitter_api_key === "string" &&