diff --git a/lib/node_modules/@stdlib/math/base/assert/is-evenf/README.md b/lib/node_modules/@stdlib/math/base/assert/is-evenf/README.md index befd8dc79fc4..7a70375b5701 100644 --- a/lib/node_modules/@stdlib/math/base/assert/is-evenf/README.md +++ b/lib/node_modules/@stdlib/math/base/assert/is-evenf/README.md @@ -88,15 +88,11 @@ bool = isEvenf( NaN ); var randu = require( '@stdlib/random/array/discrete-uniform' ); var isEvenf = require( '@stdlib/math/base/assert/is-evenf' ); -var bool; -var x; -var i; - -x = randu( 100, 0, 100 ); +var x = randu( 100, 0, 100 ); +var i; for ( i = 0; i < 100; i++ ) { - bool = isEvenf( x[ i ] ); - console.log( '%d is %s', x[ i ], ( bool ) ? 'even' : 'not even' ); + console.log( '%d is %s', x[ i ], ( isEvenf( x[ i ] ) ) ? 'even' : 'not even' ); } ``` @@ -135,6 +131,8 @@ for ( i = 0; i < 100; i++ ) { Tests if a finite single-precision floating-point number is an even number. ```c +#include + bool out = stdlib_base_is_evenf( 1.0f ); // returns false @@ -169,6 +167,7 @@ bool stdlib_base_is_evenf( const float x ); ### Examples ```c +#include "stdlib/math/base/assert/is_evenf.h" #include #include #include diff --git a/lib/node_modules/@stdlib/math/base/assert/is-evenf/examples/index.js b/lib/node_modules/@stdlib/math/base/assert/is-evenf/examples/index.js index 6c027cf95a43..902a4b448a12 100644 --- a/lib/node_modules/@stdlib/math/base/assert/is-evenf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/assert/is-evenf/examples/index.js @@ -21,13 +21,9 @@ var randu = require( '@stdlib/random/array/discrete-uniform' ); var isEvenf = require( './../lib' ); -var bool; -var x; -var i; - -x = randu( 100, 0, 100 ); +var x = randu( 100, 0, 100 ); +var i; for ( i = 0; i < 100; i++ ) { - bool = isEvenf( x[ i ] ); - console.log( '%d is %s', x[ i ], ( bool ) ? 'even' : 'not even' ); + console.log( '%d is %s', x[ i ], ( isEvenf( x[ i ] ) ) ? 'even' : 'not even' ); } diff --git a/lib/node_modules/@stdlib/math/base/assert/is-evenf/manifest.json b/lib/node_modules/@stdlib/math/base/assert/is-evenf/manifest.json index 41144940fa1f..79807a5d1d1a 100644 --- a/lib/node_modules/@stdlib/math/base/assert/is-evenf/manifest.json +++ b/lib/node_modules/@stdlib/math/base/assert/is-evenf/manifest.json @@ -36,6 +36,10 @@ "libraries": [], "libpath": [], "dependencies": [ + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/create-int32", + "@stdlib/napi/export", "@stdlib/math/base/assert/is-integerf" ] }, diff --git a/lib/node_modules/@stdlib/math/base/assert/is-evenf/src/addon.c b/lib/node_modules/@stdlib/math/base/assert/is-evenf/src/addon.c index 14b1af778d63..9eddfd2ccb98 100644 --- a/lib/node_modules/@stdlib/math/base/assert/is-evenf/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/assert/is-evenf/src/addon.c @@ -17,9 +17,12 @@ */ #include "stdlib/math/base/assert/is_evenf.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/create_int32.h" +#include "stdlib/napi/export.h" #include #include -#include /** * Receives JavaScript callback invocation data. @@ -29,60 +32,10 @@ * @return Node-API value */ static napi_value addon( napi_env env, napi_callback_info info ) { - napi_status status; - - // Get callback arguments: - size_t argc = 1; - napi_value argv[ 1 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - // Check whether we were provided the correct number of arguments: - if ( argc < 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Insufficient arguments." ); - assert( status == napi_ok ); - return NULL; - } - if ( argc > 1 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Too many arguments." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - bool result = stdlib_base_is_evenf( (float)x ); - - napi_value v; - status = napi_create_int32( env, (int32_t)result, &v ); - assert( status == napi_ok ); - - return v; -} - -/** -* Initializes a Node-API module. -* -* @param env environment under which the function is invoked -* @param exports exports object -* @return main export -*/ -static napi_value init( napi_env env, napi_value exports ) { - napi_value fcn; - napi_status status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, addon, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; + STDLIB_NAPI_ARGV( env, info, argv, argc, 1 ); + STDLIB_NAPI_ARGV_FLOAT( env, x, argv, 0 ); + STDLIB_NAPI_CREATE_INT32( env, (int32_t)stdlib_base_is_evenf( x ), out ); + return out; } -NAPI_MODULE( NODE_GYP_MODULE_NAME, init ) +STDLIB_NAPI_MODULE_EXPORT_FCN( addon )