Skip to content

Commit b1fc11e

Browse files
committed
Refactor OpenCV initialization functions to streamline Promise and callback handling in README and test files
1 parent ea83124 commit b1fc11e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ TypeScript is supported (thanks to `mirada`).
1111
```js
1212
import cvModule from "@techstark/opencv-js";
1313

14-
async function main() {
15-
// This works with both Promise and callback APIs
14+
async function getCv() {
1615
let cv;
1716
if (cvModule instanceof Promise) {
1817
cv = await cvModule;
@@ -22,7 +21,11 @@ async function main() {
2221
});
2322
cv = cvModule;
2423
}
24+
return cv;
25+
}
2526

27+
async function main() {
28+
const cv = await getCv();
2629
console.log("OpenCV.js is ready!");
2730
// You can now use OpenCV functions here
2831
console.log(cv.getBuildInformation());

test/cv.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export async function setupOpenCv() {
1818
cv = cvModule;
1919
}
2020
global.cv = cv;
21-
return { cv };
2221
}
2322

2423
export function translateException(err: any) {

0 commit comments

Comments
 (0)