sec-edgar-api 0.0.5 → 0.0.6

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.
Files changed (36) hide show
  1. package/README.md +9 -45
  2. package/build/index.d.ts +2 -7
  3. package/build/index.js +12 -8
  4. package/build/services/Client/Client.d.ts +1 -2
  5. package/build/services/Client/index.js +1 -5
  6. package/build/services/DocumentParser/DocumentParser.d.ts +15 -0
  7. package/build/services/DocumentParser/DocumentParser.js +19 -0
  8. package/build/services/DocumentParser/XMLParser.d.ts +25 -0
  9. package/build/services/DocumentParser/XMLParser.js +178 -0
  10. package/build/services/DocumentParser/index.d.ts +2 -0
  11. package/build/services/DocumentParser/index.js +4 -0
  12. package/build/services/DocumentParser/parsers/index.d.ts +7 -0
  13. package/build/services/DocumentParser/parsers/index.js +9 -0
  14. package/build/services/DocumentParser/parsers/parse-form-13g.d.ts +8 -0
  15. package/build/services/DocumentParser/parsers/parse-form-13g.js +88 -0
  16. package/build/services/DocumentParser/parsers/parse-form-4.d.ts +8 -0
  17. package/build/services/DocumentParser/parsers/parse-form-4.js +220 -0
  18. package/build/services/ReportParser/ReportParser.d.ts +1 -1
  19. package/build/services/ReportParser/ReportTranslatedProxy.d.ts +1 -1
  20. package/build/services/ReportParser/ReportWrapper.js +1 -2
  21. package/build/services/ReportParser/resolvers/helpers.d.ts +1 -1
  22. package/build/services/SecEdgarApi/RequestWrapper.d.ts +30 -0
  23. package/build/services/SecEdgarApi/RequestWrapper.js +133 -0
  24. package/build/services/SecEdgarApi/SecEdgarApi.d.ts +143 -22
  25. package/build/services/SecEdgarApi/SecEdgarApi.js +292 -33
  26. package/build/services/SecEdgarApi/Throttler.js +1 -1
  27. package/build/services/SecEdgarApi/index.js +1 -5
  28. package/build/types/common.type.d.ts +12 -0
  29. package/build/types/common.type.js +2 -0
  30. package/build/types/index.d.ts +2 -0
  31. package/build/types/index.js +3 -5
  32. package/build/types/parsed-filings.type.d.ts +58 -0
  33. package/build/types/parsed-filings.type.js +2 -0
  34. package/build/types/report-raw.type.d.ts +3 -3
  35. package/build/types/submission.type.d.ts +19 -1
  36. package/package.json +1 -5
package/README.md CHANGED
@@ -1,8 +1,15 @@
1
- # sec-edgar-api
1
+ # SEC Edgar API
2
2
 
3
3
  Fetch and parse earnings reports and other documents filed with the SEC using the EDGAR API.
4
4
  This package is focused on the earnings reports for stock analysis.
5
5
 
6
+ Some main data points available include:
7
+
8
+ - Earnings Reports
9
+ - Insider Transactions
10
+ - Institutional Holders
11
+ - Filing History
12
+
6
13
  ## Installation
7
14
 
8
15
  ```SH
@@ -93,7 +100,7 @@ interface ReportTranslated {
93
100
  import package contents
94
101
 
95
102
  ```TS
96
- import { factFileReader, reportParser, secEdgarApi } from 'sec-edgar-api'
103
+ import { secEdgarApi } from 'sec-edgar-api'
97
104
  ```
98
105
 
99
106
  You can fetch reports individually directly from the SEC website, (throttled to 10 requests per second)
@@ -103,38 +110,6 @@ You can fetch reports individually directly from the SEC website, (throttled to
103
110
  const reports = await secEdgarApi.getReports({ symbol: 'AAPL' })
104
111
  ```
105
112
 
106
- or download all data from the SEC website and read directly from the files so you don't have to worry about rate limiting.
107
-
108
- ```TS
109
- import { factsDownloader } from 'sec-edgar-api/downloader'
110
-
111
- const downloadDirectory = './downloads/companyfacts'
112
-
113
- // Download companyfacts directory from sec.gov (over 15GB)
114
- await factsDownloader.downloadCompanyFactsDirectory({
115
- outputDirname: downloadDirectory,
116
- onDownloadComplete: () => process.stdout.write('\n'),
117
- onChunk: ({ percentComplete, stage }) => {
118
- // Write progress bar to console
119
- const countBarsComplete = Math.ceil(percentComplete * 30)
120
- const barStr = `${'='.repeat(countBarsComplete)}${' '.repeat(30 - countBarsComplete)}`
121
- const percentStr = `${(Math.round(percentComplete * 10000) / 100).toFixed(2)}%`
122
- const statusStr = stage === 'download' ? 'Downloading...' : 'Unzipping...'
123
-
124
- process.stdout.write(`\r<${barStr}> ${percentStr} ${statusStr}`)
125
- },
126
- })
127
-
128
- // read companyfacts directory
129
- const companyFacts = factFileReader.readFactFile({
130
- companyFactsDirname: downloadDirectory,
131
- symbol: 'AAPL',
132
- })
133
-
134
- // parse reports (same return value as secEdgarApi.getReports())
135
- const reports = reportParser.parseReports(companyFacts)
136
- ```
137
-
138
113
  ## Resolvers
139
114
 
140
115
  **WARNING** Still in testing. Values may not be accurate for all companies since the properties provided in the reports differ.
@@ -170,17 +145,6 @@ Files for mapping & resolving properties:
170
145
  - Mapping properties: `src/util/key-translations.ts`
171
146
  - Resolving properties: `src/services/ReportParser.ts` (add resolvers to the `resolvers/` directory, import to `/resolver/index.ts`, and add to ReportParser.resolveAll)
172
147
 
173
- These are the scripts I used to get keys commonly used across reports, which you can use to add to `key-translations.ts`
174
-
175
- ```TS
176
- import { readAllCompanyFactFiles, getPropertyUsageCounts } from './scripts/script-helpers'
177
-
178
- const companyFactsList = readAllCompanyFactFiles(path.resolve('./downloads/companyfacts'), 10)
179
- const propertyUsageCounts = getPropertyUsageCounts(companyFactsList)
180
-
181
- fs.writeFileSync('./downloads/property-usage-counts.json', JSON.stringify(propertyUsageCounts, null, 2))
182
- ```
183
-
184
148
  ### Resources
185
149
 
186
150
  - Validate resolved values: https://finance.yahoo.com/
package/build/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import FactFileReader from './services/FactFileReader';
2
1
  import ReportParser from './services/ReportParser';
3
2
  import SecEdgarApi from './services/SecEdgarApi';
4
3
  /**
@@ -6,11 +5,6 @@ import SecEdgarApi from './services/SecEdgarApi';
6
5
  * reports as json objects.
7
6
  */
8
7
  declare const reportParser: ReportParser;
9
- /**
10
- * Reads files from the companyfacts directory (which can be downloaded
11
- * using secEdgarApi.downloadCompanyFacts()).
12
- */
13
- declare const factFileReader: FactFileReader;
14
8
  /**
15
9
  * Gets company reports and filings from the SEC EDGAR API. Requests are
16
10
  * throttled with 120ms delay between requests to avoid rate limiting.
@@ -18,4 +12,5 @@ declare const factFileReader: FactFileReader;
18
12
  * @see https://www.sec.gov/edgar/sec-api-documentation
19
13
  */
20
14
  declare const secEdgarApi: SecEdgarApi;
21
- export { reportParser, factFileReader, secEdgarApi };
15
+ export { reportParser, secEdgarApi };
16
+ export * from './types';
package/build/index.js CHANGED
@@ -1,7 +1,16 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
2
12
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.secEdgarApi = exports.factFileReader = exports.reportParser = void 0;
4
- var FactFileReader_1 = require("./services/FactFileReader");
13
+ exports.secEdgarApi = exports.reportParser = void 0;
5
14
  var ReportParser_1 = require("./services/ReportParser");
6
15
  var SecEdgarApi_1 = require("./services/SecEdgarApi");
7
16
  /**
@@ -10,12 +19,6 @@ var SecEdgarApi_1 = require("./services/SecEdgarApi");
10
19
  */
11
20
  var reportParser = new ReportParser_1.default();
12
21
  exports.reportParser = reportParser;
13
- /**
14
- * Reads files from the companyfacts directory (which can be downloaded
15
- * using secEdgarApi.downloadCompanyFacts()).
16
- */
17
- var factFileReader = new FactFileReader_1.default();
18
- exports.factFileReader = factFileReader;
19
22
  /**
20
23
  * Gets company reports and filings from the SEC EDGAR API. Requests are
21
24
  * throttled with 120ms delay between requests to avoid rate limiting.
@@ -24,3 +27,4 @@ exports.factFileReader = factFileReader;
24
27
  */
25
28
  var secEdgarApi = new SecEdgarApi_1.default();
26
29
  exports.secEdgarApi = secEdgarApi;
30
+ __exportStar(require("./types"), exports);
@@ -1,7 +1,6 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { ClientRequest, IncomingMessage, RequestOptions } from 'http';
4
- type Primitive = string | number | boolean | null | undefined;
3
+ declare type Primitive = string | number | boolean | null | undefined;
5
4
  interface HttpClient {
6
5
  request: (options: string | URL | RequestOptions, callback?: (res: IncomingMessage) => void) => ClientRequest;
7
6
  }
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
5
  }) : (function(o, m, k, k2) {
10
6
  if (k2 === undefined) k2 = k;
11
7
  o[k2] = m[k];
@@ -0,0 +1,15 @@
1
+ import { InsiderTransaction, XMLParams } from '../../types';
2
+ import XMLParser from './XMLParser';
3
+ import parsers from './parsers';
4
+ interface DocumentParserArgs {
5
+ parser?: XMLParser;
6
+ parsersByName?: typeof parsers;
7
+ }
8
+ export default class DocumentParser {
9
+ private readonly parser;
10
+ private readonly parsersByName;
11
+ constructor(args?: DocumentParserArgs);
12
+ parseInsiderTransactions(params: XMLParams): InsiderTransaction[];
13
+ parseHolders(params: XMLParams): import("../../types").Holder[];
14
+ }
15
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var XMLParser_1 = require("./XMLParser");
4
+ var parsers_1 = require("./parsers");
5
+ var DocumentParser = /** @class */ (function () {
6
+ function DocumentParser(args) {
7
+ var _a = args !== null && args !== void 0 ? args : {}, _b = _a.parser, parser = _b === void 0 ? new XMLParser_1.default() : _b, _c = _a.parsersByName, parsersByName = _c === void 0 ? parsers_1.default : _c;
8
+ this.parser = parser;
9
+ this.parsersByName = parsersByName;
10
+ }
11
+ DocumentParser.prototype.parseInsiderTransactions = function (params) {
12
+ return this.parsersByName.parseForm4(params, this.parser);
13
+ };
14
+ DocumentParser.prototype.parseHolders = function (params) {
15
+ return this.parsersByName.parseForm13g(params, this.parser);
16
+ };
17
+ return DocumentParser;
18
+ }());
19
+ exports.default = DocumentParser;
@@ -0,0 +1,25 @@
1
+ interface OnCharacterData {
2
+ char: string;
3
+ index: number;
4
+ path: string;
5
+ pathOccurrenceCount: number;
6
+ }
7
+ interface Parse2Params {
8
+ xml: string;
9
+ onCharacter?: (data: OnCharacterData) => void;
10
+ onOpenTag?: (data: OnCharacterData) => void;
11
+ onCloseTag?: (data: OnCharacterData) => void;
12
+ }
13
+ interface IterateTablesParams {
14
+ xml: string;
15
+ parentPath?: string;
16
+ trimSpaces?: boolean;
17
+ }
18
+ export default class XMLParser {
19
+ iterateXML(params: Parse2Params): string[];
20
+ /**
21
+ * Returns text in each table cell mapped by `${table}.${row}.${col}`
22
+ */
23
+ getTableTextMap(params: IterateTablesParams): Map<string, string>;
24
+ }
25
+ export {};
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var XMLParser = /** @class */ (function () {
4
+ function XMLParser() {
5
+ }
6
+ XMLParser.prototype.iterateXML = function (params) {
7
+ var _a, _b, _c, _d;
8
+ var xml = params.xml, onCharacter = params.onCharacter, onCloseTag = params.onCloseTag, onOpenTag = params.onOpenTag;
9
+ var selfEnclosingTags = new Set([
10
+ 'filename',
11
+ 'description',
12
+ 'br',
13
+ 'meta',
14
+ 'link',
15
+ 'img',
16
+ 'input',
17
+ 'hr',
18
+ 'area',
19
+ 'base',
20
+ 'col',
21
+ 'command',
22
+ 'embed',
23
+ 'keygen',
24
+ 'param',
25
+ 'source',
26
+ 'track',
27
+ 'wbr',
28
+ ]);
29
+ var pathOccurrenceCountMap = new Map();
30
+ var curPath = '';
31
+ var curTag = '';
32
+ var didStart = false;
33
+ var pathsArr = [];
34
+ for (var i = 0; i < xml.length; i++) {
35
+ var char = xml[i];
36
+ if (char === '<' && xml[i + 1] !== '/' && xml[i + 1] !== '?' && xml[i + 1] !== '!') {
37
+ var iOpen = i;
38
+ didStart = true;
39
+ i++;
40
+ var j = 0;
41
+ var didEndTagName = false;
42
+ while (xml[i] !== '>') {
43
+ didEndTagName =
44
+ didEndTagName ||
45
+ xml[i] === ' ' ||
46
+ xml[i] === '\n' ||
47
+ xml[i] === '\r' ||
48
+ xml[i] === '\t' ||
49
+ xml[i] === '/';
50
+ if (!didEndTagName) {
51
+ curTag += xml[i].toLowerCase();
52
+ }
53
+ i++;
54
+ j++;
55
+ if (j > 1000) {
56
+ throw new Error('too many iterations');
57
+ }
58
+ }
59
+ // map path for non-self-enclosing tags
60
+ if (!selfEnclosingTags.has(curTag)) {
61
+ curPath = "".concat(curPath).concat(curPath.length > 0 ? '.' : '').concat(curTag).toLowerCase();
62
+ var pathOccurrenceCount = (_a = pathOccurrenceCountMap.get(curPath)) !== null && _a !== void 0 ? _a : 0;
63
+ pathOccurrenceCountMap.set(curPath, pathOccurrenceCount + 1);
64
+ pathsArr.push(curPath);
65
+ onOpenTag === null || onOpenTag === void 0 ? void 0 : onOpenTag({
66
+ char: char,
67
+ index: iOpen,
68
+ path: curPath,
69
+ pathOccurrenceCount: (_b = pathOccurrenceCountMap.get(curPath)) !== null && _b !== void 0 ? _b : 0,
70
+ });
71
+ }
72
+ curTag = '';
73
+ }
74
+ else if (char === '<' && xml[i + 1] === '/') {
75
+ while (xml[i] !== '>') {
76
+ i++;
77
+ }
78
+ onCloseTag === null || onCloseTag === void 0 ? void 0 : onCloseTag({
79
+ char: char,
80
+ index: i,
81
+ path: curPath,
82
+ pathOccurrenceCount: (_c = pathOccurrenceCountMap.get(curPath)) !== null && _c !== void 0 ? _c : 0,
83
+ });
84
+ curPath = curPath.slice(0, curPath.lastIndexOf('.'));
85
+ }
86
+ else if (didStart) {
87
+ onCharacter === null || onCharacter === void 0 ? void 0 : onCharacter({
88
+ char: char,
89
+ index: i,
90
+ path: curPath,
91
+ pathOccurrenceCount: (_d = pathOccurrenceCountMap.get(curPath)) !== null && _d !== void 0 ? _d : 0,
92
+ });
93
+ }
94
+ }
95
+ return pathsArr;
96
+ };
97
+ /**
98
+ * Returns text in each table cell mapped by `${table}.${row}.${col}`
99
+ */
100
+ XMLParser.prototype.getTableTextMap = function (params) {
101
+ var xml = params.xml, parentPath = params.parentPath, _a = params.trimSpaces, trimSpaces = _a === void 0 ? true : _a;
102
+ var rowPaths = new Set([
103
+ "".concat(parentPath, ".table.tbody.tr"),
104
+ "".concat(parentPath, ".table.thead.tr"),
105
+ "".concat(parentPath, ".table.tfoot.tr"),
106
+ "".concat(parentPath, ".table.tr"),
107
+ ]);
108
+ var colPaths = new Set([
109
+ "".concat(parentPath, ".table.tbody.tr.td"),
110
+ "".concat(parentPath, ".table.thead.tr.td"),
111
+ "".concat(parentPath, ".table.tfoot.tr.td"),
112
+ "".concat(parentPath, ".table.tr.td"),
113
+ "".concat(parentPath, ".table.tbody.tr.th"),
114
+ "".concat(parentPath, ".table.thead.tr.th"),
115
+ "".concat(parentPath, ".table.tfoot.tr.th"),
116
+ "".concat(parentPath, ".table.tr.th"),
117
+ ]);
118
+ var table = 0;
119
+ var row = 0;
120
+ var col = 0;
121
+ var textByColKey = new Map();
122
+ var spaceChars = new Set(['\n', '\r', '\t']);
123
+ this.iterateXML({
124
+ xml: xml,
125
+ onOpenTag: function (_a) {
126
+ var _b;
127
+ var path = _a.path;
128
+ var colKey = "".concat(table, ".").concat(row, ".").concat(col);
129
+ var textCur = (_b = textByColKey.get(colKey)) !== null && _b !== void 0 ? _b : '';
130
+ var pathLower = path.toLowerCase();
131
+ if (textCur.trim().length === 0 && col === 0) {
132
+ textByColKey.delete(colKey);
133
+ }
134
+ var isTable = parentPath ? pathLower === "".concat(parentPath, ".table") : pathLower.endsWith('table');
135
+ var isRow = parentPath ? rowPaths.has(pathLower) : pathLower.endsWith('tr');
136
+ var isCol = parentPath
137
+ ? colPaths.has(pathLower)
138
+ : pathLower.endsWith('td') || pathLower.endsWith('th');
139
+ if (isTable) {
140
+ table++;
141
+ col = 0;
142
+ row = 0;
143
+ }
144
+ else if (isRow) {
145
+ row++;
146
+ col = 0;
147
+ }
148
+ else if (isCol) {
149
+ col++;
150
+ }
151
+ },
152
+ onCharacter: function (_a) {
153
+ var _b;
154
+ var char = _a.char;
155
+ char = spaceChars.has(char) ? ' ' : char;
156
+ var colKey = "".concat(table, ".").concat(row, ".").concat(col);
157
+ var textCur = (_b = textByColKey.get(colKey)) !== null && _b !== void 0 ? _b : '';
158
+ if (trimSpaces && char === ' ' && textCur.endsWith(' '))
159
+ return;
160
+ textByColKey.set(colKey, "".concat(textCur).concat(char));
161
+ },
162
+ onCloseTag: function () {
163
+ var _a;
164
+ var colKey = "".concat(table, ".").concat(row, ".").concat(col);
165
+ var textCur = (_a = textByColKey.get(colKey)) !== null && _a !== void 0 ? _a : '';
166
+ if (textCur.trim().length === 0 && col === 0) {
167
+ textByColKey.delete(colKey);
168
+ }
169
+ else if (!textCur.endsWith(' ')) {
170
+ textByColKey.set(colKey, "".concat(textCur, " "));
171
+ }
172
+ },
173
+ });
174
+ return textByColKey;
175
+ };
176
+ return XMLParser;
177
+ }());
178
+ exports.default = XMLParser;
@@ -0,0 +1,2 @@
1
+ import DocumentParser from './DocumentParser';
2
+ export default DocumentParser;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var DocumentParser_1 = require("./DocumentParser");
4
+ exports.default = DocumentParser_1.default;
@@ -0,0 +1,7 @@
1
+ import { parseForm4 } from './parse-form-4';
2
+ import { parseForm13g } from './parse-form-13g';
3
+ declare const parsers: {
4
+ parseForm4: typeof parseForm4;
5
+ parseForm13g: typeof parseForm13g;
6
+ };
7
+ export default parsers;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var parse_form_4_1 = require("./parse-form-4");
4
+ var parse_form_13g_1 = require("./parse-form-13g");
5
+ var parsers = {
6
+ parseForm4: parse_form_4_1.parseForm4,
7
+ parseForm13g: parse_form_13g_1.parseForm13g,
8
+ };
9
+ exports.default = parsers;
@@ -0,0 +1,8 @@
1
+ import { Holder, XMLParams } from '../../../types';
2
+ import XMLParser from '../XMLParser';
3
+ /**
4
+ * Form SC 13G - Holders
5
+ *
6
+ * example at https://www.sec.gov/Archives/edgar/data/320193/000119312523038262/d382361dsc13ga.htm
7
+ */
8
+ export declare function parseForm13g(params: XMLParams, xmlParser?: XMLParser): Holder[];
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseForm13g = void 0;
4
+ var XMLParser_1 = require("../XMLParser");
5
+ /**
6
+ * Form SC 13G - Holders
7
+ *
8
+ * example at https://www.sec.gov/Archives/edgar/data/320193/000119312523038262/d382361dsc13ga.htm
9
+ */
10
+ function parseForm13g(params, xmlParser) {
11
+ var _a, _b, _c, _d;
12
+ if (xmlParser === void 0) { xmlParser = new XMLParser_1.default(); }
13
+ var xml = params.xml;
14
+ var textMap = xmlParser.getTableTextMap({ xml: xml });
15
+ var holders = [];
16
+ var getKey = function (text) {
17
+ var keyMap = {
18
+ 'name of reporting': 'name',
19
+ 'names of reporting': 'name',
20
+ 'citizenship or place': 'origin',
21
+ 'sole voting power': 'votingPowerSole',
22
+ 'shared voting power': 'votingPowerShared',
23
+ 'sole dispositive power': 'dispositivePowerSole',
24
+ 'shared dispositive power': 'dispositivePowerShared',
25
+ 'aggregate amount beneficially owned': 'shares',
26
+ 'percent of class': 'percentOfClass',
27
+ 'type of reporting person': 'typeOfReportingPerson',
28
+ };
29
+ var textLower = text.toLowerCase();
30
+ for (var key in keyMap) {
31
+ if (textLower.includes(key))
32
+ return keyMap[key];
33
+ }
34
+ return null;
35
+ };
36
+ var _loop_1 = function (text) {
37
+ var colName = getKey(text);
38
+ var isNewHolder = colName === 'name';
39
+ if (isNewHolder) {
40
+ if (((_a = holders[holders.length - 1]) === null || _a === void 0 ? void 0 : _a.name) === '') {
41
+ holders.pop();
42
+ }
43
+ holders.push({
44
+ name: '',
45
+ origin: '',
46
+ shares: 0,
47
+ percentOfClass: '',
48
+ votingPowerSole: null,
49
+ votingPowerShared: null,
50
+ dispositivePowerSole: null,
51
+ dispositivePowerShared: null,
52
+ typeOfReportingPerson: null,
53
+ });
54
+ }
55
+ var holder = holders[holders.length - 1];
56
+ // continue if no colName or if the value is already set
57
+ if (colName === null || ![0, '', null].includes(holder[colName]))
58
+ return "continue";
59
+ var textParts = text.split('&nbsp;').filter(function (t) { return t.trim() !== ''; });
60
+ var colNameIndex = textParts.findIndex(function (t) { return getKey(t) === colName; });
61
+ var value = (_c = (_b = textParts[colNameIndex + 1]) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
62
+ switch (colName) {
63
+ case 'shares':
64
+ holder.shares = Number(value.replace(/[^0-9]/g, '')) || 0;
65
+ break;
66
+ case 'typeOfReportingPerson':
67
+ holder[colName] = value === '' ? null : value;
68
+ break;
69
+ case 'votingPowerSole':
70
+ case 'votingPowerShared':
71
+ case 'dispositivePowerSole':
72
+ case 'dispositivePowerShared':
73
+ holder[colName] = value.toLowerCase() === 'none' ? null : value;
74
+ break;
75
+ default:
76
+ holder[colName] = value;
77
+ }
78
+ };
79
+ for (var _i = 0, _e = Array.from(textMap.values()); _i < _e.length; _i++) {
80
+ var text = _e[_i];
81
+ _loop_1(text);
82
+ }
83
+ if (((_d = holders[holders.length - 1]) === null || _d === void 0 ? void 0 : _d.name) === '') {
84
+ holders.pop();
85
+ }
86
+ return holders;
87
+ }
88
+ exports.parseForm13g = parseForm13g;
@@ -0,0 +1,8 @@
1
+ import { InsiderTransaction, XMLParams } from '../../../types';
2
+ import XMLParser from '../XMLParser';
3
+ /**
4
+ * Form 4 - Insider Transactions
5
+ *
6
+ * example at https://www.sec.gov/Archives/edgar/data/320193/000032019323000079/xslF345X05/wk-form4_1691533817.xml
7
+ */
8
+ export declare function parseForm4(params: XMLParams, xmlParser?: XMLParser): InsiderTransaction[];