df-script 1.8.0 → 2.0.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 (64) hide show
  1. package/README.md +153 -203
  2. package/dist/api.d.ts +41 -36
  3. package/dist/columnExpressions/ColumnExpr.d.ts +5 -8
  4. package/dist/columnExpressions/ExprBase.d.ts +7 -0
  5. package/dist/columnExpressions/constants.d.ts +1 -0
  6. package/dist/columnExpressions/functions/all.d.ts +13 -13
  7. package/dist/columnExpressions/functions/coalesce.d.ts +2 -2
  8. package/dist/columnExpressions/functions/duration.d.ts +16 -21
  9. package/dist/columnExpressions/functions/element.d.ts +10 -10
  10. package/dist/columnExpressions/functions/exclude.d.ts +14 -14
  11. package/dist/columnExpressions/functions/implode.d.ts +7 -7
  12. package/dist/columnExpressions/functions/lit.d.ts +9 -9
  13. package/dist/columnExpressions/functions/seqRange.d.ts +69 -0
  14. package/dist/columnExpressions/functions/struct.d.ts +6 -6
  15. package/dist/columnExpressions/functions/when.d.ts +31 -32
  16. package/dist/columnExpressions/index.d.ts +4 -7
  17. package/dist/columnExpressions/mixins/AggregationExpr.d.ts +672 -141
  18. package/dist/columnExpressions/mixins/ArithmeticExpr.d.ts +701 -327
  19. package/dist/columnExpressions/mixins/ArrayExpr.d.ts +543 -231
  20. package/dist/columnExpressions/mixins/ComparisonExpr.d.ts +398 -201
  21. package/dist/columnExpressions/mixins/LogicalExpr.d.ts +59 -29
  22. package/dist/columnExpressions/mixins/ManipulationExpr.d.ts +23 -9
  23. package/dist/columnExpressions/mixins/StandardExpr.d.ts +3234 -0
  24. package/dist/columnExpressions/mixins/StringExpr.d.ts +1299 -396
  25. package/dist/columnExpressions/mixins/StructExpr.d.ts +72 -30
  26. package/dist/columnExpressions/mixins/TemporalExpr.d.ts +518 -212
  27. package/dist/columnExpressions/mixins/WindowExpr.d.ts +270 -102
  28. package/dist/columnExpressions/typeInference.d.ts +13 -0
  29. package/dist/columnExpressions/types.d.ts +6 -1
  30. package/dist/columnExpressions/utils.d.ts +16 -0
  31. package/dist/constants.d.ts +38 -0
  32. package/dist/dataframe/dataframe.d.ts +755 -608
  33. package/dist/dataframe/grouped/grouped.d.ts +24 -6
  34. package/dist/dataframe/grouped.d.ts +70 -0
  35. package/dist/dataframe/index.d.ts +1 -1
  36. package/dist/dataframe/lazy.d.ts +37 -0
  37. package/dist/dataframe/types.d.ts +46 -22
  38. package/dist/dataframe/utils.d.ts +10 -4
  39. package/dist/datatypes/index.d.ts +11 -4
  40. package/dist/expressions.js +1 -0
  41. package/dist/expressions.mjs +1 -0
  42. package/dist/functions/concat.d.ts +68 -16
  43. package/dist/functions/index.d.ts +2 -2
  44. package/dist/functions/readCsv.d.ts +35 -0
  45. package/dist/functions/readJson.d.ts +33 -0
  46. package/dist/index.js +5 -6
  47. package/dist/index.mjs +5 -6
  48. package/dist/types.d.ts +148 -7
  49. package/dist/utils/array.d.ts +54 -18
  50. package/dist/utils/binary.d.ts +6 -2
  51. package/dist/utils/csv.d.ts +4 -1
  52. package/dist/utils/date.d.ts +3 -19
  53. package/dist/utils/duration.d.ts +7 -5
  54. package/dist/utils/json.d.ts +56 -2
  55. package/dist/utils/number.d.ts +5 -2
  56. package/dist/utils/object.d.ts +7 -12
  57. package/dist/utils/string.d.ts +83 -2
  58. package/dist/utils/table.d.ts +76 -0
  59. package/dist/utils.js +4 -0
  60. package/dist/utils.mjs +4 -0
  61. package/package.json +29 -8
  62. package/dist/assets/index-DBhGK6Tp.css +0 -1
  63. package/dist/assets/index-DEJEV_tU.js +0 -195
  64. package/dist/index.html +0 -17
package/dist/types.d.ts CHANGED
@@ -28,6 +28,10 @@ export interface IExpr {
28
28
  _literalValue?: any;
29
29
  _aggFn?: AggFn<any> | null;
30
30
  _castType?: RegisteredDataType;
31
+ _binaryMeta?: {
32
+ left: any;
33
+ right: any;
34
+ };
31
35
  _groupingOpsIndex?: number;
32
36
  _partitionOpsIndex?: number;
33
37
  _partitionBy?: (string | IExpr)[] | null;
@@ -36,6 +40,10 @@ export interface IExpr {
36
40
  [key: string]: any;
37
41
  } | null;
38
42
  _isWindow?: boolean;
43
+ _baseExpr?: IExpr;
44
+ _fieldName?: string;
45
+ _isUnnest?: boolean;
46
+ _branchOperands?: any[];
39
47
  alias(name: string): this;
40
48
  cast(dataType: RegisteredDataType): this;
41
49
  _resolve(val: any, columns: ColumnDict, height: number): ColumnData | any;
@@ -47,9 +55,30 @@ export interface IExpr {
47
55
  }
48
56
  export type TimeUnit = "s" | "ms" | "us" | "ns";
49
57
  export type DatetimeTimeUnit = "ms" | "us" | "ns";
50
- export type DateDiffUnit = "ms" | "milliseconds" | "s" | "seconds" | "m" | "minutes" | "h" | "hours" | "d" | "days" | "w" | "weeks" | "mo" | "months" | "q" | "quarters" | "y" | "years";
51
- export interface DateDiffOptions {
52
- roundMode?: "exact" | "floor" | "ceil" | "round" | "trunc";
58
+ export type DurationUnit = "ns" | "us" | "ms" | "s" | "m" | "h" | "d" | "w" | "mo" | "q" | "y" | "i";
59
+ export interface DurationInterval {
60
+ months: number;
61
+ days: number;
62
+ ms: number;
63
+ indexUnits: number;
64
+ isCalendar: boolean;
65
+ isIndex: boolean;
66
+ }
67
+ export interface DurationOptions {
68
+ weeks?: IntoExpr | number;
69
+ days?: IntoExpr | number;
70
+ hours?: IntoExpr | number;
71
+ minutes?: IntoExpr | number;
72
+ seconds?: IntoExpr | number;
73
+ milliseconds?: IntoExpr | number;
74
+ microseconds?: IntoExpr | number;
75
+ nanoseconds?: IntoExpr | number;
76
+ }
77
+ export interface ParseDurationStringOptions {
78
+ to?: DurationUnit;
79
+ }
80
+ export interface ToDurationOptions extends ParseDurationStringOptions {
81
+ fallback?: number;
53
82
  }
54
83
  export interface StrptimeOptions {
55
84
  format: string;
@@ -61,6 +90,95 @@ export interface StrftimeOptions {
61
90
  locale?: string;
62
91
  timeZone?: string;
63
92
  }
93
+ export type StringEncoding = "hex" | "base64";
94
+ export interface StringEncodeOptions {
95
+ encoding: StringEncoding;
96
+ }
97
+ export interface StringDecodeOptions extends StringEncodeOptions {
98
+ strict?: boolean;
99
+ }
100
+ export type EscapeRegexMode = "tc39" | "nonAlphanumericAscii";
101
+ export interface EscapeRegexOptions {
102
+ /**
103
+ * Escaping mode:
104
+ * - "tc39" (default): TC39 ECMAScript standard specification (syntax metacharacters + set operators).
105
+ * - "nonAlphanumericAscii": Escapes all non-alphanumeric ASCII characters ([^A-Za-z0-9]) matching Polars / Rust regex::escape.
106
+ */
107
+ mode?: EscapeRegexMode;
108
+ }
109
+ export interface ExtractRegexEngineOptions {
110
+ /**
111
+ * Index or name of the capture group to extract.
112
+ */
113
+ groupIndex?: number | string;
114
+ /**
115
+ * Whether matching should be case-insensitive for ASCII characters.
116
+ */
117
+ asciiCaseInsensitive?: boolean;
118
+ /**
119
+ * Whether to return all matches (global flag). Defaults to false.
120
+ */
121
+ global?: boolean;
122
+ }
123
+ export type RegexEngineOptions = Omit<ExtractRegexEngineOptions, "groupIndex">;
124
+ export interface ExtractManyOptions extends ExtractRegexEngineOptions {
125
+ /**
126
+ * Whether overlapping matches are allowed.
127
+ */
128
+ overlapping?: boolean;
129
+ /**
130
+ * Guarantees in case there are overlapping matches that the leftmost match is used.
131
+ * In case there are multiple candidates for the leftmost match, the pattern which comes
132
+ * first in patterns is used. May not be used together with overlapping = true.
133
+ */
134
+ leftmost?: boolean;
135
+ }
136
+ export interface FindOptions extends ExtractRegexEngineOptions, EscapeRegexOptions {
137
+ /**
138
+ * Treat pattern as literal string instead of regex.
139
+ */
140
+ literal?: boolean;
141
+ }
142
+ export interface FindManyOptions extends ExtractManyOptions, EscapeRegexOptions {
143
+ /**
144
+ * Treat patterns as literal strings instead of regex.
145
+ */
146
+ literal?: boolean;
147
+ }
148
+ export interface ReplaceOptions extends RegexEngineOptions, EscapeRegexOptions {
149
+ /**
150
+ * Treat pattern as a literal string instead of regex.
151
+ */
152
+ literal?: boolean;
153
+ /**
154
+ * Number of occurrences to replace. Use -1 or Infinity to replace all. Defaults to 1.
155
+ */
156
+ n?: number;
157
+ }
158
+ export interface ReplaceManyOptions extends FindManyOptions {
159
+ }
160
+ export interface SplitOptions extends RegexEngineOptions, EscapeRegexOptions {
161
+ /**
162
+ * Treat delimiter as literal string (default: true). Set to false for regex matching.
163
+ */
164
+ literal?: boolean;
165
+ /**
166
+ * Include delimiter in the split results.
167
+ */
168
+ inclusive?: boolean;
169
+ /**
170
+ * Maximum number of splits to perform.
171
+ */
172
+ limit?: number;
173
+ /**
174
+ * If true, pads missing splits with null to guarantee exact limit + 1 parts.
175
+ */
176
+ exact?: boolean;
177
+ /**
178
+ * If true, throws an InvalidArgumentError if the split does not yield at least limit + 1 parts.
179
+ */
180
+ strict?: boolean;
181
+ }
64
182
  export type BusinessDayRollType = "raise" | "forward" | "backward";
65
183
  export interface IsBusinessDayOptions {
66
184
  holidays?: (Date | string | number)[] | Set<number>;
@@ -96,6 +214,19 @@ export interface DateTimeParts {
96
214
  timeZone?: string | null;
97
215
  }
98
216
  export type ReplaceDateOptions = Partial<Omit<DateTimeParts, "dayOfWeek">>;
217
+ /** Rolling Window Configuration */
218
+ export interface RollingOptions {
219
+ windowSize: number;
220
+ }
221
+ /** Sorting Configuration */
222
+ export interface SortArrayOptions<T = any> {
223
+ descending?: boolean | boolean[];
224
+ nullsLast?: boolean;
225
+ customComp?: ((a: any, b: any) => number) | Partial<Record<keyof T, (a: any, b: any) => number>> | null;
226
+ }
227
+ export interface SortOptions<T = any> extends SortArrayOptions<T> {
228
+ by: keyof T | (keyof T)[] | IExpr | IExpr[];
229
+ }
99
230
  /** Concatenation Configuration */
100
231
  export type ConcatHow = "vertical" | "horizontal" | "diagonal";
101
232
  export interface HorizontalConcatOptions {
@@ -106,10 +237,9 @@ export interface ConcatOptions {
106
237
  horizontal?: HorizontalConcatOptions;
107
238
  }
108
239
  export type ConcatItem = DataFrame<any> | ColumnDict | RowRecord[];
109
- export type { UniqueArrayStatsOptions, JoinArrayOptions } from "./utils/array";
110
240
  export interface ExplodeOptions {
111
- empty_as_null?: boolean;
112
- keep_nulls?: boolean;
241
+ emptyAsNull?: boolean;
242
+ keepNulls?: boolean;
113
243
  }
114
244
  import type { DataType } from "./datatypes/DataType";
115
245
  export type InferDataType<T> = T extends DataType<infer U> ? U : any;
@@ -127,5 +257,16 @@ export interface FillNullOptions {
127
257
  }
128
258
  export interface ToStructOptions {
129
259
  fields?: string[] | ((idx: number) => string);
130
- upper_bound?: number;
260
+ upperBound?: number;
261
+ }
262
+ export interface SkewOptions {
263
+ bias?: boolean;
264
+ }
265
+ export interface KurtosisOptions {
266
+ fisher?: boolean;
267
+ bias?: boolean;
268
+ }
269
+ export interface EntropyOptions {
270
+ base?: number;
271
+ normalize?: boolean;
131
272
  }
@@ -1,33 +1,41 @@
1
- import type { AnyTypedArray, ColumnData } from "../types";
1
+ import type { AnyTypedArray, ColumnData, SkewOptions, KurtosisOptions, EntropyOptions, SortArrayOptions } 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, nullOnOob: 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;
15
- export interface SortArrayOptions {
16
- descending?: boolean;
17
- nullsLast?: boolean;
18
- }
19
- export declare function sortArray(arr: unknown, { descending, nullsLast }?: SortArrayOptions): any[];
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[];
22
+ export declare function compareScalarValues(a: any, b: any, { descending, nullsLast, customComp }?: SortArrayOptions): number;
23
+ export declare function sortArray(arr: unknown, { descending, nullsLast, customComp }?: SortArrayOptions): any[];
20
24
  export declare function getArrayStats(arr: unknown): {
21
25
  sum: number | null;
26
+ product: number | null;
22
27
  count: number;
23
28
  min: any;
24
29
  max: any;
30
+ nanMin: any;
31
+ nanMax: any;
25
32
  minIdx: number | null;
26
33
  maxIdx: number | null;
27
34
  mean: number | null;
28
35
  variance: number;
29
36
  std: number;
30
37
  nullCount: number;
38
+ nanCount: number;
31
39
  len: number;
32
40
  hasNulls: boolean;
33
41
  isNumeric: boolean;
@@ -85,9 +93,9 @@ export interface StepSliceArrayOptions {
85
93
  * If false, throws an error when the starting offset is out of bounds.
86
94
  * @default true
87
95
  */
88
- null_on_oob?: boolean;
96
+ nullOnOob?: boolean;
89
97
  }
90
- export declare function stepSliceArray<T>(arr: ArrayLike<T>, { step, offsetStart, offsetEnd, maxItemsGathered, null_on_oob }?: StepSliceArrayOptions): T[] | null;
98
+ export declare function stepSliceArray<T>(arr: ArrayLike<T>, { step, offsetStart, offsetEnd, maxItemsGathered, nullOnOob }?: StepSliceArrayOptions): T[] | null;
91
99
  /**
92
100
  * Options configuration for the `joinArray` utility.
93
101
  */
@@ -203,11 +211,6 @@ export type FillSeqOptions = FillSeqBaseOptions & ({
203
211
  step?: number | ((context: IndependentStepContext) => any);
204
212
  });
205
213
  export declare function fillSequence(targetArray: any, initialValue: any, options?: FillSeqOptions): void;
206
- /**
207
- * Computes the median of a numeric array, filtering out non-numeric and NaN values.
208
- * Returns null if no valid numbers remain.
209
- */
210
- export declare function computeMedian(values: ArrayLike<any>): number | null;
211
214
  /**
212
215
  * Computes the quantile of a numeric array using linear interpolation, filtering out non-numeric and NaN values.
213
216
  * q must be in [0, 1]. Returns null if no valid numbers remain or q is out of bounds.
@@ -269,3 +272,36 @@ export interface BinarySearchOptions<T = any> {
269
272
  * @returns Index insertion point.
270
273
  */
271
274
  export declare function binarySearch<T = any>(arr: ArrayLike<T>, target: number, options?: BinarySearchOptions<T>): number;
275
+ /**
276
+ * Computes the sample skewness of a numeric dataset as the Fisher-Pearson coefficient of skewness.
277
+ * @param arr ArrayLike dataset
278
+ * @param options Skewness calculation options ({ bias?: boolean }, default bias=true)
279
+ */
280
+ export declare function computeSkewness(arr: ArrayLike<any>, options?: SkewOptions): number | null;
281
+ /**
282
+ * Computes the kurtosis of a numeric dataset.
283
+ * @param arr ArrayLike dataset
284
+ * @param options Kurtosis calculation options ({ fisher?: boolean, bias?: boolean }, default fisher=true, bias=true)
285
+ */
286
+ export declare function computeKurtosis(arr: ArrayLike<any>, options?: KurtosisOptions): number | null;
287
+ /**
288
+ * Computes the Shannon entropy of a dataset.
289
+ * @param arr ArrayLike dataset
290
+ * @param options Entropy options ({ base?: number, normalize?: boolean }, default base=Math.E, normalize=true)
291
+ */
292
+ export declare function computeEntropy(arr: ArrayLike<any>, options?: EntropyOptions): number | null;
293
+ /** Reduces elements in an array using a bitwise binary operation across valid BigInts/numbers. */
294
+ export declare function reduceBitwise(arr: ArrayLike<any>, op: (acc: bigint, val: bigint) => bigint): number | bigint | null;
295
+ /** Finds the value in target column corresponding to the minimum or maximum value in `by` column. */
296
+ export declare function computeBy(pairs: Array<[any, any]> | null | undefined, statKey: "minIdx" | "maxIdx"): any;
297
+ export interface FilterByMaskOptions {
298
+ nullify?: boolean;
299
+ }
300
+ /**
301
+ * Filters an array or ArrayLike structure where the mask evaluates to truthy.
302
+ * @param arr The source array or ArrayLike structure to filter.
303
+ * @param mask A boolean mask array or truthy/falsy scalar.
304
+ * @param options Configuration options ({ nullify?: boolean }). If nullify is true, non-matching items become null while preserving length.
305
+ * @returns Filtered array containing matching elements (or nullified elements).
306
+ */
307
+ export declare function filterByMask<T = any>(arr: ArrayLike<T> | null | undefined, mask: any, options?: FilterByMaskOptions): (T | null)[];
@@ -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;
@@ -67,7 +67,10 @@ export interface WriteCSVOptions extends FormatCSVValueOptions {
67
67
  */
68
68
  includeBom?: boolean;
69
69
  }
70
- export declare function formatCsvValue(options?: FormatCSVValueOptions): (val: any) => string;
70
+ export declare function formatCsvValue(options?: FormatCSVValueOptions): (val: any) => {
71
+ str: string;
72
+ isNumeric: boolean;
73
+ };
71
74
  export declare function stringifyCSV(columns: ColumnDict, height: number, options?: WriteCSVOptions & {
72
75
  onRow?: (rowStr: string) => void;
73
76
  }): string;
@@ -1,30 +1,14 @@
1
- import type { TimeUnit, StrptimeOptions, StrftimeOptions, IsBusinessDayOptions, DayOffsetOptions, DateDiffUnit, DateDiffOptions, UtcOffsetOptions, ReplaceDateOptions, DateTimeParts } from "../types";
2
- export declare const TIME_PREFIX_REGEX: RegExp;
3
- export declare const ZONE_OFFSET_REGEX: RegExp;
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;
1
+ import type { TimeUnit, StrptimeOptions, StrftimeOptions, IsBusinessDayOptions, DayOffsetOptions, UtcOffsetOptions, ReplaceDateOptions, DateTimeParts } from "../types";
2
+ export declare function createUTCDate(year: number, monthZeroIndexed?: number, day?: number, hour?: number, minute?: number, second?: number, ms?: number): Date;
6
3
  export declare function _getDateTimeParts(d: Date, timeZone?: string): DateTimeParts;
7
- export declare function _getTimeZoneOffsetMinutes(d: Date, tz: string): number;
8
4
  export declare function toValidDate(input: unknown, options?: {
9
5
  dateOnly?: boolean;
10
6
  }): Date | null;
11
7
  export declare function toValidTime(val: unknown): string | null;
12
8
  export declare function toEpoch(d: Date, unit?: TimeUnit): number | bigint;
13
- export declare function normalizeEpochToMs(n: number | bigint): number;
14
- export declare function getCentury(d: Date): number | null;
15
- export declare function getISO(d: Date, options?: {
16
- field: "week" | "year";
17
- }): number | null;
18
- export declare function getMillennium(d: Date): number | null;
19
- export declare function getMonthOffset(d: Date, monthOffset: number, day?: number): Date | null;
20
- export declare function dateDiff(d1: Date, d2: Date, unit: DateDiffUnit, { roundMode }?: DateDiffOptions): number | null;
21
- export declare function getOrdinalDay(d: Date): number | null;
22
- export declare function getQuarter(d: Date): number | null;
23
- export declare function isLeapYear(yOrDate: number | Date): boolean;
24
- export declare const FORMAT_REGEX: RegExp;
25
9
  export declare function strftime(d: Date, { format, locale, timeZone }: StrftimeOptions): string;
26
10
  export declare function strptime(str: string, { format, strict, defaultTimeZone }: StrptimeOptions): Date | null;
27
11
  export declare function offsetDay(d: Date, n: number | any, { excludeWeekdays, holidays, roll }?: DayOffsetOptions): number;
28
- export declare function getTimeZoneOffset(d: Date, timeZone?: string, options?: UtcOffsetOptions): number | string;
29
12
  export declare function isBusinessDay(d: Date, options?: IsBusinessDayOptions): boolean | null;
13
+ export declare function getTimeZoneOffset(d: Date, timeZone?: string, options?: UtcOffsetOptions): number | string;
30
14
  export declare function replaceDateComponents(d: Date, opts?: ReplaceDateOptions): Date;
@@ -1,5 +1,7 @@
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;
1
+ import type { DurationInterval, ParseDurationStringOptions, ToDurationOptions } from "../types";
2
+ export declare const FIXED_DURATION_UNITS: Readonly<Record<string, number>>;
3
+ export declare function scaleDurationMs(ms: number, timeUnit: "ms" | "us" | "ns" | string): number;
4
+ export declare function parseDurationInterval(str: string): DurationInterval;
5
+ export declare function addCalendarDuration(d: unknown, interval: DurationInterval | string, step?: number): Date;
6
+ export declare function parseDurationString(str: string, options?: ParseDurationStringOptions): number;
7
+ export declare function toDuration(v?: unknown, options?: ToDurationOptions): number;
@@ -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<T = unknown>(input: unknown, options?: SafeJsonParseOptions<T>): 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,9 @@ 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, Opts extends SafeJsonParseOptions<T, F> = SafeJsonParseOptions<T, F>>(input: I, options?: Opts): Opts extends {
79
+ format: "ndjson";
80
+ } ? (T[] | I | F) : (T | I | F);
79
81
  export interface SafeJsonReplacerOptions {
80
82
  /** Custom formatter function for Date objects. Ignored if onDate is specified. */
81
83
  formatDate?: (v: Date) => string;
@@ -119,3 +121,55 @@ export interface SafeJsonReplacerOptions {
119
121
  replacer?: ((this: any, k: string, v: any) => any) | (string | number)[] | null;
120
122
  }
121
123
  export declare function createSafeJsonReplacer(options?: SafeJsonReplacerOptions): (this: any, k: string, v: any) => any;
124
+ /**
125
+ * Represents the type of operation a JSONPath token performs.
126
+ */
127
+ export type JsonTokenType =
128
+ /**
129
+ * Selects an object property by name (e.g., .foo or ['foo'])
130
+ */
131
+ "prop"
132
+ /**
133
+ * Selects a zero-based or negative array index (e.g., [0] or [-1])
134
+ */
135
+ | "idx"
136
+ /**
137
+ * Selects a range or stepped slice of an array (e.g., [1:5:2])
138
+ */
139
+ | "slice"
140
+ /**
141
+ * Selects all immediate properties of an object or elements of an array (e.g., .* or [*])
142
+ */
143
+ | "wildcard"
144
+ /**
145
+ * Recursively searches and collects matching keys down the hierarchy (e.g., ..foo)
146
+ */
147
+ | "rec";
148
+ /**
149
+ * Parsed AST token representing a single evaluation step in a JSONPath expression.
150
+ */
151
+ export interface JsonToken {
152
+ /** The evaluation operation type. */
153
+ type: JsonTokenType;
154
+ /** Property name or recursive search key. Used by "prop" and "rec" tokens. */
155
+ key?: string;
156
+ /** Target index position. Used by "idx" tokens. Supports negative indices. */
157
+ idx?: number;
158
+ /** Starting array index (inclusive). Used by "slice" tokens. Defaults to 0 or end of array depending on step. */
159
+ start?: number;
160
+ /** Ending array index (exclusive). Used by "slice" tokens. Defaults to array bound depending on step. */
161
+ end?: number;
162
+ /** Increment step value. Used by "slice" tokens. Defaults to 1. Cannot be 0. */
163
+ step?: number;
164
+ }
165
+ /**
166
+ * Tokenizes a JSONPath query string (e.g. "$.user.items[0]") into an array
167
+ * of executable query tokens without polluting global regex state.
168
+ * Returns null if path contains unparsed/invalid syntax fragments.
169
+ */
170
+ export declare function tokenizeJsonPath(path: string): JsonToken[] | null;
171
+ export declare function evaluateJsonToken(item: any, tok: JsonToken, next: any[]): void;
172
+ /**
173
+ * Extracts the first match from a JSON string or object using the provided JSONPath expression.
174
+ */
175
+ 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;
@@ -1,15 +1,4 @@
1
- /** @internalfile */
2
- export declare const TAG_DATE = "[object Date]";
3
- export declare const TAG_REGEXP = "[object RegExp]";
4
- export declare const TAG_SET = "[object Set]";
5
- export declare const TAG_MAP = "[object Map]";
6
- export declare const TAG_ERROR = "[object Error]";
7
- export declare const TAG_URL_PARAMS = "[object URLSearchParams]";
8
- export declare const TAG_STRING = "[object String]";
9
- export declare const TAG_NUMBER = "[object Number]";
10
- export declare const TAG_BOOLEAN = "[object Boolean]";
11
- export declare const TAG_BIGINT = "[object BigInt]";
12
- export declare const TAG_SYMBOL = "[object Symbol]";
1
+ export declare const typedArrayTagGetter: (() => any) | undefined;
13
2
  export declare function isObj(v: unknown): v is Record<PropertyKey, unknown>;
14
3
  export declare function isPlainObj(v: unknown): v is Record<PropertyKey, unknown>;
15
4
  export declare function isClass(v: unknown): v is new (...args: any[]) => any;
@@ -24,4 +13,10 @@ export declare function isNumberObj(v: unknown): v is Number;
24
13
  export declare function isBooleanObj(v: unknown): v is Boolean;
25
14
  export declare function isBigIntObj(v: unknown): v is Object;
26
15
  export declare function isSymbolObj(v: unknown): v is Object;
16
+ export declare function isDetachedBuffer(v: unknown): boolean;
17
+ export declare function isArrayBuffer(v: unknown): v is ArrayBuffer;
18
+ export declare function isSharedArrayBuffer(v: unknown): v is SharedArrayBuffer;
19
+ export declare function isDataView(v: unknown): v is DataView;
20
+ export declare function isUint8Array(v: unknown): v is Uint8Array;
21
+ export declare function isUint8ClampedArray(v: unknown): v is Uint8ClampedArray;
27
22
  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
  /**
@@ -48,13 +48,14 @@ export type StripCharsOptions = {
48
48
  caseInsensitive?: boolean;
49
49
  };
50
50
  };
51
+ export declare function _trimByMode(str: string, mode?: StripMode): string;
51
52
  export declare function stripChars(str: string | null | undefined, characters?: string | RegExp | null, options?: StripCharsOptions): string | null;
52
53
  export declare function toCanonicalString(val: any, { depth, maxDepth }?: {
53
54
  depth?: number;
54
55
  maxDepth?: number;
55
56
  }): string;
56
57
  export interface ChangeCaseOptions {
57
- format: "camel" | "kebab" | "pascal" | "snake";
58
+ format: "camel" | "kebab" | "pascal" | "snake" | "title";
58
59
  }
59
60
  /**
60
61
  * Fully robust, Unicode-aware string tokenization engine.
@@ -65,3 +66,83 @@ export declare function toWords(str: any): string[];
65
66
  * High-performance, predictable case converter
66
67
  */
67
68
  export declare function changeCase(str: any, options: ChangeCaseOptions): string;
69
+ /**
70
+ * Serializes a value to a JSON string with BigInt support using createSafeJsonReplacer.
71
+ */
72
+ export declare function encodeObjectToJson(value: unknown): string;
73
+ /**
74
+ * Encodes a JSON string into a UTF-8 Uint8Array byte array.
75
+ */
76
+ export declare function encodeJsonToBytes(json: string): Uint8Array;
77
+ /**
78
+ * Encodes a byte array or binary-coercible input into a standard Base64 string representation.
79
+ * Uses 8192-byte chunking or native methods to prevent stack overflow errors.
80
+ */
81
+ export declare function encodeBytesToBase64(bytes: unknown): string;
82
+ /**
83
+ * Converts a standard Base64 string into a URL-safe Base64URL string.
84
+ * Replaces '+' with '-', '/' with '_', and strips trailing '=' padding in a single pass.
85
+ */
86
+ export declare function encodeBase64ToBase64URL(b64: string): string;
87
+ /**
88
+ * Encodes a string into a hexadecimal string representation.
89
+ */
90
+ export declare function encodeHex(str: string): string;
91
+ /**
92
+ * Encodes a string into a Base64 string representation.
93
+ */
94
+ export declare function encodeBase64(str: string): string;
95
+ /**
96
+ * Encodes string to hex or base64 based on specified encoding option.
97
+ */
98
+ export declare function encodeString(str: string | null | undefined, encoding: StringEncoding): string | null;
99
+ /**
100
+ * Converts a Base64URL string back into standard Base64 format.
101
+ * Restores URL-safe characters ('-' to '+', '_' to '/') in a single pass and appends '=' padding.
102
+ */
103
+ export declare function decodeBase64URLToBase64(b64Url: string): string;
104
+ /**
105
+ * Decodes a standard Base64 string directly into a Uint8Array byte array.
106
+ */
107
+ export declare function decodeBase64ToBytes(b64: string, strict?: boolean): Uint8Array;
108
+ /**
109
+ * Decodes a Uint8Array byte array back into a parsed JSON object.
110
+ */
111
+ export declare function decodeBytesToJson(bytes: Uint8Array): unknown;
112
+ /**
113
+ * Decodes a Hex-encoded string directly into a Uint8Array byte array.
114
+ */
115
+ export declare function decodeHexToBytes(hex: string): Uint8Array;
116
+ /**
117
+ * Decodes a Hex-encoded string into a standard UTF-8 string.
118
+ */
119
+ export declare function decodeHex(str: string, strict?: boolean): string | null;
120
+ /**
121
+ * Decodes a Base64 or Base64URL-encoded string into a standard UTF-8 string.
122
+ */
123
+ export declare function decodeBase64(str: string, strict?: boolean): string | null;
124
+ /**
125
+ * Decodes hex or base64 encoded string back to standard UTF-8 string.
126
+ */
127
+ export declare function decodeString(str: string | null | undefined, encoding: StringEncoding, options?: {
128
+ strict?: boolean;
129
+ } | boolean): string | null;
130
+ export type UnicodeSurrogateType = "all" | "high" | "low";
131
+ export type IsUnicodeSurrogateOptions = {
132
+ type?: UnicodeSurrogateType;
133
+ };
134
+ export declare function escapeRegExp(val: unknown, options?: EscapeRegexOptions): string;
135
+ export declare function toCleanRegExp(str: string | null | undefined, pattern: string | RegExp, options?: RegexEngineOptions): {
136
+ reg: RegExp;
137
+ input: string;
138
+ } | null;
139
+ export declare function extractRegexEngine(str: string | null | undefined, pattern: string | RegExp, options?: ExtractRegexEngineOptions): Record<string, string | null>[] | null;
140
+ export declare function extractRegex(str: string | null | undefined, pattern: string | RegExp, options?: ExtractRegexEngineOptions): string | null;
141
+ export declare function extractRegexAll(str: string | null | undefined, pattern: string | RegExp, options?: ExtractRegexEngineOptions): (string | null)[] | null;
142
+ export declare function extractRegexGroups(str: string | null | undefined, pattern: string | RegExp, options?: ExtractManyOptions): Record<string, string | null> | null;
143
+ export declare function extractRegexMany(str: string | null | undefined, patterns: (string | RegExp)[] | (string | RegExp), options?: ExtractManyOptions): (string | null)[] | null;
144
+ export declare function findRegex(str: string | null | undefined, pattern: string | RegExp, options?: FindOptions): number | null;
145
+ export declare function findManyRegex(str: string | null | undefined, patterns: (string | RegExp)[] | (string | RegExp), options?: FindManyOptions): (number | null)[] | null;
146
+ export declare function splitString(str: string | null | undefined, delimiter: string, options?: SplitOptions): (string | null)[] | null;
147
+ export declare function replaceString(str: string | null | undefined, pattern: string | RegExp, replacement: string | ((match: string, ...args: any[]) => string), options?: ReplaceOptions): string | null;
148
+ 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;