@nxtedition/rocksdb 5.2.2 → 5.2.13
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 +597 -100
- package/binding.gyp +5 -4
- package/chained-batch.js +13 -18
- package/deps/rocksdb/rocksdb/README.md +32 -0
- package/deps/rocksdb/rocksdb/hdfs/README +23 -0
- package/deps/rocksdb/rocksdb/port/README +10 -0
- package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/test/DistributedMutexTest.cpp +1145 -0
- package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/README +13 -0
- package/deps/rocksdb/rocksdb.gyp +44 -62
- package/deps/snappy/snappy-1.1.7/README.md +149 -0
- package/index.js +189 -0
- package/iterator.js +88 -24
- package/package.json +23 -17
- package/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/deps/rocksdb/rocksdb/cmake/modules/CxxFlags.cmake +0 -7
- package/deps/rocksdb/rocksdb/cmake/modules/FindJeMalloc.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/FindNUMA.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/FindSnappy.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/FindTBB.cmake +0 -33
- package/deps/rocksdb/rocksdb/cmake/modules/Findgflags.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/Findlz4.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/Findzstd.cmake +0 -29
- package/deps/rocksdb/rocksdb/cmake/modules/ReadVersion.cmake +0 -10
- package/leveldown.js +0 -113
- package/package-lock.json +0 -23687
package/package.json
CHANGED
|
@@ -1,32 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/rocksdb",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.13",
|
|
4
4
|
"description": "A low-level Node.js RocksDB binding",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"main": "
|
|
6
|
+
"main": "index.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"install": "node-gyp-build",
|
|
9
|
-
"test": "
|
|
9
|
+
"test": "standard && (nyc -s tape test/*-test.js | faucet) && nyc report",
|
|
10
10
|
"test-gc": "node --expose-gc test/gc.js",
|
|
11
11
|
"test-electron": "electron test/electron.js",
|
|
12
12
|
"test-prebuild": "cross-env PREBUILDS_ONLY=1 npm t",
|
|
13
13
|
"coverage": "nyc report -r lcovonly",
|
|
14
14
|
"rebuild": "npm run install --build-from-source",
|
|
15
15
|
"prebuild": "prebuildify -t 8.14.0 --napi --strip",
|
|
16
|
+
"download-prebuilds": "prebuildify-ci download",
|
|
17
|
+
"hallmark": "hallmark --fix",
|
|
18
|
+
"dependency-check": "dependency-check --no-dev -i napi-macros . test/*.js",
|
|
19
|
+
"prepublishOnly": "npm run dependency-check",
|
|
20
|
+
"prebuild-linux-arm": "prebuildify-cross -i linux-armv6 -i linux-armv7 -i linux-arm64 -t 8.14.0 --napi --strip",
|
|
21
|
+
"prebuild-android-arm": "prebuildify-cross -i android-armv7 -i android-arm64 -t 8.14.0 --napi --strip",
|
|
16
22
|
"prebuild-linux-x64": "prebuildify-cross -i centos7-devtoolset7 -i alpine -t 8.14.0 --napi --strip",
|
|
17
23
|
"prebuild-darwin-x64+arm64": "prebuildify -t 8.14.0 --napi --strip --arch x64+arm64",
|
|
18
|
-
"prebuild-win32-
|
|
19
|
-
"
|
|
20
|
-
"hallmark": "hallmark fix",
|
|
21
|
-
"dependency-check": "npx dependency-check --no-dev -i napi-macros . test/*.js",
|
|
22
|
-
"prepublishOnly": "npm run dependency-check"
|
|
24
|
+
"prebuild-win32-x86": "prebuildify -t 8.14.0 --napi --strip",
|
|
25
|
+
"prebuild-win32-x64": "prebuildify -t 8.14.0 --napi --strip"
|
|
23
26
|
},
|
|
24
27
|
"dependencies": {
|
|
25
|
-
"abstract-
|
|
26
|
-
"
|
|
28
|
+
"abstract-level": "^1.0.2",
|
|
29
|
+
"catering": "^2.1.1",
|
|
30
|
+
"module-error": "^1.0.1",
|
|
31
|
+
"napi-macros": "~2.0.0",
|
|
27
32
|
"node-gyp-build": "^4.3.0"
|
|
28
33
|
},
|
|
29
34
|
"devDependencies": {
|
|
35
|
+
"@types/node": "^17.0.16",
|
|
36
|
+
"@voxpelli/tsconfig": "^3.1.0",
|
|
30
37
|
"async-each": "^1.0.3",
|
|
31
38
|
"cross-env": "^7.0.3",
|
|
32
39
|
"delayed": "^2.0.0",
|
|
@@ -34,9 +41,8 @@
|
|
|
34
41
|
"du": "^1.0.0",
|
|
35
42
|
"electron": "^18.0.1",
|
|
36
43
|
"faucet": "^0.0.1",
|
|
37
|
-
"glob": "^
|
|
38
|
-
"hallmark": "^4.
|
|
39
|
-
"level-concat-iterator": "^3.0.0",
|
|
44
|
+
"glob": "^7.2.0",
|
|
45
|
+
"hallmark": "^4.1.0",
|
|
40
46
|
"mkfiletree": "^2.0.0",
|
|
41
47
|
"node-gyp": "^9.0.0",
|
|
42
48
|
"nyc": "^15.0.0",
|
|
@@ -45,9 +51,9 @@
|
|
|
45
51
|
"prebuildify-cross": "^5.0.0",
|
|
46
52
|
"readfiletree": "^1.0.0",
|
|
47
53
|
"rimraf": "^3.0.0",
|
|
48
|
-
"standard": "^16.0.
|
|
49
|
-
"tape": "^5.0
|
|
50
|
-
"tempy": "^
|
|
54
|
+
"standard": "^16.0.4",
|
|
55
|
+
"tape": "^5.5.0",
|
|
56
|
+
"tempy": "^1.0.1"
|
|
51
57
|
},
|
|
52
58
|
"standard": {
|
|
53
59
|
"ignore": [
|
|
@@ -65,6 +71,6 @@
|
|
|
65
71
|
"level"
|
|
66
72
|
],
|
|
67
73
|
"engines": {
|
|
68
|
-
"node": ">=
|
|
74
|
+
"node": ">=17.0.0"
|
|
69
75
|
}
|
|
70
76
|
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
macro(get_cxx_std_flags FLAGS_VARIABLE)
|
|
2
|
-
if( CMAKE_CXX_STANDARD_REQUIRED )
|
|
3
|
-
set(${FLAGS_VARIABLE} ${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION})
|
|
4
|
-
else()
|
|
5
|
-
set(${FLAGS_VARIABLE} ${CMAKE_CXX${CMAKE_CXX_STANDARD}_EXTENSION_COMPILE_OPTION})
|
|
6
|
-
endif()
|
|
7
|
-
endmacro()
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# - Find JeMalloc library
|
|
2
|
-
# Find the native JeMalloc includes and library
|
|
3
|
-
#
|
|
4
|
-
# JeMalloc_INCLUDE_DIRS - where to find jemalloc.h, etc.
|
|
5
|
-
# JeMalloc_LIBRARIES - List of libraries when using jemalloc.
|
|
6
|
-
# JeMalloc_FOUND - True if jemalloc found.
|
|
7
|
-
|
|
8
|
-
find_path(JeMalloc_INCLUDE_DIRS
|
|
9
|
-
NAMES jemalloc/jemalloc.h
|
|
10
|
-
HINTS ${JEMALLOC_ROOT_DIR}/include)
|
|
11
|
-
|
|
12
|
-
find_library(JeMalloc_LIBRARIES
|
|
13
|
-
NAMES jemalloc
|
|
14
|
-
HINTS ${JEMALLOC_ROOT_DIR}/lib)
|
|
15
|
-
|
|
16
|
-
include(FindPackageHandleStandardArgs)
|
|
17
|
-
find_package_handle_standard_args(JeMalloc DEFAULT_MSG JeMalloc_LIBRARIES JeMalloc_INCLUDE_DIRS)
|
|
18
|
-
|
|
19
|
-
mark_as_advanced(
|
|
20
|
-
JeMalloc_LIBRARIES
|
|
21
|
-
JeMalloc_INCLUDE_DIRS)
|
|
22
|
-
|
|
23
|
-
if(JeMalloc_FOUND AND NOT (TARGET JeMalloc::JeMalloc))
|
|
24
|
-
add_library (JeMalloc::JeMalloc UNKNOWN IMPORTED)
|
|
25
|
-
set_target_properties(JeMalloc::JeMalloc
|
|
26
|
-
PROPERTIES
|
|
27
|
-
IMPORTED_LOCATION ${JeMalloc_LIBRARIES}
|
|
28
|
-
INTERFACE_INCLUDE_DIRECTORIES ${JeMalloc_INCLUDE_DIRS})
|
|
29
|
-
endif()
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# - Find NUMA
|
|
2
|
-
# Find the NUMA library and includes
|
|
3
|
-
#
|
|
4
|
-
# NUMA_INCLUDE_DIRS - where to find numa.h, etc.
|
|
5
|
-
# NUMA_LIBRARIES - List of libraries when using NUMA.
|
|
6
|
-
# NUMA_FOUND - True if NUMA found.
|
|
7
|
-
|
|
8
|
-
find_path(NUMA_INCLUDE_DIRS
|
|
9
|
-
NAMES numa.h numaif.h
|
|
10
|
-
HINTS ${NUMA_ROOT_DIR}/include)
|
|
11
|
-
|
|
12
|
-
find_library(NUMA_LIBRARIES
|
|
13
|
-
NAMES numa
|
|
14
|
-
HINTS ${NUMA_ROOT_DIR}/lib)
|
|
15
|
-
|
|
16
|
-
include(FindPackageHandleStandardArgs)
|
|
17
|
-
find_package_handle_standard_args(NUMA DEFAULT_MSG NUMA_LIBRARIES NUMA_INCLUDE_DIRS)
|
|
18
|
-
|
|
19
|
-
mark_as_advanced(
|
|
20
|
-
NUMA_LIBRARIES
|
|
21
|
-
NUMA_INCLUDE_DIRS)
|
|
22
|
-
|
|
23
|
-
if(NUMA_FOUND AND NOT (TARGET NUMA::NUMA))
|
|
24
|
-
add_library (NUMA::NUMA UNKNOWN IMPORTED)
|
|
25
|
-
set_target_properties(NUMA::NUMA
|
|
26
|
-
PROPERTIES
|
|
27
|
-
IMPORTED_LOCATION ${NUMA_LIBRARIES}
|
|
28
|
-
INTERFACE_INCLUDE_DIRECTORIES ${NUMA_INCLUDE_DIRS})
|
|
29
|
-
endif()
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# - Find Snappy
|
|
2
|
-
# Find the snappy compression library and includes
|
|
3
|
-
#
|
|
4
|
-
# Snappy_INCLUDE_DIRS - where to find snappy.h, etc.
|
|
5
|
-
# Snappy_LIBRARIES - List of libraries when using snappy.
|
|
6
|
-
# Snappy_FOUND - True if snappy found.
|
|
7
|
-
|
|
8
|
-
find_path(Snappy_INCLUDE_DIRS
|
|
9
|
-
NAMES snappy.h
|
|
10
|
-
HINTS ${snappy_ROOT_DIR}/include)
|
|
11
|
-
|
|
12
|
-
find_library(Snappy_LIBRARIES
|
|
13
|
-
NAMES snappy
|
|
14
|
-
HINTS ${snappy_ROOT_DIR}/lib)
|
|
15
|
-
|
|
16
|
-
include(FindPackageHandleStandardArgs)
|
|
17
|
-
find_package_handle_standard_args(Snappy DEFAULT_MSG Snappy_LIBRARIES Snappy_INCLUDE_DIRS)
|
|
18
|
-
|
|
19
|
-
mark_as_advanced(
|
|
20
|
-
Snappy_LIBRARIES
|
|
21
|
-
Snappy_INCLUDE_DIRS)
|
|
22
|
-
|
|
23
|
-
if(Snappy_FOUND AND NOT (TARGET Snappy::snappy))
|
|
24
|
-
add_library (Snappy::snappy UNKNOWN IMPORTED)
|
|
25
|
-
set_target_properties(Snappy::snappy
|
|
26
|
-
PROPERTIES
|
|
27
|
-
IMPORTED_LOCATION ${Snappy_LIBRARIES}
|
|
28
|
-
INTERFACE_INCLUDE_DIRECTORIES ${Snappy_INCLUDE_DIRS})
|
|
29
|
-
endif()
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# - Find TBB
|
|
2
|
-
# Find the Thread Building Blocks library and includes
|
|
3
|
-
#
|
|
4
|
-
# TBB_INCLUDE_DIRS - where to find tbb.h, etc.
|
|
5
|
-
# TBB_LIBRARIES - List of libraries when using TBB.
|
|
6
|
-
# TBB_FOUND - True if TBB found.
|
|
7
|
-
|
|
8
|
-
if(NOT DEFINED TBB_ROOT_DIR)
|
|
9
|
-
set(TBB_ROOT_DIR "$ENV{TBBROOT}")
|
|
10
|
-
endif()
|
|
11
|
-
|
|
12
|
-
find_path(TBB_INCLUDE_DIRS
|
|
13
|
-
NAMES tbb/tbb.h
|
|
14
|
-
HINTS ${TBB_ROOT_DIR}/include)
|
|
15
|
-
|
|
16
|
-
find_library(TBB_LIBRARIES
|
|
17
|
-
NAMES tbb
|
|
18
|
-
HINTS ${TBB_ROOT_DIR}/lib ENV LIBRARY_PATH)
|
|
19
|
-
|
|
20
|
-
include(FindPackageHandleStandardArgs)
|
|
21
|
-
find_package_handle_standard_args(TBB DEFAULT_MSG TBB_LIBRARIES TBB_INCLUDE_DIRS)
|
|
22
|
-
|
|
23
|
-
mark_as_advanced(
|
|
24
|
-
TBB_LIBRARIES
|
|
25
|
-
TBB_INCLUDE_DIRS)
|
|
26
|
-
|
|
27
|
-
if(TBB_FOUND AND NOT (TARGET TBB::TBB))
|
|
28
|
-
add_library (TBB::TBB UNKNOWN IMPORTED)
|
|
29
|
-
set_target_properties(TBB::TBB
|
|
30
|
-
PROPERTIES
|
|
31
|
-
IMPORTED_LOCATION ${TBB_LIBRARIES}
|
|
32
|
-
INTERFACE_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIRS})
|
|
33
|
-
endif()
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# - Find gflags library
|
|
2
|
-
# Find the gflags includes and library
|
|
3
|
-
#
|
|
4
|
-
# GFLAGS_INCLUDE_DIR - where to find gflags.h.
|
|
5
|
-
# GFLAGS_LIBRARIES - List of libraries when using gflags.
|
|
6
|
-
# gflags_FOUND - True if gflags found.
|
|
7
|
-
|
|
8
|
-
find_path(GFLAGS_INCLUDE_DIR
|
|
9
|
-
NAMES gflags/gflags.h)
|
|
10
|
-
|
|
11
|
-
find_library(GFLAGS_LIBRARIES
|
|
12
|
-
NAMES gflags)
|
|
13
|
-
|
|
14
|
-
include(FindPackageHandleStandardArgs)
|
|
15
|
-
find_package_handle_standard_args(gflags
|
|
16
|
-
DEFAULT_MSG GFLAGS_LIBRARIES GFLAGS_INCLUDE_DIR)
|
|
17
|
-
|
|
18
|
-
mark_as_advanced(
|
|
19
|
-
GFLAGS_LIBRARIES
|
|
20
|
-
GFLAGS_INCLUDE_DIR)
|
|
21
|
-
|
|
22
|
-
if(gflags_FOUND AND NOT (TARGET gflags::gflags))
|
|
23
|
-
add_library(gflags::gflags UNKNOWN IMPORTED)
|
|
24
|
-
set_target_properties(gflags::gflags
|
|
25
|
-
PROPERTIES
|
|
26
|
-
IMPORTED_LOCATION ${GFLAGS_LIBRARIES}
|
|
27
|
-
INTERFACE_INCLUDE_DIRECTORIES ${GFLAGS_INCLUDE_DIR}
|
|
28
|
-
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
|
|
29
|
-
endif()
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# - Find Lz4
|
|
2
|
-
# Find the lz4 compression library and includes
|
|
3
|
-
#
|
|
4
|
-
# lz4_INCLUDE_DIRS - where to find lz4.h, etc.
|
|
5
|
-
# lz4_LIBRARIES - List of libraries when using lz4.
|
|
6
|
-
# lz4_FOUND - True if lz4 found.
|
|
7
|
-
|
|
8
|
-
find_path(lz4_INCLUDE_DIRS
|
|
9
|
-
NAMES lz4.h
|
|
10
|
-
HINTS ${lz4_ROOT_DIR}/include)
|
|
11
|
-
|
|
12
|
-
find_library(lz4_LIBRARIES
|
|
13
|
-
NAMES lz4
|
|
14
|
-
HINTS ${lz4_ROOT_DIR}/lib)
|
|
15
|
-
|
|
16
|
-
include(FindPackageHandleStandardArgs)
|
|
17
|
-
find_package_handle_standard_args(lz4 DEFAULT_MSG lz4_LIBRARIES lz4_INCLUDE_DIRS)
|
|
18
|
-
|
|
19
|
-
mark_as_advanced(
|
|
20
|
-
lz4_LIBRARIES
|
|
21
|
-
lz4_INCLUDE_DIRS)
|
|
22
|
-
|
|
23
|
-
if(lz4_FOUND AND NOT (TARGET lz4::lz4))
|
|
24
|
-
add_library(lz4::lz4 UNKNOWN IMPORTED)
|
|
25
|
-
set_target_properties(lz4::lz4
|
|
26
|
-
PROPERTIES
|
|
27
|
-
IMPORTED_LOCATION ${lz4_LIBRARIES}
|
|
28
|
-
INTERFACE_INCLUDE_DIRECTORIES ${lz4_INCLUDE_DIRS})
|
|
29
|
-
endif()
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# - Find zstd
|
|
2
|
-
# Find the zstd compression library and includes
|
|
3
|
-
#
|
|
4
|
-
# zstd_INCLUDE_DIRS - where to find zstd.h, etc.
|
|
5
|
-
# zstd_LIBRARIES - List of libraries when using zstd.
|
|
6
|
-
# zstd_FOUND - True if zstd found.
|
|
7
|
-
|
|
8
|
-
find_path(zstd_INCLUDE_DIRS
|
|
9
|
-
NAMES zstd.h
|
|
10
|
-
HINTS ${zstd_ROOT_DIR}/include)
|
|
11
|
-
|
|
12
|
-
find_library(zstd_LIBRARIES
|
|
13
|
-
NAMES zstd
|
|
14
|
-
HINTS ${zstd_ROOT_DIR}/lib)
|
|
15
|
-
|
|
16
|
-
include(FindPackageHandleStandardArgs)
|
|
17
|
-
find_package_handle_standard_args(zstd DEFAULT_MSG zstd_LIBRARIES zstd_INCLUDE_DIRS)
|
|
18
|
-
|
|
19
|
-
mark_as_advanced(
|
|
20
|
-
zstd_LIBRARIES
|
|
21
|
-
zstd_INCLUDE_DIRS)
|
|
22
|
-
|
|
23
|
-
if(zstd_FOUND AND NOT (TARGET zstd::zstd))
|
|
24
|
-
add_library (zstd::zstd UNKNOWN IMPORTED)
|
|
25
|
-
set_target_properties(zstd::zstd
|
|
26
|
-
PROPERTIES
|
|
27
|
-
IMPORTED_LOCATION ${zstd_LIBRARIES}
|
|
28
|
-
INTERFACE_INCLUDE_DIRECTORIES ${zstd_INCLUDE_DIRS})
|
|
29
|
-
endif()
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# Read rocksdb version from version.h header file.
|
|
2
|
-
|
|
3
|
-
function(get_rocksdb_version version_var)
|
|
4
|
-
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/include/rocksdb/version.h" version_header_file)
|
|
5
|
-
foreach(component MAJOR MINOR PATCH)
|
|
6
|
-
string(REGEX MATCH "#define ROCKSDB_${component} ([0-9]+)" _ ${version_header_file})
|
|
7
|
-
set(ROCKSDB_VERSION_${component} ${CMAKE_MATCH_1})
|
|
8
|
-
endforeach()
|
|
9
|
-
set(${version_var} "${ROCKSDB_VERSION_MAJOR}.${ROCKSDB_VERSION_MINOR}.${ROCKSDB_VERSION_PATCH}" PARENT_SCOPE)
|
|
10
|
-
endfunction()
|
package/leveldown.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const util = require('util')
|
|
4
|
-
const { AbstractLevelDOWN } = require('abstract-leveldown')
|
|
5
|
-
const binding = require('./binding')
|
|
6
|
-
const ChainedBatch = require('./chained-batch')
|
|
7
|
-
const Iterator = require('./iterator')
|
|
8
|
-
|
|
9
|
-
function LevelDOWN (location) {
|
|
10
|
-
if (!(this instanceof LevelDOWN)) {
|
|
11
|
-
return new LevelDOWN(location)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (typeof location !== 'string') {
|
|
15
|
-
throw new Error('constructor requires a location string argument')
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
AbstractLevelDOWN.call(this, {
|
|
19
|
-
bufferKeys: true,
|
|
20
|
-
snapshots: true,
|
|
21
|
-
permanence: true,
|
|
22
|
-
seek: true,
|
|
23
|
-
clear: true,
|
|
24
|
-
getMany: true,
|
|
25
|
-
createIfMissing: true,
|
|
26
|
-
errorIfExists: true
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
this.location = location
|
|
30
|
-
this.context = binding.db_init()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
util.inherits(LevelDOWN, AbstractLevelDOWN)
|
|
34
|
-
|
|
35
|
-
LevelDOWN.prototype._open = function (options, callback) {
|
|
36
|
-
binding.db_open(this.context, this.location, options, callback)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
LevelDOWN.prototype._close = function (callback) {
|
|
40
|
-
binding.db_close(this.context, callback)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
LevelDOWN.prototype._serializeKey = function (key) {
|
|
44
|
-
return Buffer.isBuffer(key) ? key : String(key)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
LevelDOWN.prototype._serializeValue = function (value) {
|
|
48
|
-
return Buffer.isBuffer(value) ? value : String(value)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
LevelDOWN.prototype._put = function (key, value, options, callback) {
|
|
52
|
-
const batch = new ChainedBatch(this)
|
|
53
|
-
batch.put(key, value)
|
|
54
|
-
batch.write(options, callback)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
LevelDOWN.prototype._get = function (key, options, callback) {
|
|
58
|
-
binding.db_get_many(this.context, [key], options, (err, val) => {
|
|
59
|
-
if (err) {
|
|
60
|
-
callback(err)
|
|
61
|
-
} else if (!val[0]) {
|
|
62
|
-
callback(new Error('NotFound'))
|
|
63
|
-
} else {
|
|
64
|
-
callback(null, val[0])
|
|
65
|
-
}
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
LevelDOWN.prototype._getMany = function (keys, options, callback) {
|
|
70
|
-
binding.db_get_many(this.context, keys, options, callback)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
LevelDOWN.prototype._del = function (key, options, callback) {
|
|
74
|
-
const batch = new ChainedBatch(this)
|
|
75
|
-
batch.del(key)
|
|
76
|
-
batch.write(options, callback)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
LevelDOWN.prototype._chainedBatch = function () {
|
|
80
|
-
return new ChainedBatch(this)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
LevelDOWN.prototype._batch = function (operations, options, callback) {
|
|
84
|
-
let batch = null
|
|
85
|
-
for (const op of operations) {
|
|
86
|
-
if (op.type === 'del') {
|
|
87
|
-
if (!('key' in op)) continue
|
|
88
|
-
batch = batch || this.batch()
|
|
89
|
-
batch.del(op.key)
|
|
90
|
-
} else if (op.type === 'put') {
|
|
91
|
-
if (!('key' in op)) continue
|
|
92
|
-
if (!('value' in op)) continue
|
|
93
|
-
batch = batch || this.batch()
|
|
94
|
-
batch.put(op.key, op.value)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (batch) {
|
|
98
|
-
batch.write(options, callback)
|
|
99
|
-
} else {
|
|
100
|
-
process.nextTick(callback)
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
LevelDOWN.prototype._iterator = function (options) {
|
|
105
|
-
if (this.status !== 'open') {
|
|
106
|
-
// Prevent segfault
|
|
107
|
-
throw new Error('cannot call iterator() before open()')
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return new Iterator(this, options)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
module.exports = LevelDOWN
|