df-script 1.4.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.
Files changed (134) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +269 -0
  3. package/dist/api.d.ts +39 -0
  4. package/dist/api.js +18 -0
  5. package/dist/bundle.min.js +1 -0
  6. package/dist/columnExpressions/ColumnExpr.d.ts +368 -0
  7. package/dist/columnExpressions/ColumnExpr.js +23 -0
  8. package/dist/columnExpressions/ExprBase.d.ts +24 -0
  9. package/dist/columnExpressions/ExprBase.js +133 -0
  10. package/dist/columnExpressions/constants.d.ts +2 -0
  11. package/dist/columnExpressions/constants.js +5 -0
  12. package/dist/columnExpressions/functions/all.d.ts +5 -0
  13. package/dist/columnExpressions/functions/all.js +11 -0
  14. package/dist/columnExpressions/functions/coalesce.d.ts +3 -0
  15. package/dist/columnExpressions/functions/coalesce.js +40 -0
  16. package/dist/columnExpressions/functions/exclude.d.ts +5 -0
  17. package/dist/columnExpressions/functions/exclude.js +13 -0
  18. package/dist/columnExpressions/functions/lit.d.ts +5 -0
  19. package/dist/columnExpressions/functions/lit.js +22 -0
  20. package/dist/columnExpressions/functions/when.d.ts +24 -0
  21. package/dist/columnExpressions/functions/when.js +81 -0
  22. package/dist/columnExpressions/index.d.ts +19 -0
  23. package/dist/columnExpressions/index.js +81 -0
  24. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +50 -0
  25. package/dist/columnExpressions/mixins/AggregationExpr.js +172 -0
  26. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +67 -0
  27. package/dist/columnExpressions/mixins/ArithmeticExpr.js +143 -0
  28. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +60 -0
  29. package/dist/columnExpressions/mixins/ComparisonExpr.js +389 -0
  30. package/dist/columnExpressions/mixins/ListExpr.d.ts +63 -0
  31. package/dist/columnExpressions/mixins/ListExpr.js +248 -0
  32. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +33 -0
  33. package/dist/columnExpressions/mixins/LogicalExpr.js +54 -0
  34. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +31 -0
  35. package/dist/columnExpressions/mixins/ManipulationExpr.js +35 -0
  36. package/dist/columnExpressions/mixins/StringExpr.d.ts +79 -0
  37. package/dist/columnExpressions/mixins/StringExpr.js +249 -0
  38. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +69 -0
  39. package/dist/columnExpressions/mixins/TemporalExpr.js +127 -0
  40. package/dist/columnExpressions/mixins/WindowExpr.d.ts +50 -0
  41. package/dist/columnExpressions/mixins/WindowExpr.js +281 -0
  42. package/dist/columnExpressions/types.d.ts +7 -0
  43. package/dist/columnExpressions/types.js +2 -0
  44. package/dist/dataframe/constants.d.ts +1 -0
  45. package/dist/dataframe/constants.js +4 -0
  46. package/dist/dataframe/dataframe.d.ts +42 -0
  47. package/dist/dataframe/dataframe.js +749 -0
  48. package/dist/dataframe/grouped/grouped.d.ts +15 -0
  49. package/dist/dataframe/grouped/grouped.js +113 -0
  50. package/dist/dataframe/index.d.ts +4 -0
  51. package/dist/dataframe/index.js +20 -0
  52. package/dist/dataframe/types.d.ts +33 -0
  53. package/dist/dataframe/types.js +2 -0
  54. package/dist/dataframe/utils.d.ts +11 -0
  55. package/dist/dataframe/utils.js +215 -0
  56. package/dist/datatypes/DataType.d.ts +40 -0
  57. package/dist/datatypes/DataType.js +47 -0
  58. package/dist/datatypes/index.d.ts +29 -0
  59. package/dist/datatypes/index.js +46 -0
  60. package/dist/datatypes/types/Binary.d.ts +9 -0
  61. package/dist/datatypes/types/Binary.js +18 -0
  62. package/dist/datatypes/types/Boolean.d.ts +9 -0
  63. package/dist/datatypes/types/Boolean.js +19 -0
  64. package/dist/datatypes/types/Date.d.ts +8 -0
  65. package/dist/datatypes/types/Date.js +21 -0
  66. package/dist/datatypes/types/Datetime.d.ts +8 -0
  67. package/dist/datatypes/types/Datetime.js +17 -0
  68. package/dist/datatypes/types/Decimal.d.ts +10 -0
  69. package/dist/datatypes/types/Decimal.js +28 -0
  70. package/dist/datatypes/types/Duration.d.ts +8 -0
  71. package/dist/datatypes/types/Duration.js +17 -0
  72. package/dist/datatypes/types/Float32.d.ts +8 -0
  73. package/dist/datatypes/types/Float32.js +17 -0
  74. package/dist/datatypes/types/Float64.d.ts +8 -0
  75. package/dist/datatypes/types/Float64.js +17 -0
  76. package/dist/datatypes/types/Int16.d.ts +8 -0
  77. package/dist/datatypes/types/Int16.js +17 -0
  78. package/dist/datatypes/types/Int32.d.ts +8 -0
  79. package/dist/datatypes/types/Int32.js +17 -0
  80. package/dist/datatypes/types/Int64.d.ts +8 -0
  81. package/dist/datatypes/types/Int64.js +17 -0
  82. package/dist/datatypes/types/Int8.d.ts +8 -0
  83. package/dist/datatypes/types/Int8.js +17 -0
  84. package/dist/datatypes/types/List.d.ts +10 -0
  85. package/dist/datatypes/types/List.js +31 -0
  86. package/dist/datatypes/types/Null.d.ts +9 -0
  87. package/dist/datatypes/types/Null.js +17 -0
  88. package/dist/datatypes/types/Object.d.ts +9 -0
  89. package/dist/datatypes/types/Object.js +17 -0
  90. package/dist/datatypes/types/Struct.d.ts +14 -0
  91. package/dist/datatypes/types/Struct.js +39 -0
  92. package/dist/datatypes/types/Time.d.ts +8 -0
  93. package/dist/datatypes/types/Time.js +29 -0
  94. package/dist/datatypes/types/UInt16.d.ts +8 -0
  95. package/dist/datatypes/types/UInt16.js +17 -0
  96. package/dist/datatypes/types/UInt32.d.ts +8 -0
  97. package/dist/datatypes/types/UInt32.js +17 -0
  98. package/dist/datatypes/types/UInt64.d.ts +8 -0
  99. package/dist/datatypes/types/UInt64.js +17 -0
  100. package/dist/datatypes/types/UInt8.d.ts +8 -0
  101. package/dist/datatypes/types/UInt8.js +17 -0
  102. package/dist/datatypes/types/Utf8.d.ts +10 -0
  103. package/dist/datatypes/types/Utf8.js +20 -0
  104. package/dist/datatypes/types.d.ts +172 -0
  105. package/dist/datatypes/types.js +286 -0
  106. package/dist/exceptions/index.d.ts +13 -0
  107. package/dist/exceptions/index.js +43 -0
  108. package/dist/exceptions/utils.d.ts +2 -0
  109. package/dist/exceptions/utils.js +9 -0
  110. package/dist/functions/concat.d.ts +4 -0
  111. package/dist/functions/concat.js +248 -0
  112. package/dist/functions/index.d.ts +1 -0
  113. package/dist/functions/index.js +17 -0
  114. package/dist/index.d.ts +7 -0
  115. package/dist/index.js +1 -0
  116. package/dist/types.d.ts +47 -0
  117. package/dist/types.js +2 -0
  118. package/dist/utils/boolean.d.ts +1 -0
  119. package/dist/utils/boolean.js +18 -0
  120. package/dist/utils/date.d.ts +57 -0
  121. package/dist/utils/date.js +349 -0
  122. package/dist/utils/guards.d.ts +14 -0
  123. package/dist/utils/guards.js +143 -0
  124. package/dist/utils/index.d.ts +5 -0
  125. package/dist/utils/index.js +21 -0
  126. package/dist/utils/json.d.ts +2 -0
  127. package/dist/utils/json.js +33 -0
  128. package/dist/utils/list.d.ts +23 -0
  129. package/dist/utils/list.js +128 -0
  130. package/dist/utils/number.d.ts +86 -0
  131. package/dist/utils/number.js +223 -0
  132. package/dist/utils/string.d.ts +52 -0
  133. package/dist/utils/string.js +120 -0
  134. package/package.json +34 -0
@@ -0,0 +1,172 @@
1
+ import { DataType, SignedIntegerType, UnsignedIntegerType, FloatDataType, TemporalDataType, NestedDataType, NumericDataType } from "./DataType";
2
+ import type { RowRecord } from "../types";
3
+ export declare class Int8Type extends SignedIntegerType {
4
+ readonly name = "Int8";
5
+ coerce(val: any): number | null;
6
+ equals(other: DataType): boolean;
7
+ allocate(size: number): Int8Array;
8
+ }
9
+ export declare const Int8: Int8Type;
10
+ export declare class Int16Type extends SignedIntegerType {
11
+ readonly name = "Int16";
12
+ coerce(val: any): number | null;
13
+ equals(other: DataType): boolean;
14
+ allocate(size: number): Int16Array;
15
+ }
16
+ export declare const Int16: Int16Type;
17
+ export declare class Int32Type extends SignedIntegerType {
18
+ readonly name = "Int32";
19
+ coerce(val: any): number | null;
20
+ equals(other: DataType): boolean;
21
+ allocate(size: number): Int32Array;
22
+ }
23
+ export declare const Int32: Int32Type;
24
+ export declare class Int64Type extends SignedIntegerType<bigint | null> {
25
+ readonly name = "Int64";
26
+ coerce(val: any): bigint | null;
27
+ equals(other: DataType): boolean;
28
+ allocate(size: number): BigInt64Array;
29
+ }
30
+ export declare const Int64: Int64Type;
31
+ export declare class UInt8Type extends UnsignedIntegerType {
32
+ readonly name = "UInt8";
33
+ coerce(val: any): number | null;
34
+ equals(other: DataType): boolean;
35
+ allocate(size: number): Uint8Array;
36
+ }
37
+ export declare const UInt8: UInt8Type;
38
+ export declare class UInt16Type extends UnsignedIntegerType {
39
+ readonly name = "UInt16";
40
+ coerce(val: any): number | null;
41
+ equals(other: DataType): boolean;
42
+ allocate(size: number): Uint16Array;
43
+ }
44
+ export declare const UInt16: UInt16Type;
45
+ export declare class UInt32Type extends UnsignedIntegerType {
46
+ readonly name = "UInt32";
47
+ coerce(val: any): number | null;
48
+ equals(other: DataType): boolean;
49
+ allocate(size: number): Uint32Array;
50
+ }
51
+ export declare const UInt32: UInt32Type;
52
+ export declare class UInt64Type extends UnsignedIntegerType<bigint | null> {
53
+ readonly name = "UInt64";
54
+ coerce(val: any): bigint | null;
55
+ equals(other: DataType): boolean;
56
+ allocate(size: number): BigUint64Array;
57
+ }
58
+ export declare const UInt64: UInt64Type;
59
+ export declare class Float32Type extends FloatDataType {
60
+ readonly name = "Float32";
61
+ coerce(val: any): number | null;
62
+ equals(other: DataType): boolean;
63
+ allocate(size: number): Float32Array;
64
+ }
65
+ export declare const Float32: Float32Type;
66
+ export declare class Float64Type extends FloatDataType {
67
+ readonly name = "Float64";
68
+ coerce(val: any): number | null;
69
+ equals(other: DataType): boolean;
70
+ allocate(size: number): Float64Array;
71
+ }
72
+ export declare const Float64: Float64Type;
73
+ export declare class DecimalType extends NumericDataType {
74
+ readonly precision?: number | undefined;
75
+ readonly scale?: number | undefined;
76
+ readonly name: string;
77
+ constructor(precision?: number | undefined, scale?: number | undefined);
78
+ coerce(val: any): number | null;
79
+ equals(other: DataType): boolean;
80
+ allocate(size: number): (number | null)[];
81
+ }
82
+ export declare class BooleanType extends DataType {
83
+ readonly name = "Boolean";
84
+ get isBoolean(): boolean;
85
+ coerce(val: any): boolean | null;
86
+ equals(other: DataType): boolean;
87
+ allocate(size: number): (boolean | null)[];
88
+ }
89
+ export declare const Boolean: BooleanType;
90
+ export declare class Utf8Type extends DataType {
91
+ readonly name = "Utf8";
92
+ get isString(): boolean;
93
+ get isUtf8(): boolean;
94
+ coerce(val: any): string | null;
95
+ equals(other: DataType): boolean;
96
+ allocate(size: number): (string | null)[];
97
+ }
98
+ export declare const Utf8: Utf8Type;
99
+ export declare class BinaryType extends DataType {
100
+ readonly name = "Binary";
101
+ get isBinary(): boolean;
102
+ coerce(val: any): Uint8Array | null;
103
+ equals(other: DataType): boolean;
104
+ allocate(size: number): (Uint8Array | null)[];
105
+ }
106
+ export declare const Binary: BinaryType;
107
+ export declare class NullType extends DataType {
108
+ readonly name = "Null";
109
+ get isNull(): boolean;
110
+ coerce(_val: any): null;
111
+ equals(other: DataType): boolean;
112
+ allocate(size: number): null[];
113
+ }
114
+ export declare const Null: NullType;
115
+ export declare class ObjectType extends DataType {
116
+ readonly name = "Object";
117
+ get isObject(): boolean;
118
+ coerce(val: any): any;
119
+ equals(other: DataType): boolean;
120
+ allocate(size: number): any[];
121
+ }
122
+ export declare const Object: ObjectType;
123
+ export declare class DateType extends TemporalDataType {
124
+ readonly name = "Date";
125
+ coerce(val: any): Date | null;
126
+ equals(other: DataType): boolean;
127
+ allocate(size: number): (Date | null)[];
128
+ }
129
+ export declare const Date: DateType;
130
+ export declare class DatetimeType extends TemporalDataType {
131
+ readonly name = "Datetime";
132
+ coerce(val: any): Date | null;
133
+ equals(other: DataType): boolean;
134
+ allocate(size: number): (Date | null)[];
135
+ }
136
+ export declare const Datetime: DatetimeType;
137
+ export declare class TimeType extends TemporalDataType {
138
+ readonly name = "Time";
139
+ coerce(val: any): string | null;
140
+ equals(other: DataType): boolean;
141
+ allocate(size: number): (string | null)[];
142
+ }
143
+ export declare const Time: TimeType;
144
+ export declare class DurationType extends TemporalDataType {
145
+ readonly name = "Duration";
146
+ coerce(val: any): number | null;
147
+ equals(other: DataType): boolean;
148
+ allocate(size: number): (number | null)[];
149
+ }
150
+ export declare const Duration: DurationType;
151
+ export declare class ListType<TInner = any> extends NestedDataType<TInner[] | null> {
152
+ readonly innerType: DataType<TInner>;
153
+ readonly name = "List";
154
+ constructor(innerType: DataType<TInner>);
155
+ coerce(val: any): TInner[] | null;
156
+ equals(other: DataType): boolean;
157
+ allocate(size: number): (TInner[] | null)[];
158
+ }
159
+ export declare const List: <TInner>(inner: DataType<TInner>) => ListType<TInner>;
160
+ export declare class StructType<TFields extends RowRecord = any> extends NestedDataType<TFields | null> {
161
+ readonly fields: {
162
+ [K in keyof TFields]: DataType<TFields[K]>;
163
+ };
164
+ readonly name = "Struct";
165
+ constructor(fields: {
166
+ [K in keyof TFields]: DataType<TFields[K]>;
167
+ });
168
+ coerce(val: any): TFields | null;
169
+ equals(other: DataType): boolean;
170
+ allocate(size: number): (TFields | null)[];
171
+ }
172
+ export declare const Struct: <TFields extends RowRecord>(fields: { [K in keyof TFields]: DataType<TFields[K]>; }) => StructType<TFields>;
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Struct = exports.StructType = exports.List = exports.ListType = exports.Duration = exports.DurationType = exports.Time = exports.TimeType = exports.Datetime = exports.DatetimeType = exports.Date = exports.DateType = exports.Object = exports.ObjectType = exports.Null = exports.NullType = exports.Binary = exports.BinaryType = exports.Utf8 = exports.Utf8Type = exports.Boolean = exports.BooleanType = exports.DecimalType = exports.Float64 = exports.Float64Type = exports.Float32 = exports.Float32Type = exports.UInt64 = exports.UInt64Type = exports.UInt32 = exports.UInt32Type = exports.UInt16 = exports.UInt16Type = exports.UInt8 = exports.UInt8Type = exports.Int64 = exports.Int64Type = exports.Int32 = exports.Int32Type = exports.Int16 = exports.Int16Type = exports.Int8 = exports.Int8Type = void 0;
4
+ const DataType_1 = require("./DataType");
5
+ const utils_1 = require("../utils");
6
+ // ============================================================================
7
+ // Numeric Types
8
+ // ============================================================================
9
+ class Int8Type extends DataType_1.SignedIntegerType {
10
+ name = "Int8";
11
+ coerce(val) { return (0, utils_1.toValidInt)(val, "Int8"); }
12
+ equals(other) { return other.name === "Int8"; }
13
+ allocate(size) { return new Int8Array(size); }
14
+ }
15
+ exports.Int8Type = Int8Type;
16
+ exports.Int8 = new Int8Type();
17
+ class Int16Type extends DataType_1.SignedIntegerType {
18
+ name = "Int16";
19
+ coerce(val) { return (0, utils_1.toValidInt)(val, "Int16"); }
20
+ equals(other) { return other.name === "Int16"; }
21
+ allocate(size) { return new Int16Array(size); }
22
+ }
23
+ exports.Int16Type = Int16Type;
24
+ exports.Int16 = new Int16Type();
25
+ class Int32Type extends DataType_1.SignedIntegerType {
26
+ name = "Int32";
27
+ coerce(val) { return (0, utils_1.toValidInt)(val, "Int32"); }
28
+ equals(other) { return other.name === "Int32"; }
29
+ allocate(size) { return new Int32Array(size); }
30
+ }
31
+ exports.Int32Type = Int32Type;
32
+ exports.Int32 = new Int32Type();
33
+ class Int64Type extends DataType_1.SignedIntegerType {
34
+ name = "Int64";
35
+ coerce(val) { return (0, utils_1.toValidBigInt)(val); }
36
+ equals(other) { return other.name === "Int64"; }
37
+ allocate(size) { return new BigInt64Array(size); }
38
+ }
39
+ exports.Int64Type = Int64Type;
40
+ exports.Int64 = new Int64Type();
41
+ class UInt8Type extends DataType_1.UnsignedIntegerType {
42
+ name = "UInt8";
43
+ coerce(val) { return (0, utils_1.toValidInt)(val, "UInt8"); }
44
+ equals(other) { return other.name === "UInt8"; }
45
+ allocate(size) { return new Uint8Array(size); }
46
+ }
47
+ exports.UInt8Type = UInt8Type;
48
+ exports.UInt8 = new UInt8Type();
49
+ class UInt16Type extends DataType_1.UnsignedIntegerType {
50
+ name = "UInt16";
51
+ coerce(val) { return (0, utils_1.toValidInt)(val, "UInt16"); }
52
+ equals(other) { return other.name === "UInt16"; }
53
+ allocate(size) { return new Uint16Array(size); }
54
+ }
55
+ exports.UInt16Type = UInt16Type;
56
+ exports.UInt16 = new UInt16Type();
57
+ class UInt32Type extends DataType_1.UnsignedIntegerType {
58
+ name = "UInt32";
59
+ coerce(val) { return (0, utils_1.toValidInt)(val, "UInt32"); }
60
+ equals(other) { return other.name === "UInt32"; }
61
+ allocate(size) { return new Uint32Array(size); }
62
+ }
63
+ exports.UInt32Type = UInt32Type;
64
+ exports.UInt32 = new UInt32Type();
65
+ class UInt64Type extends DataType_1.UnsignedIntegerType {
66
+ name = "UInt64";
67
+ coerce(val) { return (0, utils_1.toValidBigInt)(val, "UInt64"); }
68
+ equals(other) { return other.name === "UInt64"; }
69
+ allocate(size) { return new BigUint64Array(size); }
70
+ }
71
+ exports.UInt64Type = UInt64Type;
72
+ exports.UInt64 = new UInt64Type();
73
+ class Float32Type extends DataType_1.FloatDataType {
74
+ name = "Float32";
75
+ coerce(val) { return (0, utils_1.toValidFloat)(val, "Float32"); }
76
+ equals(other) { return other.name === "Float32"; }
77
+ allocate(size) { return new Float32Array(size); }
78
+ }
79
+ exports.Float32Type = Float32Type;
80
+ exports.Float32 = new Float32Type();
81
+ class Float64Type extends DataType_1.FloatDataType {
82
+ name = "Float64";
83
+ coerce(val) { return (0, utils_1.toValidFloat)(val, "Float64"); }
84
+ equals(other) { return other.name === "Float64"; }
85
+ allocate(size) { return new Float64Array(size); }
86
+ }
87
+ exports.Float64Type = Float64Type;
88
+ exports.Float64 = new Float64Type();
89
+ class DecimalType extends DataType_1.NumericDataType {
90
+ precision;
91
+ scale;
92
+ name;
93
+ constructor(precision, scale) {
94
+ super();
95
+ this.precision = precision;
96
+ this.scale = scale;
97
+ this.name = precision !== undefined && scale !== undefined
98
+ ? `Decimal(${precision}, ${scale})`
99
+ : "Decimal";
100
+ }
101
+ coerce(val) {
102
+ return (0, utils_1.toValidDecimal)(val, { precision: this.precision, scale: this.scale });
103
+ }
104
+ equals(other) {
105
+ return other instanceof DecimalType &&
106
+ this.precision === other.precision &&
107
+ this.scale === other.scale;
108
+ }
109
+ allocate(size) { return new Array(size).fill(null); }
110
+ }
111
+ exports.DecimalType = DecimalType;
112
+ // ============================================================================
113
+ // Standard Types
114
+ // ============================================================================
115
+ class BooleanType extends DataType_1.DataType {
116
+ name = "Boolean";
117
+ get isBoolean() { return true; }
118
+ coerce(val) {
119
+ if (val == null)
120
+ return null;
121
+ return !!val;
122
+ }
123
+ equals(other) { return other.name === "Boolean"; }
124
+ allocate(size) { return new Array(size).fill(null); }
125
+ }
126
+ exports.BooleanType = BooleanType;
127
+ exports.Boolean = new BooleanType();
128
+ class Utf8Type extends DataType_1.DataType {
129
+ name = "Utf8";
130
+ get isString() { return true; }
131
+ get isUtf8() { return true; }
132
+ coerce(val) {
133
+ if (val == null)
134
+ return null;
135
+ return String(val);
136
+ }
137
+ equals(other) { return other.name === "Utf8"; }
138
+ allocate(size) { return new Array(size).fill(null); }
139
+ }
140
+ exports.Utf8Type = Utf8Type;
141
+ exports.Utf8 = new Utf8Type();
142
+ class BinaryType extends DataType_1.DataType {
143
+ name = "Binary";
144
+ get isBinary() { return true; }
145
+ coerce(val) { return (0, utils_1.toValidBinary)(val); }
146
+ equals(other) { return other.name === "Binary"; }
147
+ allocate(size) { return new Array(size).fill(null); }
148
+ }
149
+ exports.BinaryType = BinaryType;
150
+ exports.Binary = new BinaryType();
151
+ class NullType extends DataType_1.DataType {
152
+ name = "Null";
153
+ get isNull() { return true; }
154
+ coerce(_val) { return null; }
155
+ equals(other) { return other.name === "Null"; }
156
+ allocate(size) { return new Array(size).fill(null); }
157
+ }
158
+ exports.NullType = NullType;
159
+ exports.Null = new NullType();
160
+ class ObjectType extends DataType_1.DataType {
161
+ name = "Object";
162
+ get isObject() { return true; }
163
+ coerce(val) { return val === undefined ? null : val; }
164
+ equals(other) { return other.name === "Object"; }
165
+ allocate(size) { return new Array(size).fill(null); }
166
+ }
167
+ exports.ObjectType = ObjectType;
168
+ exports.Object = new ObjectType();
169
+ // ============================================================================
170
+ // Temporal Types
171
+ // ============================================================================
172
+ class DateType extends DataType_1.TemporalDataType {
173
+ name = "Date";
174
+ coerce(val) {
175
+ const d = (0, utils_1.toValidDate)(val);
176
+ if (!d)
177
+ return null;
178
+ d.setUTCHours(0, 0, 0, 0);
179
+ return d;
180
+ }
181
+ equals(other) { return other.name === "Date"; }
182
+ allocate(size) { return new Array(size).fill(null); }
183
+ }
184
+ exports.DateType = DateType;
185
+ exports.Date = new DateType();
186
+ class DatetimeType extends DataType_1.TemporalDataType {
187
+ name = "Datetime";
188
+ coerce(val) { return (0, utils_1.toValidDate)(val); }
189
+ equals(other) { return other.name === "Datetime"; }
190
+ allocate(size) { return new Array(size).fill(null); }
191
+ }
192
+ exports.DatetimeType = DatetimeType;
193
+ exports.Datetime = new DatetimeType();
194
+ class TimeType extends DataType_1.TemporalDataType {
195
+ name = "Time";
196
+ coerce(val) {
197
+ if (val == null)
198
+ return null;
199
+ if (typeof val === "string") {
200
+ const trimmed = val.trim();
201
+ if (utils_1.TIME_PREFIX_REGEX.test(trimmed)) {
202
+ const d = new globalThis.Date(`1970-01-01T${trimmed}${utils_1.ZONE_OFFSET_REGEX.test(trimmed) ? "" : "Z"}`);
203
+ if ((0, utils_1.isValidDateObj)(d)) {
204
+ return d.toISOString().split("T")[1].slice(0, 12);
205
+ }
206
+ }
207
+ }
208
+ const d = (0, utils_1.toValidDate)(val);
209
+ return d ? d.toISOString().split("T")[1].slice(0, 12) : null;
210
+ }
211
+ equals(other) { return other.name === "Time"; }
212
+ allocate(size) { return new Array(size).fill(null); }
213
+ }
214
+ exports.TimeType = TimeType;
215
+ exports.Time = new TimeType();
216
+ class DurationType extends DataType_1.TemporalDataType {
217
+ name = "Duration";
218
+ coerce(val) { return (0, utils_1.toValidNumber)(val); }
219
+ equals(other) { return other.name === "Duration"; }
220
+ allocate(size) { return new Array(size).fill(null); }
221
+ }
222
+ exports.DurationType = DurationType;
223
+ exports.Duration = new DurationType();
224
+ // ============================================================================
225
+ // Nested Types
226
+ // ============================================================================
227
+ class ListType extends DataType_1.NestedDataType {
228
+ innerType;
229
+ name = "List";
230
+ constructor(innerType) {
231
+ super();
232
+ this.innerType = innerType;
233
+ }
234
+ coerce(val) {
235
+ if (val == null)
236
+ return null;
237
+ const arr = (0, utils_1.isArrayOrTypedArray)(val) ? Array.from(val) : [val];
238
+ const len = arr.length;
239
+ const res = new Array(len);
240
+ for (let i = 0; i < len; i++) {
241
+ res[i] = this.innerType.coerce(arr[i]);
242
+ }
243
+ return res;
244
+ }
245
+ equals(other) {
246
+ return other instanceof ListType && this.innerType.equals(other.innerType);
247
+ }
248
+ allocate(size) { return new Array(size).fill(null); }
249
+ }
250
+ exports.ListType = ListType;
251
+ const List = (inner) => new ListType(inner);
252
+ exports.List = List;
253
+ class StructType extends DataType_1.NestedDataType {
254
+ fields;
255
+ name = "Struct";
256
+ constructor(fields) {
257
+ super();
258
+ this.fields = fields;
259
+ }
260
+ coerce(val) {
261
+ if (!(0, utils_1.isObj)(val))
262
+ return null;
263
+ const res = {};
264
+ for (const [k, type] of globalThis.Object.entries(this.fields)) {
265
+ res[k] = type.coerce(val[k]);
266
+ }
267
+ return res;
268
+ }
269
+ equals(other) {
270
+ if (!(other instanceof StructType))
271
+ return false;
272
+ const keysThis = globalThis.Object.keys(this.fields);
273
+ const keysOther = globalThis.Object.keys(other.fields);
274
+ if (keysThis.length !== keysOther.length)
275
+ return false;
276
+ for (const k of keysThis) {
277
+ if (!other.fields[k] || !this.fields[k].equals(other.fields[k]))
278
+ return false;
279
+ }
280
+ return true;
281
+ }
282
+ allocate(size) { return new Array(size).fill(null); }
283
+ }
284
+ exports.StructType = StructType;
285
+ const Struct = (fields) => new StructType(fields);
286
+ exports.Struct = Struct;
@@ -0,0 +1,13 @@
1
+ export declare class DFScriptError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export declare class DataFrameError extends DFScriptError {
5
+ }
6
+ export declare class ColumnNotFoundError extends DataFrameError {
7
+ constructor(columnName: string, message?: string);
8
+ }
9
+ export declare class SchemaError extends DFScriptError {
10
+ }
11
+ export declare class ComputeError extends DFScriptError {
12
+ }
13
+ export * from "./utils";
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
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);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ComputeError = exports.SchemaError = exports.ColumnNotFoundError = exports.DataFrameError = exports.DFScriptError = void 0;
18
+ class DFScriptError extends Error {
19
+ constructor(message) {
20
+ super(message);
21
+ this.name = this.constructor.name;
22
+ if (Error.captureStackTrace) {
23
+ Error.captureStackTrace(this, this.constructor);
24
+ }
25
+ }
26
+ }
27
+ exports.DFScriptError = DFScriptError;
28
+ class DataFrameError extends DFScriptError {
29
+ }
30
+ exports.DataFrameError = DataFrameError;
31
+ class ColumnNotFoundError extends DataFrameError {
32
+ constructor(columnName, message) {
33
+ super(message || `Column "${columnName}" does not exist in the DataFrame.`);
34
+ }
35
+ }
36
+ exports.ColumnNotFoundError = ColumnNotFoundError;
37
+ class SchemaError extends DFScriptError {
38
+ }
39
+ exports.SchemaError = SchemaError;
40
+ class ComputeError extends DFScriptError {
41
+ }
42
+ exports.ComputeError = ComputeError;
43
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1,2 @@
1
+ import type { ColumnDict } from "../types";
2
+ export declare function assertColumnExists(columnName: string, columns: ColumnDict, context: string, suffix?: string): void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertColumnExists = assertColumnExists;
4
+ const index_1 = require("./index");
5
+ function assertColumnExists(columnName, columns, context, suffix = "") {
6
+ if (!(columnName in columns)) {
7
+ throw new index_1.ColumnNotFoundError(columnName, `${context} "${columnName}" does not exist${suffix}`);
8
+ }
9
+ }
@@ -0,0 +1,4 @@
1
+ import { DataFrame } from "../dataframe/dataframe";
2
+ import type { ConcatOptions, ConcatItem, RowRecord } from "../types";
3
+ export declare function normalizeToDataFrames(item: any, context: string, index: number): DataFrame<any>[];
4
+ export declare function concat<U extends RowRecord = any>(rawItems: ConcatItem | ConcatItem[], options?: ConcatOptions): DataFrame<U>;