hazo_scrape 1.2.0 → 1.2.1
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/CHANGE_LOG.md +5 -0
- package/dist/parse/map_rows.d.ts +4 -1
- package/dist/parse/map_rows.d.ts.map +1 -1
- package/dist/parse/map_rows.js +14 -4
- package/package.json +1 -1
package/CHANGE_LOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# hazo_scrape — Change Log
|
|
2
2
|
|
|
3
|
+
## 1.2.1 — 2026-07-23
|
|
4
|
+
|
|
5
|
+
### Fixed — republish of 1.2.0's `dist`
|
|
6
|
+
- `1.2.0`'s published tarball had a stale `dist/` — the `mapRows` source fix below was made, but `npm run build` was never re-run before that publish, so the shipped `dist/parse/map_rows.js`/`.d.ts` still only accepted 3 arguments. Caught by `extractor_asx`'s own `tsc --noEmit` failing after bumping the dependency (`Expected 3 arguments, but got 4`). No source changes in this release — just a correct rebuild + republish under a new version (npm doesn't allow overwriting a published version).
|
|
7
|
+
|
|
3
8
|
## 1.2.0 — 2026-07-22
|
|
4
9
|
|
|
5
10
|
### Added — `mapRows` optional `opts.dateFormats`
|
package/dist/parse/map_rows.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ColumnKeywords, ColumnMap, MappedRow } from './types.js';
|
|
2
|
+
export interface MapRowsOptions {
|
|
3
|
+
dateFormats?: string[];
|
|
4
|
+
}
|
|
2
5
|
export declare function mapRows(table: {
|
|
3
6
|
headers: string[];
|
|
4
7
|
rows: string[][];
|
|
5
|
-
}, map: ColumnMap, keywords: ColumnKeywords): MappedRow[];
|
|
8
|
+
}, map: ColumnMap, keywords: ColumnKeywords, opts?: MapRowsOptions): MappedRow[];
|
|
6
9
|
//# sourceMappingURL=map_rows.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map_rows.d.ts","sourceRoot":"","sources":["../../src/parse/map_rows.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"map_rows.d.ts","sourceRoot":"","sources":["../../src/parse/map_rows.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAQ,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI7E,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAaD,wBAAgB,OAAO,CACrB,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,EAC9C,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,cAAc,EACxB,IAAI,CAAC,EAAE,cAAc,GACpB,SAAS,EAAE,CAwBb"}
|
package/dist/parse/map_rows.js
CHANGED
|
@@ -15,18 +15,28 @@
|
|
|
15
15
|
// Ragged rows (shorter than a candidate's index) never throw: the raw string
|
|
16
16
|
// is treated as '' and value is computed from that empty string (null for
|
|
17
17
|
// number/date, null for text after trim). Rows are taken as-is, never padded.
|
|
18
|
+
//
|
|
19
|
+
// opts.dateFormats (added 2026-07-22): forwarded verbatim to parseDate's
|
|
20
|
+
// `opts.formats` for every date-typed cell. Without it, a genuinely
|
|
21
|
+
// ambiguous slash date (both components <=12, e.g. "09/11/2012") correctly
|
|
22
|
+
// stays null — see parse_date.ts's "never guess" design and this file's own
|
|
23
|
+
// pinned MQG test. A caller that KNOWS the source's date convention (e.g. a
|
|
24
|
+
// SourceRegistry entry's `nuances.date_formats`) can pass it here to resolve
|
|
25
|
+
// what would otherwise be an unresolvable ambiguity. Omitting it preserves
|
|
26
|
+
// the exact prior behavior — this is purely additive.
|
|
18
27
|
import { parseNumber } from './parse_number.js';
|
|
19
28
|
import { parseDate } from './parse_date.js';
|
|
20
|
-
function cellValue(type, raw) {
|
|
29
|
+
function cellValue(type, raw, dateFormats) {
|
|
21
30
|
if (type === 'number')
|
|
22
31
|
return parseNumber(raw);
|
|
23
32
|
if (type === 'date')
|
|
24
|
-
return parseDate(raw);
|
|
33
|
+
return parseDate(raw, dateFormats ? { formats: dateFormats } : undefined);
|
|
25
34
|
const trimmed = raw.trim();
|
|
26
35
|
return trimmed === '' ? null : trimmed;
|
|
27
36
|
}
|
|
28
|
-
export function mapRows(table, map, keywords) {
|
|
37
|
+
export function mapRows(table, map, keywords, opts) {
|
|
29
38
|
const keys = Object.keys(map.matched);
|
|
39
|
+
const dateFormats = opts?.dateFormats;
|
|
30
40
|
return table.rows.map((row) => {
|
|
31
41
|
const mappedRow = {};
|
|
32
42
|
for (const key of keys) {
|
|
@@ -38,7 +48,7 @@ export function mapRows(table, map, keywords) {
|
|
|
38
48
|
header: candidate.header,
|
|
39
49
|
index: candidate.index,
|
|
40
50
|
raw,
|
|
41
|
-
value: cellValue(type, raw),
|
|
51
|
+
value: cellValue(type, raw, dateFormats),
|
|
42
52
|
};
|
|
43
53
|
});
|
|
44
54
|
}
|