Repository: nodejs/node
File: test/js-native-api/test_object/test_object.c (C)

Code before:
  NODE_API_CALL(
      env, napi_create_string_utf8(env, "age", NAPI_AUTO_LENGTH, &names[1]));
  NODE_API_CALL(env, napi_create_int32(env, 42, &values[1]));

  NODE_API_CALL(
      env, napi_create_string_utf8(env, "active", NAPI_AUTO_LENGTH, &names[2]));
  NODE_API_CALL(env, napi_get_boolean(env, true, &values[2]));

  napi_value null_prototype;
  NODE_API_CALL(env, napi_get_null(env, &null_prototype));
  NODE_API_CALL(env,
                napi_create_object_with_properties(
                    env, null_prototype, names, values, 3, &result));

  return result;
}

static napi_value TestCreateObjectWithPropertiesEmpty(napi_env env,
                                                      napi_callback_info info) {
  napi_value result;

  napi_value null_prototype;
  NODE_API_CALL(env, napi_get_null(env, &null_prototype));
  NODE_API_CALL(env,
                napi_create_object_with_properties(
                    env, null_prototype, NULL, NULL, 0, &result));

  return result;
}

static napi_value TestCreateObjectWithCustomPrototype(napi_env env,
                                                      napi_callback_info info) {
  napi_value prototype;
  napi_value method_name;
  napi_value method_func;
  napi_value names[1];
  napi_value values[1];
  napi_value result;

  NODE_API_CALL(env, napi_create_object(env, &prototype));
  NODE_API_CALL(
      env,
      napi_create_string_utf8(env, "test", NAPI_AUTO_LENGTH, &method_name));
  NODE_API_CALL(env,
                napi_create_function(env,
                                     "test",
                                     NAPI_AUTO_LENGTH,
                                     TestCreateObjectWithProperties,
                                     NULL,
                                     &method_func));
  NODE_API_CALL(env,

Review comment (suggestion):
To verify that the prototype can be a C `NULL` value.

```suggestion
  NODE_API_CALL(env,
                napi_create_object_with_properties(
                    env, NULL, NULL, NULL, 0, &result));
```

Code after:
  NODE_API_CALL(
      env, napi_create_string_utf8(env, "age", NAPI_AUTO_LENGTH, &names[1]));
  NODE_API_CALL(env, napi_create_int32(env, 42, &values[1]));

  NODE_API_CALL(
      env, napi_create_string_utf8(env, "active", NAPI_AUTO_LENGTH, &names[2]));
  NODE_API_CALL(env, napi_get_boolean(env, true, &values[2]));

  napi_value null_prototype;
  NODE_API_CALL(env, napi_get_null(env, &null_prototype));
  NODE_API_CALL(env,
                napi_create_object_with_properties(
                    env, null_prototype, names, values, 3, &result));

  return result;
}

static napi_value TestCreateObjectWithPropertiesEmpty(napi_env env,
                                                      napi_callback_info info) {
  napi_value result;

  NODE_API_CALL(
      env,
      napi_create_object_with_properties(env, NULL, NULL, NULL, 0, &result));

  return result;
}

static napi_value TestCreateObjectWithCustomPrototype(napi_env env,
                                                      napi_callback_info info) {
  napi_value prototype;
  napi_value method_name;
  napi_value method_func;
  napi_value names[1];
  napi_value values[1];
  napi_value result;

  NODE_API_CALL(env, napi_create_object(env, &prototype));
  NODE_API_CALL(
      env,
      napi_create_string_utf8(env, "test", NAPI_AUTO_LENGTH, &method_name));
  NODE_API_CALL(env,
                napi_create_function(env,
                                     "test",
                                     NAPI_AUTO_LENGTH,
                                     TestCreateObjectWithProperties,
                                     NULL,
                                     &method_func));
  NODE_API_CALL(env,
                napi_set_property(env, prototype, method_name, method_func));