├── .dntrc ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .npmignore ├── .pre-commit-config.yaml ├── CHANGELOG.md ├── CMakeLists.txt ├── LICENSE.md ├── Makefile ├── README.md ├── appveyor.yml ├── doc ├── .build.sh ├── asyncworker.md ├── buffers.md ├── callback.md ├── converters.md ├── errors.md ├── json.md ├── maybe_types.md ├── methods.md ├── new.md ├── node_misc.md ├── object_wrappers.md ├── persistent.md ├── scopes.md ├── script.md ├── string_bytes.md ├── v8_internals.md └── v8_misc.md ├── examples └── async_pi_estimate │ ├── README.md │ ├── addon.cc │ ├── addon.js │ ├── async.cc │ ├── async.h │ ├── binding.gyp │ ├── package.json │ ├── pi_est.cc │ ├── pi_est.h │ ├── sync.cc │ └── sync.h ├── include_dirs.js ├── nan.h ├── nan_callbacks.h ├── nan_callbacks_12_inl.h ├── nan_callbacks_pre_12_inl.h ├── nan_converters.h ├── nan_converters_43_inl.h ├── nan_converters_pre_43_inl.h ├── nan_define_own_property_helper.h ├── nan_implementation_12_inl.h ├── nan_implementation_pre_12_inl.h ├── nan_json.h ├── nan_maybe_43_inl.h ├── nan_maybe_pre_43_inl.h ├── nan_new.h ├── nan_object_wrap.h ├── nan_persistent_12_inl.h ├── nan_persistent_pre_12_inl.h ├── nan_private.h ├── nan_scriptorigin.h ├── nan_string_bytes.h ├── nan_typedarray_contents.h ├── nan_weak.h ├── package.json ├── test ├── .jshintrc ├── binding.gyp ├── cpp │ ├── accessors.cpp │ ├── accessors2.cpp │ ├── asyncprogressqueueworker.cpp │ ├── asyncprogressqueueworkerstream.cpp │ ├── asyncprogressworker.cpp │ ├── asyncprogressworkersignal.cpp │ ├── asyncprogressworkerstream.cpp │ ├── asyncresource.cpp │ ├── asyncworker.cpp │ ├── asyncworkererror.cpp │ ├── buffer.cpp │ ├── bufferworkerpersistent.cpp │ ├── callbackcontext.cpp │ ├── converters.cpp │ ├── error.cpp │ ├── gc.cpp │ ├── indexedinterceptors.cpp │ ├── isolatedata.cpp │ ├── json-parse.cpp │ ├── json-stringify.cpp │ ├── makecallback.cpp │ ├── maybe.cpp │ ├── methodswithdata.cpp │ ├── morenews.cpp │ ├── multifile1.cpp │ ├── multifile2.cpp │ ├── multifile2.h │ ├── namedinterceptors.cpp │ ├── nancallback.cpp │ ├── nannew.cpp │ ├── news.cpp │ ├── objectwraphandle.cpp │ ├── persistent.cpp │ ├── private.cpp │ ├── returnemptystring.cpp │ ├── returnnull.cpp │ ├── returnundefined.cpp │ ├── returnvalue.cpp │ ├── setcallhandler.cpp │ ├── settemplate.cpp │ ├── sleep.h │ ├── strings.cpp │ ├── symbols.cpp │ ├── threadlocal.cpp │ ├── trycatch.cpp │ ├── typedarrays.cpp │ ├── weak.cpp │ ├── weak2.cpp │ └── wrappedobjectfactory.cpp ├── js │ ├── accessors-test.js │ ├── accessors2-test.js │ ├── asyncprogressqueueworker-test.js │ ├── asyncprogressqueueworkerstream-test.js │ ├── asyncprogressworker-test.js │ ├── asyncprogressworkersignal-test.js │ ├── asyncprogressworkerstream-test.js │ ├── asyncresource-test.js │ ├── asyncworker-test.js │ ├── asyncworkererror-test.js │ ├── buffer-test.js │ ├── bufferworkerpersistent-test.js │ ├── callbackcontext-test.js │ ├── converters-test.js │ ├── error-test.js │ ├── gc-fn.js │ ├── gc-test.js │ ├── indexedinterceptors-test.js │ ├── isolatedata-test.js │ ├── json-parse-test.js │ ├── json-stringify-test.js │ ├── makecallback-test.js │ ├── maybe-test.js │ ├── methodswithdata-test.js │ ├── morenews-test.js │ ├── multifile-test.js │ ├── namedinterceptors-test.js │ ├── nancallback-test.js │ ├── nannew-test.js │ ├── news-test.js │ ├── objectwraphandle-test.js │ ├── persistent-test.js │ ├── private-test.js │ ├── returnemptystring-test.js │ ├── returnnull-test.js │ ├── returnundefined-test.js │ ├── returnvalue-test.js │ ├── setcallhandler-test.js │ ├── settemplate-test.js │ ├── strings-test.js │ ├── symbols-test.js │ ├── threadlocal-test.js │ ├── trycatch-test.js │ ├── typedarrays-test.js │ ├── weak-test.js │ ├── weak2-test.js │ └── wrappedobjectfactory-test.js └── tap-as-worker.js └── tools ├── 1to2.js ├── README.md └── package.json /.dntrc: -------------------------------------------------------------------------------- 1 | ## DNT config file 2 | ## see https://github.com/rvagg/dnt 3 | 4 | NODE_VERSIONS="\ 5 | master \ 6 | v0.11.13 \ 7 | v0.10.30 \ 8 | v0.10.29 \ 9 | v0.10.28 \ 10 | v0.10.26 \ 11 | v0.10.25 \ 12 | v0.10.24 \ 13 | v0.10.23 \ 14 | v0.10.22 \ 15 | v0.10.21 \ 16 | v0.10.20 \ 17 | v0.10.19 \ 18 | v0.8.28 \ 19 | v0.8.27 \ 20 | v0.8.26 \ 21 | v0.8.24 \ 22 | " 23 | OUTPUT_PREFIX="nan-" 24 | TEST_CMD=" \ 25 | cd /dnt/ && \ 26 | npm install && \ 27 | node_modules/.bin/node-gyp --nodedir /usr/src/node/ rebuild --directory test && \ 28 | node_modules/.bin/tap --gc test/js/*-test.js \ 29 | " 30 | 31 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs 2 | # https://github.com/actions/setup-node 3 | # https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories 4 | 5 | name: ci 6 | on: 7 | push: 8 | # branches: [main] 9 | pull_request: 10 | # branches: [main] 11 | workflow_dispatch: 12 | permissions: 13 | contents: read 14 | jobs: 15 | pre-commit: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v4 19 | - uses: pre-commit/action@v3.0.1 20 | 21 | ci: 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | node-version: [24.x, 23.x, 22.x, 21.x, 20.x, 19.x, 18.x, 17.x, 16.x] 26 | os: [windows-latest] 27 | include: 28 | - node-version: lts/* 29 | os: macos-13 # macOS on Intel 30 | - node-version: lts/* 31 | os: macos-latest # macOS on arm64 32 | - node-version: lts/* 33 | os: ubuntu-latest # Linux on x64 34 | - node-version: lts/* 35 | os: ubuntu-24.04-arm # Linux on arm64 36 | - node-version: lts/* 37 | os: windows-2025 38 | - node-version: 14.x 39 | os: windows-2019 40 | - node-version: 12.x 41 | os: windows-2019 42 | - node-version: 10.x 43 | os: windows-2019 44 | - node-version: 8.x 45 | os: windows-2019 46 | runs-on: ${{ matrix.os }} 47 | steps: 48 | - uses: actions/checkout@v4 49 | - uses: actions/setup-node@v4 50 | with: 51 | node-version: ${{ matrix.node-version }} 52 | - run: npm install 53 | # TODO: On Windows Node.js v11 these will fail but `make test` will succeed 54 | - if: matrix.node-version != '11.x' 55 | run: | 56 | npm run-script rebuild-tests 57 | npm test 58 | - run: make test 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | node_modules/ -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | test/ 2 | examples/ 3 | .dntrc 4 | .npmignore 5 | appveyor.yml 6 | Makefile 7 | cpplint.py 8 | nan-*.tgz 9 | doc/.build.sh 10 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/cpplint/cpplint 3 | rev: 2.0.0 4 | hooks: 5 | - id: cpplint 6 | args: 7 | - --filter=-whitespace/indent_namespace,-whitespace/parens 8 | - --linelength=88 9 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 [NAN contributors]() 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TOPLEVEL ?= $(dir $(lastword $(MAKEFILE_LIST))) 2 | CPPLINT ?= $(TOPLEVEL)/cpplint.py 3 | PYTHON ?= python 4 | BUILDTYPE ?= Release 5 | MODULES = symbols strings 6 | SOURCES = $(MODULES:%=test/cpp/%.cpp) 7 | ADDONS = $(MODULES:%=test/build/$(BUILDTYPE)/%.node) 8 | 9 | LINT_SOURCES = \ 10 | examples/async_pi_estimate/addon.cc \ 11 | examples/async_pi_estimate/async.cc \ 12 | examples/async_pi_estimate/async.h \ 13 | examples/async_pi_estimate/pi_est.cc \ 14 | examples/async_pi_estimate/pi_est.h \ 15 | examples/async_pi_estimate/sync.cc \ 16 | examples/async_pi_estimate/sync.h \ 17 | nan.h \ 18 | nan_callbacks.h \ 19 | nan_callbacks_12_inl.h \ 20 | nan_callbacks_pre_12_inl.h \ 21 | nan_converters.h \ 22 | nan_converters_43_inl.h \ 23 | nan_converters_pre_43_inl.h \ 24 | nan_define_own_property_helper.h \ 25 | nan_implementation_12_inl.h \ 26 | nan_implementation_pre_12_inl.h \ 27 | nan_json.h \ 28 | nan_maybe_43_inl.h \ 29 | nan_maybe_pre_43_inl.h \ 30 | nan_new.h \ 31 | nan_object_wrap.h \ 32 | nan_persistent_12_inl.h \ 33 | nan_persistent_pre_12_inl.h \ 34 | nan_private.h \ 35 | nan_scriptorigin.h \ 36 | nan_string_bytes.h \ 37 | nan_weak.h \ 38 | test/cpp/accessors.cpp \ 39 | test/cpp/accessors2.cpp \ 40 | test/cpp/asyncresource.cpp \ 41 | test/cpp/asyncworker.cpp \ 42 | test/cpp/asyncprogressworker.cpp \ 43 | test/cpp/asyncprogressworkerstream.cpp \ 44 | test/cpp/asyncprogressworkersignal.cpp \ 45 | test/cpp/asyncprogressqueueworker.cpp \ 46 | test/cpp/asyncprogressqueueworkerstream.cpp \ 47 | test/cpp/asyncworkererror.cpp \ 48 | test/cpp/buffer.cpp \ 49 | test/cpp/bufferworkerpersistent.cpp \ 50 | test/cpp/error.cpp \ 51 | test/cpp/gc.cpp \ 52 | test/cpp/indexedinterceptors.cpp \ 53 | test/cpp/callbackcontext.cpp \ 54 | test/cpp/converters.cpp \ 55 | test/cpp/isolatedata.cpp \ 56 | test/cpp/json-parse.cpp \ 57 | test/cpp/json-stringify.cpp \ 58 | test/cpp/makecallback.cpp \ 59 | test/cpp/maybe.cpp \ 60 | test/cpp/morenews.cpp \ 61 | test/cpp/multifile1.cpp \ 62 | test/cpp/multifile2.cpp \ 63 | test/cpp/multifile2.h \ 64 | test/cpp/namedinterceptors.cpp \ 65 | test/cpp/nancallback.cpp \ 66 | test/cpp/nannew.cpp \ 67 | test/cpp/news.cpp \ 68 | test/cpp/objectwraphandle.cpp \ 69 | test/cpp/persistent.cpp \ 70 | test/cpp/private.cpp \ 71 | test/cpp/returnemptystring.cpp \ 72 | test/cpp/returnnull.cpp \ 73 | test/cpp/returnundefined.cpp \ 74 | test/cpp/returnvalue.cpp \ 75 | test/cpp/setcallhandler.cpp \ 76 | test/cpp/settemplate.cpp \ 77 | test/cpp/sleep.h \ 78 | test/cpp/strings.cpp \ 79 | test/cpp/symbols.cpp \ 80 | test/cpp/threadlocal.cpp \ 81 | test/cpp/trycatch.cpp \ 82 | test/cpp/typedarrays.cpp \ 83 | test/cpp/weak.cpp \ 84 | test/cpp/weak2.cpp \ 85 | test/cpp/wrappedobjectfactory.cpp \ 86 | node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc 87 | 88 | FILTER = -build/include_subdir,-whitespace/parens 89 | 90 | .PHONY: lint 91 | 92 | lint: 93 | cd $(TOPLEVEL) && $(PYTHON) $(CPPLINT) --filter=$(FILTER) $(LINT_SOURCES) 94 | 95 | test: $(ADDONS) 96 | npm test 97 | 98 | forcetest: 99 | cd test && ../node_modules/.bin/node-gyp rebuild && cd .. 100 | npm test 101 | 102 | docs: README.md doc/.build.sh doc/asyncworker.md doc/buffers.md doc/callback.md \ 103 | doc/converters.md doc/errors.md doc/maybe_types.md doc/methods.md doc/new.md \ 104 | doc/node_misc.md doc/persistent.md doc/scopes.md doc/script.md doc/string_bytes.md \ 105 | doc/v8_internals.md doc/json.md doc/v8_misc.md 106 | doc/.build.sh 107 | 108 | 109 | $(ADDONS): nan.h nan_new.h nan_implementation_pre_12_inl.h nan_implementation_12_inl.h \ 110 | nan_callbacks.h nan_callbacks_12_inl.h nan_callbacks_pre_12_inl.h \ 111 | nan_converters.h nan_converters_43_inl.h nan_converters_pre_43_inl.h \ 112 | nan_define_own_property_helper.h \ 113 | nan_json.h nan_maybe_43_inl.h nan_maybe_pre_43_inl.h \ 114 | nan_persistent_12_inl.h nan_persistent_pre_12_inl.h nan_private.h \ 115 | nan_weak.h nan_scriptorigin.h nan_string_bytes.h \ 116 | test/binding.gyp $(SOURCES) 117 | cd test/ && ../node_modules/.bin/node-gyp rebuild 118 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # http://www.appveyor.com/docs/appveyor-yml 2 | # https://www.appveyor.com/docs/windows-images-software 3 | # https://nodejs.org/en/about/previous-releases 4 | # https://devguide.python.org/versions 5 | 6 | # Test supported Node.js versions before unsupported versions. 7 | # Run on the most current Visual Studio possible for each nodejs_version. 8 | # Run on the earliest supported Python version when possible (currently py39). 9 | # For all supported Node.js versions test also on the latest Python (currently py313). 10 | 11 | image: 12 | - Visual Studio 2022 13 | 14 | environment: 15 | NODE_GYP_FORCE_PYTHON: C:\Python39-x64\python.exe 16 | matrix: # Test against these versions of Io.js and Node.js. 17 | # - nodejs_version: "23" # Enable after nodejs/nan#979 or similar. 18 | - nodejs_version: "22" 19 | - nodejs_version: "22" 20 | NODE_GYP_FORCE_PYTHON: C:\Python312-x64\python.exe 21 | - nodejs_version: "21" 22 | - nodejs_version: "20" 23 | - nodejs_version: "19" 24 | - nodejs_version: "18" 25 | - nodejs_version: "17" 26 | - nodejs_version: "16" 27 | - nodejs_version: "14" 28 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 29 | - nodejs_version: "12" 30 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 31 | - nodejs_version: "10" 32 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 33 | - nodejs_version: "8" 34 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 35 | 36 | matrix: 37 | fast_finish: true 38 | 39 | # Install scripts. (runs after repo cloning) 40 | install: 41 | # Output useful info for debugging. 42 | - node --version 43 | - npm --version 44 | - py --list 45 | - py -VV # py is 64-bit AMD64 Python 3 on Visual Studio images 46 | - python -VV # python is 32-bit Intel Python 3 on Visual Studio images 47 | # Get the latest stable version of Node 0.STABLE.latest 48 | - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) x64 49 | - node --version 50 | - set PATH=%APPDATA%\npm;%PATH% 51 | # Typical npm stuff. 52 | - npm install 53 | - npm run rebuild-tests 54 | 55 | # Post-install test scripts. 56 | test_script: 57 | # Output useful info for debugging. 58 | - node --version 59 | - npm --version 60 | - py --list 61 | - py -VV # py is 64-bit AMD64 Python 3 on Visual Studio images 62 | - python -VV # python is 32-bit Intel Python 3 on Visual Studio images 63 | # run tests 64 | - node node_modules\tap\bin\tap.js --gc test/js/*-test.js 65 | 66 | # Don't actually build. 67 | build: off 68 | 69 | # Set build version format here instead of in the admin panel. 70 | version: "{build}" 71 | -------------------------------------------------------------------------------- /doc/.build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | files=" \ 4 | methods.md \ 5 | scopes.md \ 6 | persistent.md \ 7 | new.md \ 8 | converters.md \ 9 | maybe_types.md \ 10 | script.md \ 11 | json.md \ 12 | errors.md \ 13 | buffers.md \ 14 | callback.md \ 15 | asyncworker.md \ 16 | string_bytes.md \ 17 | object_wrappers.md \ 18 | v8_internals.md \ 19 | v8_misc.md \ 20 | node_misc.md \ 21 | " 22 | 23 | __dirname=$(dirname "${BASH_SOURCE[0]}") 24 | head=$(perl -e 'while (<>) { if (!$en){print;} if ($_=~/