df-script 1.5.0 → 1.7.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 (159) hide show
  1. package/README.md +125 -9
  2. package/dist/api.d.ts +3 -2
  3. package/dist/assets/index-DBhGK6Tp.css +1 -0
  4. package/dist/assets/index-DEJEV_tU.js +195 -0
  5. package/dist/columnExpressions/ColumnExpr.d.ts +14 -7
  6. package/dist/columnExpressions/ExprBase.d.ts +26 -12
  7. package/dist/columnExpressions/constants.d.ts +1 -0
  8. package/dist/columnExpressions/functions/all.d.ts +23 -0
  9. package/dist/columnExpressions/functions/coalesce.d.ts +31 -2
  10. package/dist/columnExpressions/functions/element.d.ts +26 -1
  11. package/dist/columnExpressions/functions/exclude.d.ts +24 -0
  12. package/dist/columnExpressions/functions/implode.d.ts +28 -0
  13. package/dist/columnExpressions/functions/lit.d.ts +27 -0
  14. package/dist/columnExpressions/functions/seq_range.d.ts +36 -0
  15. package/dist/columnExpressions/functions/struct.d.ts +31 -0
  16. package/dist/columnExpressions/functions/when.d.ts +38 -8
  17. package/dist/columnExpressions/index.d.ts +2 -1
  18. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +336 -2
  19. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +620 -10
  20. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +567 -0
  21. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +353 -0
  22. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +82 -0
  23. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +40 -0
  24. package/dist/columnExpressions/mixins/StringExpr.d.ts +658 -5
  25. package/dist/columnExpressions/mixins/StructExpr.d.ts +70 -0
  26. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +530 -4
  27. package/dist/columnExpressions/mixins/WindowExpr.d.ts +313 -2
  28. package/dist/columnExpressions/types.d.ts +2 -0
  29. package/dist/constants.d.ts +11 -0
  30. package/dist/dataframe/dataframe.d.ts +933 -3
  31. package/dist/dataframe/grouped/grouped.d.ts +41 -6
  32. package/dist/dataframe/types.d.ts +1 -0
  33. package/dist/dataframe/utils.d.ts +1 -0
  34. package/dist/datatypes/index.d.ts +3 -2
  35. package/dist/datatypes/types.d.ts +52 -7
  36. package/dist/exceptions/index.d.ts +23 -0
  37. package/dist/functions/concat.d.ts +50 -0
  38. package/dist/functions/read_csv.d.ts +9 -0
  39. package/dist/functions/read_json.d.ts +7 -2
  40. package/dist/index.html +17 -0
  41. package/dist/index.js +6 -6
  42. package/dist/index.mjs +6 -0
  43. package/dist/types.d.ts +51 -16
  44. package/dist/utils/{list.d.ts → array.d.ts} +68 -15
  45. package/dist/utils/binary.d.ts +3 -0
  46. package/dist/utils/csv.d.ts +1 -0
  47. package/dist/utils/date.d.ts +23 -54
  48. package/dist/utils/index.d.ts +3 -2
  49. package/dist/utils/json.d.ts +1 -0
  50. package/dist/utils/number.d.ts +15 -29
  51. package/dist/utils/object.d.ts +27 -0
  52. package/dist/utils/string.d.ts +15 -5
  53. package/package.json +18 -4
  54. package/dist/api.js +0 -26
  55. package/dist/bundle.min.js +0 -1
  56. package/dist/columnExpressions/ColumnExpr.js +0 -219
  57. package/dist/columnExpressions/ExprBase.js +0 -92
  58. package/dist/columnExpressions/constants.js +0 -7
  59. package/dist/columnExpressions/functions/all.js +0 -11
  60. package/dist/columnExpressions/functions/coalesce.js +0 -44
  61. package/dist/columnExpressions/functions/element.js +0 -11
  62. package/dist/columnExpressions/functions/exclude.js +0 -13
  63. package/dist/columnExpressions/functions/implode.js +0 -7
  64. package/dist/columnExpressions/functions/lit.js +0 -17
  65. package/dist/columnExpressions/functions/repeat.d.ts +0 -47
  66. package/dist/columnExpressions/functions/repeat.js +0 -131
  67. package/dist/columnExpressions/functions/seq_range.js +0 -91
  68. package/dist/columnExpressions/functions/when.js +0 -85
  69. package/dist/columnExpressions/index.js +0 -38
  70. package/dist/columnExpressions/mixins/AggregationExpr.js +0 -76
  71. package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -131
  72. package/dist/columnExpressions/mixins/BooleanExpr.d.ts +0 -40
  73. package/dist/columnExpressions/mixins/BooleanExpr.js +0 -67
  74. package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -250
  75. package/dist/columnExpressions/mixins/ListExpr.d.ts +0 -39
  76. package/dist/columnExpressions/mixins/ListExpr.js +0 -224
  77. package/dist/columnExpressions/mixins/LogicalExpr.js +0 -53
  78. package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -71
  79. package/dist/columnExpressions/mixins/NumericExpr.d.ts +0 -92
  80. package/dist/columnExpressions/mixins/NumericExpr.js +0 -259
  81. package/dist/columnExpressions/mixins/StringExpr.js +0 -237
  82. package/dist/columnExpressions/mixins/StructExpr.js +0 -139
  83. package/dist/columnExpressions/mixins/TemporalExpr.js +0 -126
  84. package/dist/columnExpressions/mixins/WindowExpr.js +0 -151
  85. package/dist/columnExpressions/types.js +0 -2
  86. package/dist/columnExpressions/utils.js +0 -45
  87. package/dist/dataframe/constants.js +0 -7
  88. package/dist/dataframe/dataframe.js +0 -990
  89. package/dist/dataframe/grouped/grouped.js +0 -114
  90. package/dist/dataframe/index.js +0 -20
  91. package/dist/dataframe/types.js +0 -2
  92. package/dist/dataframe/utils.js +0 -307
  93. package/dist/datatypes/DataType.js +0 -76
  94. package/dist/datatypes/index.js +0 -46
  95. package/dist/datatypes/types/Binary.d.ts +0 -9
  96. package/dist/datatypes/types/Binary.js +0 -18
  97. package/dist/datatypes/types/Boolean.d.ts +0 -9
  98. package/dist/datatypes/types/Boolean.js +0 -19
  99. package/dist/datatypes/types/Date.d.ts +0 -8
  100. package/dist/datatypes/types/Date.js +0 -21
  101. package/dist/datatypes/types/Datetime.d.ts +0 -8
  102. package/dist/datatypes/types/Datetime.js +0 -17
  103. package/dist/datatypes/types/Decimal.d.ts +0 -10
  104. package/dist/datatypes/types/Decimal.js +0 -28
  105. package/dist/datatypes/types/Duration.d.ts +0 -8
  106. package/dist/datatypes/types/Duration.js +0 -17
  107. package/dist/datatypes/types/Float32.d.ts +0 -8
  108. package/dist/datatypes/types/Float32.js +0 -17
  109. package/dist/datatypes/types/Float64.d.ts +0 -8
  110. package/dist/datatypes/types/Float64.js +0 -17
  111. package/dist/datatypes/types/Int16.d.ts +0 -8
  112. package/dist/datatypes/types/Int16.js +0 -17
  113. package/dist/datatypes/types/Int32.d.ts +0 -8
  114. package/dist/datatypes/types/Int32.js +0 -17
  115. package/dist/datatypes/types/Int64.d.ts +0 -8
  116. package/dist/datatypes/types/Int64.js +0 -17
  117. package/dist/datatypes/types/Int8.d.ts +0 -8
  118. package/dist/datatypes/types/Int8.js +0 -17
  119. package/dist/datatypes/types/List.d.ts +0 -10
  120. package/dist/datatypes/types/List.js +0 -31
  121. package/dist/datatypes/types/Null.d.ts +0 -9
  122. package/dist/datatypes/types/Null.js +0 -17
  123. package/dist/datatypes/types/Object.d.ts +0 -9
  124. package/dist/datatypes/types/Object.js +0 -17
  125. package/dist/datatypes/types/Struct.d.ts +0 -14
  126. package/dist/datatypes/types/Struct.js +0 -39
  127. package/dist/datatypes/types/Time.d.ts +0 -8
  128. package/dist/datatypes/types/Time.js +0 -29
  129. package/dist/datatypes/types/UInt16.d.ts +0 -8
  130. package/dist/datatypes/types/UInt16.js +0 -17
  131. package/dist/datatypes/types/UInt32.d.ts +0 -8
  132. package/dist/datatypes/types/UInt32.js +0 -17
  133. package/dist/datatypes/types/UInt64.d.ts +0 -8
  134. package/dist/datatypes/types/UInt64.js +0 -17
  135. package/dist/datatypes/types/UInt8.d.ts +0 -8
  136. package/dist/datatypes/types/UInt8.js +0 -17
  137. package/dist/datatypes/types/Utf8.d.ts +0 -10
  138. package/dist/datatypes/types/Utf8.js +0 -20
  139. package/dist/datatypes/types.js +0 -290
  140. package/dist/exceptions/index.js +0 -46
  141. package/dist/exceptions/utils.js +0 -28
  142. package/dist/functions/concat.js +0 -260
  143. package/dist/functions/index.js +0 -9
  144. package/dist/functions/read_csv.js +0 -53
  145. package/dist/functions/read_json.js +0 -21
  146. package/dist/functions/transpose.d.ts +0 -7
  147. package/dist/functions/transpose.js +0 -84
  148. package/dist/types.js +0 -2
  149. package/dist/utils/boolean.d.ts +0 -1
  150. package/dist/utils/boolean.js +0 -18
  151. package/dist/utils/csv.js +0 -313
  152. package/dist/utils/date.js +0 -348
  153. package/dist/utils/guards.d.ts +0 -12
  154. package/dist/utils/guards.js +0 -112
  155. package/dist/utils/index.js +0 -23
  156. package/dist/utils/json.js +0 -217
  157. package/dist/utils/list.js +0 -361
  158. package/dist/utils/number.js +0 -401
  159. package/dist/utils/string.js +0 -209
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AggregationExpr = void 0;
4
- const ExprBase_1 = require("../ExprBase");
5
- const exceptions_1 = require("../../exceptions");
6
- const utils_1 = require("../../utils");
7
- class AggregationExpr extends ExprBase_1.ExprBase {
8
- _deriveAgg(fn) {
9
- const newInst = (0, ExprBase_1.derive)(this);
10
- newInst.aggFn = fn;
11
- newInst.groupingOpsIndex = this.ops.length;
12
- newInst.partitionOpsIndex = this.ops.length;
13
- return newInst;
14
- }
15
- all() {
16
- return this._deriveAgg(v => (0, utils_1.isArrayOfType)(v, (x) => !!x, { mode: "every" }));
17
- }
18
- all_null() {
19
- return this._deriveAgg(v => (0, utils_1.isArrayOfType)(v, "nullish", { mode: "every" }));
20
- }
21
- any() {
22
- return this._deriveAgg(v => (0, utils_1.isArrayOfType)(v, (x) => !!x, { mode: "some" }));
23
- }
24
- any_null() {
25
- return this._deriveAgg(v => (0, utils_1.isArrayOfType)(v, "nullish", { mode: "some" }));
26
- }
27
- avg() {
28
- return this._deriveAgg(v => (0, utils_1.getListStats)(v).mean);
29
- }
30
- count(options = {}) {
31
- if (options.includeNulls)
32
- return this._deriveAgg(v => v.length);
33
- return this._deriveAgg(v => (0, utils_1.getListStats)(v).count);
34
- }
35
- first() {
36
- return this._deriveAgg(v => v[0] ?? null);
37
- }
38
- implode() {
39
- return this._deriveAgg(v => v);
40
- }
41
- last() {
42
- return this._deriveAgg(v => v[v.length - 1] ?? null);
43
- }
44
- max() {
45
- return this._deriveAgg(v => (0, utils_1.getListStats)(v).max);
46
- }
47
- mean() {
48
- return this.avg();
49
- }
50
- median() {
51
- return this._deriveAgg(v => (0, utils_1.computeMedian)(v));
52
- }
53
- min() {
54
- return this._deriveAgg(v => (0, utils_1.getListStats)(v).min);
55
- }
56
- mode() {
57
- return this._deriveAgg(v => (0, utils_1.computeMode)(v));
58
- }
59
- n_unique(options = {}) {
60
- return this._deriveAgg(v => {
61
- return (0, utils_1.getUniqueListStats)(v, options).count;
62
- });
63
- }
64
- quantile(q) {
65
- if (q < 0 || q > 1)
66
- throw new exceptions_1.ComputeError("Quantile q must be between 0 and 1");
67
- return this._deriveAgg(v => (0, utils_1.computeQuantile)(v, q));
68
- }
69
- std() {
70
- return this._deriveAgg(v => (0, utils_1.getListStats)(v).std);
71
- }
72
- sum() {
73
- return this._deriveAgg(v => (0, utils_1.getListStats)(v).sum);
74
- }
75
- }
76
- exports.AggregationExpr = AggregationExpr;
@@ -1,131 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArithmeticExpr = void 0;
4
- const ExprBase_1 = require("../ExprBase");
5
- const utils_1 = require("../utils");
6
- const utils_2 = require("../../utils");
7
- class ArithmeticExpr extends ExprBase_1.ExprBase {
8
- abs() {
9
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => Math.abs(v)));
10
- }
11
- acos() {
12
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => (v < -1 || v > 1) ? null : Math.acos(v)));
13
- }
14
- acosh() {
15
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => v < 1 ? null : Math.acosh(v)));
16
- }
17
- add(val) {
18
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => v + r));
19
- }
20
- asin() {
21
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => (v < -1 || v > 1) ? null : Math.asin(v)));
22
- }
23
- asinh() {
24
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.asinh));
25
- }
26
- atan() {
27
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.atan));
28
- }
29
- atanh() {
30
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => (v <= -1 || v >= 1) ? null : Math.atanh(v)));
31
- }
32
- cbrt() {
33
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.cbrt));
34
- }
35
- ceil() {
36
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.ceil));
37
- }
38
- clip(lower = null, upper = null) {
39
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => (0, utils_2.clamp)(v, { min: lower, max: upper })));
40
- }
41
- cos() {
42
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.cos));
43
- }
44
- cosh() {
45
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.cosh));
46
- }
47
- degrees() {
48
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => v * (180 / Math.PI)));
49
- }
50
- div(val) {
51
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => r === 0 ? null : v / r));
52
- }
53
- exp() {
54
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.exp));
55
- }
56
- expm1() {
57
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.expm1));
58
- }
59
- floor() {
60
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.floor));
61
- }
62
- floordiv(val) {
63
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => r === 0 ? null : Math.floor(v / r)));
64
- }
65
- hypot(val) {
66
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => Math.hypot(v, r)));
67
- }
68
- log(base = Math.E) {
69
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => v <= 0 ? null : (base === Math.E ? Math.log(v) : Math.log(v) / Math.log(base))));
70
- }
71
- log1p() {
72
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => v <= -1 ? null : Math.log1p(v)));
73
- }
74
- mod(val) {
75
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => r === 0 ? null : v % r));
76
- }
77
- mul(val) {
78
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => v * r));
79
- }
80
- negate() {
81
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => -v));
82
- }
83
- pow(val) {
84
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => Math.pow(v, r)));
85
- }
86
- radians() {
87
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => v * (Math.PI / 180)));
88
- }
89
- rand(seed, { min = 0, max = 1, integer = false } = {}) {
90
- return (0, ExprBase_1.derive)(this, (vArray) => {
91
- const len = vArray.length;
92
- const out = new Float64Array(len);
93
- const rnd = seed !== undefined ? (0, utils_2.mulberry32)(seed) : Math.random;
94
- const range = max - min;
95
- for (let i = 0; i < len; i++) {
96
- const raw = rnd();
97
- out[i] = integer ? Math.floor(raw * (range + 1)) + min : raw * range + min;
98
- }
99
- return out;
100
- });
101
- }
102
- round(decimals = 0) {
103
- const factor = Math.pow(10, decimals);
104
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => Math.round(v * factor) / factor));
105
- }
106
- sign() {
107
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.sign));
108
- }
109
- sin() {
110
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.sin));
111
- }
112
- sinh() {
113
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.sinh));
114
- }
115
- sqrt() {
116
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => v < 0 ? null : Math.sqrt(v)));
117
- }
118
- sub(val) {
119
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => v - r));
120
- }
121
- tan() {
122
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.tan));
123
- }
124
- tanh() {
125
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.tanh));
126
- }
127
- trunc() {
128
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Math.trunc));
129
- }
130
- }
131
- exports.ArithmeticExpr = ArithmeticExpr;
@@ -1,40 +0,0 @@
1
- import type { ExprConstructor } from "../types";
2
- export declare const BooleanExpr: <TBase extends ExprConstructor>(Base: TBase) => {
3
- new (...args: any[]): {
4
- and(other: any): /*elided*/ any;
5
- not(): /*elided*/ any;
6
- or(other: any): /*elided*/ any;
7
- xor(other: any): /*elided*/ any;
8
- all(): /*elided*/ any;
9
- all_null(): /*elided*/ any;
10
- any(): /*elided*/ any;
11
- any_null(): /*elided*/ any;
12
- ops: import("../..").OpFn[];
13
- colName?: string;
14
- outputName?: string;
15
- isLiteral?: boolean;
16
- literalValue?: any;
17
- aggFn?: import("../..").AggFn<any> | null;
18
- groupingOpsIndex?: number;
19
- partitionOpsIndex?: number;
20
- partitionBy?: (string | import("../..").IExpr)[] | null;
21
- windowOp?: {
22
- type: string;
23
- [key: string]: any;
24
- } | null;
25
- isWindow?: boolean;
26
- alias(name: string): /*elided*/ any;
27
- cast(dataType: import("../..").RegisteredDataType): /*elided*/ any;
28
- _resolve(val: any, columns: import("../..").ColumnDict, height: number): import("../..").ColumnData | any;
29
- evaluate(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
30
- evaluatePreGrouping(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
31
- evaluatePostGrouping(aggregatedArray: any[], columns: import("../..").ColumnDict): import("../..").ColumnData;
32
- evaluatePrePartition(columns: import("../..").ColumnDict, height: number): import("../..").ColumnData;
33
- evaluatePostPartition(aggregatedArray: any[], columns: import("../..").ColumnDict): import("../..").ColumnData;
34
- evaluateWindow?(groupPreValues: any[], partitionIndices: number[], currentIndex: number): any;
35
- debug(label?: string): /*elided*/ any;
36
- _window(evaluateWindow: (this: import("../..").IExpr, groupPreValues: any[], partitionIndices: number[], currentIndex: number) => any): /*elided*/ any;
37
- _rolling(windowSize: number, aggFn: (vals: any[]) => any): /*elided*/ any;
38
- _deriveAgg(fn: import("../..").AggFn<any>): /*elided*/ any;
39
- };
40
- } & TBase;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BooleanExpr = void 0;
4
- const ExprBase_1 = require("../ExprBase");
5
- const utils_1 = require("../../utils");
6
- const BooleanExpr = (Base) => {
7
- return class extends Base {
8
- and(other) {
9
- return (0, ExprBase_1.derive)(this, (vArray, columns) => {
10
- const height = vArray.length;
11
- const otherVal = this._resolve(other, columns, height);
12
- const isOtherArray = (0, utils_1.isArrayOrTypedArray)(otherVal);
13
- const result = new Array(height);
14
- for (let i = 0; i < height; i++) {
15
- const v = vArray[i];
16
- const w = isOtherArray ? otherVal[i] : otherVal;
17
- if (v === false || w === false)
18
- result[i] = false;
19
- else if (v == null || w == null)
20
- result[i] = null;
21
- else
22
- result[i] = true;
23
- }
24
- return result;
25
- });
26
- }
27
- not() {
28
- return (0, ExprBase_1.derive)(this, (0, ExprBase_1.kleeneUnary)((v) => !v));
29
- }
30
- or(other) {
31
- return (0, ExprBase_1.derive)(this, (vArray, columns) => {
32
- const height = vArray.length;
33
- const otherVal = this._resolve(other, columns, height);
34
- const isOtherArray = (0, utils_1.isArrayOrTypedArray)(otherVal);
35
- const result = new Array(height);
36
- for (let i = 0; i < height; i++) {
37
- const v = vArray[i];
38
- const w = isOtherArray ? otherVal[i] : otherVal;
39
- if (v === true || w === true)
40
- result[i] = true;
41
- else if (v == null || w == null)
42
- result[i] = null;
43
- else
44
- result[i] = false;
45
- }
46
- return result;
47
- });
48
- }
49
- xor(other) {
50
- return (0, ExprBase_1.derive)(this, (0, ExprBase_1.kleeneBinary)(this, other, (v, w) => !!v !== !!w));
51
- }
52
- // Boolean Aggregations
53
- all() {
54
- return this._deriveAgg((v) => (0, utils_1.isArrayOfType)(v, (x) => !!x, { mode: "every" }));
55
- }
56
- all_null() {
57
- return this._deriveAgg((v) => (0, utils_1.isArrayOfType)(v, "nullish", { mode: "every" }));
58
- }
59
- any() {
60
- return this._deriveAgg((v) => (0, utils_1.isArrayOfType)(v, (x) => !!x, { mode: "some" }));
61
- }
62
- any_null() {
63
- return this._deriveAgg((v) => (0, utils_1.isArrayOfType)(v, "nullish", { mode: "some" }));
64
- }
65
- };
66
- };
67
- exports.BooleanExpr = BooleanExpr;
@@ -1,250 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComparisonExpr = void 0;
4
- const ExprBase_1 = require("../ExprBase");
5
- const utils_1 = require("../utils");
6
- const utils_2 = require("../../utils");
7
- function computeIsIn(vArray, columns, values, invert) {
8
- const height = vArray.length;
9
- const result = new Array(height);
10
- if (values && typeof values === 'object' && 'evaluate' in values) {
11
- const resolved = values.evaluate(columns, height);
12
- for (let i = 0; i < height; i++) {
13
- const v = vArray[i];
14
- if (v == null) {
15
- result[i] = null;
16
- }
17
- else {
18
- const candidates = resolved[i];
19
- const set = new Set();
20
- if ((0, utils_2.isArrayOrTypedArray)(candidates)) {
21
- const cLen = candidates.length;
22
- for (let j = 0; j < cLen; j++) {
23
- set.add((0, utils_2.toCanonicalString)(candidates[j]));
24
- }
25
- }
26
- else {
27
- set.add((0, utils_2.toCanonicalString)(candidates));
28
- }
29
- const hasVal = set.has((0, utils_2.toCanonicalString)(v));
30
- result[i] = invert ? !hasVal : hasVal;
31
- }
32
- }
33
- }
34
- else {
35
- const arr = (0, utils_2.isArrayOrTypedArray)(values) ? values : [];
36
- const set = new Set();
37
- const arrLen = arr.length;
38
- for (let j = 0; j < arrLen; j++) {
39
- set.add((0, utils_2.toCanonicalString)(arr[j]));
40
- }
41
- for (let i = 0; i < height; i++) {
42
- const v = vArray[i];
43
- if (v == null) {
44
- result[i] = null;
45
- }
46
- else {
47
- const hasVal = set.has((0, utils_2.toCanonicalString)(v));
48
- result[i] = invert ? !hasVal : hasVal;
49
- }
50
- }
51
- }
52
- return result;
53
- }
54
- function evaluateDuplication(vArray, checkDuplicate) {
55
- const { frequencies } = (0, utils_2.getUniqueListStats)(vArray, { strict: true });
56
- const height = vArray.length;
57
- const result = new Array(height);
58
- for (let i = 0; i < height; i++) {
59
- const count = frequencies.get(vArray[i]) || 0;
60
- result[i] = checkDuplicate ? count > 1 : count === 1;
61
- }
62
- return result;
63
- }
64
- function compareMissing(vArray, rResolved, invert) {
65
- const height = vArray.length;
66
- const result = new Array(height);
67
- if ((0, utils_2.isArrayOrTypedArray)(rResolved)) {
68
- for (let i = 0; i < height; i++) {
69
- const v = vArray[i];
70
- const r = rResolved[i];
71
- if (v == null && r == null) {
72
- result[i] = !invert;
73
- }
74
- else if (v == null || r == null) {
75
- result[i] = invert;
76
- }
77
- else {
78
- result[i] = invert ? v !== r : v === r;
79
- }
80
- }
81
- }
82
- else {
83
- for (let i = 0; i < height; i++) {
84
- const v = vArray[i];
85
- if (v == null && rResolved == null) {
86
- result[i] = !invert;
87
- }
88
- else if (v == null || rResolved == null) {
89
- result[i] = invert;
90
- }
91
- else {
92
- result[i] = invert ? v !== rResolved : v === rResolved;
93
- }
94
- }
95
- }
96
- return result;
97
- }
98
- class ComparisonExpr extends ExprBase_1.ExprBase {
99
- between(lower, upper, closed = "both") {
100
- return (0, ExprBase_1.derive)(this, (vArray, columns) => {
101
- const height = vArray.length;
102
- const lResolved = this._resolve(lower, columns, height);
103
- const uResolved = this._resolve(upper, columns, height);
104
- const result = new Array(height);
105
- const isLArray = (0, utils_2.isArrayOrTypedArray)(lResolved);
106
- const isUArray = (0, utils_2.isArrayOrTypedArray)(uResolved);
107
- for (let i = 0; i < height; i++) {
108
- const v = vArray[i];
109
- const l = isLArray ? lResolved[i] : lResolved;
110
- const u = isUArray ? uResolved[i] : uResolved;
111
- if (v == null || l == null || u == null) {
112
- result[i] = null;
113
- }
114
- else {
115
- const geLower = closed === "both" || closed === "left" ? v >= l : v > l;
116
- const leUpper = closed === "both" || closed === "right" ? v <= u : v < u;
117
- result[i] = geLower && leUpper;
118
- }
119
- }
120
- return result;
121
- });
122
- }
123
- eq(val) {
124
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => v === r));
125
- }
126
- eq_missing(val) {
127
- return (0, ExprBase_1.derive)(this, (vArray, columns) => {
128
- const rResolved = this._resolve(val, columns, vArray.length);
129
- return compareMissing(vArray, rResolved, false);
130
- });
131
- }
132
- ge(val) {
133
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => v >= r));
134
- }
135
- gt(val) {
136
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => v > r));
137
- }
138
- has_nulls() {
139
- return this._deriveAgg((v) => {
140
- for (let i = 0; i < v.length; i++) {
141
- if (v[i] == null)
142
- return true;
143
- }
144
- return false;
145
- });
146
- }
147
- is_close(other, { abs_tol = 1e-8, rel_tol = 1e-8, nans_equal = false } = {}) {
148
- return (0, ExprBase_1.derive)(this, (vArray, columns) => {
149
- const height = vArray.length;
150
- const otherVal = this._resolve(other, columns, height);
151
- const isOtherArray = (0, utils_2.isArrayOrTypedArray)(otherVal);
152
- const result = new Array(height);
153
- for (let i = 0; i < height; i++) {
154
- const v = vArray[i];
155
- const o = isOtherArray ? otherVal[i] : otherVal;
156
- if (v == null || o == null) {
157
- result[i] = null;
158
- }
159
- else if ((0, utils_2.isValidNumber)(v) && (0, utils_2.isValidNumber)(o)) {
160
- const absDiff = Math.abs(v - o);
161
- const threshold = Math.max(rel_tol * Math.max(Math.abs(v), Math.abs(o)), abs_tol);
162
- result[i] = absDiff <= threshold;
163
- }
164
- else if (Number.isNaN(v) && Number.isNaN(o)) {
165
- result[i] = nans_equal;
166
- }
167
- else {
168
- result[i] = (v === o);
169
- }
170
- }
171
- return result;
172
- });
173
- }
174
- is_duplicated() {
175
- return (0, ExprBase_1.derive)(this, (vArray) => evaluateDuplication(vArray, true));
176
- }
177
- is_empty({ ignoreNulls = false } = {}) {
178
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => {
179
- if (typeof v === "string") {
180
- return v.length === 0;
181
- }
182
- if ((0, utils_2.isArrayOrTypedArray)(v)) {
183
- if (ignoreNulls) {
184
- return (0, utils_2.isArrayOfType)(v, "nullish", {
185
- mode: "every"
186
- });
187
- }
188
- return v.length === 0;
189
- }
190
- return null;
191
- }));
192
- }
193
- is_finite() {
194
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Number.isFinite));
195
- }
196
- is_in(values) {
197
- return (0, ExprBase_1.derive)(this, (vArray, columns) => computeIsIn(vArray, columns, values, false));
198
- }
199
- is_infinite() {
200
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => v === Infinity || v === -Infinity));
201
- }
202
- is_nan() {
203
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)(Number.isNaN));
204
- }
205
- is_not_nan() {
206
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneUnary)((v) => !Number.isNaN(v)));
207
- }
208
- is_not_null() {
209
- return (0, ExprBase_1.derive)(this, (vArray) => {
210
- const height = vArray.length;
211
- const result = new Array(height);
212
- for (let i = 0; i < height; i++) {
213
- result[i] = vArray[i] != null;
214
- }
215
- return result;
216
- });
217
- }
218
- is_null() {
219
- return (0, ExprBase_1.derive)(this, (vArray) => {
220
- const height = vArray.length;
221
- const result = new Array(height);
222
- for (let i = 0; i < height; i++) {
223
- result[i] = vArray[i] == null;
224
- }
225
- return result;
226
- });
227
- }
228
- is_unique() {
229
- return (0, ExprBase_1.derive)(this, (vArray) => evaluateDuplication(vArray, false));
230
- }
231
- le(val) {
232
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => v <= r));
233
- }
234
- lt(val) {
235
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => v < r));
236
- }
237
- ne(val) {
238
- return (0, ExprBase_1.derive)(this, (0, utils_1.kleeneBinary)(this, val, (v, r) => v !== r));
239
- }
240
- ne_missing(val) {
241
- return (0, ExprBase_1.derive)(this, (vArray, columns) => {
242
- const rResolved = this._resolve(val, columns, vArray.length);
243
- return compareMissing(vArray, rResolved, true);
244
- });
245
- }
246
- not_in(values) {
247
- return (0, ExprBase_1.derive)(this, (vArray, columns) => computeIsIn(vArray, columns, values, true));
248
- }
249
- }
250
- exports.ComparisonExpr = ComparisonExpr;
@@ -1,39 +0,0 @@
1
- import { ExprBase } from "../ExprBase";
2
- import { StepSliceListOptions } from "../../utils";
3
- import type { UniqueListStatsOptions, JoinListOptions, ExplodeOptions, IExpr } from "../../types";
4
- export declare class ListExprNamespace {
5
- expr: any;
6
- constructor(expr: any);
7
- _deriveList(fn: (arr: any[] | ArrayBufferView) => any): any;
8
- all(): any;
9
- any(): any;
10
- contains(item: any): any;
11
- contains_all(items: ArrayLike<any>): any;
12
- contains_any(items: ArrayLike<any>): any;
13
- count_matches(item: any): any;
14
- drop_nulls(): any;
15
- explode({ empty_as_null, keep_nulls }?: ExplodeOptions): any;
16
- first(null_on_oob?: boolean): any;
17
- gather(indices: number | ArrayLike<number>, null_on_oob?: boolean): any;
18
- gather_every(options?: StepSliceListOptions): any;
19
- get(index: number, null_on_oob?: boolean): any;
20
- join(separator?: string, options?: JoinListOptions): any;
21
- last(null_on_oob?: boolean): any;
22
- len(): any;
23
- lengths(): any;
24
- max(): any;
25
- mean(): any;
26
- median(): any;
27
- min(): any;
28
- mode(): any;
29
- n_unique(options?: UniqueListStatsOptions): any;
30
- reverse(): any;
31
- slice(offset: number, length?: number): any;
32
- sort(descending?: boolean): any;
33
- sum(): any;
34
- unique(options?: UniqueListStatsOptions): any;
35
- eval(expr: IExpr): any;
36
- }
37
- export declare class ListExpr extends ExprBase {
38
- get list(): ListExprNamespace;
39
- }