@nxtedition/rocksdb 11.1.2 → 11.1.3
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 +10 -2
- package/package.json +1 -1
- package/regex.js +10 -2
package/binding.cc
CHANGED
|
@@ -1497,7 +1497,7 @@ NAPI_METHOD(regex_init) {
|
|
|
1497
1497
|
}
|
|
1498
1498
|
|
|
1499
1499
|
NAPI_METHOD(regex_test) {
|
|
1500
|
-
NAPI_ARGV(
|
|
1500
|
+
NAPI_ARGV(4);
|
|
1501
1501
|
|
|
1502
1502
|
std::regex* regex;
|
|
1503
1503
|
NAPI_STATUS_THROWS(napi_get_value_external(env, argv[0], reinterpret_cast<void**>(®ex)));
|
|
@@ -1505,7 +1505,15 @@ NAPI_METHOD(regex_test) {
|
|
|
1505
1505
|
rocksdb::Slice value;
|
|
1506
1506
|
NAPI_STATUS_THROWS(GetValue(env, argv[1], value));
|
|
1507
1507
|
|
|
1508
|
-
|
|
1508
|
+
int offset = 0;
|
|
1509
|
+
NAPI_STATUS_THROWS(GetValue(env, argv[2], offset));
|
|
1510
|
+
offset = std::max(0, std::min<int>(offset, value.size()));
|
|
1511
|
+
|
|
1512
|
+
int length = 0;
|
|
1513
|
+
NAPI_STATUS_THROWS(GetValue(env, argv[3], length));
|
|
1514
|
+
length = std::max(0, std::min<int>(length, value.size() - offset));
|
|
1515
|
+
|
|
1516
|
+
const bool match = std::regex_search(value.data() + offset, value.data() + offset + length, *regex);
|
|
1509
1517
|
|
|
1510
1518
|
napi_value result;
|
|
1511
1519
|
NAPI_STATUS_THROWS(napi_get_boolean(env, match, &result));
|
package/package.json
CHANGED
package/regex.js
CHANGED
|
@@ -9,8 +9,16 @@ class Regex {
|
|
|
9
9
|
this.#context = binding.regex_init(pattern)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
test (
|
|
13
|
-
|
|
12
|
+
test (buffer, byteOffset, byteLength) {
|
|
13
|
+
if (byteOffset === undefined) {
|
|
14
|
+
byteOffset = 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (byteLength === undefined) {
|
|
18
|
+
byteLength = buffer.byteLength - byteOffset
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return binding.regex_test(this.#context, buffer, byteOffset, byteLength)
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
testMany (values) {
|