File: object_freeze_seal.cc

package info (click to toggle)
node-addon-api 5.0.0-6%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,920 kB
  • sloc: cpp: 7,531; ansic: 5,297; javascript: 4,654; makefile: 7
file content (25 lines) | stat: -rw-r--r-- 591 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "napi.h"
#include "test_helper.h"

#if (NAPI_VERSION > 7)

using namespace Napi;

Value Freeze(const CallbackInfo& info) {
  Object obj = info[0].As<Object>();
  return Boolean::New(info.Env(), MaybeUnwrapOr(obj.Freeze(), false));
}

Value Seal(const CallbackInfo& info) {
  Object obj = info[0].As<Object>();
  return Boolean::New(info.Env(), MaybeUnwrapOr(obj.Seal(), false));
}

Object InitObjectFreezeSeal(Env env) {
  Object exports = Object::New(env);
  exports["freeze"] = Function::New(env, Freeze);
  exports["seal"] = Function::New(env, Seal);
  return exports;
}

#endif