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,8 @@
1
+ import { TemporalDataType, DataType } from "../DataType";
2
+ export declare class DatetimeType extends TemporalDataType {
3
+ readonly name = "Datetime";
4
+ coerce(val: any): Date | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): (Date | null)[];
7
+ }
8
+ export declare const Datetime: DatetimeType;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Datetime = exports.DatetimeType = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class DatetimeType extends DataType_1.TemporalDataType {
7
+ name = "Datetime";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidDate)(val);
10
+ }
11
+ equals(other) {
12
+ return other.name === "Datetime";
13
+ }
14
+ allocate(size) { return new Array(size).fill(null); }
15
+ }
16
+ exports.DatetimeType = DatetimeType;
17
+ exports.Datetime = new DatetimeType();
@@ -0,0 +1,10 @@
1
+ import { NumericDataType, DataType } from "../DataType";
2
+ export declare class DecimalType extends NumericDataType {
3
+ readonly precision?: number | undefined;
4
+ readonly scale?: number | undefined;
5
+ readonly name: string;
6
+ constructor(precision?: number | undefined, scale?: number | undefined);
7
+ coerce(val: any): number | null;
8
+ equals(other: DataType): boolean;
9
+ allocate(size: number): (number | null)[];
10
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DecimalType = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class DecimalType extends DataType_1.NumericDataType {
7
+ precision;
8
+ scale;
9
+ name;
10
+ constructor(precision, scale) {
11
+ super();
12
+ this.precision = precision;
13
+ this.scale = scale;
14
+ this.name = precision !== undefined && scale !== undefined
15
+ ? `Decimal(${precision}, ${scale})`
16
+ : "Decimal";
17
+ }
18
+ coerce(val) {
19
+ return (0, utils_1.toValidDecimal)(val, { precision: this.precision, scale: this.scale });
20
+ }
21
+ equals(other) {
22
+ return other instanceof DecimalType &&
23
+ this.precision === other.precision &&
24
+ this.scale === other.scale;
25
+ }
26
+ allocate(size) { return new Array(size).fill(null); }
27
+ }
28
+ exports.DecimalType = DecimalType;
@@ -0,0 +1,8 @@
1
+ import { TemporalDataType, DataType } from "../DataType";
2
+ export declare class DurationType extends TemporalDataType {
3
+ readonly name = "Duration";
4
+ coerce(val: any): number | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): (number | null)[];
7
+ }
8
+ export declare const Duration: DurationType;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Duration = exports.DurationType = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class DurationType extends DataType_1.TemporalDataType {
7
+ name = "Duration";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidNumber)(val);
10
+ }
11
+ equals(other) {
12
+ return other.name === "Duration";
13
+ }
14
+ allocate(size) { return new Array(size).fill(null); }
15
+ }
16
+ exports.DurationType = DurationType;
17
+ exports.Duration = new DurationType();
@@ -0,0 +1,8 @@
1
+ import { FloatDataType, DataType } from "../DataType";
2
+ export declare class Float32Type extends FloatDataType {
3
+ readonly name = "Float32";
4
+ coerce(val: any): number | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): Float32Array;
7
+ }
8
+ export declare const Float32: Float32Type;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Float32 = exports.Float32Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class Float32Type extends DataType_1.FloatDataType {
7
+ name = "Float32";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidFloat)(val, "Float32");
10
+ }
11
+ equals(other) {
12
+ return other.name === "Float32";
13
+ }
14
+ allocate(size) { return new Float32Array(size); }
15
+ }
16
+ exports.Float32Type = Float32Type;
17
+ exports.Float32 = new Float32Type();
@@ -0,0 +1,8 @@
1
+ import { FloatDataType, DataType } from "../DataType";
2
+ export declare class Float64Type extends FloatDataType {
3
+ readonly name = "Float64";
4
+ coerce(val: any): number | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): Float64Array;
7
+ }
8
+ export declare const Float64: Float64Type;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Float64 = exports.Float64Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class Float64Type extends DataType_1.FloatDataType {
7
+ name = "Float64";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidFloat)(val);
10
+ }
11
+ equals(other) {
12
+ return other.name === "Float64";
13
+ }
14
+ allocate(size) { return new Float64Array(size); }
15
+ }
16
+ exports.Float64Type = Float64Type;
17
+ exports.Float64 = new Float64Type();
@@ -0,0 +1,8 @@
1
+ import { SignedIntegerType, DataType } from "../DataType";
2
+ export declare class Int16Type extends SignedIntegerType {
3
+ readonly name = "Int16";
4
+ coerce(val: any): number | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): Int16Array;
7
+ }
8
+ export declare const Int16: Int16Type;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Int16 = exports.Int16Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class Int16Type extends DataType_1.SignedIntegerType {
7
+ name = "Int16";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidInt)(val, "Int16");
10
+ }
11
+ equals(other) {
12
+ return other.name === "Int16";
13
+ }
14
+ allocate(size) { return new Int16Array(size); }
15
+ }
16
+ exports.Int16Type = Int16Type;
17
+ exports.Int16 = new Int16Type();
@@ -0,0 +1,8 @@
1
+ import { SignedIntegerType, DataType } from "../DataType";
2
+ export declare class Int32Type extends SignedIntegerType {
3
+ readonly name = "Int32";
4
+ coerce(val: any): number | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): Int32Array;
7
+ }
8
+ export declare const Int32: Int32Type;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Int32 = exports.Int32Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class Int32Type extends DataType_1.SignedIntegerType {
7
+ name = "Int32";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidInt)(val);
10
+ }
11
+ equals(other) {
12
+ return other.name === "Int32";
13
+ }
14
+ allocate(size) { return new Int32Array(size); }
15
+ }
16
+ exports.Int32Type = Int32Type;
17
+ exports.Int32 = new Int32Type();
@@ -0,0 +1,8 @@
1
+ import { SignedIntegerType, DataType } from "../DataType";
2
+ export declare class Int64Type extends SignedIntegerType<bigint | null> {
3
+ readonly name = "Int64";
4
+ coerce(val: any): bigint | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): BigInt64Array;
7
+ }
8
+ export declare const Int64: Int64Type;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Int64 = exports.Int64Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class Int64Type extends DataType_1.SignedIntegerType {
7
+ name = "Int64";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidBigInt)(val);
10
+ }
11
+ equals(other) {
12
+ return other.name === "Int64";
13
+ }
14
+ allocate(size) { return new BigInt64Array(size); }
15
+ }
16
+ exports.Int64Type = Int64Type;
17
+ exports.Int64 = new Int64Type();
@@ -0,0 +1,8 @@
1
+ import { SignedIntegerType, DataType } from "../DataType";
2
+ export declare class Int8Type extends SignedIntegerType {
3
+ readonly name = "Int8";
4
+ coerce(val: any): number | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): Int8Array;
7
+ }
8
+ export declare const Int8: Int8Type;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Int8 = exports.Int8Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class Int8Type extends DataType_1.SignedIntegerType {
7
+ name = "Int8";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidInt)(val, "Int8");
10
+ }
11
+ equals(other) {
12
+ return other.name === "Int8";
13
+ }
14
+ allocate(size) { return new Int8Array(size); }
15
+ }
16
+ exports.Int8Type = Int8Type;
17
+ exports.Int8 = new Int8Type();
@@ -0,0 +1,10 @@
1
+ import { NestedDataType, DataType } from "../DataType";
2
+ export declare class ListType<TInner = any> extends NestedDataType<TInner[] | null> {
3
+ readonly innerType: DataType<TInner>;
4
+ readonly name = "List";
5
+ constructor(innerType: DataType<TInner>);
6
+ coerce(val: any): TInner[] | null;
7
+ equals(other: DataType): boolean;
8
+ allocate(size: number): (TInner[] | null)[];
9
+ }
10
+ export declare const List: <TInner>(inner: DataType<TInner>) => ListType<TInner>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.List = exports.ListType = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class ListType extends DataType_1.NestedDataType {
7
+ innerType;
8
+ name = "List";
9
+ constructor(innerType) {
10
+ super();
11
+ this.innerType = innerType;
12
+ }
13
+ coerce(val) {
14
+ if (val == null)
15
+ return null;
16
+ const arr = (0, utils_1.isArrayOrTypedArray)(val) ? Array.from(val) : [val];
17
+ const len = arr.length;
18
+ const res = new Array(len);
19
+ for (let i = 0; i < len; i++) {
20
+ res[i] = this.innerType.coerce(arr[i]);
21
+ }
22
+ return res;
23
+ }
24
+ equals(other) {
25
+ return other instanceof ListType && this.innerType.equals(other.innerType);
26
+ }
27
+ allocate(size) { return new Array(size).fill(null); }
28
+ }
29
+ exports.ListType = ListType;
30
+ const List = (inner) => new ListType(inner);
31
+ exports.List = List;
@@ -0,0 +1,9 @@
1
+ import { DataType } from "../DataType";
2
+ export declare class NullType extends DataType {
3
+ readonly name = "Null";
4
+ get isNull(): boolean;
5
+ coerce(_val: any): null;
6
+ equals(other: DataType): boolean;
7
+ allocate(size: number): null[];
8
+ }
9
+ export declare const Null: NullType;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Null = exports.NullType = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ class NullType extends DataType_1.DataType {
6
+ name = "Null";
7
+ get isNull() { return true; }
8
+ coerce(_val) {
9
+ return null;
10
+ }
11
+ equals(other) {
12
+ return other.name === "Null";
13
+ }
14
+ allocate(size) { return new Array(size).fill(null); }
15
+ }
16
+ exports.NullType = NullType;
17
+ exports.Null = new NullType();
@@ -0,0 +1,9 @@
1
+ import { DataType } from "../DataType";
2
+ export declare class ObjectType extends DataType {
3
+ readonly name = "Object";
4
+ get isObject(): boolean;
5
+ coerce(val: any): any;
6
+ equals(other: DataType): boolean;
7
+ allocate(size: number): any[];
8
+ }
9
+ export declare const Object: ObjectType;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Object = exports.ObjectType = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ class ObjectType extends DataType_1.DataType {
6
+ name = "Object";
7
+ get isObject() { return true; }
8
+ coerce(val) {
9
+ return val === undefined ? null : val;
10
+ }
11
+ equals(other) {
12
+ return other.name === "Object";
13
+ }
14
+ allocate(size) { return new Array(size).fill(null); }
15
+ }
16
+ exports.ObjectType = ObjectType;
17
+ exports.Object = new ObjectType();
@@ -0,0 +1,14 @@
1
+ import { NestedDataType, DataType } from "../DataType";
2
+ export declare class StructType<TFields extends Record<string, any> = any> extends NestedDataType<TFields | null> {
3
+ readonly fields: {
4
+ [K in keyof TFields]: DataType<TFields[K]>;
5
+ };
6
+ readonly name = "Struct";
7
+ constructor(fields: {
8
+ [K in keyof TFields]: DataType<TFields[K]>;
9
+ });
10
+ coerce(val: any): TFields | null;
11
+ equals(other: DataType): boolean;
12
+ allocate(size: number): (TFields | null)[];
13
+ }
14
+ export declare const Struct: <TFields extends Record<string, any>>(fields: { [K in keyof TFields]: DataType<TFields[K]>; }) => StructType<TFields>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Struct = exports.StructType = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class StructType extends DataType_1.NestedDataType {
7
+ fields;
8
+ name = "Struct";
9
+ constructor(fields) {
10
+ super();
11
+ this.fields = fields;
12
+ }
13
+ coerce(val) {
14
+ if (!(0, utils_1.isObj)(val))
15
+ return null;
16
+ const res = {};
17
+ for (const [k, type] of Object.entries(this.fields)) {
18
+ res[k] = type.coerce(val[k]);
19
+ }
20
+ return res;
21
+ }
22
+ equals(other) {
23
+ if (!(other instanceof StructType))
24
+ return false;
25
+ const keysThis = Object.keys(this.fields);
26
+ const keysOther = Object.keys(other.fields);
27
+ if (keysThis.length !== keysOther.length)
28
+ return false;
29
+ for (const k of keysThis) {
30
+ if (!other.fields[k] || !this.fields[k].equals(other.fields[k]))
31
+ return false;
32
+ }
33
+ return true;
34
+ }
35
+ allocate(size) { return new Array(size).fill(null); }
36
+ }
37
+ exports.StructType = StructType;
38
+ const Struct = (fields) => new StructType(fields);
39
+ exports.Struct = Struct;
@@ -0,0 +1,8 @@
1
+ import { TemporalDataType, DataType } from "../DataType";
2
+ export declare class TimeType extends TemporalDataType {
3
+ readonly name = "Time";
4
+ coerce(val: any): string | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): (string | null)[];
7
+ }
8
+ export declare const Time: TimeType;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Time = exports.TimeType = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class TimeType extends DataType_1.TemporalDataType {
7
+ name = "Time";
8
+ coerce(val) {
9
+ if (val == null)
10
+ return null;
11
+ if (typeof val === "string") {
12
+ const trimmed = val.trim();
13
+ if (utils_1.TIME_PREFIX_REGEX.test(trimmed)) {
14
+ const d = new Date(`1970-01-01T${trimmed}${utils_1.ZONE_OFFSET_REGEX.test(trimmed) ? "" : "Z"}`);
15
+ if ((0, utils_1.isValidDateObj)(d)) {
16
+ return d.toISOString().split("T")[1].slice(0, 12);
17
+ }
18
+ }
19
+ }
20
+ const d = (0, utils_1.toValidDate)(val);
21
+ return d ? d.toISOString().split("T")[1].slice(0, 12) : null;
22
+ }
23
+ equals(other) {
24
+ return other.name === "Time";
25
+ }
26
+ allocate(size) { return new Array(size).fill(null); }
27
+ }
28
+ exports.TimeType = TimeType;
29
+ exports.Time = new TimeType();
@@ -0,0 +1,8 @@
1
+ import { UnsignedIntegerType, DataType } from "../DataType";
2
+ export declare class UInt16Type extends UnsignedIntegerType {
3
+ readonly name = "UInt16";
4
+ coerce(val: any): number | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): Uint16Array;
7
+ }
8
+ export declare const UInt16: UInt16Type;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UInt16 = exports.UInt16Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class UInt16Type extends DataType_1.UnsignedIntegerType {
7
+ name = "UInt16";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidInt)(val, "UInt16");
10
+ }
11
+ equals(other) {
12
+ return other.name === "UInt16";
13
+ }
14
+ allocate(size) { return new Uint16Array(size); }
15
+ }
16
+ exports.UInt16Type = UInt16Type;
17
+ exports.UInt16 = new UInt16Type();
@@ -0,0 +1,8 @@
1
+ import { UnsignedIntegerType, DataType } from "../DataType";
2
+ export declare class UInt32Type extends UnsignedIntegerType {
3
+ readonly name = "UInt32";
4
+ coerce(val: any): number | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): Uint32Array;
7
+ }
8
+ export declare const UInt32: UInt32Type;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UInt32 = exports.UInt32Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class UInt32Type extends DataType_1.UnsignedIntegerType {
7
+ name = "UInt32";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidInt)(val, "UInt32");
10
+ }
11
+ equals(other) {
12
+ return other.name === "UInt32";
13
+ }
14
+ allocate(size) { return new Uint32Array(size); }
15
+ }
16
+ exports.UInt32Type = UInt32Type;
17
+ exports.UInt32 = new UInt32Type();
@@ -0,0 +1,8 @@
1
+ import { UnsignedIntegerType, DataType } from "../DataType";
2
+ export declare class UInt64Type extends UnsignedIntegerType<bigint | null> {
3
+ readonly name = "UInt64";
4
+ coerce(val: any): bigint | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): BigUint64Array;
7
+ }
8
+ export declare const UInt64: UInt64Type;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UInt64 = exports.UInt64Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class UInt64Type extends DataType_1.UnsignedIntegerType {
7
+ name = "UInt64";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidBigInt)(val);
10
+ }
11
+ equals(other) {
12
+ return other.name === "UInt64";
13
+ }
14
+ allocate(size) { return new BigUint64Array(size); }
15
+ }
16
+ exports.UInt64Type = UInt64Type;
17
+ exports.UInt64 = new UInt64Type();
@@ -0,0 +1,8 @@
1
+ import { UnsignedIntegerType, DataType } from "../DataType";
2
+ export declare class UInt8Type extends UnsignedIntegerType {
3
+ readonly name = "UInt8";
4
+ coerce(val: any): number | null;
5
+ equals(other: DataType): boolean;
6
+ allocate(size: number): Uint8Array;
7
+ }
8
+ export declare const UInt8: UInt8Type;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UInt8 = exports.UInt8Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ const utils_1 = require("../../utils");
6
+ class UInt8Type extends DataType_1.UnsignedIntegerType {
7
+ name = "UInt8";
8
+ coerce(val) {
9
+ return (0, utils_1.toValidInt)(val, "UInt8");
10
+ }
11
+ equals(other) {
12
+ return other.name === "UInt8";
13
+ }
14
+ allocate(size) { return new Uint8Array(size); }
15
+ }
16
+ exports.UInt8Type = UInt8Type;
17
+ exports.UInt8 = new UInt8Type();
@@ -0,0 +1,10 @@
1
+ import { DataType } from "../DataType";
2
+ export declare class Utf8Type extends DataType {
3
+ readonly name = "Utf8";
4
+ get isString(): boolean;
5
+ get isUtf8(): boolean;
6
+ coerce(val: any): string | null;
7
+ equals(other: DataType): boolean;
8
+ allocate(size: number): (string | null)[];
9
+ }
10
+ export declare const Utf8: Utf8Type;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Utf8 = exports.Utf8Type = void 0;
4
+ const DataType_1 = require("../DataType");
5
+ class Utf8Type extends DataType_1.DataType {
6
+ name = "Utf8";
7
+ get isString() { return true; }
8
+ get isUtf8() { return true; }
9
+ coerce(val) {
10
+ if (val == null)
11
+ return null;
12
+ return String(val);
13
+ }
14
+ equals(other) {
15
+ return other.name === "Utf8";
16
+ }
17
+ allocate(size) { return new Array(size).fill(null); }
18
+ }
19
+ exports.Utf8Type = Utf8Type;
20
+ exports.Utf8 = new Utf8Type();