react-native-scanbot-sdk
Version:
Scanbot Document and Barcode Scanner SDK React Native Plugin for Android and iOS
58 lines (50 loc) • 1.1 kB
text/typescript
import { ResultWrapper } from '../base';
export class PartiallyConstructible {
/** @internal */
_marker() {}
}
export type DeepPartial<T> = T extends PartiallyConstructible
? { [P in keyof T]?: DeepPartial<T[P]> }
: T;
/** @internal */
export function mapRTUUIResult<T>(
result: ResultWrapper<DeepPartial<T>>,
LClass: new (source: DeepPartial<T>) => T
): ResultWrapper<T> {
if (result.status === 'CANCELED') {
return result;
} else {
return {
...result,
data: new LClass(result.data),
};
}
}
/** @internal */
export function mapRTUUIListResult<T>(
result: ResultWrapper<DeepPartial<T>[]>,
LClass: new (source: DeepPartial<T>) => T
): ResultWrapper<T[]> {
if (result.status === 'CANCELED') {
return result;
} else {
return {
...result,
data: result.data.map((i) => new LClass(i)),
};
}
}
export class Point {
public x: number;
public y: number;
public constructor(x: number, y: number) {
this.x = x;
this.y = y;
}
}
export type Rectangle = {
width: number;
height: number;
x: number;
y: number;
};