df-script 1.5.0 → 1.6.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 (133) hide show
  1. package/README.md +124 -8
  2. package/dist/api.d.ts +1 -1
  3. package/dist/columnExpressions/ColumnExpr.d.ts +2 -2
  4. package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
  5. package/dist/columnExpressions/functions/element.d.ts +1 -1
  6. package/dist/columnExpressions/functions/when.d.ts +2 -2
  7. package/dist/columnExpressions/index.d.ts +1 -1
  8. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +2 -2
  9. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +11 -10
  10. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +39 -0
  11. package/dist/columnExpressions/mixins/ListExpr.d.ts +2 -2
  12. package/dist/columnExpressions/mixins/StringExpr.d.ts +2 -2
  13. package/dist/columnExpressions/types.d.ts +1 -0
  14. package/dist/constants.d.ts +11 -0
  15. package/dist/dataframe/dataframe.d.ts +1 -1
  16. package/dist/datatypes/index.d.ts +3 -2
  17. package/dist/datatypes/types.d.ts +7 -7
  18. package/dist/index.js +6 -6
  19. package/dist/types.d.ts +4 -2
  20. package/dist/utils/array.d.ts +217 -0
  21. package/dist/utils/binary.d.ts +3 -0
  22. package/dist/utils/date.d.ts +21 -35
  23. package/dist/utils/guards.d.ts +11 -10
  24. package/dist/utils/index.d.ts +3 -2
  25. package/dist/utils/list.d.ts +23 -1
  26. package/dist/utils/number.d.ts +14 -29
  27. package/dist/utils/object.d.ts +26 -0
  28. package/dist/utils/string.d.ts +3 -5
  29. package/package.json +2 -2
  30. package/dist/api.js +0 -26
  31. package/dist/bundle.min.js +0 -1
  32. package/dist/columnExpressions/ColumnExpr.js +0 -219
  33. package/dist/columnExpressions/ExprBase.js +0 -92
  34. package/dist/columnExpressions/constants.js +0 -7
  35. package/dist/columnExpressions/functions/all.js +0 -11
  36. package/dist/columnExpressions/functions/coalesce.js +0 -44
  37. package/dist/columnExpressions/functions/element.js +0 -11
  38. package/dist/columnExpressions/functions/exclude.js +0 -13
  39. package/dist/columnExpressions/functions/implode.js +0 -7
  40. package/dist/columnExpressions/functions/lit.js +0 -17
  41. package/dist/columnExpressions/functions/repeat.d.ts +0 -47
  42. package/dist/columnExpressions/functions/repeat.js +0 -131
  43. package/dist/columnExpressions/functions/seq_range.js +0 -91
  44. package/dist/columnExpressions/functions/when.js +0 -85
  45. package/dist/columnExpressions/index.js +0 -38
  46. package/dist/columnExpressions/mixins/AggregationExpr.js +0 -76
  47. package/dist/columnExpressions/mixins/ArithmeticExpr.js +0 -131
  48. package/dist/columnExpressions/mixins/BooleanExpr.d.ts +0 -40
  49. package/dist/columnExpressions/mixins/BooleanExpr.js +0 -67
  50. package/dist/columnExpressions/mixins/ComparisonExpr.js +0 -250
  51. package/dist/columnExpressions/mixins/ListExpr.js +0 -224
  52. package/dist/columnExpressions/mixins/LogicalExpr.js +0 -53
  53. package/dist/columnExpressions/mixins/ManipulationExpr.js +0 -71
  54. package/dist/columnExpressions/mixins/NumericExpr.d.ts +0 -92
  55. package/dist/columnExpressions/mixins/NumericExpr.js +0 -259
  56. package/dist/columnExpressions/mixins/StringExpr.js +0 -237
  57. package/dist/columnExpressions/mixins/StructExpr.js +0 -139
  58. package/dist/columnExpressions/mixins/TemporalExpr.js +0 -126
  59. package/dist/columnExpressions/mixins/WindowExpr.js +0 -151
  60. package/dist/columnExpressions/types.js +0 -2
  61. package/dist/columnExpressions/utils.js +0 -45
  62. package/dist/dataframe/constants.js +0 -7
  63. package/dist/dataframe/dataframe.js +0 -990
  64. package/dist/dataframe/grouped/grouped.js +0 -114
  65. package/dist/dataframe/index.js +0 -20
  66. package/dist/dataframe/types.js +0 -2
  67. package/dist/dataframe/utils.js +0 -307
  68. package/dist/datatypes/DataType.js +0 -76
  69. package/dist/datatypes/index.js +0 -46
  70. package/dist/datatypes/types/Binary.d.ts +0 -9
  71. package/dist/datatypes/types/Binary.js +0 -18
  72. package/dist/datatypes/types/Boolean.d.ts +0 -9
  73. package/dist/datatypes/types/Boolean.js +0 -19
  74. package/dist/datatypes/types/Date.d.ts +0 -8
  75. package/dist/datatypes/types/Date.js +0 -21
  76. package/dist/datatypes/types/Datetime.d.ts +0 -8
  77. package/dist/datatypes/types/Datetime.js +0 -17
  78. package/dist/datatypes/types/Decimal.d.ts +0 -10
  79. package/dist/datatypes/types/Decimal.js +0 -28
  80. package/dist/datatypes/types/Duration.d.ts +0 -8
  81. package/dist/datatypes/types/Duration.js +0 -17
  82. package/dist/datatypes/types/Float32.d.ts +0 -8
  83. package/dist/datatypes/types/Float32.js +0 -17
  84. package/dist/datatypes/types/Float64.d.ts +0 -8
  85. package/dist/datatypes/types/Float64.js +0 -17
  86. package/dist/datatypes/types/Int16.d.ts +0 -8
  87. package/dist/datatypes/types/Int16.js +0 -17
  88. package/dist/datatypes/types/Int32.d.ts +0 -8
  89. package/dist/datatypes/types/Int32.js +0 -17
  90. package/dist/datatypes/types/Int64.d.ts +0 -8
  91. package/dist/datatypes/types/Int64.js +0 -17
  92. package/dist/datatypes/types/Int8.d.ts +0 -8
  93. package/dist/datatypes/types/Int8.js +0 -17
  94. package/dist/datatypes/types/List.d.ts +0 -10
  95. package/dist/datatypes/types/List.js +0 -31
  96. package/dist/datatypes/types/Null.d.ts +0 -9
  97. package/dist/datatypes/types/Null.js +0 -17
  98. package/dist/datatypes/types/Object.d.ts +0 -9
  99. package/dist/datatypes/types/Object.js +0 -17
  100. package/dist/datatypes/types/Struct.d.ts +0 -14
  101. package/dist/datatypes/types/Struct.js +0 -39
  102. package/dist/datatypes/types/Time.d.ts +0 -8
  103. package/dist/datatypes/types/Time.js +0 -29
  104. package/dist/datatypes/types/UInt16.d.ts +0 -8
  105. package/dist/datatypes/types/UInt16.js +0 -17
  106. package/dist/datatypes/types/UInt32.d.ts +0 -8
  107. package/dist/datatypes/types/UInt32.js +0 -17
  108. package/dist/datatypes/types/UInt64.d.ts +0 -8
  109. package/dist/datatypes/types/UInt64.js +0 -17
  110. package/dist/datatypes/types/UInt8.d.ts +0 -8
  111. package/dist/datatypes/types/UInt8.js +0 -17
  112. package/dist/datatypes/types/Utf8.d.ts +0 -10
  113. package/dist/datatypes/types/Utf8.js +0 -20
  114. package/dist/datatypes/types.js +0 -290
  115. package/dist/exceptions/index.js +0 -46
  116. package/dist/exceptions/utils.js +0 -28
  117. package/dist/functions/concat.js +0 -260
  118. package/dist/functions/index.js +0 -9
  119. package/dist/functions/read_csv.js +0 -53
  120. package/dist/functions/read_json.js +0 -21
  121. package/dist/functions/transpose.d.ts +0 -7
  122. package/dist/functions/transpose.js +0 -84
  123. package/dist/types.js +0 -2
  124. package/dist/utils/boolean.d.ts +0 -1
  125. package/dist/utils/boolean.js +0 -18
  126. package/dist/utils/csv.js +0 -313
  127. package/dist/utils/date.js +0 -348
  128. package/dist/utils/guards.js +0 -112
  129. package/dist/utils/index.js +0 -23
  130. package/dist/utils/json.js +0 -217
  131. package/dist/utils/list.js +0 -361
  132. package/dist/utils/number.js +0 -401
  133. package/dist/utils/string.js +0 -209
@@ -0,0 +1,217 @@
1
+ import type { AnyTypedArray } from "../types";
2
+ export declare function isTypedArray(v: unknown): v is AnyTypedArray;
3
+ export declare function isArrayOrTypedArray(v: unknown): v is any[] | AnyTypedArray;
4
+ export type ArrayItemType = "string" | "number" | "boolean" | "bigint" | "object" | "plainObject" | "date" | "any" | "null" | "undefined" | "nullish" | (new (...args: any[]) => any) | ((v: unknown) => boolean);
5
+ export type ArrayCheckMode = "every" | "some";
6
+ export type IsArrayOfTypeOptionsParams = {
7
+ mode?: ArrayCheckMode;
8
+ allowNulls?: boolean;
9
+ allowEmpty?: boolean;
10
+ };
11
+ export declare function toValidArray<T>(val: T | T[] | null | undefined): T[];
12
+ export declare function toValidStringArray(val: unknown): string[];
13
+ export declare function isArrayOfType(arr: unknown, type: ArrayItemType, { mode, allowNulls, allowEmpty }?: IsArrayOfTypeOptionsParams): boolean;
14
+ export interface SortArrayOptions {
15
+ descending?: boolean;
16
+ nullsLast?: boolean;
17
+ }
18
+ export declare function sortArray(arr: unknown, { descending, nullsLast }?: SortArrayOptions): any[];
19
+ export declare function getArrayStats(arr: unknown): {
20
+ sum: number | null;
21
+ count: number;
22
+ min: any;
23
+ max: any;
24
+ mean: number | null;
25
+ variance: number;
26
+ std: number;
27
+ nullCount: number;
28
+ len: number;
29
+ hasNulls: boolean;
30
+ isNumeric: boolean;
31
+ };
32
+ /**
33
+ * Options configuration for the `getUniqueArrayStats` utility.
34
+ */
35
+ export interface UniqueArrayStatsOptions {
36
+ /**
37
+ * If true, uses strict serialization comparison (via keySelector or toCanonicalString)
38
+ * to group complex nested types (like Arrays, Sets, Maps, and Dates) by value instead of reference.
39
+ * @default false
40
+ */
41
+ strict?: boolean;
42
+ /**
43
+ * Custom function to extract a unique comparison key from each element.
44
+ * If strict is true and no selector is provided, falls back to `toCanonicalString`.
45
+ */
46
+ keySelector?: (val: any) => any;
47
+ }
48
+ export declare function getUniqueArrayStats(arr: ArrayLike<any>, { strict, keySelector }?: UniqueArrayStatsOptions): {
49
+ values: any[];
50
+ count: number;
51
+ frequencies: Map<any, number>;
52
+ };
53
+ /**
54
+ * Options configuration for the `stepSliceArray` utility.
55
+ */
56
+ export interface StepSliceArrayOptions {
57
+ /**
58
+ * The step size to slice the array by. Cannot be zero.
59
+ * Positive values slice forward (left-to-right), negative values slice backward (right-to-left).
60
+ * @default 1
61
+ */
62
+ step?: number;
63
+ /**
64
+ * The index to start slicing from (inclusive).
65
+ * Supports negative values to start relative to the end of the array.
66
+ * @default 0
67
+ */
68
+ offsetStart?: number;
69
+ /**
70
+ * The index to end slicing at (exclusive).
71
+ * Supports negative values to end relative to the end of the array.
72
+ * Defaults to the end of the array (if step > 0) or -1 (if step < 0).
73
+ */
74
+ offsetEnd?: number;
75
+ /**
76
+ * Caps the maximum number of items gathered in the sliced result array.
77
+ * If specified, the slicing process stops once this limit is reached.
78
+ */
79
+ maxItemsGathered?: number;
80
+ /**
81
+ * If true, returns null when the starting offset is out of bounds.
82
+ * If false, throws an error when the starting offset is out of bounds.
83
+ * @default true
84
+ */
85
+ null_on_oob?: boolean;
86
+ }
87
+ export declare function stepSliceArray<T>(arr: ArrayLike<T>, { step, offsetStart, offsetEnd, maxItemsGathered, null_on_oob }?: StepSliceArrayOptions): T[] | null;
88
+ /**
89
+ * Options configuration for the `joinArray` utility.
90
+ */
91
+ export interface JoinArrayOptions {
92
+ /**
93
+ * If true, nullish elements (null and undefined) are completely ignored during joining.
94
+ * If false (default), nullish elements are serialized as empty strings or custom `nullValue`.
95
+ * @default false
96
+ */
97
+ ignoreNulls?: boolean;
98
+ /**
99
+ * Custom string representation for nullish values.
100
+ * Only applied if `ignoreNulls` is false.
101
+ * @default ""
102
+ */
103
+ nullValue?: string;
104
+ /**
105
+ * Optional prefix string prepended to the final joined result.
106
+ * @default ""
107
+ */
108
+ prefix?: string;
109
+ /**
110
+ * Optional suffix string appended to the final joined result.
111
+ * @default ""
112
+ */
113
+ suffix?: string;
114
+ /**
115
+ * Maximum number of array elements to join.
116
+ * If specified, elements beyond this limit are omitted and `truncationMarker` is appended.
117
+ */
118
+ limit?: number;
119
+ /**
120
+ * Custom placeholder string appended to the joined string when limit truncation occurs.
121
+ * Only applied if `limit` is specified and the array length exceeds it.
122
+ * @default "..."
123
+ */
124
+ truncationMarker?: string;
125
+ /**
126
+ * Callback function used to format each individual non-null element to a custom string representation.
127
+ */
128
+ valueFormatter?: (val: any, index: number) => string;
129
+ }
130
+ /**
131
+ * Joins the elements of an array-like structure into a string using a separator.
132
+ * Excludes nullish checks and formats nested arrays cleanly.
133
+ */
134
+ export declare function joinArray(arr: ArrayLike<any>, separator?: string, { ignoreNulls, nullValue, prefix, suffix, limit, truncationMarker, valueFormatter }?: JoinArrayOptions): string;
135
+ export interface FillSeqBaseOptions {
136
+ /**
137
+ * Type coercion helper applied to each generated value before writing.
138
+ *
139
+ * @param v The newly generated candidate value.
140
+ * @returns The coerced value to write to the array.
141
+ */
142
+ coerce?: (v: any) => any;
143
+ /**
144
+ * Conditional predicate determining if a value should be replaced at a given index.
145
+ *
146
+ * @param v The original/current value at the target index.
147
+ * @param index The absolute index of the current element.
148
+ * @param array The entire target array.
149
+ * @returns True if the candidate value should overwrite the original value, false otherwise.
150
+ */
151
+ condition?: (v: any, index: number, array: any[]) => boolean;
152
+ /**
153
+ * If true, iterates and populates in reverse (from startIndex down to endIndex).
154
+ * @default false
155
+ */
156
+ reverse?: boolean;
157
+ /**
158
+ * The index at which array iteration and writing begins.
159
+ * @default reverse ? length - 1 : 0
160
+ */
161
+ startIndex?: number;
162
+ /**
163
+ * The exclusive boundary index at which iteration and writing stops.
164
+ * @default reverse ? -1 : length
165
+ */
166
+ endIndex?: number;
167
+ }
168
+ export interface CumulativeStepContext {
169
+ /** The accumulated value returned by the step function from the previous stepped index. */
170
+ prev: any;
171
+ /** The relative iteration counter of the stepping process (starts at 1). */
172
+ index: number;
173
+ /** The original value at the current index in the target array. */
174
+ originalValue: any;
175
+ /** The absolute index of the current element in the parent array. */
176
+ absoluteIndex: number;
177
+ /** The entire target array being populated/modified. */
178
+ targetArray: any;
179
+ }
180
+ export interface IndependentStepContext {
181
+ /** The relative iteration counter of the generation process (starts at 0). */
182
+ index: number;
183
+ /** The static starting value passed to the sequence generator. */
184
+ initialValue: any;
185
+ /** The original value at the current index in the target array. */
186
+ originalValue: any;
187
+ /** The absolute index of the current element in the parent array. */
188
+ absoluteIndex: number;
189
+ /** The entire target array being populated/modified. */
190
+ targetArray: any;
191
+ }
192
+ export type FillSeqOptions = FillSeqBaseOptions & ({
193
+ mode: "constant";
194
+ step?: never;
195
+ } | {
196
+ mode?: "cumulative";
197
+ step?: number | ((context: CumulativeStepContext) => any);
198
+ } | {
199
+ mode: "independent";
200
+ step?: number | ((context: IndependentStepContext) => any);
201
+ });
202
+ export declare function fillSequence(targetArray: any, initialValue: any, options?: FillSeqOptions): void;
203
+ /**
204
+ * Computes the median of a numeric array, filtering out non-numeric and NaN values.
205
+ * Returns null if no valid numbers remain.
206
+ */
207
+ export declare function computeMedian(values: ArrayLike<any>): number | null;
208
+ /**
209
+ * Computes the quantile of a numeric array using linear interpolation, filtering out non-numeric and NaN values.
210
+ * q must be in [0, 1]. Returns null if no valid numbers remain or q is out of bounds.
211
+ */
212
+ export declare function computeQuantile(values: ArrayLike<any>, q: number): number | null;
213
+ /**
214
+ * Computes the mode(s) of an array, filtering out null/undefined values.
215
+ * Returns an array of the most frequent values, sorted, or null if empty/no mode.
216
+ */
217
+ export declare function computeMode(values: ArrayLike<any>): any[] | null;
@@ -0,0 +1,3 @@
1
+ import type { AnyTypedArray } from "../types";
2
+ export declare function isValidBinary(v: unknown): v is string | any[] | AnyTypedArray;
3
+ export declare function toValidBinary(v: unknown): Uint8Array | null;
@@ -5,7 +5,7 @@ import type { TimeUnit } from "../types";
5
5
  * - "12:34" (matches "12:34")
6
6
  * - "10:37:16.123" (matches "10:37")
7
7
  * - "2026-05-25" (does not match)
8
- */
8
+ * */
9
9
  export declare const TIME_PREFIX_REGEX: RegExp;
10
10
  /**
11
11
  * Matches timezone offset indicators at the end of a string.
@@ -18,40 +18,26 @@ export declare const TIME_PREFIX_REGEX: RegExp;
18
18
  */
19
19
  export declare const ZONE_OFFSET_REGEX: RegExp;
20
20
  /**
21
- * Matches only UTC offset indicators at the end of a string.
21
+ * Matches strict ISO 8601 date-only format (YYYY-MM-DD).
22
22
  * Examples:
23
- * - "12:34:56Z" (matches "Z")
24
- * - "12:34:56+00:00" (matches "+00:00")
25
- * - "12:34:56-0000" (matches "-0000")
26
- * - "12:34:56+02:00" (does not match)
23
+ * - "2026-05-25" (matches)
24
+ * - "2026-05-25T10:37:16Z" (does not match)
27
25
  */
28
- export declare const UTC_INDICATOR_REGEX: RegExp;
29
- export declare const MS_PER_SECOND = 1000;
30
- export declare const MS_PER_MINUTE = 60000;
31
- export declare const MS_PER_HOUR = 3600000;
32
- export declare const MS_PER_DAY = 86400000;
33
- export declare const US_PER_MS = 1000;
34
- export declare const NS_PER_MS = 1000000;
35
- export interface UtcOffsetResult {
36
- timeZoneTime: Date;
37
- utcTime: Date;
38
- offset: number;
39
- formatted: string;
40
- }
41
- export declare function toEpoch(d: Date, unit?: TimeUnit): number;
42
- export declare function getCentury(d: Date): number;
43
- export declare function getISOWeek(d: Date): number;
44
- export declare function getMillennium(d: Date): number;
45
- export declare function getMonthOffset(d: Date, monthOffset: number, day?: number): Date;
46
- export declare function getOrdinalDay(d: Date): number;
47
- export declare function getQuarter(d: Date): number;
48
- export declare function getUtcOffset(timeZone: string): UtcOffsetResult;
26
+ export declare const ISO_DATE_ONLY_REGEX: RegExp;
27
+ export declare function toValidDate(input: unknown, options?: {
28
+ dateOnly?: boolean;
29
+ }): Date | null;
30
+ export declare function toValidTime(val: unknown): string | null;
31
+ export declare function toEpoch(d: Date, unit?: TimeUnit): number | bigint;
32
+ export declare function normalizeEpochToMs(n: number | bigint): number;
33
+ export declare function getCentury(d: Date): number | null;
34
+ export declare function getISOWeek(d: Date): number | null;
35
+ export declare function getMillennium(d: Date): number | null;
36
+ export declare function getMonthOffset(d: Date, monthOffset: number, day?: number): Date | null;
37
+ export declare function getOrdinalDay(d: Date): number | null;
38
+ export declare function getQuarter(d: Date): number | null;
49
39
  export declare function isLeapYear(yOrDate: number | Date): boolean;
50
- export declare function isUtcString(timestamp: string | null | undefined): boolean;
51
- export declare function isValidDate(v: unknown): v is string | number | bigint | Date;
52
- export declare function isValidDateObj(d: unknown): d is Date;
53
- export declare function normalizeEpochToMs(n: number): number;
54
- export declare const STRFTIME_DIRECTIVES: readonly ["%ms", "%f", "%Y", "%y", "%m", "%d", "%e", "%H", "%I", "%p", "%M", "%S", "%A", "%a", "%B", "%b", "%h", "%j", "%u", "%w", "%Z", "%z"];
55
- export declare function strftime(d: Date, format: string, locale?: string): string;
56
- export declare function strptime(str: string, format: string, strict?: boolean): Date | null;
57
- export declare function toValidDate(input: unknown): Date | null;
40
+ export declare const FORMAT_REGEX: RegExp;
41
+ export declare function expandFormatShorthands(format: string): string;
42
+ export declare function strftime(d: Date, format: string, locale?: string, timeZone?: string): string;
43
+ export declare function strptime(str: string, format: string, strict?: boolean, defaultTimeZone?: string): Date | null;
@@ -1,12 +1,13 @@
1
- export declare function isTypedArray(v: unknown): v is ArrayBufferView;
2
- export declare function isArrayOrTypedArray(v: unknown): v is ArrayLike<any> & Iterable<any>;
3
- export declare function isNonEmptyArray<T = unknown>(arr: unknown): arr is ArrayLike<T>;
4
- export declare function isNonEmptyArrayObjs<T extends object>(arr: unknown): arr is T[];
5
- export declare function isNonEmptyObj(v: unknown): v is Record<string, unknown>;
6
- export declare function isObj(v: unknown): v is Record<string, unknown>;
7
- export declare function isPlainObj(v: unknown): v is Record<string, unknown>;
1
+ import type { ValidScalarTypes } from "../types";
2
+ /** Array Guards **/
3
+ export type AnyTypedArray = ArrayBufferView & ArrayLike<number | bigint> & Iterable<number | bigint>;
4
+ export declare function isTypedArray(v: unknown): v is AnyTypedArray;
5
+ export declare function isArrayOrTypedArray(v: unknown): v is any[] | AnyTypedArray;
6
+ export declare function isObj(v: unknown): v is Record<PropertyKey, unknown>;
7
+ export declare function isPlainObj(v: unknown): v is Record<PropertyKey, unknown>;
8
+ /** Class Guards **/
8
9
  export declare function isClass(v: unknown): v is new (...args: any[]) => any;
9
- export declare function isScalar(v: unknown): v is string | number | boolean | bigint | Date | Uint8Array;
10
- export declare function isValidBinary(v: unknown): v is Uint8Array | string | ArrayLike<any>;
10
+ /** Scalar & Conversion Guards **/
11
+ export declare function isScalar<V>(v: V): v is Extract<V, Exclude<ValidScalarTypes, null | undefined>>;
12
+ export declare function isValidBinary(v: unknown): v is string | any[] | AnyTypedArray;
11
13
  export declare function toValidBinary(v: unknown): Uint8Array | null;
12
- export declare function tryParseBoolean(v: unknown): boolean | undefined;
@@ -1,7 +1,8 @@
1
- export * from "./guards";
1
+ export * from "./object";
2
2
  export * from "./number";
3
3
  export * from "./date";
4
- export * from "./list";
4
+ export * from "./array";
5
5
  export * from "./string";
6
6
  export * from "./json";
7
7
  export * from "./csv";
8
+ export * from "./binary";
@@ -8,7 +8,14 @@ export type IsArrayOfTypeOptionsParams = {
8
8
  export declare function toValidArray<T>(val: T | T[] | null | undefined): T[];
9
9
  export declare function toValidStringArray(val: unknown): string[];
10
10
  export declare function isArrayOfType(arr: unknown, type: ArrayItemType, { mode, allowNulls, allowEmpty }?: IsArrayOfTypeOptionsParams): boolean;
11
- export declare function sortList(arr: unknown, descending?: boolean): any[];
11
+ export interface SortListOptions {
12
+ descending?: boolean;
13
+ nullsLast?: boolean;
14
+ isAllNumbers?: boolean;
15
+ isAllStrings?: boolean;
16
+ hasNulls?: boolean;
17
+ }
18
+ export declare function sortList(arr: unknown, options?: SortListOptions): any[];
12
19
  export declare function getListStats(arr: unknown): {
13
20
  sum: number | null;
14
21
  count: number;
@@ -193,3 +200,18 @@ export type FillSeqOptions = FillSeqBaseOptions & ({
193
200
  step?: number | ((context: IndependentStepContext) => any);
194
201
  });
195
202
  export declare function fillSequence(targetArray: any, initialValue: any, options?: FillSeqOptions): void;
203
+ /**
204
+ * Computes the median of a numeric array, filtering out non-numeric and NaN values.
205
+ * Returns null if no valid numbers remain.
206
+ */
207
+ export declare function computeMedian(values: ArrayLike<any>): number | null;
208
+ /**
209
+ * Computes the quantile of a numeric array using linear interpolation, filtering out non-numeric and NaN values.
210
+ * q must be in [0, 1]. Returns null if no valid numbers remain or q is out of bounds.
211
+ */
212
+ export declare function computeQuantile(values: ArrayLike<any>, q: number): number | null;
213
+ /**
214
+ * Computes the mode(s) of an array, filtering out null/undefined values.
215
+ * Returns an array of the most frequent values, sorted, or null if empty/no mode.
216
+ */
217
+ export declare function computeMode(values: ArrayLike<any>): any[] | null;
@@ -1,8 +1,13 @@
1
1
  export interface NumericValidationOptions {
2
2
  allowNonFiniteNumbers?: boolean;
3
+ allowNaN?: boolean;
3
4
  }
4
5
  export declare function isValidNumber(v: unknown, options?: NumericValidationOptions): v is number;
5
- export declare function toValidNumber(v: unknown, options?: NumericValidationOptions): number | null;
6
+ export interface ParseNumberOptions extends NumericValidationOptions {
7
+ strictNumericString?: boolean;
8
+ floatScientific?: boolean;
9
+ }
10
+ export declare function toValidNumber(v: unknown, { allowNonFiniteNumbers, strictNumericString, floatScientific }?: ParseNumberOptions): number | null;
6
11
  export interface NumericFormatOptions extends Intl.NumberFormatOptions {
7
12
  /** BCP 47 language tag (e.g., 'en-US' for dot, 'de-DE' for comma). Defaults to 'en-US'. */
8
13
  locale?: string;
@@ -10,23 +15,20 @@ export interface NumericFormatOptions extends Intl.NumberFormatOptions {
10
15
  accountingNegatives?: boolean;
11
16
  /** Fallback string if the value cannot be parsed into a formatable number. */
12
17
  fallback?: string;
18
+ /** If true, returns the fallback string for Infinity and -Infinity values. */
19
+ formatNonFinite?: boolean;
13
20
  }
14
21
  /**
15
22
  * Formats any numeric value (number, bigint, numeric string, Date, etc.) for output,
16
23
  * handling NaN, Infinity, scientific notation, precision, and accounting formats.
17
24
  */
18
- export declare function formatNumber({ locale, accountingNegatives, fallback, ...intlOpts }?: NumericFormatOptions): (value: unknown) => string;
25
+ export declare function formatNumber({ locale, accountingNegatives, fallback, formatNonFinite, ...intlOpts }?: NumericFormatOptions): (value: unknown) => string;
19
26
  export type FloatPrecision = "Float32" | "Float64";
20
- export interface FloatOptions extends NumericValidationOptions {
27
+ export interface FloatOptions extends ParseNumberOptions {
21
28
  floatPrecision?: FloatPrecision;
22
- /**
23
- * When true, explicitly accepts scientific notation strings (e.g. "1.23e+4").
24
- * The result is still validated against the precision range.
25
- */
26
- floatScientific?: boolean;
27
29
  }
28
- export declare function isValidFloat(v: unknown, { floatPrecision, allowNonFiniteNumbers, floatScientific }?: FloatOptions): boolean;
29
- export declare function toValidFloat(v: unknown, { floatPrecision, allowNonFiniteNumbers, floatScientific }?: FloatOptions): number | null;
30
+ export declare function isValidFloat(v: unknown, { floatPrecision, allowNonFiniteNumbers }?: FloatOptions): v is number;
31
+ export declare function toValidFloat(v: unknown, { floatPrecision, allowNonFiniteNumbers, floatScientific, strictNumericString }?: FloatOptions): number | null;
30
32
  export declare const INT_RANGES: {
31
33
  readonly Int8: {
32
34
  readonly min: -128;
@@ -63,7 +65,6 @@ export interface IntOptions {
63
65
  range?: IntRange;
64
66
  coerce?: IntCoerceType;
65
67
  }
66
- export declare function isValidInt(v: unknown, range?: IntRange): v is number;
67
68
  export declare function toValidInt(v: unknown, { range, coerce }?: IntOptions): number | null;
68
69
  export declare const BIGINT_RANGES: {
69
70
  readonly Int64: {
@@ -84,15 +85,14 @@ export interface BigIntOptions {
84
85
  range?: BigIntRange;
85
86
  truncate?: boolean;
86
87
  }
87
- export declare function isValidBigInt(v: unknown, range?: BigIntRange): v is bigint;
88
88
  export declare function toValidBigInt(v: unknown, { range, truncate }?: BigIntOptions): bigint | null;
89
89
  export interface DecimalOptions {
90
90
  precision?: number;
91
91
  scale?: number;
92
92
  }
93
- export declare function isValidDecimal(v: unknown, { precision, scale }?: DecimalOptions): boolean;
93
+ export declare function roundToScale(v: number, scale: number): number;
94
94
  export declare function toValidDecimal(v: unknown, { precision, scale }?: DecimalOptions): number | null;
95
- export declare function clamp<T extends number | bigint>(val: T, { min, max, safe }?: {
95
+ export declare function clamp<T extends number | bigint>(val: T, options?: {
96
96
  min?: T | null;
97
97
  max?: T | null;
98
98
  safe?: boolean;
@@ -102,18 +102,3 @@ export declare function clamp<T extends number | bigint>(val: T, { min, max, saf
102
102
  * Returns a function that generates a pseudo-random float in the range [0, 1).
103
103
  */
104
104
  export declare function mulberry32(seed: number): () => number;
105
- /**
106
- * Computes the median of a numeric array, filtering out non-numeric and NaN values.
107
- * Returns null if no valid numbers remain.
108
- */
109
- export declare function computeMedian(values: ArrayLike<any>): number | null;
110
- /**
111
- * Computes the quantile of a numeric array using linear interpolation, filtering out non-numeric and NaN values.
112
- * q must be in [0, 1]. Returns null if no valid numbers remain or q is out of bounds.
113
- */
114
- export declare function computeQuantile(values: ArrayLike<any>, q: number): number | null;
115
- /**
116
- * Computes the mode(s) of an array, filtering out null/undefined values.
117
- * Returns an array of the most frequent values, sorted, or null if empty/no mode.
118
- */
119
- export declare function computeMode(values: ArrayLike<any>): any[] | null;
@@ -0,0 +1,26 @@
1
+ export declare const TAG_DATE = "[object Date]";
2
+ export declare const TAG_REGEXP = "[object RegExp]";
3
+ export declare const TAG_SET = "[object Set]";
4
+ export declare const TAG_MAP = "[object Map]";
5
+ export declare const TAG_ERROR = "[object Error]";
6
+ export declare const TAG_URL_PARAMS = "[object URLSearchParams]";
7
+ export declare const TAG_STRING = "[object String]";
8
+ export declare const TAG_NUMBER = "[object Number]";
9
+ export declare const TAG_BOOLEAN = "[object Boolean]";
10
+ export declare const TAG_BIGINT = "[object BigInt]";
11
+ export declare const TAG_SYMBOL = "[object Symbol]";
12
+ export declare function isObj(v: unknown): v is Record<PropertyKey, unknown>;
13
+ export declare function isPlainObj(v: unknown): v is Record<PropertyKey, unknown>;
14
+ export declare function isClass(v: unknown): v is new (...args: any[]) => any;
15
+ export declare function isValidDateObj(v: unknown): v is Date;
16
+ export declare function isRegExp(v: unknown): v is RegExp;
17
+ export declare function isSet(v: unknown): v is Set<unknown>;
18
+ export declare function isMap(v: unknown): v is Map<unknown, unknown>;
19
+ export declare function isURLSearchParams(v: unknown): v is URLSearchParams;
20
+ export declare function isError(v: unknown): v is Error;
21
+ export declare function isStringObj(v: unknown): v is String;
22
+ export declare function isNumberObj(v: unknown): v is Number;
23
+ export declare function isBooleanObj(v: unknown): v is Boolean;
24
+ export declare function isBigIntObj(v: unknown): v is Object;
25
+ export declare function isSymbolObj(v: unknown): v is Object;
26
+ export declare function unboxPrimitiveObj(v: unknown): unknown;
@@ -1,3 +1,5 @@
1
+ export declare function isBlankString(v: unknown): v is string;
2
+ export declare function escapeRegExp(val: unknown): string;
1
3
  export type StripMode = "both" | "start" | "end";
2
4
  export type StripCharsOptions = {
3
5
  /**
@@ -46,11 +48,7 @@ export type StripCharsOptions = {
46
48
  caseInsensitive?: boolean;
47
49
  };
48
50
  };
49
- /**
50
- * Strips characters from the start, end, or both ends of a string.
51
- */
52
- export declare function stripChars(str: string | null | undefined, characters?: string | RegExp | null, { mode, returnStringOnNull, maxScanStart, maxScanEnd, maxMatchesStart, maxMatchesEnd, trimFirst, stringOptions: { literal, caseInsensitive } }?: StripCharsOptions): string | null;
53
- export declare function isBlankString(v: unknown): v is string;
51
+ export declare function stripChars(str: string | null | undefined, characters?: string | RegExp | null, options?: StripCharsOptions): string | null;
54
52
  export declare function toCanonicalString(val: any, { depth, maxDepth }?: {
55
53
  depth?: number;
56
54
  maxDepth?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "df-script",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "A zero-dependency, high-performance, expression-based DataFrame library for TypeScript/JavaScript.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,7 @@
10
10
  "README.md"
11
11
  ],
12
12
  "scripts": {
13
- "build": "tsc && esbuild src/index.ts --bundle --minify --outfile=dist/index.js --platform=node",
13
+ "build": "tsc --emitDeclarationOnly && esbuild src/index.ts --bundle --minify --outfile=dist/index.js --platform=node",
14
14
  "test": "tsx _tests/run_all_project_tests.ts",
15
15
  "prepublishOnly": "npm run build"
16
16
  },
package/dist/api.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.$df = void 0;
4
- const dataframe_1 = require("./dataframe");
5
- const columnExpressions_1 = require("./columnExpressions");
6
- const datatypes_1 = require("./datatypes");
7
- const functions_1 = require("./functions");
8
- function data(data, schema) {
9
- return new dataframe_1.DataFrame(data, schema);
10
- }
11
- exports.$df = {
12
- data,
13
- col: (name) => new columnExpressions_1.ColumnExpr(name),
14
- all: columnExpressions_1.all,
15
- exclude: columnExpressions_1.exclude,
16
- coalesce: columnExpressions_1.coalesce,
17
- concat: functions_1.concat,
18
- read_json: functions_1.read_json,
19
- read_csv: functions_1.read_csv,
20
- lit: columnExpressions_1.lit,
21
- when: columnExpressions_1.when,
22
- implode: columnExpressions_1.implode,
23
- seq_range: columnExpressions_1.seq_range,
24
- element: columnExpressions_1.element,
25
- DataType: datatypes_1.DataTypeRegistry
26
- };