df-script 1.7.0 → 1.9.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 (36) hide show
  1. package/README.md +51 -12
  2. package/dist/api.d.ts +2 -1
  3. package/dist/columnExpressions/ExprBase.d.ts +8 -0
  4. package/dist/columnExpressions/constants.d.ts +2 -0
  5. package/dist/columnExpressions/functions/duration.d.ts +33 -0
  6. package/dist/columnExpressions/functions/when.d.ts +8 -6
  7. package/dist/columnExpressions/index.d.ts +2 -0
  8. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +203 -1
  9. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +57 -41
  10. package/dist/columnExpressions/mixins/StringExpr.d.ts +277 -13
  11. package/dist/columnExpressions/mixins/StructExpr.d.ts +7 -7
  12. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +123 -72
  13. package/dist/columnExpressions/typeInference.d.ts +13 -0
  14. package/dist/columnExpressions/types.d.ts +1 -1
  15. package/dist/columnExpressions/utils.d.ts +19 -0
  16. package/dist/constants.d.ts +44 -3
  17. package/dist/dataframe/dataframe.d.ts +233 -109
  18. package/dist/dataframe/types.d.ts +25 -3
  19. package/dist/dataframe/utils.d.ts +21 -1
  20. package/dist/datatypes/types.d.ts +8 -3
  21. package/dist/exceptions/index.d.ts +10 -0
  22. package/dist/exceptions/utils.d.ts +2 -0
  23. package/dist/index.js +5 -5
  24. package/dist/index.mjs +5 -5
  25. package/dist/types.d.ts +132 -1
  26. package/dist/utils/array.d.ts +62 -6
  27. package/dist/utils/binary.d.ts +6 -2
  28. package/dist/utils/date.d.ts +6 -2
  29. package/dist/utils/duration.d.ts +5 -0
  30. package/dist/utils/index.d.ts +1 -0
  31. package/dist/utils/json.d.ts +54 -2
  32. package/dist/utils/number.d.ts +5 -2
  33. package/dist/utils/object.d.ts +13 -0
  34. package/dist/utils/string.d.ts +78 -2
  35. package/dist/utils/table.d.ts +76 -0
  36. package/package.json +13 -3
package/dist/types.d.ts CHANGED
@@ -27,6 +27,11 @@ export interface IExpr {
27
27
  _isLiteral?: boolean;
28
28
  _literalValue?: any;
29
29
  _aggFn?: AggFn<any> | null;
30
+ _castType?: RegisteredDataType;
31
+ _binaryMeta?: {
32
+ left: any;
33
+ right: any;
34
+ };
30
35
  _groupingOpsIndex?: number;
31
36
  _partitionOpsIndex?: number;
32
37
  _partitionBy?: (string | IExpr)[] | null;
@@ -35,6 +40,10 @@ export interface IExpr {
35
40
  [key: string]: any;
36
41
  } | null;
37
42
  _isWindow?: boolean;
43
+ _baseExpr?: IExpr;
44
+ _fieldName?: string;
45
+ _isUnnest?: boolean;
46
+ _branchOperands?: any[];
38
47
  alias(name: string): this;
39
48
  cast(dataType: RegisteredDataType): this;
40
49
  _resolve(val: any, columns: ColumnDict, height: number): ColumnData | any;
@@ -45,6 +54,7 @@ export interface IExpr {
45
54
  debug(label?: string): this;
46
55
  }
47
56
  export type TimeUnit = "s" | "ms" | "us" | "ns";
57
+ export type DatetimeTimeUnit = "ms" | "us" | "ns";
48
58
  export type DateDiffUnit = "ms" | "milliseconds" | "s" | "seconds" | "m" | "minutes" | "h" | "hours" | "d" | "days" | "w" | "weeks" | "mo" | "months" | "q" | "quarters" | "y" | "years";
49
59
  export interface DateDiffOptions {
50
60
  roundMode?: "exact" | "floor" | "ceil" | "round" | "trunc";
@@ -59,12 +69,101 @@ export interface StrftimeOptions {
59
69
  locale?: string;
60
70
  timeZone?: string;
61
71
  }
72
+ export type StringEncoding = "hex" | "base64";
73
+ export interface StringEncodeOptions {
74
+ encoding: StringEncoding;
75
+ }
76
+ export interface StringDecodeOptions extends StringEncodeOptions {
77
+ strict?: boolean;
78
+ }
79
+ export type EscapeRegexMode = "tc39" | "non_alphanumeric_ascii";
80
+ export interface EscapeRegexOptions {
81
+ /**
82
+ * Escaping mode:
83
+ * - "tc39" (default): TC39 ECMAScript standard specification (syntax metacharacters + set operators).
84
+ * - "non_alphanumeric_ascii": Escapes all non-alphanumeric ASCII characters ([^A-Za-z0-9]) matching Polars / Rust regex::escape.
85
+ */
86
+ mode?: EscapeRegexMode;
87
+ }
88
+ export interface ExtractRegexEngineOptions {
89
+ /**
90
+ * Index or name of the capture group to extract.
91
+ */
92
+ groupIndex?: number | string;
93
+ /**
94
+ * Whether matching should be case-insensitive for ASCII characters.
95
+ */
96
+ asciiCaseInsensitive?: boolean;
97
+ /**
98
+ * Whether to return all matches (global flag). Defaults to false.
99
+ */
100
+ global?: boolean;
101
+ }
102
+ export type RegexEngineOptions = Omit<ExtractRegexEngineOptions, "groupIndex">;
103
+ export interface ExtractManyOptions extends ExtractRegexEngineOptions {
104
+ /**
105
+ * Whether overlapping matches are allowed.
106
+ */
107
+ overlapping?: boolean;
108
+ /**
109
+ * Guarantees in case there are overlapping matches that the leftmost match is used.
110
+ * In case there are multiple candidates for the leftmost match, the pattern which comes
111
+ * first in patterns is used. May not be used together with overlapping = true.
112
+ */
113
+ leftmost?: boolean;
114
+ }
115
+ export interface FindOptions extends ExtractRegexEngineOptions, EscapeRegexOptions {
116
+ /**
117
+ * Treat pattern as literal string instead of regex.
118
+ */
119
+ literal?: boolean;
120
+ }
121
+ export interface FindManyOptions extends ExtractManyOptions, EscapeRegexOptions {
122
+ /**
123
+ * Treat patterns as literal strings instead of regex.
124
+ */
125
+ literal?: boolean;
126
+ }
127
+ export interface ReplaceOptions extends RegexEngineOptions, EscapeRegexOptions {
128
+ /**
129
+ * Treat pattern as a literal string instead of regex.
130
+ */
131
+ literal?: boolean;
132
+ /**
133
+ * Number of occurrences to replace. Use -1 or Infinity to replace all. Defaults to 1.
134
+ */
135
+ n?: number;
136
+ }
137
+ export interface ReplaceManyOptions extends FindManyOptions {
138
+ }
139
+ export interface SplitOptions extends RegexEngineOptions, EscapeRegexOptions {
140
+ /**
141
+ * Treat delimiter as literal string (default: true). Set to false for regex matching.
142
+ */
143
+ literal?: boolean;
144
+ /**
145
+ * Include delimiter in the split results.
146
+ */
147
+ inclusive?: boolean;
148
+ /**
149
+ * Maximum number of splits to perform.
150
+ */
151
+ limit?: number;
152
+ /**
153
+ * If true, pads missing splits with null to guarantee exact limit + 1 parts.
154
+ */
155
+ exact?: boolean;
156
+ /**
157
+ * If true, throws an InvalidArgumentError if the split does not yield at least limit + 1 parts.
158
+ */
159
+ strict?: boolean;
160
+ }
62
161
  export type BusinessDayRollType = "raise" | "forward" | "backward";
63
162
  export interface IsBusinessDayOptions {
64
163
  holidays?: (Date | string | number)[] | Set<number>;
65
164
  excludeWeekdays?: number[];
66
165
  }
67
- export interface BusinessDayOffsetOptions extends IsBusinessDayOptions {
166
+ export interface DayOffsetOptions extends IsBusinessDayOptions {
68
167
  roll?: BusinessDayRollType;
69
168
  }
70
169
  export type UtcOffsetType = "base" | "total" | "daylightSavingTime";
@@ -73,6 +172,27 @@ export interface UtcOffsetOptions {
73
172
  type?: UtcOffsetType;
74
173
  format?: UtcOffsetFormat;
75
174
  }
175
+ export interface DateTimeParts {
176
+ /** Calendar year (e.g. 2026). */
177
+ year: number;
178
+ /** 1-indexed calendar month from 1 to 12 (1 = January, 12 = December). */
179
+ month: number;
180
+ /** 1-indexed day of the month from 1 to 31. */
181
+ day: number;
182
+ /** 0-indexed hour of day from 0 to 23 (0 = Midnight). */
183
+ hour: number;
184
+ /** 0-indexed minute of hour from 0 to 59. */
185
+ minute: number;
186
+ /** 0-indexed second of minute from 0 to 59. */
187
+ second: number;
188
+ /** 0-indexed millisecond from 0 to 999. */
189
+ ms: number;
190
+ /** 0-indexed day of week (0 = Sunday, 6 = Saturday). */
191
+ dayOfWeek?: number;
192
+ /** Optional target timezone identifier (e.g. "UTC", "America/New_York"). */
193
+ timeZone?: string | null;
194
+ }
195
+ export type ReplaceDateOptions = Partial<Omit<DateTimeParts, "dayOfWeek">>;
76
196
  /** Concatenation Configuration */
77
197
  export type ConcatHow = "vertical" | "horizontal" | "diagonal";
78
198
  export interface HorizontalConcatOptions {
@@ -106,3 +226,14 @@ export interface ToStructOptions {
106
226
  fields?: string[] | ((idx: number) => string);
107
227
  upper_bound?: number;
108
228
  }
229
+ export interface SkewOptions {
230
+ bias?: boolean;
231
+ }
232
+ export interface KurtosisOptions {
233
+ fisher?: boolean;
234
+ bias?: boolean;
235
+ }
236
+ export interface EntropyOptions {
237
+ base?: number;
238
+ normalize?: boolean;
239
+ }
@@ -1,17 +1,24 @@
1
- import type { AnyTypedArray, ColumnData } from "../types";
1
+ import type { AnyTypedArray, ColumnData, SkewOptions, KurtosisOptions, EntropyOptions } from "../types";
2
+ /** Array Guards **/
2
3
  export declare function isTypedArray(v: unknown): v is AnyTypedArray;
3
4
  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 declare function toValidArray<T>(val: T | T[] | null | undefined): T[];
6
+ export declare function getArrayElement(arr: any[] | AnyTypedArray, index: number, null_on_oob: boolean): any;
7
+ export type ArrayItemType = "string" | "number" | "boolean" | "bigint" | "object" | "plainObject" | "date" | "any" | "null" | "undefined" | "nullish" | (new (...args: any[]) => any) | ((v: unknown) => any);
5
8
  export type ArrayCheckMode = "every" | "some";
6
9
  export type IsArrayOfTypeOptionsParams = {
7
10
  mode?: ArrayCheckMode;
8
11
  allowNulls?: boolean;
9
12
  allowEmpty?: boolean;
10
13
  };
11
- export declare function toValidArray<T>(val: T | T[] | null | undefined): T[];
12
- export declare function toValidStringArray(val: unknown): string[];
13
- export declare function getArrayElement(arr: any[] | AnyTypedArray, index: number, null_on_oob: boolean): any;
14
- export declare function isArrayOfType(arr: unknown, type: ArrayItemType, { mode, allowNulls, allowEmpty }?: IsArrayOfTypeOptionsParams): boolean;
14
+ /**
15
+ * Checks if an array matches a specific item type contract.
16
+ */
17
+ export declare function isArrayOfType(arr: unknown, type: ArrayItemType, { mode, allowNulls, allowEmpty, }?: IsArrayOfTypeOptionsParams): boolean;
18
+ /**
19
+ * Coerces array items to a target type contract in a single optimized pass.
20
+ */
21
+ export declare function toArrayOfType<T = any>(val: unknown, type?: ArrayItemType, { mode, allowNulls, allowEmpty, }?: IsArrayOfTypeOptionsParams): T[];
15
22
  export interface SortArrayOptions {
16
23
  descending?: boolean;
17
24
  nullsLast?: boolean;
@@ -19,15 +26,19 @@ export interface SortArrayOptions {
19
26
  export declare function sortArray(arr: unknown, { descending, nullsLast }?: SortArrayOptions): any[];
20
27
  export declare function getArrayStats(arr: unknown): {
21
28
  sum: number | null;
29
+ product: number | null;
22
30
  count: number;
23
31
  min: any;
24
32
  max: any;
33
+ nanMin: any;
34
+ nanMax: any;
25
35
  minIdx: number | null;
26
36
  maxIdx: number | null;
27
37
  mean: number | null;
28
38
  variance: number;
29
39
  std: number;
30
40
  nullCount: number;
41
+ nanCount: number;
31
42
  len: number;
32
43
  hasNulls: boolean;
33
44
  isNumeric: boolean;
@@ -246,3 +257,48 @@ export declare function computeDotProduct(pairs: ColumnData<[any, any]>): number
246
257
  * Defensive against absolute sum-zero weight errors.
247
258
  */
248
259
  export declare function computeWeightedAverage(pairs: ColumnData<[any, any]>): number | null;
260
+ /**
261
+ * Generates Cartesian product pair index arrays for two lengths lenA and lenB.
262
+ */
263
+ export declare function computeCartesianProduct(lenA: number, lenB: number): {
264
+ leftIndices: number[];
265
+ rightIndices: number[];
266
+ };
267
+ export type BinarySearchSide = "left" | "right";
268
+ export interface BinarySearchOptions<T = any> {
269
+ side?: BinarySearchSide;
270
+ getValue?: (index: number, item: T) => number;
271
+ }
272
+ /**
273
+ * Performs a binary search on a sorted numeric array or ArrayLike structure.
274
+ * Supports an optional `getValue` accessor for indirect index searching without array allocations.
275
+ * @param arr Sorted array or ArrayLike structure to search within.
276
+ * @param target Target numeric value to search for.
277
+ * @param options Binary search options.
278
+ * @param options.side Search side: `"left"` (bisect_left, first index >= target) or `"right"` (bisect_right, first index > target). Default `"left"`.
279
+ * @param options.getValue Optional accessor function `(index, item) => number` for indirect searching.
280
+ * @returns Index insertion point.
281
+ */
282
+ export declare function binarySearch<T = any>(arr: ArrayLike<T>, target: number, options?: BinarySearchOptions<T>): number;
283
+ /**
284
+ * Computes the sample skewness of a numeric dataset as the Fisher-Pearson coefficient of skewness.
285
+ * @param arr ArrayLike dataset
286
+ * @param options Skewness calculation options ({ bias?: boolean }, default bias=true)
287
+ */
288
+ export declare function computeSkewness(arr: ArrayLike<any>, options?: SkewOptions): number | null;
289
+ /**
290
+ * Computes the kurtosis of a numeric dataset.
291
+ * @param arr ArrayLike dataset
292
+ * @param options Kurtosis calculation options ({ fisher?: boolean, bias?: boolean }, default fisher=true, bias=true)
293
+ */
294
+ export declare function computeKurtosis(arr: ArrayLike<any>, options?: KurtosisOptions): number | null;
295
+ /**
296
+ * Computes the Shannon entropy of a dataset.
297
+ * @param arr ArrayLike dataset
298
+ * @param options Entropy options ({ base?: number, normalize?: boolean }, default base=Math.E, normalize=true)
299
+ */
300
+ export declare function computeEntropy(arr: ArrayLike<any>, options?: EntropyOptions): number | null;
301
+ /** Reduces elements in an array using a bitwise binary operation across valid BigInts/numbers. */
302
+ export declare function reduceBitwise(arr: ArrayLike<any>, op: (acc: bigint, val: bigint) => bigint): number | bigint | null;
303
+ /** Finds the value in target column corresponding to the minimum or maximum value in `by` column. */
304
+ export declare function computeBy(pairs: Array<[any, any]> | null | undefined, statKey: "minIdx" | "maxIdx"): any;
@@ -1,3 +1,7 @@
1
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;
2
+ export interface BinaryValidationOptions {
3
+ strict?: boolean;
4
+ }
5
+ export declare function isBinaryObj(v: unknown): v is Uint8Array | Uint8ClampedArray | ArrayBuffer | SharedArrayBuffer | DataView;
6
+ export declare function isValidBinary(v: unknown, options?: BinaryValidationOptions): v is Uint8Array | Uint8ClampedArray | ArrayBuffer | SharedArrayBuffer | DataView | string | number[] | AnyTypedArray;
7
+ export declare function toValidBinary(v: unknown, options?: BinaryValidationOptions): Uint8Array | null;
@@ -1,7 +1,10 @@
1
- import type { TimeUnit, StrptimeOptions, StrftimeOptions, IsBusinessDayOptions, BusinessDayOffsetOptions, DateDiffUnit, DateDiffOptions, UtcOffsetOptions } from "../types";
1
+ import type { TimeUnit, StrptimeOptions, StrftimeOptions, IsBusinessDayOptions, DayOffsetOptions, DateDiffUnit, DateDiffOptions, UtcOffsetOptions, ReplaceDateOptions, DateTimeParts } from "../types";
2
2
  export declare const TIME_PREFIX_REGEX: RegExp;
3
3
  export declare const ZONE_OFFSET_REGEX: RegExp;
4
4
  export declare const ISO_DATE_ONLY_REGEX: RegExp;
5
+ export declare function _createUTCDate(year: number, monthZeroIndexed?: number, day?: number, hour?: number, minute?: number, second?: number, ms?: number): Date;
6
+ export declare function _getDateTimeParts(d: Date, timeZone?: string): DateTimeParts;
7
+ export declare function _getTimeZoneOffsetMinutes(d: Date, tz: string): number;
5
8
  export declare function toValidDate(input: unknown, options?: {
6
9
  dateOnly?: boolean;
7
10
  }): Date | null;
@@ -21,6 +24,7 @@ export declare function isLeapYear(yOrDate: number | Date): boolean;
21
24
  export declare const FORMAT_REGEX: RegExp;
22
25
  export declare function strftime(d: Date, { format, locale, timeZone }: StrftimeOptions): string;
23
26
  export declare function strptime(str: string, { format, strict, defaultTimeZone }: StrptimeOptions): Date | null;
24
- export declare function offsetDay(d: Date, n: number | any, { excludeWeekdays, holidays, roll }?: BusinessDayOffsetOptions): Date;
27
+ export declare function offsetDay(d: Date, n: number | any, { excludeWeekdays, holidays, roll }?: DayOffsetOptions): number;
25
28
  export declare function getTimeZoneOffset(d: Date, timeZone?: string, options?: UtcOffsetOptions): number | string;
26
29
  export declare function isBusinessDay(d: Date, options?: IsBusinessDayOptions): boolean | null;
30
+ export declare function replaceDateComponents(d: Date, opts?: ReplaceDateOptions): Date;
@@ -0,0 +1,5 @@
1
+ /** @internalfile */
2
+ /**
3
+ * Scale total milliseconds into the target time unit precision.
4
+ */
5
+ export declare function scaleDurationMs(ms: number, timeUnit: "ms" | "us" | "ns"): number;
@@ -6,3 +6,4 @@ export * from "./string";
6
6
  export * from "./json";
7
7
  export * from "./csv";
8
8
  export * from "./binary";
9
+ export * from "./duration";
@@ -65,7 +65,7 @@ export type SafeJsonParseOptions<T = unknown, F = T> = JSONParseOptions & {
65
65
  * @param options - Configuration options for validation.
66
66
  * @returns `true` if the input is a valid JSON or NDJSON string; `false` otherwise.
67
67
  */
68
- export declare function isJsonString(input: unknown, options?: JSONParseOptions): input is string;
68
+ export declare function isJsonString(input: unknown, options?: SafeJsonParseOptions): input is string;
69
69
  /**
70
70
  * Safely parses a string containing JSON or NDJSON content in a single pass, returning the parsed value if successful
71
71
  * and passing the guard validation. If parsing or validation fails, returns the fallback value (if provided)
@@ -75,7 +75,7 @@ export declare function isJsonString(input: unknown, options?: JSONParseOptions)
75
75
  * @param options - Configuration options for parsing and validation.
76
76
  * @returns The parsed value, the fallback, or the original input.
77
77
  */
78
- export declare function safeJsonParse<T = unknown, I = unknown, F = T>(input: I, { format, allowPrimitives, trimBeforeParse, reviver, ndjson: { skipInvalidLines, maxLines, skipLines }, guard, onError, fallback }?: SafeJsonParseOptions<T, F>): T | I | F;
78
+ export declare function safeJsonParse<T = unknown, I = unknown, F = T>(input: I, options?: SafeJsonParseOptions<T, F>): T | I | F;
79
79
  export interface SafeJsonReplacerOptions {
80
80
  /** Custom formatter function for Date objects. Ignored if onDate is specified. */
81
81
  formatDate?: (v: Date) => string;
@@ -119,3 +119,55 @@ export interface SafeJsonReplacerOptions {
119
119
  replacer?: ((this: any, k: string, v: any) => any) | (string | number)[] | null;
120
120
  }
121
121
  export declare function createSafeJsonReplacer(options?: SafeJsonReplacerOptions): (this: any, k: string, v: any) => any;
122
+ /**
123
+ * Represents the type of operation a JSONPath token performs.
124
+ */
125
+ export type JsonTokenType =
126
+ /**
127
+ * Selects an object property by name (e.g., .foo or ['foo'])
128
+ */
129
+ "prop"
130
+ /**
131
+ * Selects a zero-based or negative array index (e.g., [0] or [-1])
132
+ */
133
+ | "idx"
134
+ /**
135
+ * Selects a range or stepped slice of an array (e.g., [1:5:2])
136
+ */
137
+ | "slice"
138
+ /**
139
+ * Selects all immediate properties of an object or elements of an array (e.g., .* or [*])
140
+ */
141
+ | "wildcard"
142
+ /**
143
+ * Recursively searches and collects matching keys down the hierarchy (e.g., ..foo)
144
+ * */
145
+ | "rec";
146
+ /**
147
+ * Parsed AST token representing a single evaluation step in a JSONPath expression.
148
+ */
149
+ export interface JsonToken {
150
+ /** The evaluation operation type. */
151
+ type: JsonTokenType;
152
+ /** Property name or recursive search key. Used by "prop" and "rec" tokens. */
153
+ key?: string;
154
+ /** Target index position. Used by "idx" tokens. Supports negative indices. */
155
+ idx?: number;
156
+ /** Starting array index (inclusive). Used by "slice" tokens. Defaults to 0 or end of array depending on step. */
157
+ start?: number;
158
+ /** Ending array index (exclusive). Used by "slice" tokens. Defaults to array bound depending on step. */
159
+ end?: number;
160
+ /** Increment step value. Used by "slice" tokens. Defaults to 1. Cannot be 0. */
161
+ step?: number;
162
+ }
163
+ /**
164
+ * Tokenizes a JSONPath query string (e.g. "$.user.items[0]") into an array
165
+ * of executable query tokens without polluting global regex state.
166
+ * Returns null if path contains unparsed/invalid syntax fragments.
167
+ */
168
+ export declare function tokenizeJsonPath(path: string): JsonToken[] | null;
169
+ export declare function evaluateJsonToken(item: any, tok: JsonToken, next: any[]): void;
170
+ /**
171
+ * Extracts the first match from a JSON string or object using the provided JSONPath expression.
172
+ */
173
+ export declare function jsonPathMatch(jsonInput: unknown, path: string): string | null;
@@ -82,11 +82,14 @@ export type BigIntRange = {
82
82
  min: bigint;
83
83
  max: bigint;
84
84
  } | BigIntRangeType;
85
- export interface BigIntOptions {
85
+ export interface IsValidBigIntOptions {
86
86
  range?: BigIntRange;
87
+ }
88
+ export interface toValidBigIntOptions extends IsValidBigIntOptions {
87
89
  truncate?: boolean;
88
90
  }
89
- export declare function toValidBigInt(v: unknown, { range, truncate }?: BigIntOptions): bigint | null;
91
+ export declare function isValidBigInt(v: unknown, { range }?: IsValidBigIntOptions): v is bigint;
92
+ export declare function toValidBigInt(v: unknown, { range, truncate }?: toValidBigIntOptions): bigint | null;
90
93
  export interface DecimalOptions {
91
94
  precision?: number;
92
95
  scale?: number;
@@ -10,6 +10,13 @@ export declare const TAG_NUMBER = "[object Number]";
10
10
  export declare const TAG_BOOLEAN = "[object Boolean]";
11
11
  export declare const TAG_BIGINT = "[object BigInt]";
12
12
  export declare const TAG_SYMBOL = "[object Symbol]";
13
+ export declare const TAG_UINT8ARRAY = "[object Uint8Array]";
14
+ export declare const TAG_UINT8CLAMPEDARRAY = "[object Uint8ClampedArray]";
15
+ export declare const TAG_ARRAYBUFFER = "[object ArrayBuffer]";
16
+ export declare const TAG_SHAREDARRAYBUFFER = "[object SharedArrayBuffer]";
17
+ export declare const TAG_DATAVIEW = "[object DataView]";
18
+ export declare const TAG_OBJECT = "[object Object]";
19
+ export declare const typedArrayTagGetter: (() => any) | undefined;
13
20
  export declare function isObj(v: unknown): v is Record<PropertyKey, unknown>;
14
21
  export declare function isPlainObj(v: unknown): v is Record<PropertyKey, unknown>;
15
22
  export declare function isClass(v: unknown): v is new (...args: any[]) => any;
@@ -24,4 +31,10 @@ export declare function isNumberObj(v: unknown): v is Number;
24
31
  export declare function isBooleanObj(v: unknown): v is Boolean;
25
32
  export declare function isBigIntObj(v: unknown): v is Object;
26
33
  export declare function isSymbolObj(v: unknown): v is Object;
34
+ export declare function isDetachedBuffer(v: unknown): boolean;
35
+ export declare function isArrayBuffer(v: unknown): v is ArrayBuffer;
36
+ export declare function isSharedArrayBuffer(v: unknown): v is SharedArrayBuffer;
37
+ export declare function isDataView(v: unknown): v is DataView;
38
+ export declare function isUint8Array(v: unknown): v is Uint8Array;
39
+ export declare function isUint8ClampedArray(v: unknown): v is Uint8ClampedArray;
27
40
  export declare function unboxPrimitiveObj(v: unknown): unknown;
@@ -1,5 +1,5 @@
1
+ import type { StringEncoding, EscapeRegexOptions, ExtractManyOptions, ExtractRegexEngineOptions, RegexEngineOptions, FindOptions, FindManyOptions, SplitOptions, ReplaceOptions, ReplaceManyOptions } from "../types";
1
2
  export declare function isBlankString(v: unknown): v is string;
2
- export declare function escapeRegExp(val: unknown): string;
3
3
  export type StripMode = "both" | "start" | "end";
4
4
  export type StripCharsOptions = {
5
5
  /**
@@ -54,7 +54,7 @@ export declare function toCanonicalString(val: any, { depth, maxDepth }?: {
54
54
  maxDepth?: number;
55
55
  }): string;
56
56
  export interface ChangeCaseOptions {
57
- format: "camel" | "kebab" | "pascal" | "snake";
57
+ format: "camel" | "kebab" | "pascal" | "snake" | "title";
58
58
  }
59
59
  /**
60
60
  * Fully robust, Unicode-aware string tokenization engine.
@@ -65,3 +65,79 @@ export declare function toWords(str: any): string[];
65
65
  * High-performance, predictable case converter
66
66
  */
67
67
  export declare function changeCase(str: any, options: ChangeCaseOptions): string;
68
+ /**
69
+ * Serializes a value to a JSON string with BigInt support using createSafeJsonReplacer.
70
+ */
71
+ export declare function encodeObjectToJson(value: unknown): string;
72
+ /**
73
+ * Encodes a JSON string into a UTF-8 Uint8Array byte array.
74
+ */
75
+ export declare function encodeJsonToBytes(json: string): Uint8Array;
76
+ /**
77
+ * Encodes a byte array or binary-coercible input into a standard Base64 string representation.
78
+ * Uses 8192-byte chunking or native methods to prevent stack overflow errors.
79
+ */
80
+ export declare function encodeBytesToBase64(bytes: unknown): string;
81
+ /**
82
+ * Converts a standard Base64 string into a URL-safe Base64URL string.
83
+ * Replaces '+' with '-', '/' with '_', and strips trailing '=' padding in a single pass.
84
+ */
85
+ export declare function encodeBase64ToBase64URL(b64: string): string;
86
+ /**
87
+ * Encodes a string into a hexadecimal string representation.
88
+ */
89
+ export declare function encodeHex(str: string): string;
90
+ /**
91
+ * Encodes a string into a Base64 string representation.
92
+ */
93
+ export declare function encodeBase64(str: string): string;
94
+ /**
95
+ * Encodes string to hex or base64 based on specified encoding option.
96
+ */
97
+ export declare function encodeString(str: string | null | undefined, encoding: StringEncoding): string | null;
98
+ /**
99
+ * Converts a Base64URL string back into standard Base64 format.
100
+ * Restores URL-safe characters ('-' to '+', '_' to '/') in a single pass and appends '=' padding.
101
+ */
102
+ export declare function decodeBase64URLToBase64(b64Url: string): string;
103
+ /**
104
+ * Decodes a standard Base64 string directly into a Uint8Array byte array.
105
+ */
106
+ export declare function decodeBase64ToBytes(b64: string, strict?: boolean): Uint8Array;
107
+ /**
108
+ * Decodes a Uint8Array byte array back into a parsed JSON object.
109
+ */
110
+ export declare function decodeBytesToJson(bytes: Uint8Array): unknown;
111
+ /**
112
+ * Decodes a Hex-encoded string directly into a Uint8Array byte array.
113
+ */
114
+ export declare function decodeHexToBytes(hex: string): Uint8Array;
115
+ /**
116
+ * Decodes a Hex-encoded string into a standard UTF-8 string.
117
+ */
118
+ export declare function decodeHex(str: string, strict?: boolean): string | null;
119
+ /**
120
+ * Decodes a Base64 or Base64URL-encoded string into a standard UTF-8 string.
121
+ */
122
+ export declare function decodeBase64(str: string, strict?: boolean): string | null;
123
+ /**
124
+ * Decodes hex or base64 encoded string back to standard UTF-8 string.
125
+ */
126
+ export declare function decodeString(str: string | null | undefined, encoding: StringEncoding, options?: {
127
+ strict?: boolean;
128
+ } | boolean): string | null;
129
+ export declare function escapeRegExp(val: unknown, options?: EscapeRegexOptions): string;
130
+ export declare function toCleanRegExp(str: string | null | undefined, pattern: string | RegExp, options?: RegexEngineOptions): {
131
+ reg: RegExp;
132
+ input: string;
133
+ } | null;
134
+ export declare function extractRegexEngine(str: string | null | undefined, pattern: string | RegExp, options?: ExtractRegexEngineOptions): Record<string, string | null>[] | null;
135
+ export declare function extractRegex(str: string | null | undefined, pattern: string | RegExp, options?: ExtractRegexEngineOptions): string | null;
136
+ export declare function extractRegexAll(str: string | null | undefined, pattern: string | RegExp, options?: ExtractRegexEngineOptions): (string | null)[] | null;
137
+ export declare function extractRegexGroups(str: string | null | undefined, pattern: string | RegExp, options?: ExtractManyOptions): Record<string, string | null> | null;
138
+ export declare function extractRegexMany(str: string | null | undefined, patterns: (string | RegExp)[] | (string | RegExp), options?: ExtractManyOptions): (string | null)[] | null;
139
+ export declare function findRegex(str: string | null | undefined, pattern: string | RegExp, options?: FindOptions): number | null;
140
+ export declare function findManyRegex(str: string | null | undefined, patterns: (string | RegExp)[] | (string | RegExp), options?: FindManyOptions): (number | null)[] | null;
141
+ export declare function splitString(str: string | null | undefined, delimiter: string, options?: SplitOptions): (string | null)[] | null;
142
+ export declare function replaceString(str: string | null | undefined, pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string), options?: ReplaceOptions): string | null;
143
+ export declare function replaceManyString(str: string | null | undefined, patterns: (string | RegExp)[] | Record<string, string>, replaceWith?: (string | ((match: string, ...args: any[]) => string))[] | string | ((match: string, ...args: any[]) => string), options?: ReplaceManyOptions): string | null;
@@ -0,0 +1,76 @@
1
+ /** @file Table Formatting and HTML / Markdown Generation Utilities */
2
+ import type { ColumnDict } from "../types";
3
+ export type ColumnAlignment = "left" | "center" | "right";
4
+ export interface MarkdownOptions {
5
+ /**
6
+ * Whether to include the row index column in output.
7
+ * @default false
8
+ */
9
+ index?: boolean;
10
+ /**
11
+ * Name of the index column if `index: true`.
12
+ * @default "(index)"
13
+ */
14
+ indexName?: string;
15
+ /**
16
+ * Text alignment for table columns. Can be a single alignment for all columns
17
+ * or a map from column name to alignment.
18
+ * @default "left"
19
+ */
20
+ align?: ColumnAlignment | Record<string, ColumnAlignment>;
21
+ /**
22
+ * String representation for null or undefined values.
23
+ * @default "null"
24
+ */
25
+ nullValue?: string;
26
+ }
27
+ export interface HtmlOptions {
28
+ /**
29
+ * Whether to include the row index column in output.
30
+ * @default false
31
+ */
32
+ index?: boolean;
33
+ /**
34
+ * Name of the index column if `index: true`.
35
+ * @default ""
36
+ */
37
+ indexName?: string;
38
+ /**
39
+ * CSS class name(s) to add to the `<table>` element.
40
+ */
41
+ classes?: string | string[];
42
+ /**
43
+ * HTML `id` attribute to set on the `<table>` element.
44
+ */
45
+ tableId?: string;
46
+ /**
47
+ * HTML `border` attribute value.
48
+ */
49
+ border?: number | string;
50
+ /**
51
+ * Whether to escape HTML entities in cell values (`&`, `<`, `>`, `"`, `'`).
52
+ * @default true
53
+ */
54
+ escape?: boolean;
55
+ /**
56
+ * String representation for null or undefined values.
57
+ * @default "null"
58
+ */
59
+ nullValue?: string;
60
+ }
61
+ /**
62
+ * Escapes HTML characters in a string to prevent XSS and broken layouts.
63
+ */
64
+ export declare function escapeHtml(str: string): string;
65
+ /**
66
+ * Formats a generic JavaScript value as a safe string for display in tables.
67
+ */
68
+ export declare function formatCellValue(val: any, nullValue?: string): string;
69
+ /**
70
+ * Formats DataFrame columnar data into a GitHub-Flavored Markdown (GFM) table string.
71
+ */
72
+ export declare function stringifyMarkdownTable(columns: ColumnDict, height: number, options?: MarkdownOptions): string;
73
+ /**
74
+ * Formats DataFrame columnar data into an HTML table string.
75
+ */
76
+ export declare function stringifyHtmlTable(columns: ColumnDict, height: number, options?: HtmlOptions): string;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "df-script",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "A zero-dependency, high-performance, expression-based DataFrame library for TypeScript/JavaScript.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
+ "typings": "dist/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
11
  "types": "./dist/index.d.ts",
@@ -19,10 +20,11 @@
19
20
  "README.md"
20
21
  ],
21
22
  "scripts": {
22
- "build": "tsc --emitDeclarationOnly && esbuild src/index.ts --bundle --minify --outfile=dist/index.js --platform=node --mangle-props=^_ && esbuild src/index.ts --bundle --minify --outfile=dist/index.mjs --platform=neutral --format=esm --external:fs --mangle-props=^_",
23
+ "build": "tsc --emitDeclarationOnly && esbuild src/index.ts --bundle --minify --outfile=dist/index.js --platform=node --mangle-props=\\\"^_\\\" && esbuild src/index.ts --bundle --minify --outfile=dist/index.mjs --platform=neutral --format=esm --external:fs --mangle-props=\\\"^_\\\"",
23
24
  "test": "tsx _tests/run_all_project_tests.ts",
24
25
  "prepublishOnly": "npm run build",
25
- "extract-docs": "node scripts/extract-docs.mjs"
26
+ "extract-docs": "node scripts/extract-docs.mjs",
27
+ "release": "node scripts/publish.mjs"
26
28
  },
27
29
  "keywords": [
28
30
  "dataframe",
@@ -39,6 +41,14 @@
39
41
  "expression-engine"
40
42
  ],
41
43
  "author": "Trent Morris",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/trentamorris/df-script.git"
47
+ },
48
+ "bugs": {
49
+ "url": "https://github.com/trentamorris/df-script/issues"
50
+ },
51
+ "homepage": "https://github.com/trentamorris/df-script#readme",
42
52
  "license": "MIT",
43
53
  "funding": {
44
54
  "type": "custom",