From ecf3b5382bccc04933e4fef649485ae79acb3c22 Mon Sep 17 00:00:00 2001 From: Caoyuan Deng Date: Sat, 7 Mar 2026 23:06:43 -0800 Subject: [PATCH] Let TimeHelper instance could be treated as Series. This fixed #156 --- src/Series.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Series.ts b/src/Series.ts index e3627d6..98187ed 100644 --- a/src/Series.ts +++ b/src/Series.ts @@ -1,5 +1,5 @@ export class Series { - constructor(public data: any[], public offset: number = 0) {} + constructor(public data: any[], public offset: number = 0) { } public get(index: number): any { const realIndex = this.data.length - 1 - (this.offset + index); @@ -27,6 +27,7 @@ export class Series { static from(source: any): Series { if (source instanceof Series) return source; if (Array.isArray(source)) return new Series(source); + if (typeof source === 'object' && '__value' in source && source.__value instanceof Series) return source.__value; return new Series([source]); // Treat scalar as single-element array? Or handle differently? // Ideally, scalar should be treated as a series where get(0) returns the value, and get(>0) might be undefined or NaN? // But for now, let's wrap in array.