1. napi_status napi_create_buffer(napi_env env,
    2. size_t size,
    3. void** data,
    4. napi_value* result)
    • [in] env: The environment that the API is invoked under.
    • [in] size: Size in bytes of the underlying buffer.
    • [out] data: Raw pointer to the underlying buffer.
    • [out] result: A napi_value representing a node::Buffer.

    Returns napi_ok if the API succeeded.

    This API allocates a node::Buffer object. While this is still a fully-supported data structure, in most cases using a TypedArray will suffice.