@ohos-ports/nodejs-polars 0.22.2-beta.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.
- package/LICENSE +19 -0
- package/README.md +217 -0
- package/bin/cfg.d.ts +156 -0
- package/bin/cfg.js +52 -0
- package/bin/dataframe.d.ts +2008 -0
- package/bin/dataframe.js +771 -0
- package/bin/datatypes/conversion.d.ts +2 -0
- package/bin/datatypes/conversion.js +2 -0
- package/bin/datatypes/datatype.d.ts +252 -0
- package/bin/datatypes/datatype.js +386 -0
- package/bin/datatypes/field.d.ts +26 -0
- package/bin/datatypes/field.js +36 -0
- package/bin/datatypes/index.d.ts +42 -0
- package/bin/datatypes/index.js +119 -0
- package/bin/error.d.ts +7 -0
- package/bin/error.js +17 -0
- package/bin/functions.d.ts +26 -0
- package/bin/functions.js +208 -0
- package/bin/groupby.d.ts +173 -0
- package/bin/groupby.js +156 -0
- package/bin/html.d.ts +4 -0
- package/bin/html.js +18 -0
- package/bin/index.d.ts +252 -0
- package/bin/index.js +265 -0
- package/bin/internals/construction.d.ts +7 -0
- package/bin/internals/construction.js +237 -0
- package/bin/internals/polars_internal.d.ts +2 -0
- package/bin/internals/polars_internal.js +7 -0
- package/bin/io.d.ts +421 -0
- package/bin/io.js +332 -0
- package/bin/lazy/dataframe.d.ts +693 -0
- package/bin/lazy/dataframe.js +421 -0
- package/bin/lazy/expr/datetime.d.ts +8 -0
- package/bin/lazy/expr/datetime.js +25 -0
- package/bin/lazy/expr/index.d.ts +1155 -0
- package/bin/lazy/expr/index.js +629 -0
- package/bin/lazy/expr/list.d.ts +8 -0
- package/bin/lazy/expr/list.js +115 -0
- package/bin/lazy/expr/string.d.ts +534 -0
- package/bin/lazy/expr/string.js +131 -0
- package/bin/lazy/expr/struct.d.ts +126 -0
- package/bin/lazy/expr/struct.js +26 -0
- package/bin/lazy/functions.d.ts +620 -0
- package/bin/lazy/functions.js +691 -0
- package/bin/lazy/groupby.d.ts +24 -0
- package/bin/lazy/groupby.js +22 -0
- package/bin/lazy/index.d.ts +4 -0
- package/bin/lazy/index.js +20 -0
- package/bin/lazy/whenthen.d.ts +67 -0
- package/bin/lazy/whenthen.js +81 -0
- package/bin/native-polars.d.ts +2 -0
- package/bin/native-polars.js +267 -0
- package/bin/series/datetime.d.ts +8 -0
- package/bin/series/datetime.js +25 -0
- package/bin/series/index.d.ts +1116 -0
- package/bin/series/index.js +689 -0
- package/bin/series/list.d.ts +8 -0
- package/bin/series/list.js +87 -0
- package/bin/series/string.d.ts +300 -0
- package/bin/series/string.js +125 -0
- package/bin/series/struct.d.ts +36 -0
- package/bin/series/struct.js +35 -0
- package/bin/shared_traits.d.ts +1325 -0
- package/bin/shared_traits.js +2 -0
- package/bin/sql.d.ts +244 -0
- package/bin/sql.js +63 -0
- package/bin/types.d.ts +284 -0
- package/bin/types.js +2 -0
- package/bin/utils.d.ts +38 -0
- package/bin/utils.js +69 -0
- package/package.json +51 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { Field } from "./field";
|
|
2
|
+
export declare abstract class DataType<Dtype extends DataTypeName = any> {
|
|
3
|
+
readonly __dtype: Dtype;
|
|
4
|
+
get variant(): DataTypeName;
|
|
5
|
+
protected identity: string;
|
|
6
|
+
protected get inner(): null | any[];
|
|
7
|
+
equals(other: DataType): boolean;
|
|
8
|
+
/** Null type */
|
|
9
|
+
static get Null(): Null;
|
|
10
|
+
/** `true` and `false`. */
|
|
11
|
+
static get Bool(): Bool;
|
|
12
|
+
/** An `i8` */
|
|
13
|
+
static get Int8(): Int8;
|
|
14
|
+
/** An `i16` */
|
|
15
|
+
static get Int16(): Int16;
|
|
16
|
+
/** An `i32` */
|
|
17
|
+
static get Int32(): Int32;
|
|
18
|
+
/** An `i64` */
|
|
19
|
+
static get Int64(): Int64;
|
|
20
|
+
/** An `u8` */
|
|
21
|
+
static get UInt8(): UInt8;
|
|
22
|
+
/** An `u16` */
|
|
23
|
+
static get UInt16(): UInt16;
|
|
24
|
+
/** An `u32` */
|
|
25
|
+
static get UInt32(): UInt32;
|
|
26
|
+
/** An `u64` */
|
|
27
|
+
static get UInt64(): UInt64;
|
|
28
|
+
/** A `f32` */
|
|
29
|
+
static get Float32(): Float32;
|
|
30
|
+
/** A `f64` */
|
|
31
|
+
static get Float64(): Float64;
|
|
32
|
+
static get Date(): Date;
|
|
33
|
+
/** Time of day type */
|
|
34
|
+
static get Time(): Time;
|
|
35
|
+
/** Type for wrapping arbitrary JS objects */
|
|
36
|
+
static get Object(): Object_;
|
|
37
|
+
/** A categorical encoding of a set of strings */
|
|
38
|
+
static get Categorical(): Categorical;
|
|
39
|
+
/** Decimal type */
|
|
40
|
+
static Decimal(precision?: number, scale?: number): Decimal;
|
|
41
|
+
/**
|
|
42
|
+
* Calendar date and time type
|
|
43
|
+
* @param timeUnit any of 'ms' | 'ns' | 'us'
|
|
44
|
+
* @param timeZone timezone string as defined by Intl.DateTimeFormat `America/New_York` for example.
|
|
45
|
+
*/
|
|
46
|
+
static Datetime(timeUnit?: TimeUnit | "ms" | "ns" | "us", timeZone?: string | null | undefined): Datetime;
|
|
47
|
+
/**
|
|
48
|
+
* Nested list/array type
|
|
49
|
+
*
|
|
50
|
+
* @param inner The `DataType` of values within the list
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
static List(inner: DataType): List;
|
|
54
|
+
/**
|
|
55
|
+
* List of fixed length
|
|
56
|
+
* This is called `Array` in other polars implementations, but `Array` is widely used in JS, so we use `FixedSizeList` instead.
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
static FixedSizeList(inner: DataType, listSize: number): FixedSizeList;
|
|
60
|
+
/**
|
|
61
|
+
* Struct type
|
|
62
|
+
*/
|
|
63
|
+
static Struct(fields: Field[]): DataType;
|
|
64
|
+
static Struct(fields: {
|
|
65
|
+
[key: string]: DataType;
|
|
66
|
+
}): DataType;
|
|
67
|
+
/** A variable-length UTF-8 encoded string whose offsets are represented as `i64`. */
|
|
68
|
+
static get Utf8(): Utf8;
|
|
69
|
+
static get String(): String;
|
|
70
|
+
toString(): string;
|
|
71
|
+
toJSON(): {
|
|
72
|
+
[x: string]: {
|
|
73
|
+
[x: string]: any;
|
|
74
|
+
};
|
|
75
|
+
} | {
|
|
76
|
+
[x: string]: DataTypeName;
|
|
77
|
+
};
|
|
78
|
+
asFixedSizeList(): (this & FixedSizeList) | null;
|
|
79
|
+
}
|
|
80
|
+
export declare class Null extends DataType<"Null"> {
|
|
81
|
+
__dtype: "Null";
|
|
82
|
+
}
|
|
83
|
+
export declare class Bool extends DataType<"Bool"> {
|
|
84
|
+
__dtype: "Bool";
|
|
85
|
+
}
|
|
86
|
+
export declare class Int8 extends DataType<"Int8"> {
|
|
87
|
+
__dtype: "Int8";
|
|
88
|
+
}
|
|
89
|
+
export declare class Int16 extends DataType<"Int16"> {
|
|
90
|
+
__dtype: "Int16";
|
|
91
|
+
}
|
|
92
|
+
export declare class Int32 extends DataType<"Int32"> {
|
|
93
|
+
__dtype: "Int32";
|
|
94
|
+
}
|
|
95
|
+
export declare class Int64 extends DataType<"Int64"> {
|
|
96
|
+
__dtype: "Int64";
|
|
97
|
+
}
|
|
98
|
+
export declare class UInt8 extends DataType<"UInt8"> {
|
|
99
|
+
__dtype: "UInt8";
|
|
100
|
+
}
|
|
101
|
+
export declare class UInt16 extends DataType<"UInt16"> {
|
|
102
|
+
__dtype: "UInt16";
|
|
103
|
+
}
|
|
104
|
+
export declare class UInt32 extends DataType<"UInt32"> {
|
|
105
|
+
__dtype: "UInt32";
|
|
106
|
+
}
|
|
107
|
+
export declare class UInt64 extends DataType<"UInt64"> {
|
|
108
|
+
__dtype: "UInt64";
|
|
109
|
+
}
|
|
110
|
+
export declare class Float32 extends DataType<"Float32"> {
|
|
111
|
+
__dtype: "Float32";
|
|
112
|
+
}
|
|
113
|
+
export declare class Float64 extends DataType<"Float64"> {
|
|
114
|
+
__dtype: "Float64";
|
|
115
|
+
}
|
|
116
|
+
export declare class Date extends DataType<"Date"> {
|
|
117
|
+
__dtype: "Date";
|
|
118
|
+
}
|
|
119
|
+
export declare class Time extends DataType<"Time"> {
|
|
120
|
+
__dtype: "Time";
|
|
121
|
+
}
|
|
122
|
+
export declare class Object_ extends DataType<"Object"> {
|
|
123
|
+
__dtype: "Object";
|
|
124
|
+
}
|
|
125
|
+
export declare class Utf8 extends DataType<"Utf8"> {
|
|
126
|
+
__dtype: "Utf8";
|
|
127
|
+
}
|
|
128
|
+
export declare class String extends DataType<"String"> {
|
|
129
|
+
__dtype: "String";
|
|
130
|
+
}
|
|
131
|
+
export declare class Categorical extends DataType<"Categorical"> {
|
|
132
|
+
__dtype: "Categorical";
|
|
133
|
+
}
|
|
134
|
+
export declare class Decimal extends DataType<"Decimal"> {
|
|
135
|
+
__dtype: "Decimal";
|
|
136
|
+
private precision;
|
|
137
|
+
private scale;
|
|
138
|
+
constructor(precision?: number, scale?: number);
|
|
139
|
+
get inner(): (number | null)[];
|
|
140
|
+
equals(other: DataType): boolean;
|
|
141
|
+
toJSON(): {
|
|
142
|
+
[x: string]: {
|
|
143
|
+
[x: string]: {
|
|
144
|
+
precision: number | null;
|
|
145
|
+
scale: number | null;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Datetime type
|
|
152
|
+
*/
|
|
153
|
+
export declare class Datetime extends DataType<"Datetime"> {
|
|
154
|
+
private timeUnit;
|
|
155
|
+
private timeZone?;
|
|
156
|
+
__dtype: "Datetime";
|
|
157
|
+
constructor(timeUnit?: TimeUnit | "ms" | "ns" | "us", timeZone?: string | null | undefined);
|
|
158
|
+
get inner(): (string | null | undefined)[];
|
|
159
|
+
equals(other: DataType): boolean;
|
|
160
|
+
}
|
|
161
|
+
export declare class List extends DataType<"List"> {
|
|
162
|
+
protected __inner: DataType;
|
|
163
|
+
__dtype: "List";
|
|
164
|
+
constructor(__inner: DataType);
|
|
165
|
+
get inner(): DataType<any>[];
|
|
166
|
+
equals(other: DataType): boolean;
|
|
167
|
+
}
|
|
168
|
+
export declare class FixedSizeList extends DataType<"FixedSizeList"> {
|
|
169
|
+
protected __inner: DataType;
|
|
170
|
+
protected listSize: number;
|
|
171
|
+
__dtype: "FixedSizeList";
|
|
172
|
+
constructor(__inner: DataType, listSize: number);
|
|
173
|
+
get inner(): [DataType, number];
|
|
174
|
+
equals(other: DataType): boolean;
|
|
175
|
+
toJSON(): {
|
|
176
|
+
[x: string]: {
|
|
177
|
+
[x: string]: {
|
|
178
|
+
type: {
|
|
179
|
+
[x: string]: {
|
|
180
|
+
[x: string]: any;
|
|
181
|
+
};
|
|
182
|
+
} | {
|
|
183
|
+
[x: string]: DataTypeName;
|
|
184
|
+
};
|
|
185
|
+
size: number;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
export declare class Struct extends DataType<"Struct"> {
|
|
191
|
+
__dtype: "Struct";
|
|
192
|
+
private fields;
|
|
193
|
+
constructor(inner: {
|
|
194
|
+
[name: string]: DataType;
|
|
195
|
+
} | Field[]);
|
|
196
|
+
get inner(): Field[];
|
|
197
|
+
equals(other: DataType): boolean;
|
|
198
|
+
toJSON(): any;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Datetime time unit
|
|
202
|
+
*/
|
|
203
|
+
export declare enum TimeUnit {
|
|
204
|
+
Nanoseconds = "ns",
|
|
205
|
+
Microseconds = "us",
|
|
206
|
+
Milliseconds = "ms"
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* @ignore
|
|
210
|
+
* Timeunit namespace
|
|
211
|
+
*/
|
|
212
|
+
export declare namespace TimeUnit {
|
|
213
|
+
function from(s: "ms" | "ns" | "us"): TimeUnit;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Datatype namespace
|
|
217
|
+
*/
|
|
218
|
+
export declare namespace DataType {
|
|
219
|
+
type Categorical = import(".").Categorical;
|
|
220
|
+
type Int8 = import(".").Int8;
|
|
221
|
+
type Int16 = import(".").Int16;
|
|
222
|
+
type Int32 = import(".").Int32;
|
|
223
|
+
type Int64 = import(".").Int64;
|
|
224
|
+
type UInt8 = import(".").UInt8;
|
|
225
|
+
type UInt16 = import(".").UInt16;
|
|
226
|
+
type UInt32 = import(".").UInt32;
|
|
227
|
+
type UInt64 = import(".").UInt64;
|
|
228
|
+
type Float32 = import(".").Float32;
|
|
229
|
+
type Float64 = import(".").Float64;
|
|
230
|
+
type Bool = import(".").Bool;
|
|
231
|
+
type Utf8 = import(".").Utf8;
|
|
232
|
+
type String = import(".").String;
|
|
233
|
+
type List = import(".").List;
|
|
234
|
+
type FixedSizeList = import(".").FixedSizeList;
|
|
235
|
+
type Date = import(".").Date;
|
|
236
|
+
type Datetime = import(".").Datetime;
|
|
237
|
+
type Time = import(".").Time;
|
|
238
|
+
type Object = import(".").Object_;
|
|
239
|
+
type Null = import(".").Null;
|
|
240
|
+
type Struct = import(".").Struct;
|
|
241
|
+
type Decimal = import(".").Decimal;
|
|
242
|
+
/**
|
|
243
|
+
* deserializes a datatype from the serde output of rust polars `DataType`
|
|
244
|
+
* @param dtype dtype object
|
|
245
|
+
*/
|
|
246
|
+
function deserialize(dtype: any): DataType;
|
|
247
|
+
}
|
|
248
|
+
export type DataTypeName = "Null" | "Bool" | "Int8" | "Int16" | "Int32" | "Int64" | "UInt8" | "UInt16" | "UInt32" | "UInt64" | "Float32" | "Float64" | "Decimal" | "Date" | "Datetime" | "Time" | "Object" | "Utf8" | "String" | "Categorical" | "List" | "FixedSizeList" | "Struct";
|
|
249
|
+
export type JsType = number | boolean | string;
|
|
250
|
+
export type DTypeToJs<T> = T extends DataType.Decimal ? bigint : T extends DataType.Float64 ? number : T extends DataType.Float32 ? number : T extends DataType.Int64 ? bigint : T extends DataType.Int32 ? number : T extends DataType.Int16 ? number : T extends DataType.Int8 ? number : T extends DataType.Bool ? boolean : T extends DataType.Utf8 ? string : T extends DataType.String ? string : never;
|
|
251
|
+
export type DTypeToJsLoose<T> = T extends DataType.Decimal ? number | bigint : T extends DataType.Float64 ? number | bigint : T extends DataType.Float32 ? number | bigint : T extends DataType.Int64 ? number | bigint : T extends DataType.Int32 ? number | bigint : T extends DataType.Int16 ? number | bigint : T extends DataType.Int8 ? number | bigint : T extends DataType.Bool ? boolean : T extends DataType.Utf8 ? string : T extends DataType.String ? string : never;
|
|
252
|
+
export type DtypeToJsName<T> = T extends DataType.Decimal ? "Decimal" : T extends DataType.Float64 ? "Float64" : T extends DataType.Float32 ? "Float32" : T extends DataType.Int64 ? "Int64" : T extends DataType.Int32 ? "Int32" : T extends DataType.Int16 ? "Int16" : T extends DataType.Int8 ? "Int8" : T extends DataType.UInt64 ? "UInt64" : T extends DataType.UInt32 ? "UInt32" : T extends DataType.UInt16 ? "UInt16" : T extends DataType.UInt8 ? "UInt8" : T extends DataType.Bool ? "Bool" : T extends DataType.Utf8 ? "Utf8" : never;
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeUnit = exports.Struct = exports.FixedSizeList = exports.List = exports.Datetime = exports.Decimal = exports.Categorical = exports.String = exports.Utf8 = exports.Object_ = exports.Time = exports.Date = exports.Float64 = exports.Float32 = exports.UInt64 = exports.UInt32 = exports.UInt16 = exports.UInt8 = exports.Int64 = exports.Int32 = exports.Int16 = exports.Int8 = exports.Bool = exports.Null = exports.DataType = void 0;
|
|
4
|
+
const field_1 = require("./field");
|
|
5
|
+
class DataType {
|
|
6
|
+
get variant() {
|
|
7
|
+
return this.constructor.name;
|
|
8
|
+
}
|
|
9
|
+
identity = "DataType";
|
|
10
|
+
get inner() {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
equals(other) {
|
|
14
|
+
return (this.variant === other.variant &&
|
|
15
|
+
this.inner === null &&
|
|
16
|
+
other.inner === null);
|
|
17
|
+
}
|
|
18
|
+
/** Null type */
|
|
19
|
+
static get Null() {
|
|
20
|
+
return new Null();
|
|
21
|
+
}
|
|
22
|
+
/** `true` and `false`. */
|
|
23
|
+
static get Bool() {
|
|
24
|
+
return new Bool();
|
|
25
|
+
}
|
|
26
|
+
/** An `i8` */
|
|
27
|
+
static get Int8() {
|
|
28
|
+
return new Int8();
|
|
29
|
+
}
|
|
30
|
+
/** An `i16` */
|
|
31
|
+
static get Int16() {
|
|
32
|
+
return new Int16();
|
|
33
|
+
}
|
|
34
|
+
/** An `i32` */
|
|
35
|
+
static get Int32() {
|
|
36
|
+
return new Int32();
|
|
37
|
+
}
|
|
38
|
+
/** An `i64` */
|
|
39
|
+
static get Int64() {
|
|
40
|
+
return new Int64();
|
|
41
|
+
}
|
|
42
|
+
/** An `u8` */
|
|
43
|
+
static get UInt8() {
|
|
44
|
+
return new UInt8();
|
|
45
|
+
}
|
|
46
|
+
/** An `u16` */
|
|
47
|
+
static get UInt16() {
|
|
48
|
+
return new UInt16();
|
|
49
|
+
}
|
|
50
|
+
/** An `u32` */
|
|
51
|
+
static get UInt32() {
|
|
52
|
+
return new UInt32();
|
|
53
|
+
}
|
|
54
|
+
/** An `u64` */
|
|
55
|
+
static get UInt64() {
|
|
56
|
+
return new UInt64();
|
|
57
|
+
}
|
|
58
|
+
/** A `f32` */
|
|
59
|
+
static get Float32() {
|
|
60
|
+
return new Float32();
|
|
61
|
+
}
|
|
62
|
+
/** A `f64` */
|
|
63
|
+
static get Float64() {
|
|
64
|
+
return new Float64();
|
|
65
|
+
}
|
|
66
|
+
static get Date() {
|
|
67
|
+
return new Date();
|
|
68
|
+
}
|
|
69
|
+
/** Time of day type */
|
|
70
|
+
static get Time() {
|
|
71
|
+
return new Time();
|
|
72
|
+
}
|
|
73
|
+
/** Type for wrapping arbitrary JS objects */
|
|
74
|
+
static get Object() {
|
|
75
|
+
return new Object_();
|
|
76
|
+
}
|
|
77
|
+
/** A categorical encoding of a set of strings */
|
|
78
|
+
static get Categorical() {
|
|
79
|
+
return new Categorical();
|
|
80
|
+
}
|
|
81
|
+
/** Decimal type */
|
|
82
|
+
static Decimal(precision, scale) {
|
|
83
|
+
return new Decimal(precision, scale);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Calendar date and time type
|
|
87
|
+
* @param timeUnit any of 'ms' | 'ns' | 'us'
|
|
88
|
+
* @param timeZone timezone string as defined by Intl.DateTimeFormat `America/New_York` for example.
|
|
89
|
+
*/
|
|
90
|
+
static Datetime(timeUnit, timeZone = null) {
|
|
91
|
+
return new Datetime(timeUnit ?? "ms", timeZone);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Nested list/array type
|
|
95
|
+
*
|
|
96
|
+
* @param inner The `DataType` of values within the list
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
static List(inner) {
|
|
100
|
+
return new List(inner);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* List of fixed length
|
|
104
|
+
* This is called `Array` in other polars implementations, but `Array` is widely used in JS, so we use `FixedSizeList` instead.
|
|
105
|
+
*
|
|
106
|
+
*/
|
|
107
|
+
static FixedSizeList(inner, listSize) {
|
|
108
|
+
return new FixedSizeList(inner, listSize);
|
|
109
|
+
}
|
|
110
|
+
static Struct(fields) {
|
|
111
|
+
return new Struct(fields);
|
|
112
|
+
}
|
|
113
|
+
/** A variable-length UTF-8 encoded string whose offsets are represented as `i64`. */
|
|
114
|
+
static get Utf8() {
|
|
115
|
+
return new Utf8();
|
|
116
|
+
}
|
|
117
|
+
static get String() {
|
|
118
|
+
return new String();
|
|
119
|
+
}
|
|
120
|
+
toString() {
|
|
121
|
+
if (this.inner) {
|
|
122
|
+
return `${this.identity}(${this.variant}(${this.inner}))`;
|
|
123
|
+
}
|
|
124
|
+
return `${this.identity}(${this.variant})`;
|
|
125
|
+
}
|
|
126
|
+
toJSON() {
|
|
127
|
+
const inner = this.inner;
|
|
128
|
+
if (inner) {
|
|
129
|
+
return {
|
|
130
|
+
[this.identity]: {
|
|
131
|
+
[this.variant]: inner[0],
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
[this.identity]: this.variant,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
140
|
+
return this.toString();
|
|
141
|
+
}
|
|
142
|
+
asFixedSizeList() {
|
|
143
|
+
if (this instanceof FixedSizeList) {
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.DataType = DataType;
|
|
150
|
+
class Null extends DataType {
|
|
151
|
+
}
|
|
152
|
+
exports.Null = Null;
|
|
153
|
+
class Bool extends DataType {
|
|
154
|
+
}
|
|
155
|
+
exports.Bool = Bool;
|
|
156
|
+
class Int8 extends DataType {
|
|
157
|
+
}
|
|
158
|
+
exports.Int8 = Int8;
|
|
159
|
+
class Int16 extends DataType {
|
|
160
|
+
}
|
|
161
|
+
exports.Int16 = Int16;
|
|
162
|
+
class Int32 extends DataType {
|
|
163
|
+
}
|
|
164
|
+
exports.Int32 = Int32;
|
|
165
|
+
class Int64 extends DataType {
|
|
166
|
+
}
|
|
167
|
+
exports.Int64 = Int64;
|
|
168
|
+
class UInt8 extends DataType {
|
|
169
|
+
}
|
|
170
|
+
exports.UInt8 = UInt8;
|
|
171
|
+
class UInt16 extends DataType {
|
|
172
|
+
}
|
|
173
|
+
exports.UInt16 = UInt16;
|
|
174
|
+
class UInt32 extends DataType {
|
|
175
|
+
}
|
|
176
|
+
exports.UInt32 = UInt32;
|
|
177
|
+
class UInt64 extends DataType {
|
|
178
|
+
}
|
|
179
|
+
exports.UInt64 = UInt64;
|
|
180
|
+
class Float32 extends DataType {
|
|
181
|
+
}
|
|
182
|
+
exports.Float32 = Float32;
|
|
183
|
+
class Float64 extends DataType {
|
|
184
|
+
}
|
|
185
|
+
exports.Float64 = Float64;
|
|
186
|
+
// biome-ignore lint/suspicious/noShadowRestrictedNames: Using Polars Date
|
|
187
|
+
class Date extends DataType {
|
|
188
|
+
}
|
|
189
|
+
exports.Date = Date;
|
|
190
|
+
class Time extends DataType {
|
|
191
|
+
}
|
|
192
|
+
exports.Time = Time;
|
|
193
|
+
class Object_ extends DataType {
|
|
194
|
+
}
|
|
195
|
+
exports.Object_ = Object_;
|
|
196
|
+
class Utf8 extends DataType {
|
|
197
|
+
}
|
|
198
|
+
exports.Utf8 = Utf8;
|
|
199
|
+
// biome-ignore lint/suspicious/noShadowRestrictedNames: Using Polars String
|
|
200
|
+
class String extends DataType {
|
|
201
|
+
}
|
|
202
|
+
exports.String = String;
|
|
203
|
+
class Categorical extends DataType {
|
|
204
|
+
}
|
|
205
|
+
exports.Categorical = Categorical;
|
|
206
|
+
class Decimal extends DataType {
|
|
207
|
+
precision;
|
|
208
|
+
scale;
|
|
209
|
+
constructor(precision, scale) {
|
|
210
|
+
super();
|
|
211
|
+
this.precision = precision ?? null;
|
|
212
|
+
this.scale = scale ?? null;
|
|
213
|
+
}
|
|
214
|
+
get inner() {
|
|
215
|
+
return [this.precision, this.scale];
|
|
216
|
+
}
|
|
217
|
+
equals(other) {
|
|
218
|
+
if (other.variant === this.variant) {
|
|
219
|
+
return (this.precision === other.precision &&
|
|
220
|
+
this.scale === other.scale);
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
toJSON() {
|
|
225
|
+
return {
|
|
226
|
+
[this.identity]: {
|
|
227
|
+
[this.variant]: {
|
|
228
|
+
precision: this.precision,
|
|
229
|
+
scale: this.scale,
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
exports.Decimal = Decimal;
|
|
236
|
+
/**
|
|
237
|
+
* Datetime type
|
|
238
|
+
*/
|
|
239
|
+
class Datetime extends DataType {
|
|
240
|
+
timeUnit;
|
|
241
|
+
timeZone;
|
|
242
|
+
constructor(timeUnit = "ms", timeZone) {
|
|
243
|
+
super();
|
|
244
|
+
this.timeUnit = timeUnit;
|
|
245
|
+
this.timeZone = timeZone;
|
|
246
|
+
}
|
|
247
|
+
get inner() {
|
|
248
|
+
return [this.timeUnit, this.timeZone];
|
|
249
|
+
}
|
|
250
|
+
equals(other) {
|
|
251
|
+
if (other.variant === this.variant) {
|
|
252
|
+
return (this.timeUnit === other.timeUnit &&
|
|
253
|
+
this.timeZone === other.timeZone);
|
|
254
|
+
}
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
exports.Datetime = Datetime;
|
|
259
|
+
class List extends DataType {
|
|
260
|
+
__inner;
|
|
261
|
+
constructor(__inner) {
|
|
262
|
+
super();
|
|
263
|
+
this.__inner = __inner;
|
|
264
|
+
}
|
|
265
|
+
get inner() {
|
|
266
|
+
return [this.__inner];
|
|
267
|
+
}
|
|
268
|
+
equals(other) {
|
|
269
|
+
if (other.variant === this.variant) {
|
|
270
|
+
return this.inner[0].equals(other.inner[0]);
|
|
271
|
+
}
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
exports.List = List;
|
|
276
|
+
class FixedSizeList extends DataType {
|
|
277
|
+
__inner;
|
|
278
|
+
listSize;
|
|
279
|
+
constructor(__inner, listSize) {
|
|
280
|
+
super();
|
|
281
|
+
this.__inner = __inner;
|
|
282
|
+
this.listSize = listSize;
|
|
283
|
+
}
|
|
284
|
+
get inner() {
|
|
285
|
+
return [this.__inner, this.listSize];
|
|
286
|
+
}
|
|
287
|
+
equals(other) {
|
|
288
|
+
if (other.variant === this.variant) {
|
|
289
|
+
return (this.inner[0].equals(other.inner[0]) &&
|
|
290
|
+
this.inner[1] === other.inner[1]);
|
|
291
|
+
}
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
toJSON() {
|
|
295
|
+
return {
|
|
296
|
+
[this.identity]: {
|
|
297
|
+
[this.variant]: {
|
|
298
|
+
type: this.inner[0].toJSON(),
|
|
299
|
+
size: this.inner[1],
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
exports.FixedSizeList = FixedSizeList;
|
|
306
|
+
class Struct extends DataType {
|
|
307
|
+
fields;
|
|
308
|
+
constructor(inner) {
|
|
309
|
+
super();
|
|
310
|
+
if (Array.isArray(inner)) {
|
|
311
|
+
this.fields = inner;
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
this.fields = Object.entries(inner).map(field_1.Field.from);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
get inner() {
|
|
318
|
+
return this.fields;
|
|
319
|
+
}
|
|
320
|
+
equals(other) {
|
|
321
|
+
if (other.variant === this.variant) {
|
|
322
|
+
return this.inner
|
|
323
|
+
.map((fld, idx) => {
|
|
324
|
+
const otherfld = other.fields[idx];
|
|
325
|
+
return otherfld.name === fld.name && otherfld.dtype.equals(fld.dtype);
|
|
326
|
+
})
|
|
327
|
+
.every((value) => value);
|
|
328
|
+
}
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
toJSON() {
|
|
332
|
+
return {
|
|
333
|
+
[this.identity]: {
|
|
334
|
+
[this.variant]: this.fields,
|
|
335
|
+
},
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
exports.Struct = Struct;
|
|
340
|
+
/**
|
|
341
|
+
* Datetime time unit
|
|
342
|
+
*/
|
|
343
|
+
var TimeUnit;
|
|
344
|
+
(function (TimeUnit) {
|
|
345
|
+
TimeUnit["Nanoseconds"] = "ns";
|
|
346
|
+
TimeUnit["Microseconds"] = "us";
|
|
347
|
+
TimeUnit["Milliseconds"] = "ms";
|
|
348
|
+
})(TimeUnit || (exports.TimeUnit = TimeUnit = {}));
|
|
349
|
+
/**
|
|
350
|
+
* @ignore
|
|
351
|
+
* Timeunit namespace
|
|
352
|
+
*/
|
|
353
|
+
(function (TimeUnit) {
|
|
354
|
+
function from(s) {
|
|
355
|
+
return TimeUnit[s];
|
|
356
|
+
}
|
|
357
|
+
TimeUnit.from = from;
|
|
358
|
+
})(TimeUnit || (exports.TimeUnit = TimeUnit = {}));
|
|
359
|
+
/**
|
|
360
|
+
* Datatype namespace
|
|
361
|
+
*/
|
|
362
|
+
(function (DataType) {
|
|
363
|
+
/**
|
|
364
|
+
* deserializes a datatype from the serde output of rust polars `DataType`
|
|
365
|
+
* @param dtype dtype object
|
|
366
|
+
*/
|
|
367
|
+
function deserialize(dtype) {
|
|
368
|
+
if (typeof dtype === "string") {
|
|
369
|
+
return DataType[dtype];
|
|
370
|
+
}
|
|
371
|
+
let { variant, inner } = dtype;
|
|
372
|
+
if (variant === "Struct") {
|
|
373
|
+
inner = [
|
|
374
|
+
inner[0].map((fld) => field_1.Field.from(fld.name, deserialize(fld.dtype))),
|
|
375
|
+
];
|
|
376
|
+
}
|
|
377
|
+
if (variant === "List") {
|
|
378
|
+
inner = [deserialize(inner[0])];
|
|
379
|
+
}
|
|
380
|
+
if (variant === "FixedSizeList") {
|
|
381
|
+
inner = [deserialize(inner[0]), inner[1]];
|
|
382
|
+
}
|
|
383
|
+
return DataType[variant](...inner);
|
|
384
|
+
}
|
|
385
|
+
DataType.deserialize = deserialize;
|
|
386
|
+
})(DataType || (exports.DataType = DataType = {}));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { DataType } from "./datatype";
|
|
2
|
+
/**
|
|
3
|
+
* A field is a name and a datatype.
|
|
4
|
+
*/
|
|
5
|
+
export interface iField {
|
|
6
|
+
name: string;
|
|
7
|
+
dtype: DataType;
|
|
8
|
+
}
|
|
9
|
+
export declare class Field implements iField {
|
|
10
|
+
name: string;
|
|
11
|
+
dtype: DataType;
|
|
12
|
+
constructor(name: string, dtype: DataType);
|
|
13
|
+
toString(): string;
|
|
14
|
+
toJSON(): {
|
|
15
|
+
name: string;
|
|
16
|
+
dtype: DataType<any>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare namespace Field {
|
|
20
|
+
function from(name: string, dtype: DataType): Field;
|
|
21
|
+
function from([string, DataType]: [any, any]): Field;
|
|
22
|
+
function from(obj: {
|
|
23
|
+
name: string;
|
|
24
|
+
dtype: DataType;
|
|
25
|
+
}): Field;
|
|
26
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Field = void 0;
|
|
4
|
+
class Field {
|
|
5
|
+
name;
|
|
6
|
+
dtype;
|
|
7
|
+
constructor(name, dtype) {
|
|
8
|
+
this.name = name;
|
|
9
|
+
this.dtype = dtype;
|
|
10
|
+
}
|
|
11
|
+
toString() {
|
|
12
|
+
return `Field("${this.name}", ${this.dtype})`;
|
|
13
|
+
}
|
|
14
|
+
toJSON() {
|
|
15
|
+
return {
|
|
16
|
+
name: this.name,
|
|
17
|
+
dtype: this.dtype,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
21
|
+
return this.toJSON();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Field = Field;
|
|
25
|
+
(function (Field) {
|
|
26
|
+
function from(nameOrObj, dtype) {
|
|
27
|
+
if (typeof nameOrObj === "string" && dtype) {
|
|
28
|
+
return new Field(nameOrObj, dtype);
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(nameOrObj)) {
|
|
31
|
+
return new Field(nameOrObj[0], nameOrObj[1]);
|
|
32
|
+
}
|
|
33
|
+
return new Field(nameOrObj.name, nameOrObj.dtype);
|
|
34
|
+
}
|
|
35
|
+
Field.from = from;
|
|
36
|
+
})(Field || (exports.Field = Field = {}));
|