File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 1- import type { DataXY } from 'cheminfo-types' ;
1+ import type { DataXY , NumberArray } from 'cheminfo-types' ;
22
33import { xIsMonotonic } from '../x/index.ts' ;
44
@@ -8,7 +8,9 @@ import { xyCheck } from './xyCheck.ts';
88 * Filters x,y values to allow strictly growing values in x-axis.
99 * @param data - Object that contains property x (an ordered increasing array) and y (an array).
1010 */
11- export function xyEnsureGrowingX ( data : DataXY ) : DataXY {
11+ export function xyEnsureGrowingX < DataType extends NumberArray = NumberArray > (
12+ data : DataXY < DataType > ,
13+ ) : DataXY < DataType | number [ ] > {
1214 xyCheck ( data ) ;
1315 if ( xIsMonotonic ( data . x ) === 1 ) return data ;
1416 const x = Array . from ( data . x ) ;
Original file line number Diff line number Diff line change 1- import type { DataXY } from 'cheminfo-types' ;
1+ import type { DataXY , NumberArray } from 'cheminfo-types' ;
22
33/**
44 * Order object of array, x has to be monotone. Ensure x is growing
55 * @param data - Object of kind {x:[], y:[]}.
66 */
7- export function xyGrowingX ( data : DataXY ) : DataXY {
7+ export function xyGrowingX < DataType extends NumberArray = NumberArray > (
8+ data : DataXY < DataType > ,
9+ ) : DataXY < DataType > {
810 const { x, y } = data ;
911
1012 if ( x . length !== y . length ) {
@@ -14,7 +16,7 @@ export function xyGrowingX(data: DataXY): DataXY {
1416 if ( x . length < 2 || x [ 0 ] < ( x . at ( - 1 ) as number ) ) return data ;
1517
1618 return {
17- x : x . toReversed ( ) ,
18- y : y . toReversed ( ) ,
19+ x : x . toReversed ( ) as DataType ,
20+ y : y . toReversed ( ) as DataType ,
1921 } ;
2022}
You can’t perform that action at this time.
0 commit comments