@nxtedition/rocksdb 11.1.4 → 11.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/binding.cc CHANGED
@@ -18,12 +18,12 @@
18
18
  #include <rocksdb/table.h>
19
19
  #include <rocksdb/write_batch.h>
20
20
 
21
+ #include <boost/regex.hpp>
21
22
 
22
23
  #include <iostream>
23
24
  #include <memory>
24
25
  #include <optional>
25
26
  #include <set>
26
- #include <regex>
27
27
  #include <string>
28
28
  #include <thread>
29
29
  #include <vector>
@@ -1488,10 +1488,10 @@ NAPI_METHOD(regex_init) {
1488
1488
  NAPI_STATUS_THROWS(GetString(env, argv[0], pattern));
1489
1489
 
1490
1490
  try {
1491
- auto regex = std::make_unique<std::regex>(pattern, std::regex::optimize | std::regex::ECMAScript);
1491
+ auto regex = std::make_unique<boost::regex>(pattern, boost::regex::optimize | boost::regex::ECMAScript);
1492
1492
 
1493
1493
  napi_value result;
1494
- NAPI_STATUS_THROWS(napi_create_external(env, regex.get(), Finalize<std::regex>, regex.get(), &result));
1494
+ NAPI_STATUS_THROWS(napi_create_external(env, regex.get(), Finalize<boost::regex>, regex.get(), &result));
1495
1495
  regex.release();
1496
1496
 
1497
1497
  return result;
@@ -1504,7 +1504,7 @@ NAPI_METHOD(regex_init) {
1504
1504
  NAPI_METHOD(regex_test) {
1505
1505
  NAPI_ARGV(4);
1506
1506
 
1507
- std::regex* regex;
1507
+ boost::regex* regex;
1508
1508
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&regex)));
1509
1509
 
1510
1510
  rocksdb::Slice value;
@@ -1519,7 +1519,7 @@ NAPI_METHOD(regex_test) {
1519
1519
  length = std::max(0, std::min<int>(length, value.size() - offset));
1520
1520
 
1521
1521
  try {
1522
- const bool match = std::regex_search(value.data() + offset, value.data() + offset + length, *regex);
1522
+ const bool match = boost::regex_search(value.data() + offset, value.data() + offset + length, *regex);
1523
1523
 
1524
1524
  napi_value result;
1525
1525
  NAPI_STATUS_THROWS(napi_get_boolean(env, match, &result));
@@ -1534,7 +1534,7 @@ NAPI_METHOD(regex_test) {
1534
1534
  NAPI_METHOD(regex_test_many) {
1535
1535
  NAPI_ARGV(2);
1536
1536
 
1537
- std::regex* regex;
1537
+ boost::regex* regex;
1538
1538
  NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(&regex)));
1539
1539
 
1540
1540
  uint32_t count;
@@ -1544,19 +1544,26 @@ NAPI_METHOD(regex_test_many) {
1544
1544
  NAPI_STATUS_THROWS(napi_create_array_with_length(env, count, &result));
1545
1545
 
1546
1546
  try {
1547
+ std::vector<rocksdb::Slice> keys;
1548
+ keys.resize(count);
1549
+
1550
+ std::vector<bool> matches;
1551
+ matches.resize(count);
1552
+
1547
1553
  for (uint32_t n = 0; n < count; n++) {
1548
1554
  napi_value valueElement;
1549
1555
  NAPI_STATUS_THROWS(napi_get_element(env, argv[1], n, &valueElement));
1556
+ NAPI_STATUS_THROWS(GetValue(env, valueElement, keys[n]))
1557
+ }
1550
1558
 
1551
- rocksdb::Slice value;
1552
- NAPI_STATUS_THROWS(GetValue(env, valueElement, value));
1553
-
1554
- const bool match = std::regex_search(value.data(), value.data() + value.size(), *regex);
1555
-
1556
- napi_value matchElement;
1557
- NAPI_STATUS_THROWS(napi_get_boolean(env, match, &matchElement));
1559
+ for (uint32_t n = 0; n < count; n++) {
1560
+ matches[n] = boost::regex_search(keys[n].data(), keys[n].data() + keys[n].size(), *regex);
1561
+ }
1558
1562
 
1559
- NAPI_STATUS_THROWS(napi_set_element(env, result, n, matchElement));
1563
+ for (uint32_t n = 0; n < count; n++) {
1564
+ napi_value element;
1565
+ NAPI_STATUS_THROWS(napi_get_boolean(env, matches[n], &element));
1566
+ NAPI_STATUS_THROWS(napi_set_element(env, result, n, element));
1560
1567
  }
1561
1568
 
1562
1569
  return result;
package/binding.gyp CHANGED
@@ -3,6 +3,9 @@
3
3
  "targets": [
4
4
  {
5
5
  "target_name": "leveldown",
6
+ "defines": [
7
+ "BOOST_REGEX_STANDALONE=yes"
8
+ ],
6
9
  "conditions": [
7
10
  [
8
11
  "OS == 'linux'",
@@ -52,7 +55,7 @@
52
55
  ]
53
56
  ],
54
57
  "dependencies": ["<(module_root_dir)/deps/rocksdb/rocksdb.gyp:rocksdb"],
55
- "include_dirs": ["<!(node -e \"require('napi-macros')\")"],
58
+ "include_dirs": ["<!(node -e \"require('napi-macros')\")", "/opt/homebrew/Cellar/boost/1.86.0/include"],
56
59
  "sources": ["binding.cc"]
57
60
  }
58
61
  ]
@@ -13,7 +13,8 @@
13
13
  "ZSTD_STATIC_LINKING_ONLY=1",
14
14
  "ROCKSDB_BACKTRACE=1",
15
15
  "NIOSTATS_CONTEXT=1",
16
- "NPERF_CONTEXT=1"
16
+ "NPERF_CONTEXT=1",
17
+ "BOOST_REGEX_STANDALONE=yes"
17
18
  ],
18
19
  "include_dirs": [
19
20
  "rocksdb/",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/rocksdb",
3
- "version": "11.1.4",
3
+ "version": "11.1.7",
4
4
  "description": "A low-level Node.js RocksDB binding",
5
5
  "license": "MIT",
6
6
  "main": "index.js",