df-script 1.7.0 → 1.8.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.
package/dist/types.d.ts CHANGED
@@ -27,6 +27,7 @@ export interface IExpr {
27
27
  _isLiteral?: boolean;
28
28
  _literalValue?: any;
29
29
  _aggFn?: AggFn<any> | null;
30
+ _castType?: RegisteredDataType;
30
31
  _groupingOpsIndex?: number;
31
32
  _partitionOpsIndex?: number;
32
33
  _partitionBy?: (string | IExpr)[] | null;
@@ -45,6 +46,7 @@ export interface IExpr {
45
46
  debug(label?: string): this;
46
47
  }
47
48
  export type TimeUnit = "s" | "ms" | "us" | "ns";
49
+ export type DatetimeTimeUnit = "ms" | "us" | "ns";
48
50
  export type DateDiffUnit = "ms" | "milliseconds" | "s" | "seconds" | "m" | "minutes" | "h" | "hours" | "d" | "days" | "w" | "weeks" | "mo" | "months" | "q" | "quarters" | "y" | "years";
49
51
  export interface DateDiffOptions {
50
52
  roundMode?: "exact" | "floor" | "ceil" | "round" | "trunc";
@@ -64,7 +66,7 @@ export interface IsBusinessDayOptions {
64
66
  holidays?: (Date | string | number)[] | Set<number>;
65
67
  excludeWeekdays?: number[];
66
68
  }
67
- export interface BusinessDayOffsetOptions extends IsBusinessDayOptions {
69
+ export interface DayOffsetOptions extends IsBusinessDayOptions {
68
70
  roll?: BusinessDayRollType;
69
71
  }
70
72
  export type UtcOffsetType = "base" | "total" | "daylightSavingTime";
@@ -73,6 +75,27 @@ export interface UtcOffsetOptions {
73
75
  type?: UtcOffsetType;
74
76
  format?: UtcOffsetFormat;
75
77
  }
78
+ export interface DateTimeParts {
79
+ /** Calendar year (e.g. 2026). */
80
+ year: number;
81
+ /** 1-indexed calendar month from 1 to 12 (1 = January, 12 = December). */
82
+ month: number;
83
+ /** 1-indexed day of the month from 1 to 31. */
84
+ day: number;
85
+ /** 0-indexed hour of day from 0 to 23 (0 = Midnight). */
86
+ hour: number;
87
+ /** 0-indexed minute of hour from 0 to 59. */
88
+ minute: number;
89
+ /** 0-indexed second of minute from 0 to 59. */
90
+ second: number;
91
+ /** 0-indexed millisecond from 0 to 999. */
92
+ ms: number;
93
+ /** 0-indexed day of week (0 = Sunday, 6 = Saturday). */
94
+ dayOfWeek?: number;
95
+ /** Optional target timezone identifier (e.g. "UTC", "America/New_York"). */
96
+ timeZone?: string | null;
97
+ }
98
+ export type ReplaceDateOptions = Partial<Omit<DateTimeParts, "dayOfWeek">>;
76
99
  /** Concatenation Configuration */
77
100
  export type ConcatHow = "vertical" | "horizontal" | "diagonal";
78
101
  export interface HorizontalConcatOptions {
@@ -246,3 +246,26 @@ export declare function computeDotProduct(pairs: ColumnData<[any, any]>): number
246
246
  * Defensive against absolute sum-zero weight errors.
247
247
  */
248
248
  export declare function computeWeightedAverage(pairs: ColumnData<[any, any]>): number | null;
249
+ /**
250
+ * Generates Cartesian product pair index arrays for two lengths lenA and lenB.
251
+ */
252
+ export declare function computeCartesianProduct(lenA: number, lenB: number): {
253
+ leftIndices: number[];
254
+ rightIndices: number[];
255
+ };
256
+ export type BinarySearchSide = "left" | "right";
257
+ export interface BinarySearchOptions<T = any> {
258
+ side?: BinarySearchSide;
259
+ getValue?: (index: number, item: T) => number;
260
+ }
261
+ /**
262
+ * Performs a binary search on a sorted numeric array or ArrayLike structure.
263
+ * Supports an optional `getValue` accessor for indirect index searching without array allocations.
264
+ * @param arr Sorted array or ArrayLike structure to search within.
265
+ * @param target Target numeric value to search for.
266
+ * @param options Binary search options.
267
+ * @param options.side Search side: `"left"` (bisect_left, first index >= target) or `"right"` (bisect_right, first index > target). Default `"left"`.
268
+ * @param options.getValue Optional accessor function `(index, item) => number` for indirect searching.
269
+ * @returns Index insertion point.
270
+ */
271
+ export declare function binarySearch<T = any>(arr: ArrayLike<T>, target: number, options?: BinarySearchOptions<T>): number;
@@ -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";
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "df-script",
3
- "version": "1.7.0",
3
+ "version": "1.8.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",