Arguments checking for NAN module
npm install nan-checkArguments checking in native modules for Node.js
===============================

This project contains some helper utilities that make native addon development a bit more easier.
* Example
* Usage
* API
* Tests
``cpp
NAN_METHOD(calibrationPatternDetect)
{
NanScope();
Local
try
{
if (Nan::Check(info).ArgumentsCount(5)
.Argument(0).IsBuffer().Bind(imageBuffer)
.Argument(1).Bind(patternSize.width)
.Argument(2).Bind(patternSize.height)
.Argument(3).StringEnum
{ "CHESSBOARD", PatternType::CHESSBOARD },
{ "CIRCLES_GRID", PatternType::CIRCLES_GRID },
{ "ACIRCLES_GRID", PatternType::ACIRCLES_GRID } }).Bind(pattern)
.Argument(4).IsFunction().Bind(callback))
{
Nan::Callback *nanCallback = new Nan::Callback(callback);
Nan::AsyncQueueWorker(new DetectPatternTask(imageBuffer, patternSize, pattern, nanCallback));
Nan::ReturnValue(Nan::True());
}
Nan::ReturnValue(Nan::False());
}
catch (Nan::CheckException& exc)
{
return Nan::ThrowTypeError(exc.what());
}
}
`
Simply add NAN-Check as a dependency in the package.json of your Node addon:
` bash`
$ npm install --save nan nan-check#include
Pull in the path to NAN and NAN-Check in your binding.gyp so that you can use in your .cpp files:
` python`
"include_dirs" : [
" "]
This works like a -I when compiling your addon.
TODO: Write
To run the NAN-Check tests do:
` sh`
npm install
npm run-script rebuild-tests
npm test
Or just:
` sh``
npm install
make test
Copyright (c) 2015 Ievgen Khvedchenia.
Native Abstractions for Node.js is licensed under an MIT license.
All rights not explicitly granted in the MIT license are reserved.
See the included LICENSE file for more details.