From d71b0ae7b3e84306c5646e09903afd452387dbe8 Mon Sep 17 00:00:00 2001 From: Peter Braden Date: Fri, 9 Nov 2012 10:21:41 -0800 Subject: [PATCH] if toBuffer has a cb, run it async. re #21 --- src/Matrix.cc | 4 ++++ test/unit.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Matrix.cc b/src/Matrix.cc index 48ee47b..3a44ead 100755 --- a/src/Matrix.cc +++ b/src/Matrix.cc @@ -304,6 +304,10 @@ Handle Matrix::ToBuffer(const v8::Arguments& args){ SETUP_FUNCTION(Matrix) + if (args.Length() > 0){ + return Matrix::ToBufferAsync(args); + } + std::vector vec(0); std::vector params(0);//CV_IMWRITE_JPEG_QUALITY 90 diff --git a/test/unit.js b/test/unit.js index abbc34f..e03869d 100755 --- a/test/unit.js +++ b/test/unit.js @@ -138,12 +138,12 @@ vows.describe('Smoke Tests OpenCV').addBatch({ } - , "toBufferAsync": { + , "toBuffer Async": { topic: function(cv){ var buf = fs.readFileSync('./examples/mona.png') , cb = this.callback cv.readImage(buf.slice(0), function(err, mat){ - var buff = mat.toBufferAsync(function(){ + var buff = mat.toBuffer(function(){ cb.apply(this, arguments) }) })