JSPM

@stdlib/ndarray-base-napi-typedarray-type-to-dtype

0.0.8
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 219
  • Score
    100M100P100Q110222F
  • License Apache-2.0

C API for returning the ndarray data type corresponding to a Node-API typed array type.

Package Exports

  • @stdlib/ndarray-base-napi-typedarray-type-to-dtype
  • @stdlib/ndarray-base-napi-typedarray-type-to-dtype/lib/browser.js
  • @stdlib/ndarray-base-napi-typedarray-type-to-dtype/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stdlib/ndarray-base-napi-typedarray-type-to-dtype) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Node-API ndarray dtype

NPM version Build Status Coverage Status

C API for returning the ndarray data type corresponding to a Node-API typed array type.

Installation

npm install @stdlib/ndarray-base-napi-typedarray-type-to-dtype

Usage

#include "stdlib/ndarray/base/napi/typedarray_type_to_dtype.h"

stdlib_ndarray_napi_typedarray_type_to_dtype( napi_typedarray_type vtype )

Returns the ndarray data type corresponding to a Node-API typed array type.

#include "stdlib/ndarray/base/napi/typedarray_type_to_dtype.h"
#include "stdlib/ndarray/dtypes.h"
#include <node_api.h>
#include <assert.h>

// Add-on function export...
napi_value addon( napi_env env, napi_callback_info info ) {

    // ...

    // Get function arguments...
    size_t argc = 1;
    napi_value argv[ 1 ];
    napi_status status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL );
    assert( status == napi_ok );

    // ...

    // Get a typed array argument...
    napi_typedarray_type vtype;
    size_t xlen;
    void *X;
    status = napi_get_typedarray_info( env, argv[ 0 ], &vtype, &xlen, &X, NULL, NULL );
    assert( status == napi_ok );

    // ...

    // Return the corresponding ndarray data type for the input typed array:
    enum STDLIB_NDARRAY_DTYPE dtype = stdlib_ndarray_napi_typedarray_type_to_dtype( vtype );

    // ...
}

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright © 2016-2022. The Stdlib Authors.