web-csv-toolbox 0.8.0 → 0.9.0

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.
@@ -1,4 +1,46 @@
1
1
  import type { Field, FieldDelimiter, RecordDelimiter } from "./constants.ts";
2
+ /**
3
+ * Position object.
4
+ */
5
+ export interface Position {
6
+ /**
7
+ * Line number.
8
+ * Starts from 1.
9
+ */
10
+ line: number;
11
+ /**
12
+ * Column number.
13
+ * Starts from 1.
14
+ */
15
+ column: number;
16
+ /**
17
+ * Character offset.
18
+ * Starts from 0.
19
+ */
20
+ offset: number;
21
+ }
22
+ /**
23
+ * Token location object.
24
+ */
25
+ export interface TokenLocation {
26
+ /**
27
+ * Start location.
28
+ */
29
+ start: Position;
30
+ /**
31
+ * End location.
32
+ */
33
+ end: Position;
34
+ /**
35
+ * Row number.
36
+ * Starts from 1.
37
+ *
38
+ * @remarks
39
+ * This represents the logical row number in the CSV,
40
+ * counting from 1 for the first row, whether it is a header or not.
41
+ */
42
+ rowNumber: number;
43
+ }
2
44
  /**
3
45
  * Field token type.
4
46
  * @category Types
@@ -6,13 +48,32 @@ import type { Field, FieldDelimiter, RecordDelimiter } from "./constants.ts";
6
48
  export interface FieldToken {
7
49
  type: typeof Field;
8
50
  value: string;
51
+ location: TokenLocation;
52
+ }
53
+ /**
54
+ * Field delimiter token type.
55
+ * @category Types
56
+ */
57
+ export interface FieldDelimiterToken {
58
+ type: typeof FieldDelimiter;
59
+ value: string;
60
+ location: TokenLocation;
61
+ }
62
+ /**
63
+ * Record delimiter token type.
64
+ * @category Types
65
+ */
66
+ export interface RecordDelimiterToken {
67
+ type: typeof RecordDelimiter;
68
+ value: string;
69
+ location: TokenLocation;
9
70
  }
10
71
  /**
11
72
  * Token is a atomic unit of a CSV file.
12
73
  * It can be a field, field delimiter, or record delimiter.
13
74
  * @category Types
14
75
  */
15
- export type Token = FieldToken | typeof FieldDelimiter | typeof RecordDelimiter;
76
+ export type Token = FieldToken | FieldDelimiterToken | RecordDelimiterToken;
16
77
  /**
17
78
  * CSV Common Options.
18
79
  * @category Types