@microblink/blinkid-react-native
Version:
A small and powerful ID card scanning library. Powered by Microblink (www.microblink.com).
21 lines (17 loc) • 547 B
text/typescript
import { StringResult } from "./types";
export class BlinkIdUtilities {
/**
* Helper method for handling different string types,
* based on the document information source.
*/
static handleStringType<T>(raw: any): T | undefined {
if (typeof raw === "string") {
return raw as T;
}
// Heuristically assume it's a StringResult if it's an object and matches expected shape
if (typeof raw === "object" && raw !== null && "value" in raw) {
return new StringResult(raw) as T;
}
return undefined;
}
}