Skip to content

Commit 3ef3bcc

Browse files
add math/base/assert/is-probabilityf
1 parent a21aba8 commit 3ef3bcc

File tree

2 files changed

+5
-69
lines changed

2 files changed

+5
-69
lines changed

lib/node_modules/@stdlib/math/base/assert/is-probabilityf/manifest.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
],
3636
"libraries": [],
3737
"libpath": [],
38-
"dependencies": []
38+
"dependencies": [
39+
"@stdlib/math/base/napi/unary"
40+
]
3941
},
4042
{
4143
"task": "benchmark",

lib/node_modules/@stdlib/math/base/assert/is-probabilityf/src/addon.c

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -17,72 +17,6 @@
1717
*/
1818

1919
#include "stdlib/math/base/assert/is_probabilityf.h"
20-
#include <node_api.h>
21-
#include <stdint.h>
22-
#include <assert.h>
20+
#include "stdlib/math/base/napi/unary.h"
2321

24-
/**
25-
* Receives JavaScript callback invocation data.
26-
*
27-
* @param env environment under which the function is invoked
28-
* @param info callback data
29-
* @return Node-API value
30-
*/
31-
static napi_value addon( napi_env env, napi_callback_info info ) {
32-
napi_status status;
33-
34-
// Get callback arguments:
35-
size_t argc = 1;
36-
napi_value argv[ 1 ];
37-
status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL );
38-
assert( status == napi_ok );
39-
40-
// Check whether we were provided the correct number of arguments:
41-
if ( argc < 1 ) {
42-
status = napi_throw_error( env, NULL, "invalid invocation. Insufficient arguments." );
43-
assert( status == napi_ok );
44-
return NULL;
45-
}
46-
if ( argc > 1 ) {
47-
status = napi_throw_error( env, NULL, "invalid invocation. Too many arguments." );
48-
assert( status == napi_ok );
49-
return NULL;
50-
}
51-
52-
napi_valuetype vtype0;
53-
status = napi_typeof( env, argv[ 0 ], &vtype0 );
54-
assert( status == napi_ok );
55-
if ( vtype0 != napi_number ) {
56-
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." );
57-
assert( status == napi_ok );
58-
return NULL;
59-
}
60-
61-
float x;
62-
status = napi_get_value_float( env, argv[ 0 ], &x );
63-
assert( status == napi_ok );
64-
65-
bool result = stdlib_base_is_probabilityf( x );
66-
67-
napi_value v;
68-
status = napi_create_int32( env, (int32_t)result, &v );
69-
assert( status == napi_ok );
70-
71-
return v;
72-
}
73-
74-
/**
75-
* Initializes a Node-API module.
76-
*
77-
* @param env environment under which the function is invoked
78-
* @param exports exports object
79-
* @return main export
80-
*/
81-
static napi_value init( napi_env env, napi_value exports ) {
82-
napi_value fcn;
83-
napi_status status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, addon, NULL, &fcn );
84-
assert( status == napi_ok );
85-
return fcn;
86-
}
87-
88-
NAPI_MODULE( NODE_GYP_MODULE_NAME, init )
22+
STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_absf )

0 commit comments

Comments
 (0)